Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/filters/ffmpeg_demuxer.h" | 5 #include "media/filters/ffmpeg_demuxer.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/base64.h" | 10 #include "base/base64.h" |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 298 const bool is_audio = type() == AUDIO; | 298 const bool is_audio = type() == AUDIO; |
| 299 | 299 |
| 300 // If this is an OGG file with negative timestamps don't rebase any other | 300 // If this is an OGG file with negative timestamps don't rebase any other |
| 301 // stream types against the negative starting time. | 301 // stream types against the negative starting time. |
| 302 base::TimeDelta start_time = demuxer_->start_time(); | 302 base::TimeDelta start_time = demuxer_->start_time(); |
| 303 if (fixup_negative_ogg_timestamps_ && !is_audio && | 303 if (fixup_negative_ogg_timestamps_ && !is_audio && |
| 304 start_time < base::TimeDelta()) { | 304 start_time < base::TimeDelta()) { |
| 305 start_time = base::TimeDelta(); | 305 start_time = base::TimeDelta(); |
| 306 } | 306 } |
| 307 | 307 |
| 308 // Don't rebase timestamps for positive start times, the HTML Media Spec | |
| 309 // details this in section "4.8.10.6 Offsets into the media resource." We | |
| 310 // will still need to rebase timestamps before seeking with FFmpeg though. | |
| 311 if (start_time > base::TimeDelta()) | |
| 312 start_time = base::TimeDelta(); | |
| 313 | |
| 308 buffer->set_timestamp(stream_timestamp - start_time); | 314 buffer->set_timestamp(stream_timestamp - start_time); |
| 309 | 315 |
| 310 // If enabled, mark audio packets with negative timestamps for post-decode | 316 // If enabled, mark audio packets with negative timestamps for post-decode |
| 311 // discard. | 317 // discard. |
| 312 if (fixup_negative_ogg_timestamps_ && is_audio && | 318 if (fixup_negative_ogg_timestamps_ && is_audio && |
| 313 stream_timestamp < base::TimeDelta() && | 319 stream_timestamp < base::TimeDelta() && |
| 314 buffer->duration() != kNoTimestamp()) { | 320 buffer->duration() != kNoTimestamp()) { |
| 315 if (stream_timestamp + buffer->duration() < base::TimeDelta()) { | 321 if (stream_timestamp + buffer->duration() < base::TimeDelta()) { |
| 316 // Discard the entire packet if it's entirely before zero. | 322 // Discard the entire packet if it's entirely before zero. |
| 317 buffer->set_discard_padding( | 323 buffer->set_discard_padding( |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 581 | 587 |
| 582 void FFmpegDemuxer::Seek(base::TimeDelta time, const PipelineStatusCB& cb) { | 588 void FFmpegDemuxer::Seek(base::TimeDelta time, const PipelineStatusCB& cb) { |
| 583 DCHECK(task_runner_->BelongsToCurrentThread()); | 589 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 584 CHECK(!pending_seek_); | 590 CHECK(!pending_seek_); |
| 585 | 591 |
| 586 // TODO(scherkus): Inspect |pending_read_| and cancel IO via |blocking_url_|, | 592 // TODO(scherkus): Inspect |pending_read_| and cancel IO via |blocking_url_|, |
| 587 // otherwise we can end up waiting for a pre-seek read to complete even though | 593 // otherwise we can end up waiting for a pre-seek read to complete even though |
| 588 // we know we're going to drop it on the floor. | 594 // we know we're going to drop it on the floor. |
| 589 | 595 |
| 590 // FFmpeg requires seeks to be adjusted according to the lowest starting time. | 596 // FFmpeg requires seeks to be adjusted according to the lowest starting time. |
| 591 const base::TimeDelta seek_time = time + start_time_; | 597 // Since EnqueuePacket() rebased negative timestamps by the start time, we |
| 598 // must correct the shift here. | |
| 599 // | |
| 600 // Additionally, to workaround limitations in how we expose seekable ranges to | |
| 601 // blink, we also want to special case seeks to zero; they're unambiguously | |
|
acolwell GONE FROM CHROMIUM
2014/09/11 18:34:42
nit: Please file a bug to track the seekable range
DaleCurtis
2014/09/11 19:19:07
Done.
| |
| 602 // intended to seek to the start of the media. | |
| 603 const base::TimeDelta seek_time = | |
| 604 start_time_ < base::TimeDelta() || time == base::TimeDelta() | |
|
acolwell GONE FROM CHROMIUM
2014/09/11 18:34:42
Why not simply set seek_time to start_time_ if tim
DaleCurtis
2014/09/11 19:19:07
Done.
| |
| 605 ? time + start_time_ | |
| 606 : time; | |
| 592 | 607 |
| 593 // Choose the seeking stream based on whether it contains the seek time, if no | 608 // Choose the seeking stream based on whether it contains the seek time, if no |
| 594 // match can be found prefer the preferred stream. | 609 // match can be found prefer the preferred stream. |
| 595 // | 610 // |
| 596 // TODO(dalecurtis): Currently FFmpeg does not ensure that all streams in a | 611 // TODO(dalecurtis): Currently FFmpeg does not ensure that all streams in a |
| 597 // given container will demux all packets after the seek point. Instead it | 612 // given container will demux all packets after the seek point. Instead it |
| 598 // only guarantees that all packets after the file position of the seek will | 613 // only guarantees that all packets after the file position of the seek will |
| 599 // be demuxed. It's an open question whether FFmpeg should fix this: | 614 // be demuxed. It's an open question whether FFmpeg should fix this: |
| 600 // http://lists.ffmpeg.org/pipermail/ffmpeg-devel/2014-June/159212.html | 615 // http://lists.ffmpeg.org/pipermail/ffmpeg-devel/2014-June/159212.html |
| 601 // Tracked by http://crbug.com/387996. | 616 // Tracked by http://crbug.com/387996. |
| (...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1230 } | 1245 } |
| 1231 for (size_t i = 0; i < buffered.size(); ++i) | 1246 for (size_t i = 0; i < buffered.size(); ++i) |
| 1232 host_->AddBufferedTimeRange(buffered.start(i), buffered.end(i)); | 1247 host_->AddBufferedTimeRange(buffered.start(i), buffered.end(i)); |
| 1233 } | 1248 } |
| 1234 | 1249 |
| 1235 void FFmpegDemuxer::OnDataSourceError() { | 1250 void FFmpegDemuxer::OnDataSourceError() { |
| 1236 host_->OnDemuxerError(PIPELINE_ERROR_READ); | 1251 host_->OnDemuxerError(PIPELINE_ERROR_READ); |
| 1237 } | 1252 } |
| 1238 | 1253 |
| 1239 } // namespace media | 1254 } // namespace media |
| OLD | NEW |