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

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

Issue 2922733002: Propagate muted state from MediaStreamAudioSource into JS. (Closed)
Patch Set: Rebase: FakeAudioInputStream changes moved into earlier CL 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 023f078fd0e020bfc961d058afe748eba410c11a..f2b44ad1e7e921be4ba8d246d69043a2a2ea44c1 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)
miu 2017/06/19 19:40:37 This code assumes MediaStreamComponent::muted_ is
ossu-chromium 2017/06/26 16:06:14 From what I could gather, that constructor is (un?
+ 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";
}

Powered by Google App Engine
This is Rietveld 408576698