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

Unified Diff: media/filters/ffmpeg_demuxer.cc

Issue 1935873002: Implement disabling and enabling media tracks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@track-control2
Patch Set: Updated comments + dchecks in ffmpeg demux stream Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
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.

Powered by Google App Engine
This is Rietveld 408576698