Commit 93c37f1b authored by dalecurtis's avatar dalecurtis Committed by Commit bot

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}
parent 69efd071
......@@ -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.
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment