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

Unified Diff: media/filters/chunk_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/chunk_demuxer.cc
diff --git a/media/filters/chunk_demuxer.cc b/media/filters/chunk_demuxer.cc
index 5e9f6795fa2ac81b00dce13d2b66c3d8cfc0408e..4480b27ad460704e171538519bd6b971fbc79765 100644
--- a/media/filters/chunk_demuxer.cc
+++ b/media/filters/chunk_demuxer.cc
@@ -15,6 +15,7 @@
#include "base/macros.h"
#include "base/metrics/histogram_macros.h"
#include "base/stl_util.h"
+#include "base/strings/string_number_conversions.h"
#include "media/base/audio_decoder_config.h"
#include "media/base/bind_to_current_loop.h"
#include "media/base/media_tracks.h"
@@ -241,6 +242,14 @@ void ChunkDemuxerStream::Read(const ReadCB& read_cb) {
DCHECK(read_cb_.is_null());
read_cb_ = BindToCurrentLoop(read_cb);
+
+ if (!is_enabled_) {
+ DVLOG(1) << "Read from disabled stream, returning EOS";
+ base::ResetAndReturn(&read_cb_).Run(kOk,
+ StreamParserBuffer::CreateEOSBuffer());
+ return;
+ }
+
CompletePendingReadIfPossible_Locked();
}
@@ -269,6 +278,28 @@ VideoRotation ChunkDemuxerStream::video_rotation() {
return VIDEO_ROTATION_0;
}
+bool ChunkDemuxerStream::enabled() const {
+ base::AutoLock auto_lock(lock_);
+ return is_enabled_;
+}
+
+void ChunkDemuxerStream::set_enabled(bool enabled, base::TimeDelta timestamp) {
+ base::AutoLock auto_lock(lock_);
+
+ if (enabled == is_enabled_)
+ return;
+
+ is_enabled_ = enabled;
+ if (enabled) {
+ DCHECK(stream_);
+ stream_->Seek(timestamp);
+ } else if (!read_cb_.is_null()) {
+ DVLOG(1) << "Read from disabled stream, returning EOS";
+ base::ResetAndReturn(&read_cb_).Run(kOk,
+ StreamParserBuffer::CreateEOSBuffer());
+ }
+}
+
TextTrackConfig ChunkDemuxerStream::text_track_config() {
CHECK_EQ(type_, TEXT);
base::AutoLock auto_lock(lock_);

Powered by Google App Engine
This is Rietveld 408576698