Index: content/renderer/media/media_stream_video_capturer_source.cc |
diff --git a/content/renderer/media/media_stream_video_capturer_source.cc b/content/renderer/media/media_stream_video_capturer_source.cc |
index e03d440906d21fc26f969a89bcbbbaadcb1e9d73..5311b03fbcb004f2c47f83daf5a81d61b15ed2ec 100644 |
--- a/content/renderer/media/media_stream_video_capturer_source.cc |
+++ b/content/renderer/media/media_stream_video_capturer_source.cc |
@@ -105,11 +105,13 @@ void VideoCapturerDelegate::GetCurrentSupportedFormats( |
void VideoCapturerDelegate::StartCapture( |
const media::VideoCaptureParams& params, |
const VideoCaptureDeliverFrameCB& new_frame_callback, |
+ scoped_refptr<base::SingleThreadTaskRunner> frame_callback_task_runner, |
const RunningCallback& running_callback) { |
DCHECK(params.requested_format.IsValid()); |
DCHECK(thread_checker_.CalledOnValidThread()); |
running_callback_ = running_callback; |
+ |
perkj_chrome
2015/02/09 14:50:27
remove
hubbe
2015/02/09 20:13:32
Done.
|
// NULL in unit test. |
if (!RenderThreadImpl::current()) |
return; |
@@ -117,6 +119,13 @@ void VideoCapturerDelegate::StartCapture( |
RenderThreadImpl::current()->video_capture_impl_manager(); |
if (!manager) |
return; |
+ if (frame_callback_task_runner != |
+ RenderThreadImpl::current()->GetIOMessageLoopProxy()) { |
+ DCHECK(false) << "Only IO thread supported right now."; |
+ running_callback.Run(false); |
+ return; |
+ } |
+ |
stop_capture_cb_ = |
manager->StartCapture( |
session_id_, |
@@ -143,12 +152,11 @@ void VideoCapturerDelegate::OnStateUpdateOnRenderThread( |
DCHECK(thread_checker_.CalledOnValidThread()); |
DVLOG(3) << "OnStateUpdateOnRenderThread state = " << state; |
if (state == VIDEO_CAPTURE_STATE_STARTED && !running_callback_.is_null()) { |
- running_callback_.Run(MEDIA_DEVICE_OK); |
+ running_callback_.Run(true); |
return; |
} |
if (state > VIDEO_CAPTURE_STATE_STARTED && !running_callback_.is_null()) { |
- base::ResetAndReturn(&running_callback_).Run( |
- MEDIA_DEVICE_TRACK_START_FAILURE); |
+ base::ResetAndReturn(&running_callback_).Run(false); |
} |
} |
@@ -213,8 +221,8 @@ void VideoCapturerDelegate::OnDeviceSupportedFormatsEnumerated( |
MediaStreamVideoCapturerSource::MediaStreamVideoCapturerSource( |
const StreamDeviceInfo& device_info, |
const SourceStoppedCallback& stop_callback, |
- scoped_ptr<VideoCapturerDelegate> delegate) |
- : delegate_(delegate.Pass()) { |
+ scoped_refptr<media::VideoCapturerSource> delegate) |
+ : delegate_(delegate) { |
SetDeviceInfo(device_info); |
SetStopCallback(stop_callback); |
} |
@@ -247,10 +255,17 @@ void MediaStreamVideoCapturerSource::StartSourceImpl( |
delegate_->StartCapture( |
new_params, |
frame_callback, |
- base::Bind(&MediaStreamVideoCapturerSource::OnStartDone, |
+ RenderThreadImpl::current() ? |
+ RenderThreadImpl::current()->GetIOMessageLoopProxy() : |
+ NULL, |
+ base::Bind(&MediaStreamVideoCapturerSource::OnStarted, |
base::Unretained(this))); |
} |
+void MediaStreamVideoCapturerSource::OnStarted(bool result) { |
+ OnStartDone(result ? MEDIA_DEVICE_OK : MEDIA_DEVICE_TRACK_START_FAILURE); |
+} |
+ |
void MediaStreamVideoCapturerSource::StopSourceImpl() { |
delegate_->StopCapture(); |
} |