#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 {
MediaStreamVideoSource::MediaStreamVideoSource()
: state_(NEW),
- muted_state_(false),
track_adapter_(new VideoTrackAdapter(
ChildProcess::current()->io_message_loop_proxy())),
weak_factory_(this) {
DVLOG(3) << "DoStopSource()";
if (state_ == ENDED)
return;
+ track_adapter_->StopFrameMonitoring();
StopSourceImpl();
state_ = ENDED;
SetReadyState(blink::WebMediaStreamSource::ReadyStateEnded);
}
state_ = STARTING;
- DVLOG(3) << "Starting the capturer with"
- << " width = " << current_format_.frame_size.width()
- << " height = " << current_format_.frame_size.height()
- << " frame rate = " << current_format_.frame_rate
- << " pixel format = "
- << media::VideoCaptureFormat::PixelFormatToString(
- current_format_.pixel_format);
-
- media::VideoCaptureParams params;
- params.requested_format = current_format_;
+ DVLOG(3) << "Starting the capturer with " << current_format_.ToString();
+
StartSourceImpl(
- params,
+ current_format_,
base::Bind(&VideoTrackAdapter::DeliverFrameOnIO, track_adapter_));
}
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();
}
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;
blink::WebMediaStreamSource::ReadyState state) {
DVLOG(3) << "MediaStreamVideoSource::SetReadyState state " << state;
DCHECK(CalledOnValidThread());
- if (!owner().isNull()) {
+ if (!owner().isNull())
owner().setReadyState(state);
- }
for (std::vector<MediaStreamVideoTrack*>::iterator it = tracks_.begin();
it != tracks_.end(); ++it) {
(*it)->OnReadyStateChanged(state);
void MediaStreamVideoSource::SetMutedState(bool muted_state) {
DVLOG(3) << "MediaStreamVideoSource::SetMutedState state=" << muted_state;
DCHECK(CalledOnValidThread());
- // 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);
+ if (!owner().isNull()) {
+ owner().setReadyState(muted_state
+ ? blink::WebMediaStreamSource::ReadyStateMuted
+ : blink::WebMediaStreamSource::ReadyStateLive);
}
}