Commit 562c4aca authored by kjoswiak's avatar kjoswiak Committed by Commit bot

ffmpeg reset bitstream converters on Seek

We should not assume that the underlying decoders
keep their state after a Seek.
So for example, the SPS/PPS should be added again.

BUG=140371

Review URL: https://codereview.chromium.org/683573002

Cr-Commit-Position: refs/heads/master@{#302154}
parent 8908855a
......@@ -382,6 +382,12 @@ void FFmpegDemuxerStream::SetEndOfStream() {
void FFmpegDemuxerStream::FlushBuffers() {
DCHECK(task_runner_->BelongsToCurrentThread());
DCHECK(read_cb_.is_null()) << "There should be no pending read";
// H264 requires that we resend the header after flush.
// Reset its bitstream for converter to do so.
// This is related to chromium issue 140371 (http://crbug.com/140371).
ResetBitstreamConverter();
buffer_queue_.Clear();
end_of_stream_ = false;
last_packet_timestamp_ = kNoTimestamp();
......@@ -434,6 +440,16 @@ void FFmpegDemuxerStream::EnableBitstreamConverter() {
#endif
}
void FFmpegDemuxerStream::ResetBitstreamConverter() {
#if defined(USE_PROPRIETARY_CODECS)
if (!bitstream_converter_enabled_ || !bitstream_converter_)
return;
bitstream_converter_.reset(
new FFmpegH264ToAnnexBBitstreamConverter(stream_->codec));
#endif // defined(USE_PROPRIETARY_CODECS)
}
bool FFmpegDemuxerStream::SupportsConfigChanges() { return false; }
AudioDecoderConfig FFmpegDemuxerStream::audio_decoder_config() {
......
......@@ -124,6 +124,9 @@ class FFmpegDemuxerStream : public DemuxerStream {
static base::TimeDelta ConvertStreamTimestamp(const AVRational& time_base,
int64 timestamp);
// Resets any currently active bitstream converters.
void ResetBitstreamConverter();
FFmpegDemuxer* demuxer_;
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
AVStream* stream_;
......
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