| 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 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 | 359 |
| 360 case VIDEO_CAPTURE_STATE_STOPPING: | 360 case VIDEO_CAPTURE_STATE_STOPPING: |
| 361 case VIDEO_CAPTURE_STATE_STOPPED: | 361 case VIDEO_CAPTURE_STATE_STOPPED: |
| 362 case VIDEO_CAPTURE_STATE_ERROR: | 362 case VIDEO_CAPTURE_STATE_ERROR: |
| 363 case VIDEO_CAPTURE_STATE_ENDED: | 363 case VIDEO_CAPTURE_STATE_ENDED: |
| 364 base::ResetAndReturn(&running_callback_).Run(false); | 364 base::ResetAndReturn(&running_callback_).Run(false); |
| 365 break; | 365 break; |
| 366 | 366 |
| 367 case VIDEO_CAPTURE_STATE_PAUSED: | 367 case VIDEO_CAPTURE_STATE_PAUSED: |
| 368 case VIDEO_CAPTURE_STATE_RESUMED: | 368 case VIDEO_CAPTURE_STATE_RESUMED: |
| 369 // Not applicable to reporting on device start success/failure. | 369 // Not applicable to reporting on device starts or errors. |
| 370 break; | 370 break; |
| 371 } | 371 } |
| 372 } | 372 } |
| 373 | 373 |
| 374 void LocalVideoCapturerSource::OnDeviceFormatsInUseReceived( | 374 void LocalVideoCapturerSource::OnDeviceFormatsInUseReceived( |
| 375 const media::VideoCaptureFormats& formats_in_use) { | 375 const media::VideoCaptureFormats& formats_in_use) { |
| 376 DVLOG(3) << __func__ << ", #formats received: " << formats_in_use.size(); | 376 DVLOG(3) << __func__ << ", #formats received: " << formats_in_use.size(); |
| 377 DCHECK(thread_checker_.CalledOnValidThread()); | 377 DCHECK(thread_checker_.CalledOnValidThread()); |
| 378 // StopCapture() might have destroyed |formats_enumerated_callback_| before | 378 // StopCapture() might have destroyed |formats_enumerated_callback_| before |
| 379 // arriving here. | 379 // arriving here. |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 const VideoCaptureDeliverFrameCB& frame_callback) { | 474 const VideoCaptureDeliverFrameCB& frame_callback) { |
| 475 media::VideoCaptureParams new_params; | 475 media::VideoCaptureParams new_params; |
| 476 new_params.requested_format = format; | 476 new_params.requested_format = format; |
| 477 if (IsContentVideoCaptureDevice(device_info())) { | 477 if (IsContentVideoCaptureDevice(device_info())) { |
| 478 SetContentCaptureParamsFromConstraints( | 478 SetContentCaptureParamsFromConstraints( |
| 479 constraints, device_info().device.type, &new_params); | 479 constraints, device_info().device.type, &new_params); |
| 480 } else if (device_info().device.type == MEDIA_DEVICE_VIDEO_CAPTURE) { | 480 } else if (device_info().device.type == MEDIA_DEVICE_VIDEO_CAPTURE) { |
| 481 SetPowerLineFrequencyParamFromConstraints(constraints, &new_params); | 481 SetPowerLineFrequencyParamFromConstraints(constraints, &new_params); |
| 482 } | 482 } |
| 483 | 483 |
| 484 source_->StartCapture(new_params, | 484 is_capture_starting_ = true; |
| 485 frame_callback, | 485 source_->StartCapture( |
| 486 base::Bind(&MediaStreamVideoCapturerSource::OnStarted, | 486 new_params, frame_callback, |
| 487 base::Unretained(this))); | 487 base::Bind(&MediaStreamVideoCapturerSource::OnRunStateChanged, |
| 488 base::Unretained(this))); |
| 488 } | 489 } |
| 489 | 490 |
| 490 void MediaStreamVideoCapturerSource::StopSourceImpl() { | 491 void MediaStreamVideoCapturerSource::StopSourceImpl() { |
| 491 source_->StopCapture(); | 492 source_->StopCapture(); |
| 492 } | 493 } |
| 493 | 494 |
| 494 void MediaStreamVideoCapturerSource::OnStarted(bool result) { | 495 void MediaStreamVideoCapturerSource::OnRunStateChanged(bool is_running) { |
| 495 OnStartDone(result ? MEDIA_DEVICE_OK : MEDIA_DEVICE_TRACK_START_FAILURE); | 496 if (is_capture_starting_) { |
| 497 OnStartDone(is_running ? MEDIA_DEVICE_OK |
| 498 : MEDIA_DEVICE_TRACK_START_FAILURE); |
| 499 is_capture_starting_ = false; |
| 500 } else if (!is_running) { |
| 501 StopSource(); |
| 502 } |
| 496 } | 503 } |
| 497 | 504 |
| 498 const char* | 505 const char* |
| 499 MediaStreamVideoCapturerSource::GetPowerLineFrequencyForTesting() const { | 506 MediaStreamVideoCapturerSource::GetPowerLineFrequencyForTesting() const { |
| 500 return kPowerLineFrequency; | 507 return kPowerLineFrequency; |
| 501 } | 508 } |
| 502 | 509 |
| 503 } // namespace content | 510 } // namespace content |
| OLD | NEW |