Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(223)

Side by Side Diff: media/filters/ffmpeg_demuxer.cc

Issue 562323002: Don't rebase timestamps for positive start times. (Closed) Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | media/filters/ffmpeg_demuxer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 (http://crbug.com/137275), we also want to clamp seeks before the
602 // start time to the start time.
603 const base::TimeDelta seek_time =
604 start_time_ < base::TimeDelta() ? time + start_time_
605 : time < start_time_ ? start_time_ : time;
592 606
593 // Choose the seeking stream based on whether it contains the seek time, if no 607 // Choose the seeking stream based on whether it contains the seek time, if no
594 // match can be found prefer the preferred stream. 608 // match can be found prefer the preferred stream.
595 // 609 //
596 // TODO(dalecurtis): Currently FFmpeg does not ensure that all streams in a 610 // 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 611 // 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 612 // 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: 613 // be demuxed. It's an open question whether FFmpeg should fix this:
600 // http://lists.ffmpeg.org/pipermail/ffmpeg-devel/2014-June/159212.html 614 // http://lists.ffmpeg.org/pipermail/ffmpeg-devel/2014-June/159212.html
601 // Tracked by http://crbug.com/387996. 615 // Tracked by http://crbug.com/387996.
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
1230 } 1244 }
1231 for (size_t i = 0; i < buffered.size(); ++i) 1245 for (size_t i = 0; i < buffered.size(); ++i)
1232 host_->AddBufferedTimeRange(buffered.start(i), buffered.end(i)); 1246 host_->AddBufferedTimeRange(buffered.start(i), buffered.end(i));
1233 } 1247 }
1234 1248
1235 void FFmpegDemuxer::OnDataSourceError() { 1249 void FFmpegDemuxer::OnDataSourceError() {
1236 host_->OnDemuxerError(PIPELINE_ERROR_READ); 1250 host_->OnDemuxerError(PIPELINE_ERROR_READ);
1237 } 1251 }
1238 1252
1239 } // namespace media 1253 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/filters/ffmpeg_demuxer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698