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

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

Issue 683573002: ffmpeg reset bitstream converters on Seek (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 | « media/filters/ffmpeg_demuxer.h ('k') | no next file » | 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 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 DCHECK(task_runner_->BelongsToCurrentThread()); 427 DCHECK(task_runner_->BelongsToCurrentThread());
428 428
429 #if defined(USE_PROPRIETARY_CODECS) 429 #if defined(USE_PROPRIETARY_CODECS)
430 CHECK(bitstream_converter_.get()); 430 CHECK(bitstream_converter_.get());
431 bitstream_converter_enabled_ = true; 431 bitstream_converter_enabled_ = true;
432 #else 432 #else
433 NOTREACHED() << "Proprietary codecs not enabled."; 433 NOTREACHED() << "Proprietary codecs not enabled.";
434 #endif 434 #endif
435 } 435 }
436 436
437 void FFmpegDemuxerStream::ResetBitstreamConverter() {
438 // If a bitstream converter exists, reset it.
DaleCurtis 2014/10/27 20:36:02 DCHECK unnecessary since you access it directly be
kjoswiak 2014/10/27 20:47:32 Done.
439 DCHECK(stream_);
440
441 if (!bitstream_converter_enabled_)
442 return;
443
444 #if defined(USE_PROPRIETARY_CODECS)
445 if (bitstream_converter_ != NULL) {
DaleCurtis 2014/10/27 20:36:02 if (!bitstream_converter_) return; bitstream_co
kjoswiak 2014/10/27 20:47:32 Done.
xhwang 2014/10/27 20:59:21 How about do the same as l.152? if (stream_->cod
kjoswiak 2014/10/27 21:34:17 Ya, it does seem a little weird. Should I just go
kjoswiak 2014/10/27 21:56:41 https://chromiumcodereview.appspot.com/10879057 is
kjoswiak 2014/10/27 23:49:59 Primary issue is that we weren't guaranteed that s
446 bitstream_converter_.reset(
447 new FFmpegH264ToAnnexBBitstreamConverter(stream_->codec));
448 }
449 #endif // defined(USE_PROPRIETARY_CODECS)
450 }
451
437 bool FFmpegDemuxerStream::SupportsConfigChanges() { return false; } 452 bool FFmpegDemuxerStream::SupportsConfigChanges() { return false; }
438 453
439 AudioDecoderConfig FFmpegDemuxerStream::audio_decoder_config() { 454 AudioDecoderConfig FFmpegDemuxerStream::audio_decoder_config() {
440 DCHECK(task_runner_->BelongsToCurrentThread()); 455 DCHECK(task_runner_->BelongsToCurrentThread());
441 CHECK_EQ(type_, AUDIO); 456 CHECK_EQ(type_, AUDIO);
442 return audio_config_; 457 return audio_config_;
443 } 458 }
444 459
445 VideoDecoderConfig FFmpegDemuxerStream::video_decoder_config() { 460 VideoDecoderConfig FFmpegDemuxerStream::video_decoder_config() {
446 DCHECK(task_runner_->BelongsToCurrentThread()); 461 DCHECK(task_runner_->BelongsToCurrentThread());
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 } 601 }
587 602
588 void FFmpegDemuxer::Seek(base::TimeDelta time, const PipelineStatusCB& cb) { 603 void FFmpegDemuxer::Seek(base::TimeDelta time, const PipelineStatusCB& cb) {
589 DCHECK(task_runner_->BelongsToCurrentThread()); 604 DCHECK(task_runner_->BelongsToCurrentThread());
590 CHECK(!pending_seek_); 605 CHECK(!pending_seek_);
591 606
592 // TODO(scherkus): Inspect |pending_read_| and cancel IO via |blocking_url_|, 607 // TODO(scherkus): Inspect |pending_read_| and cancel IO via |blocking_url_|,
593 // otherwise we can end up waiting for a pre-seek read to complete even though 608 // otherwise we can end up waiting for a pre-seek read to complete even though
594 // we know we're going to drop it on the floor. 609 // we know we're going to drop it on the floor.
595 610
611 FFmpegDemuxerStream* video = GetFFmpegStream(DemuxerStream::VIDEO);
612 // H264 and VP8 require that we resend the header after flush.
xhwang 2014/10/27 20:59:21 The bit stream converter is really only for H264.
kjoswiak 2014/10/27 23:49:59 Done.
613 // Reset the bitstream converter to do so.
614 // This is related to chromium issue 140371 (http://crbug.com/140371).
615 if (video) {
DaleCurtis 2014/10/27 20:36:02 No {} necessary.
kjoswiak 2014/10/27 20:47:32 Done.
616 video->ResetBitstreamConverter();
617 }
618
596 // FFmpeg requires seeks to be adjusted according to the lowest starting time. 619 // FFmpeg requires seeks to be adjusted according to the lowest starting time.
597 // Since EnqueuePacket() rebased negative timestamps by the start time, we 620 // Since EnqueuePacket() rebased negative timestamps by the start time, we
598 // must correct the shift here. 621 // must correct the shift here.
599 // 622 //
600 // Additionally, to workaround limitations in how we expose seekable ranges to 623 // 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 624 // Blink (http://crbug.com/137275), we also want to clamp seeks before the
602 // start time to the start time. 625 // start time to the start time.
603 const base::TimeDelta seek_time = 626 const base::TimeDelta seek_time =
604 start_time_ < base::TimeDelta() ? time + start_time_ 627 start_time_ < base::TimeDelta() ? time + start_time_
605 : time < start_time_ ? start_time_ : time; 628 : time < start_time_ ? start_time_ : time;
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
1248 } 1271 }
1249 for (size_t i = 0; i < buffered.size(); ++i) 1272 for (size_t i = 0; i < buffered.size(); ++i)
1250 host_->AddBufferedTimeRange(buffered.start(i), buffered.end(i)); 1273 host_->AddBufferedTimeRange(buffered.start(i), buffered.end(i));
1251 } 1274 }
1252 1275
1253 void FFmpegDemuxer::OnDataSourceError() { 1276 void FFmpegDemuxer::OnDataSourceError() {
1254 host_->OnDemuxerError(PIPELINE_ERROR_READ); 1277 host_->OnDemuxerError(PIPELINE_ERROR_READ);
1255 } 1278 }
1256 1279
1257 } // namespace media 1280 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/ffmpeg_demuxer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698