Chromium Code Reviews| Index: content/renderer/media/media_stream_video_source.cc |
| diff --git a/content/renderer/media/media_stream_video_source.cc b/content/renderer/media/media_stream_video_source.cc |
| index 45c6abd7aa0fac26d14760a3ee48f149bf1d8b4d..26b1e22a2ba7610d1450c7c6b3aea613fa45c573 100644 |
| --- a/content/renderer/media/media_stream_video_source.cc |
| +++ b/content/renderer/media/media_stream_video_source.cc |
| @@ -15,6 +15,7 @@ |
| #include "content/renderer/media/media_stream_constraints_util.h" |
| #include "content/renderer/media/media_stream_video_track.h" |
| #include "content/renderer/media/video_track_adapter.h" |
| +#include "media/base/bind_to_current_loop.h" |
| namespace content { |
| @@ -350,6 +351,7 @@ bool MediaStreamVideoSource::IsConstraintSupported(const std::string& name) { |
| MediaStreamVideoSource::MediaStreamVideoSource() |
| : state_(NEW), |
| + muted_state_(false), |
| track_adapter_(new VideoTrackAdapter( |
| ChildProcess::current()->io_message_loop_proxy())), |
| weak_factory_(this) { |
| @@ -552,10 +554,16 @@ void MediaStreamVideoSource::FinalizeAddTrack() { |
| double max_frame_rate = 0.0f; |
| GetConstraintValueAsDouble(it->constraints, |
| kMaxFrameRate, &max_frame_rate); |
| + |
| + // QUESTION(mcasas): is Unretained OK here? |
|
Henrik Grunell
2014/07/08 11:39:53
Does this MediaStreamVideoSource object outlive th
mcasas
2014/07/08 16:12:01
MSVS has a |weak_ptr_factory_|, never mind this.
Henrik Grunell
2014/07/09 08:55:52
How/where is a weak ptr used to ensure we don't ca
mcasas
2014/07/09 12:39:35
"You can use a base::WeakPtr and base::WeakPtrFact
Henrik Grunell
2014/07/09 13:01:22
Yes. But you need to change base::Unretained(this)
|
| + VideoTrackAdapter::OnMutedCallback on_mute_callback = |
| + media::BindToCurrentLoop(base::Bind( |
| + &MediaStreamVideoSource::SetMutedState, base::Unretained(this))); |
| track_adapter_->AddTrack(it->track, it->frame_callback, |
| max_width, max_height, |
| min_aspect_ratio, max_aspect_ratio, |
| - max_frame_rate); |
| + max_frame_rate, current_format_.frame_rate, |
| + on_mute_callback); |
| } |
| DVLOG(3) << "FinalizeAddTrack() success " << success; |
| @@ -577,6 +585,16 @@ void MediaStreamVideoSource::SetReadyState( |
| } |
| } |
| +void MediaStreamVideoSource::SetMutedState(bool muted_state) { |
| + DCHECK(CalledOnValidThread()); |
| + DVLOG(3) << "MediaStreamVideoSource::SetBoolState state " << muted_state; |
| + // WebMediaStreamSource doesn't have a muted state, the tracks do. |
| + for (std::vector<MediaStreamVideoTrack*>::iterator it = tracks_.begin(); |
| + it != tracks_.end(); ++it) { |
| + (*it)->SetMutedState(muted_state); |
| + } |
| +} |
| + |
| MediaStreamVideoSource::RequestedConstraints::RequestedConstraints( |
| MediaStreamVideoTrack* track, |
| const VideoCaptureDeliverFrameCB& frame_callback, |