summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordalecurtis <dalecurtis@chromium.org>2014-09-11 13:41:33 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-11 20:52:32 +0000
commit93c37f1b01ef982bce30d4404562f05c7b1d439e (patch)
treeb33607dad849afaf7719945d7eed6258c815f784
parent69efd071162c9be1fd6a7c46437ba852c1edf666 (diff)
downloadchromium_src-93c37f1b01ef982bce30d4404562f05c7b1d439e.zip
chromium_src-93c37f1b01ef982bce30d4404562f05c7b1d439e.tar.gz
chromium_src-93c37f1b01ef982bce30d4404562f05c7b1d439e.tar.bz2
Don't rebase timestamps for positive start times.
This is wrong according to the HTML Media specification: http://dev.w3.org/html5/spec-preview/media-elements.html#offsets-into-the-media-resource "If the media resource somehow specifies an explicit timeline whose origin is not negative (i.e. gives each frame a specific time offset and gives the first frame a zero or positive offset), then the media timeline should be that timeline." BUG=413292 TEST=updated unittest. Review URL: https://codereview.chromium.org/562323002 Cr-Commit-Position: refs/heads/master@{#294461}
-rw-r--r--media/filters/ffmpeg_demuxer.cc16
-rw-r--r--media/filters/ffmpeg_demuxer_unittest.cc12
2 files changed, 17 insertions, 11 deletions
diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc
index 9df765e8..2741497 100644
--- a/media/filters/ffmpeg_demuxer.cc
+++ b/media/filters/ffmpeg_demuxer.cc
@@ -305,6 +305,12 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
start_time = base::TimeDelta();
}
+ // Don't rebase timestamps for positive start times, the HTML Media Spec
+ // details this in section "4.8.10.6 Offsets into the media resource." We
+ // will still need to rebase timestamps before seeking with FFmpeg though.
+ if (start_time > base::TimeDelta())
+ start_time = base::TimeDelta();
+
buffer->set_timestamp(stream_timestamp - start_time);
// If enabled, mark audio packets with negative timestamps for post-decode
@@ -588,7 +594,15 @@ void FFmpegDemuxer::Seek(base::TimeDelta time, const PipelineStatusCB& cb) {
// we know we're going to drop it on the floor.
// FFmpeg requires seeks to be adjusted according to the lowest starting time.
- const base::TimeDelta seek_time = time + start_time_;
+ // Since EnqueuePacket() rebased negative timestamps by the start time, we
+ // must correct the shift here.
+ //
+ // Additionally, to workaround limitations in how we expose seekable ranges to
+ // Blink (http://crbug.com/137275), we also want to clamp seeks before the
+ // start time to the start time.
+ const base::TimeDelta seek_time =
+ start_time_ < base::TimeDelta() ? time + start_time_
+ : time < start_time_ ? start_time_ : time;
// Choose the seeking stream based on whether it contains the seek time, if no
// match can be found prefer the preferred stream.
diff --git a/media/filters/ffmpeg_demuxer_unittest.cc b/media/filters/ffmpeg_demuxer_unittest.cc
index 0f8199e..d20d1aa 100644
--- a/media/filters/ffmpeg_demuxer_unittest.cc
+++ b/media/filters/ffmpeg_demuxer_unittest.cc
@@ -438,17 +438,9 @@ TEST_F(FFmpegDemuxerTest, Read_VideoPositiveStartTime) {
// Run the test twice with a seek in between.
for (int i = 0; i < 2; ++i) {
- // Check first buffer in video stream. It should have been adjusted such
- // that it starts 400ms after the first audio buffer.
- video->Read(
- NewReadCB(FROM_HERE,
- 5636,
- (video_start_time - audio_start_time).InMicroseconds()));
+ video->Read(NewReadCB(FROM_HERE, 5636, video_start_time.InMicroseconds()));
message_loop_.Run();
-
- // Since the audio buffer has a lower first timestamp, it should become
- // zero.
- audio->Read(NewReadCB(FROM_HERE, 165, 0));
+ audio->Read(NewReadCB(FROM_HERE, 165, audio_start_time.InMicroseconds()));
message_loop_.Run();
// Verify that the start time is equal to the lowest timestamp (ie the