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

Side by Side Diff: third_party/WebKit/Source/modules/mediastream/MediaStreamTrack.cpp

Issue 2922733002: Propagate muted state from MediaStreamAudioSource into JS. (Closed)
Patch Set: Made SetMuted call unconditional. Rebased. Created 3 years, 5 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/mediastream/MediaStreamTrack-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * Copyright (C) 2011 Ericsson AB. All rights reserved. 3 * Copyright (C) 2011 Ericsson AB. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 } // namespace 57 } // namespace
58 58
59 MediaStreamTrack* MediaStreamTrack::Create(ExecutionContext* context, 59 MediaStreamTrack* MediaStreamTrack::Create(ExecutionContext* context,
60 MediaStreamComponent* component) { 60 MediaStreamComponent* component) {
61 return new MediaStreamTrack(context, component); 61 return new MediaStreamTrack(context, component);
62 } 62 }
63 63
64 MediaStreamTrack::MediaStreamTrack(ExecutionContext* context, 64 MediaStreamTrack::MediaStreamTrack(ExecutionContext* context,
65 MediaStreamComponent* component) 65 MediaStreamComponent* component)
66 : ContextLifecycleObserver(context), 66 : ContextLifecycleObserver(context),
67 ready_state_(MediaStreamSource::kReadyStateLive), 67 ready_state_(component->Source()->GetReadyState()),
68 is_iterating_registered_media_streams_(false), 68 is_iterating_registered_media_streams_(false),
69 stopped_(false), 69 stopped_(false),
70 component_(component), 70 component_(component),
71 // The source's constraints aren't yet initialized at creation time. 71 // The source's constraints aren't yet initialized at creation time.
72 constraints_() { 72 constraints_() {
73 component_->Source()->AddObserver(this); 73 component_->Source()->AddObserver(this);
74 74
75 // If the source is already non-live at this point, the observer won't have
76 // been called. Update the muted state manually.
77 component_->SetMuted(ready_state_ == MediaStreamSource::kReadyStateMuted);
78
75 if (component_->Source() && 79 if (component_->Source() &&
76 component_->Source()->GetType() == MediaStreamSource::kTypeVideo) { 80 component_->Source()->GetType() == MediaStreamSource::kTypeVideo) {
77 // ImageCapture::create() only throws if |this| track is not of video type. 81 // ImageCapture::create() only throws if |this| track is not of video type.
78 NonThrowableExceptionState exception_state; 82 NonThrowableExceptionState exception_state;
79 image_capture_ = ImageCapture::Create(context, this, exception_state); 83 image_capture_ = ImageCapture::Create(context, this, exception_state);
80 } 84 }
81 } 85 }
82 86
83 MediaStreamTrack::~MediaStreamTrack() {} 87 MediaStreamTrack::~MediaStreamTrack() {}
84 88
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 } 180 }
177 } 181 }
178 182
179 component_->SetContentHint(translated_hint); 183 component_->SetContentHint(translated_hint);
180 } 184 }
181 185
182 String MediaStreamTrack::readyState() const { 186 String MediaStreamTrack::readyState() const {
183 if (Ended()) 187 if (Ended())
184 return "ended"; 188 return "ended";
185 189
190 // Although muted is tracked as a ReadyState, only "live" and "ended" are
191 // visible externally.
186 switch (ready_state_) { 192 switch (ready_state_) {
187 case MediaStreamSource::kReadyStateLive: 193 case MediaStreamSource::kReadyStateLive:
194 case MediaStreamSource::kReadyStateMuted:
188 return "live"; 195 return "live";
189 case MediaStreamSource::kReadyStateMuted:
190 return "muted";
191 case MediaStreamSource::kReadyStateEnded: 196 case MediaStreamSource::kReadyStateEnded:
192 return "ended"; 197 return "ended";
193 } 198 }
194 199
195 NOTREACHED(); 200 NOTREACHED();
196 return String(); 201 return String();
197 } 202 }
198 203
199 void MediaStreamTrack::stopTrack(ExceptionState& exception_state) { 204 void MediaStreamTrack::stopTrack(ExceptionState& exception_state) {
200 if (Ended()) 205 if (Ended())
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 416
412 DEFINE_TRACE(MediaStreamTrack) { 417 DEFINE_TRACE(MediaStreamTrack) {
413 visitor->Trace(registered_media_streams_); 418 visitor->Trace(registered_media_streams_);
414 visitor->Trace(component_); 419 visitor->Trace(component_);
415 visitor->Trace(image_capture_); 420 visitor->Trace(image_capture_);
416 EventTargetWithInlineData::Trace(visitor); 421 EventTargetWithInlineData::Trace(visitor);
417 ContextLifecycleObserver::Trace(visitor); 422 ContextLifecycleObserver::Trace(visitor);
418 } 423 }
419 424
420 } // namespace blink 425 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/mediastream/MediaStreamTrack-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698