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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 } else { | 162 } else { |
163 // Constraints specify a minimum resolution that is smaller than the | 163 // Constraints specify a minimum resolution that is smaller than the |
164 // maximum resolution and has a different aspect ratio (possibly even | 164 // maximum resolution and has a different aspect ratio (possibly even |
165 // 0x0). This indicates any frame resolution and aspect ratio is | 165 // 0x0). This indicates any frame resolution and aspect ratio is |
166 // acceptable. | 166 // acceptable. |
167 params->resolution_change_policy = | 167 params->resolution_change_policy = |
168 media::RESOLUTION_POLICY_ANY_WITHIN_LIMIT; | 168 media::RESOLUTION_POLICY_ANY_WITHIN_LIMIT; |
169 } | 169 } |
170 } | 170 } |
171 | 171 |
172 DVLOG(1) << __FUNCTION__ << " " | 172 DVLOG(1) << __func__ << " " |
173 << media::VideoCaptureFormat::ToString(params->requested_format) | 173 << media::VideoCaptureFormat::ToString(params->requested_format) |
174 << " with resolution change policy " | 174 << " with resolution change policy " |
175 << params->resolution_change_policy; | 175 << params->resolution_change_policy; |
176 } | 176 } |
177 | 177 |
178 // Interprets the properties in |constraints| to override values in |params| and | 178 // Interprets the properties in |constraints| to override values in |params| and |
179 // determine the power line frequency. | 179 // determine the power line frequency. |
180 void SetPowerLineFrequencyParamFromConstraints( | 180 void SetPowerLineFrequencyParamFromConstraints( |
181 const blink::WebMediaConstraints& constraints, | 181 const blink::WebMediaConstraints& constraints, |
182 media::VideoCaptureParams* params) { | 182 media::VideoCaptureParams* params) { |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 running_callback_ = running_callback; | 305 running_callback_ = running_callback; |
306 | 306 |
307 stop_capture_cb_ = manager_->StartCapture( | 307 stop_capture_cb_ = manager_->StartCapture( |
308 session_id_, params, media::BindToCurrentLoop(base::Bind( | 308 session_id_, params, media::BindToCurrentLoop(base::Bind( |
309 &LocalVideoCapturerSource::OnStateUpdate, | 309 &LocalVideoCapturerSource::OnStateUpdate, |
310 weak_factory_.GetWeakPtr())), | 310 weak_factory_.GetWeakPtr())), |
311 new_frame_callback); | 311 new_frame_callback); |
312 } | 312 } |
313 | 313 |
314 void LocalVideoCapturerSource::RequestRefreshFrame() { | 314 void LocalVideoCapturerSource::RequestRefreshFrame() { |
315 DVLOG(3) << __FUNCTION__; | 315 DVLOG(3) << __func__; |
316 DCHECK(thread_checker_.CalledOnValidThread()); | 316 DCHECK(thread_checker_.CalledOnValidThread()); |
317 if (stop_capture_cb_.is_null()) | 317 if (stop_capture_cb_.is_null()) |
318 return; // Do not request frames if the source is stopped. | 318 return; // Do not request frames if the source is stopped. |
319 manager_->RequestRefreshFrame(session_id_); | 319 manager_->RequestRefreshFrame(session_id_); |
320 } | 320 } |
321 | 321 |
322 void LocalVideoCapturerSource::StopCapture() { | 322 void LocalVideoCapturerSource::StopCapture() { |
323 DVLOG(3) << __FUNCTION__; | 323 DVLOG(3) << __func__; |
324 DCHECK(thread_checker_.CalledOnValidThread()); | 324 DCHECK(thread_checker_.CalledOnValidThread()); |
325 // Immediately make sure we don't provide more frames. | 325 // Immediately make sure we don't provide more frames. |
326 if (!stop_capture_cb_.is_null()) | 326 if (!stop_capture_cb_.is_null()) |
327 base::ResetAndReturn(&stop_capture_cb_).Run(); | 327 base::ResetAndReturn(&stop_capture_cb_).Run(); |
328 running_callback_.Reset(); | 328 running_callback_.Reset(); |
329 // Invalidate any potential format enumerations going on. | 329 // Invalidate any potential format enumerations going on. |
330 formats_enumerated_callback_.Reset(); | 330 formats_enumerated_callback_.Reset(); |
331 } | 331 } |
332 | 332 |
333 void LocalVideoCapturerSource::OnStateUpdate(VideoCaptureState state) { | 333 void LocalVideoCapturerSource::OnStateUpdate(VideoCaptureState state) { |
334 DVLOG(3) << __FUNCTION__ << " state = " << state; | 334 DVLOG(3) << __func__ << " state = " << state; |
335 DCHECK(thread_checker_.CalledOnValidThread()); | 335 DCHECK(thread_checker_.CalledOnValidThread()); |
336 if (running_callback_.is_null()) | 336 if (running_callback_.is_null()) |
337 return; | 337 return; |
338 const bool is_started_ok = state == VIDEO_CAPTURE_STATE_STARTED; | 338 const bool is_started_ok = state == VIDEO_CAPTURE_STATE_STARTED; |
339 running_callback_.Run(is_started_ok); | 339 running_callback_.Run(is_started_ok); |
340 if (!is_started_ok) | 340 if (!is_started_ok) |
341 running_callback_.Reset(); | 341 running_callback_.Reset(); |
342 } | 342 } |
343 | 343 |
344 void LocalVideoCapturerSource::OnDeviceFormatsInUseReceived( | 344 void LocalVideoCapturerSource::OnDeviceFormatsInUseReceived( |
345 const media::VideoCaptureFormats& formats_in_use) { | 345 const media::VideoCaptureFormats& formats_in_use) { |
346 DVLOG(3) << __FUNCTION__ << ", #formats received: " << formats_in_use.size(); | 346 DVLOG(3) << __func__ << ", #formats received: " << formats_in_use.size(); |
347 DCHECK(thread_checker_.CalledOnValidThread()); | 347 DCHECK(thread_checker_.CalledOnValidThread()); |
348 // StopCapture() might have destroyed |formats_enumerated_callback_| before | 348 // StopCapture() might have destroyed |formats_enumerated_callback_| before |
349 // arriving here. | 349 // arriving here. |
350 if (formats_enumerated_callback_.is_null()) | 350 if (formats_enumerated_callback_.is_null()) |
351 return; | 351 return; |
352 if (formats_in_use.size()) { | 352 if (formats_in_use.size()) { |
353 base::ResetAndReturn(&formats_enumerated_callback_).Run(formats_in_use); | 353 base::ResetAndReturn(&formats_enumerated_callback_).Run(formats_in_use); |
354 return; | 354 return; |
355 } | 355 } |
356 | 356 |
357 // The device doesn't seem to have formats in use so try and retrieve the | 357 // The device doesn't seem to have formats in use so try and retrieve the |
358 // whole list of supported ones. | 358 // whole list of supported ones. |
359 manager_->GetDeviceSupportedFormats( | 359 manager_->GetDeviceSupportedFormats( |
360 session_id_, | 360 session_id_, |
361 media::BindToCurrentLoop( | 361 media::BindToCurrentLoop( |
362 base::Bind( | 362 base::Bind( |
363 &LocalVideoCapturerSource::OnDeviceSupportedFormatsEnumerated, | 363 &LocalVideoCapturerSource::OnDeviceSupportedFormatsEnumerated, |
364 weak_factory_.GetWeakPtr()))); | 364 weak_factory_.GetWeakPtr()))); |
365 } | 365 } |
366 | 366 |
367 void LocalVideoCapturerSource::OnDeviceSupportedFormatsEnumerated( | 367 void LocalVideoCapturerSource::OnDeviceSupportedFormatsEnumerated( |
368 const media::VideoCaptureFormats& formats) { | 368 const media::VideoCaptureFormats& formats) { |
369 DVLOG(3) << __FUNCTION__ << ", #formats received: " << formats.size(); | 369 DVLOG(3) << __func__ << ", #formats received: " << formats.size(); |
370 DCHECK(thread_checker_.CalledOnValidThread()); | 370 DCHECK(thread_checker_.CalledOnValidThread()); |
371 // StopCapture() might have destroyed |formats_enumerated_callback_| before | 371 // StopCapture() might have destroyed |formats_enumerated_callback_| before |
372 // arriving here. | 372 // arriving here. |
373 if (formats_enumerated_callback_.is_null()) | 373 if (formats_enumerated_callback_.is_null()) |
374 return; | 374 return; |
375 if (formats.size()) { | 375 if (formats.size()) { |
376 base::ResetAndReturn(&formats_enumerated_callback_).Run(formats); | 376 base::ResetAndReturn(&formats_enumerated_callback_).Run(formats); |
377 return; | 377 return; |
378 } | 378 } |
379 | 379 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 void MediaStreamVideoCapturerSource::OnStarted(bool result) { | 457 void MediaStreamVideoCapturerSource::OnStarted(bool result) { |
458 OnStartDone(result ? MEDIA_DEVICE_OK : MEDIA_DEVICE_TRACK_START_FAILURE); | 458 OnStartDone(result ? MEDIA_DEVICE_OK : MEDIA_DEVICE_TRACK_START_FAILURE); |
459 } | 459 } |
460 | 460 |
461 const char* | 461 const char* |
462 MediaStreamVideoCapturerSource::GetPowerLineFrequencyForTesting() const { | 462 MediaStreamVideoCapturerSource::GetPowerLineFrequencyForTesting() const { |
463 return kPowerLineFrequency; | 463 return kPowerLineFrequency; |
464 } | 464 } |
465 | 465 |
466 } // namespace content | 466 } // namespace content |
OLD | NEW |