Chromium Code Reviews| 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 b414f7a6eeb7cf9dd736a09cb54b99a8e61bed78..7d92f37b5847f3d60320c0f32d03796134ba4c05 100644 |
| --- a/content/renderer/media/media_stream_video_capturer_source.cc |
| +++ b/content/renderer/media/media_stream_video_capturer_source.cc |
| @@ -14,19 +14,18 @@ |
| namespace { |
| -struct SourceVideoResolution { |
| +// Resolutions used if the source doesn't support capability enumeration. |
| +const struct { |
| int width; |
| int height; |
| -}; |
| +} kVideoResolutions[] = {{1920, 1080}, |
| + {1280, 720}, |
| + {960, 720}, |
| + {640, 480}, |
| + {640, 360}, |
| + {320, 240}, |
| + {320, 180}}; |
|
emircan
2015/03/10 01:40:06
I would prefer the earlier implementation as the s
mcasas
2015/03/13 01:09:33
Totally agree, but until such circumstance arises,
|
| -// Resolutions used if the source doesn't support capability enumeration. |
| -const SourceVideoResolution kVideoResolutions[] = {{1920, 1080}, |
| - {1280, 720}, |
| - {960, 720}, |
| - {640, 480}, |
| - {640, 360}, |
| - {320, 240}, |
| - {320, 180}}; |
| // Frame rates for sources with no support for capability enumeration. |
| const int kVideoFrameRates[] = {30, 60}; |
| @@ -88,7 +87,7 @@ void VideoCapturerDelegate::GetCurrentSupportedFormats( |
| // NULL in unit test. |
| if (!RenderThreadImpl::current()) |
| return; |
| - VideoCaptureImplManager* manager = |
| + VideoCaptureImplManager* const manager = |
| RenderThreadImpl::current()->video_capture_impl_manager(); |
| if (!manager) |
| return; |
| @@ -114,7 +113,7 @@ void VideoCapturerDelegate::StartCapture( |
| // NULL in unit test. |
| if (!RenderThreadImpl::current()) |
| return; |
| - VideoCaptureImplManager* manager = |
| + VideoCaptureImplManager* const manager = |
| RenderThreadImpl::current()->video_capture_impl_manager(); |
| if (!manager) |
| return; |
| @@ -125,14 +124,12 @@ void VideoCapturerDelegate::StartCapture( |
| return; |
| } |
| - stop_capture_cb_ = |
| - manager->StartCapture( |
| - session_id_, |
| - params, |
| - media::BindToCurrentLoop(base::Bind( |
| - &VideoCapturerDelegate::OnStateUpdateOnRenderThread, |
| - weak_factory_.GetWeakPtr())), |
| - new_frame_callback); |
| + stop_capture_cb_ = manager->StartCapture( |
| + session_id_, |
| + params, |
| + media::BindToCurrentLoop(base::Bind(&VideoCapturerDelegate::OnStateUpdate, |
| + weak_factory_.GetWeakPtr())), |
| + new_frame_callback); |
| } |
| void VideoCapturerDelegate::StopCapture() { |
| @@ -146,10 +143,10 @@ void VideoCapturerDelegate::StopCapture() { |
| source_formats_callback_.Reset(); |
| } |
| -void VideoCapturerDelegate::OnStateUpdateOnRenderThread( |
| +void VideoCapturerDelegate::OnStateUpdate( |
| VideoCaptureState state) { |
| DCHECK(thread_checker_.CalledOnValidThread()); |
| - DVLOG(3) << "OnStateUpdateOnRenderThread state = " << state; |
| + DVLOG(3) << "OnStateUpdate state = " << state; |
| if (state == VIDEO_CAPTURE_STATE_STARTED && !running_callback_.is_null()) { |
| running_callback_.Run(true); |
| return; |
| @@ -178,7 +175,7 @@ void VideoCapturerDelegate::OnDeviceFormatsInUseReceived( |
| // NULL in unit test. |
| if (!RenderThreadImpl::current()) |
| return; |
| - VideoCaptureImplManager* manager = |
| + VideoCaptureImplManager* const manager = |
| RenderThreadImpl::current()->video_capture_impl_manager(); |
| if (!manager) |
| return; |
| @@ -206,11 +203,11 @@ void VideoCapturerDelegate::OnDeviceSupportedFormatsEnumerated( |
| // The capture device doesn't seem to support capability enumeration, |
| // compose a fallback list of capabilities. |
| media::VideoCaptureFormats default_formats; |
| - for (size_t i = 0; i < arraysize(kVideoResolutions); ++i) { |
| - for (size_t j = 0; j < arraysize(kVideoFrameRates); ++j) { |
| + for (const auto& resolution : kVideoResolutions) { |
| + for (const auto& frame_rate : kVideoFrameRates) { |
|
emircan
2015/03/10 01:40:06
frame_rate is an int so copying by value would be
mcasas
2015/03/13 01:09:33
Done.
|
| default_formats.push_back(media::VideoCaptureFormat( |
| - gfx::Size(kVideoResolutions[i].width, kVideoResolutions[i].height), |
| - kVideoFrameRates[j], media::PIXEL_FORMAT_I420)); |
| + gfx::Size(resolution.width, resolution.height), frame_rate, |
| + media::PIXEL_FORMAT_I420)); |
| } |
| } |
| base::ResetAndReturn(&source_formats_callback_).Run(default_formats); |
| @@ -224,14 +221,14 @@ MediaStreamVideoCapturerSource::MediaStreamVideoCapturerSource( |
| SetStopCallback(stop_callback); |
| } |
| +MediaStreamVideoCapturerSource::~MediaStreamVideoCapturerSource() { |
| +} |
| + |
| void MediaStreamVideoCapturerSource::SetDeviceInfo( |
| const StreamDeviceInfo& device_info) { |
| MediaStreamVideoSource::SetDeviceInfo(device_info); |
| } |
| -MediaStreamVideoCapturerSource::~MediaStreamVideoCapturerSource() { |
| -} |
| - |
| void MediaStreamVideoCapturerSource::GetCurrentSupportedFormats( |
| int max_requested_width, |
| int max_requested_height, |
| @@ -264,12 +261,12 @@ void MediaStreamVideoCapturerSource::StartSourceImpl( |
| base::Unretained(this))); |
| } |
| -void MediaStreamVideoCapturerSource::OnStarted(bool result) { |
| - OnStartDone(result ? MEDIA_DEVICE_OK : MEDIA_DEVICE_TRACK_START_FAILURE); |
| -} |
| - |
| void MediaStreamVideoCapturerSource::StopSourceImpl() { |
| delegate_->StopCapture(); |
| } |
| +void MediaStreamVideoCapturerSource::OnStarted(bool result) { |
| + OnStartDone(result ? MEDIA_DEVICE_OK : MEDIA_DEVICE_TRACK_START_FAILURE); |
| +} |
| + |
| } // namespace content |