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

Unified Diff: third_party/WebKit/Source/modules/mediastream/MediaStreamTrack.cpp

Issue 2922733002: Propagate muted state from MediaStreamAudioSource into JS. (Closed)
Patch Set: Added browser tests for AudioInputStream::IsMuted propagating to JS. Created 3 years, 6 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: third_party/WebKit/Source/modules/mediastream/MediaStreamTrack.cpp
diff --git a/third_party/WebKit/Source/modules/mediastream/MediaStreamTrack.cpp b/third_party/WebKit/Source/modules/mediastream/MediaStreamTrack.cpp
index 10c2e52354652c43602fb7dd5f62b5aeb090598b..db9de010c0f7ff74bdf1c9d6cca90551f54a2df1 100644
--- a/third_party/WebKit/Source/modules/mediastream/MediaStreamTrack.cpp
+++ b/third_party/WebKit/Source/modules/mediastream/MediaStreamTrack.cpp
@@ -64,7 +64,7 @@ MediaStreamTrack* MediaStreamTrack::Create(ExecutionContext* context,
MediaStreamTrack::MediaStreamTrack(ExecutionContext* context,
MediaStreamComponent* component)
: ContextLifecycleObserver(context),
- ready_state_(MediaStreamSource::kReadyStateLive),
+ ready_state_(component->Source()->GetReadyState()),
is_iterating_registered_media_streams_(false),
stopped_(false),
component_(component),
@@ -72,6 +72,11 @@ MediaStreamTrack::MediaStreamTrack(ExecutionContext* context,
constraints_() {
component_->Source()->AddObserver(this);
+ // If the source is already non-live at this point, the observer won't have
+ // been called. Check the muted state manually.
+ if (ready_state_ == MediaStreamSource::kReadyStateMuted)
+ component_->SetMuted(true);
+
if (component_->Source() &&
component_->Source()->GetType() == MediaStreamSource::kTypeVideo) {
// ImageCapture::create() only throws if |this| track is not of video type.
@@ -183,11 +188,12 @@ String MediaStreamTrack::readyState() const {
if (Ended())
return "ended";
+ // Although muted is tracked as a ReadyState, only "live" and "ended" are
+ // visible externally.
switch (ready_state_) {
case MediaStreamSource::kReadyStateLive:
- return "live";
case MediaStreamSource::kReadyStateMuted:
- return "muted";
+ return "live";
case MediaStreamSource::kReadyStateEnded:
return "ended";
}
« media/audio/fake_audio_input_stream.h ('K') | « media/audio/fake_audio_input_stream.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698