| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/media/media_stream_video_capturer_source.h" | 5 #include "content/renderer/media/media_stream_video_capturer_source.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "content/renderer/media/video_capture_impl_manager.h" | 10 #include "content/renderer/media/video_capture_impl_manager.h" |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 } | 136 } |
| 137 running_callback_.Reset(); | 137 running_callback_.Reset(); |
| 138 source_formats_callback_.Reset(); | 138 source_formats_callback_.Reset(); |
| 139 } | 139 } |
| 140 | 140 |
| 141 void VideoCapturerDelegate::OnStateUpdateOnRenderThread( | 141 void VideoCapturerDelegate::OnStateUpdateOnRenderThread( |
| 142 VideoCaptureState state) { | 142 VideoCaptureState state) { |
| 143 DCHECK(thread_checker_.CalledOnValidThread()); | 143 DCHECK(thread_checker_.CalledOnValidThread()); |
| 144 DVLOG(3) << "OnStateUpdateOnRenderThread state = " << state; | 144 DVLOG(3) << "OnStateUpdateOnRenderThread state = " << state; |
| 145 if (state == VIDEO_CAPTURE_STATE_STARTED && !running_callback_.is_null()) { | 145 if (state == VIDEO_CAPTURE_STATE_STARTED && !running_callback_.is_null()) { |
| 146 running_callback_.Run(MEDIA_DEVICE_OK); | 146 running_callback_.Run(true); |
| 147 return; | 147 return; |
| 148 } | 148 } |
| 149 if (state > VIDEO_CAPTURE_STATE_STARTED && !running_callback_.is_null()) { | 149 if (state > VIDEO_CAPTURE_STATE_STARTED && !running_callback_.is_null()) { |
| 150 base::ResetAndReturn(&running_callback_).Run( | 150 base::ResetAndReturn(&running_callback_).Run(false); |
| 151 MEDIA_DEVICE_TRACK_START_FAILURE); | |
| 152 } | 151 } |
| 153 } | 152 } |
| 154 | 153 |
| 155 void VideoCapturerDelegate::OnDeviceFormatsInUseReceived( | 154 void VideoCapturerDelegate::OnDeviceFormatsInUseReceived( |
| 156 const media::VideoCaptureFormats& formats_in_use) { | 155 const media::VideoCaptureFormats& formats_in_use) { |
| 157 DVLOG(3) << "OnDeviceFormatsInUseReceived: " << formats_in_use.size(); | 156 DVLOG(3) << "OnDeviceFormatsInUseReceived: " << formats_in_use.size(); |
| 158 DCHECK(thread_checker_.CalledOnValidThread()); | 157 DCHECK(thread_checker_.CalledOnValidThread()); |
| 159 // StopCapture() might have destroyed |source_formats_callback_| before | 158 // StopCapture() might have destroyed |source_formats_callback_| before |
| 160 // arriving here. | 159 // arriving here. |
| 161 if (source_formats_callback_.is_null()) | 160 if (source_formats_callback_.is_null()) |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 kVideoFrameRates[j], media::PIXEL_FORMAT_I420)); | 205 kVideoFrameRates[j], media::PIXEL_FORMAT_I420)); |
| 207 } | 206 } |
| 208 } | 207 } |
| 209 base::ResetAndReturn(&source_formats_callback_).Run(default_formats); | 208 base::ResetAndReturn(&source_formats_callback_).Run(default_formats); |
| 210 } | 209 } |
| 211 } | 210 } |
| 212 | 211 |
| 213 MediaStreamVideoCapturerSource::MediaStreamVideoCapturerSource( | 212 MediaStreamVideoCapturerSource::MediaStreamVideoCapturerSource( |
| 214 const StreamDeviceInfo& device_info, | 213 const StreamDeviceInfo& device_info, |
| 215 const SourceStoppedCallback& stop_callback, | 214 const SourceStoppedCallback& stop_callback, |
| 216 scoped_ptr<VideoCapturerDelegate> delegate) | 215 scoped_refptr<media::VideoCapturerSource> delegate) |
| 217 : delegate_(delegate.Pass()) { | 216 : delegate_(delegate) { |
| 218 SetDeviceInfo(device_info); | 217 SetDeviceInfo(device_info); |
| 219 SetStopCallback(stop_callback); | 218 SetStopCallback(stop_callback); |
| 220 } | 219 } |
| 221 | 220 |
| 222 MediaStreamVideoCapturerSource::~MediaStreamVideoCapturerSource() { | 221 MediaStreamVideoCapturerSource::~MediaStreamVideoCapturerSource() { |
| 223 } | 222 } |
| 224 | 223 |
| 225 void MediaStreamVideoCapturerSource::GetCurrentSupportedFormats( | 224 void MediaStreamVideoCapturerSource::GetCurrentSupportedFormats( |
| 226 int max_requested_width, | 225 int max_requested_width, |
| 227 int max_requested_height, | 226 int max_requested_height, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 240 media::VideoCaptureParams new_params; | 239 media::VideoCaptureParams new_params; |
| 241 new_params.requested_format = format; | 240 new_params.requested_format = format; |
| 242 if (device_info().device.type == MEDIA_TAB_VIDEO_CAPTURE || | 241 if (device_info().device.type == MEDIA_TAB_VIDEO_CAPTURE || |
| 243 device_info().device.type == MEDIA_DESKTOP_VIDEO_CAPTURE) { | 242 device_info().device.type == MEDIA_DESKTOP_VIDEO_CAPTURE) { |
| 244 new_params.resolution_change_policy = | 243 new_params.resolution_change_policy = |
| 245 media::RESOLUTION_POLICY_DYNAMIC_WITHIN_LIMIT; | 244 media::RESOLUTION_POLICY_DYNAMIC_WITHIN_LIMIT; |
| 246 } | 245 } |
| 247 delegate_->StartCapture( | 246 delegate_->StartCapture( |
| 248 new_params, | 247 new_params, |
| 249 frame_callback, | 248 frame_callback, |
| 250 base::Bind(&MediaStreamVideoCapturerSource::OnStartDone, | 249 base::Bind(&MediaStreamVideoCapturerSource::OnStarted, |
| 251 base::Unretained(this))); | 250 base::Unretained(this))); |
| 252 } | 251 } |
| 253 | 252 |
| 253 void MediaStreamVideoCapturerSource::OnStarted(bool result) { |
| 254 OnStartDone(result ? MEDIA_DEVICE_OK : MEDIA_DEVICE_TRACK_START_FAILURE); |
| 255 } |
| 256 |
| 254 void MediaStreamVideoCapturerSource::StopSourceImpl() { | 257 void MediaStreamVideoCapturerSource::StopSourceImpl() { |
| 255 delegate_->StopCapture(); | 258 delegate_->StopCapture(); |
| 256 } | 259 } |
| 257 | 260 |
| 258 } // namespace content | 261 } // namespace content |
| OLD | NEW |