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

Unified Diff: content/renderer/media/media_stream_video_source.cc

Issue 509873002: Refactor MediaStreamTrack video onmute event. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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: 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 0bd016bd92fa41faa0653c73800e072866253f14..a07efa5f7ef0e3d3f44f6321483e2cdaf10b7f0b 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 {
@@ -357,7 +356,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) {
@@ -459,6 +457,7 @@ void MediaStreamVideoSource::DoStopSource() {
DVLOG(3) << "DoStopSource()";
if (state_ == ENDED)
return;
+ track_adapter_->StopFrameMonitoring();
StopSourceImpl();
state_ = ENDED;
SetReadyState(blink::WebMediaStreamSource::ReadyStateEnded);
@@ -534,6 +533,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();
}
@@ -576,15 +581,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;
@@ -610,18 +610,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);
}
}

Powered by Google App Engine
This is Rietveld 408576698