diff options
Diffstat (limited to 'content/renderer/media/media_stream_video_source.cc')
-rw-r--r-- | content/renderer/media/media_stream_video_source.cc | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/content/renderer/media/media_stream_video_source.cc b/content/renderer/media/media_stream_video_source.cc index eb6ac78..ba8bb54 100644 --- a/content/renderer/media/media_stream_video_source.cc +++ b/content/renderer/media/media_stream_video_source.cc @@ -15,7 +15,6 @@ #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 { @@ -358,7 +357,6 @@ 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) { @@ -460,6 +458,7 @@ void MediaStreamVideoSource::DoStopSource() { DVLOG(3) << "DoStopSource()"; if (state_ == ENDED) return; + track_adapter_->StopFrameMonitoring(); StopSourceImpl(); state_ = ENDED; SetReadyState(blink::WebMediaStreamSource::ReadyStateEnded); @@ -535,6 +534,12 @@ void MediaStreamVideoSource::OnStartDone(MediaStreamRequestResult result) { DCHECK_EQ(STARTING, state_); state_ = STARTED; SetReadyState(blink::WebMediaStreamSource::ReadyStateLive); + + track_adapter_->StartFrameMonitoring( + current_format_.frame_rate, + base::Bind(&MediaStreamVideoSource::SetMutedState, + weak_factory_.GetWeakPtr())); + } else { StopSource(); } @@ -577,15 +582,10 @@ void MediaStreamVideoSource::FinalizeAddTrack() { GetConstraintValueAsDouble(it->constraints, kMaxFrameRate, &max_frame_rate); - VideoTrackAdapter::OnMutedCallback on_mute_callback = - media::BindToCurrentLoop(base::Bind( - &MediaStreamVideoSource::SetMutedState, - weak_factory_.GetWeakPtr())); track_adapter_->AddTrack(it->track, it->frame_callback, max_width, max_height, min_aspect_ratio, max_aspect_ratio, - max_frame_rate, current_format_.frame_rate, - on_mute_callback); + max_frame_rate); } DVLOG(3) << "FinalizeAddTrack() result " << result; @@ -611,18 +611,10 @@ void MediaStreamVideoSource::SetReadyState( void MediaStreamVideoSource::SetMutedState(bool muted_state) { DVLOG(3) << "MediaStreamVideoSource::SetMutedState state=" << muted_state; DCHECK(CalledOnValidThread()); - if (muted_state != muted_state_) { - muted_state_ = muted_state; - if (!owner().isNull()) { - owner().setReadyState(muted_state_ + if (!owner().isNull()) { + owner().setReadyState(muted_state ? blink::WebMediaStreamSource::ReadyStateMuted : blink::WebMediaStreamSource::ReadyStateLive); - } - } - // 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); } } |