Index: media/filters/ffmpeg_demuxer.cc |
diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc |
index 0a4dad5c54666414aeb0227aec7e57c5206f9fd5..b088c57ce3922e80d4d573b3adc4d7a487954cdd 100644 |
--- a/media/filters/ffmpeg_demuxer.cc |
+++ b/media/filters/ffmpeg_demuxer.cc |
@@ -267,6 +267,7 @@ FFmpegDemuxerStream::FFmpegDemuxerStream( |
last_packet_timestamp_(kNoTimestamp()), |
last_packet_duration_(kNoTimestamp()), |
video_rotation_(VIDEO_ROTATION_0), |
+ is_enabled_(true), |
fixup_negative_timestamps_(false) { |
DCHECK(demuxer_); |
@@ -613,6 +614,12 @@ void FFmpegDemuxerStream::Read(const ReadCB& read_cb) { |
return; |
} |
+ if (!is_enabled_) { |
+ DVLOG(1) << "Read from disabled stream, returning EOS"; |
+ base::ResetAndReturn(&read_cb_).Run(kOk, DecoderBuffer::CreateEOSBuffer()); |
+ return; |
+ } |
+ |
SatisfyPendingRead(); |
} |
@@ -676,6 +683,24 @@ VideoRotation FFmpegDemuxerStream::video_rotation() { |
return video_rotation_; |
} |
+bool FFmpegDemuxerStream::enabled() const { |
+ DCHECK(task_runner_->BelongsToCurrentThread()); |
+ return is_enabled_; |
+} |
+ |
+void FFmpegDemuxerStream::set_enabled(bool enabled, base::TimeDelta timestamp) { |
chcunningham
2016/06/02 23:49:43
I feel like we need some logic here to drop frames
|
+ DCHECK(task_runner_->BelongsToCurrentThread()); |
+ if (enabled == is_enabled_) |
+ return; |
+ |
+ is_enabled_ = enabled; |
+ if (!is_enabled_ && !read_cb_.is_null()) { |
+ DVLOG(1) << "Read from disabled stream, returning EOS"; |
+ base::ResetAndReturn(&read_cb_).Run(kOk, DecoderBuffer::CreateEOSBuffer()); |
+ return; |
+ } |
+} |
+ |
void FFmpegDemuxerStream::SetLiveness(Liveness liveness) { |
DCHECK(task_runner_->BelongsToCurrentThread()); |
DCHECK_EQ(liveness_, LIVENESS_UNKNOWN); |
@@ -1538,7 +1563,8 @@ void FFmpegDemuxer::OnReadFrameDone(ScopedAVPacket packet, int result) { |
} |
FFmpegDemuxerStream* demuxer_stream = streams_[packet->stream_index]; |
- demuxer_stream->EnqueuePacket(std::move(packet)); |
+ if (demuxer_stream->enabled()) |
+ demuxer_stream->EnqueuePacket(std::move(packet)); |
} |
// Keep reading until we've reached capacity. |