Chromium Code Reviews| 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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 226 // |session_id_| identifies the capture device used for this capture session. | 226 // |session_id_| identifies the capture device used for this capture session. |
| 227 const media::VideoCaptureSessionId session_id_; | 227 const media::VideoCaptureSessionId session_id_; |
| 228 | 228 |
| 229 VideoCaptureImplManager* const manager_; | 229 VideoCaptureImplManager* const manager_; |
| 230 | 230 |
| 231 const base::Closure release_device_cb_; | 231 const base::Closure release_device_cb_; |
| 232 | 232 |
| 233 // Indicates if we are capturing generated content, e.g. Tab or Desktop. | 233 // Indicates if we are capturing generated content, e.g. Tab or Desktop. |
| 234 const bool is_content_capture_; | 234 const bool is_content_capture_; |
| 235 | 235 |
| 236 // This is run once to report whether the device was successfully started | 236 // These two are valid between StartCapture() and StopCapture(). |
| 237 // after a call to StartCapture(). | 237 // |running_call_back_| is run when capture is successfully started, and when |
| 238 // it is stopped or error happens. | |
| 238 RunningCallback running_callback_; | 239 RunningCallback running_callback_; |
| 239 | |
| 240 // This is valid between StartCapture() and StopCapture(). | |
| 241 base::Closure stop_capture_cb_; | 240 base::Closure stop_capture_cb_; |
| 242 | 241 |
| 243 // Placeholder keeping the callback between asynchronous device enumeration | 242 // Placeholder keeping the callback between asynchronous device enumeration |
| 244 // calls. | 243 // calls. |
| 245 VideoCaptureDeviceFormatsCB formats_enumerated_callback_; | 244 VideoCaptureDeviceFormatsCB formats_enumerated_callback_; |
| 246 | 245 |
| 247 // Bound to the main render thread. | 246 // Bound to the main render thread. |
| 248 base::ThreadChecker thread_checker_; | 247 base::ThreadChecker thread_checker_; |
| 249 | 248 |
| 250 base::WeakPtrFactory<LocalVideoCapturerSource> weak_factory_; | 249 base::WeakPtrFactory<LocalVideoCapturerSource> weak_factory_; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 348 formats_enumerated_callback_.Reset(); | 347 formats_enumerated_callback_.Reset(); |
| 349 } | 348 } |
| 350 | 349 |
| 351 void LocalVideoCapturerSource::OnStateUpdate(VideoCaptureState state) { | 350 void LocalVideoCapturerSource::OnStateUpdate(VideoCaptureState state) { |
| 352 DVLOG(3) << __func__ << " state = " << state; | 351 DVLOG(3) << __func__ << " state = " << state; |
| 353 DCHECK(thread_checker_.CalledOnValidThread()); | 352 DCHECK(thread_checker_.CalledOnValidThread()); |
| 354 if (running_callback_.is_null()) | 353 if (running_callback_.is_null()) |
| 355 return; | 354 return; |
| 356 switch (state) { | 355 switch (state) { |
| 357 case VIDEO_CAPTURE_STATE_STARTED: | 356 case VIDEO_CAPTURE_STATE_STARTED: |
| 358 base::ResetAndReturn(&running_callback_).Run(true); | 357 running_callback_.Run(true); |
| 359 break; | 358 break; |
| 360 | 359 |
| 361 case VIDEO_CAPTURE_STATE_STOPPING: | 360 case VIDEO_CAPTURE_STATE_STOPPING: |
| 362 case VIDEO_CAPTURE_STATE_STOPPED: | 361 case VIDEO_CAPTURE_STATE_STOPPED: |
| 363 case VIDEO_CAPTURE_STATE_ERROR: | 362 case VIDEO_CAPTURE_STATE_ERROR: |
| 364 case VIDEO_CAPTURE_STATE_ENDED: | 363 case VIDEO_CAPTURE_STATE_ENDED: |
| 365 base::ResetAndReturn(&running_callback_).Run(false); | 364 base::ResetAndReturn(&running_callback_).Run(false); |
| 366 break; | 365 break; |
| 367 | 366 |
| 368 case VIDEO_CAPTURE_STATE_PAUSED: | 367 case VIDEO_CAPTURE_STATE_PAUSED: |
| 369 case VIDEO_CAPTURE_STATE_RESUMED: | 368 case VIDEO_CAPTURE_STATE_RESUMED: |
| 370 // Not applicable to reporting on device start success/failure. | 369 // Not applicable to reporting on device start success/failure. |
|
miu
2016/10/18 22:22:30
nit: // Not applicable to reporting on device star
xjz
2016/10/19 18:12:09
Done.
| |
| 371 break; | 370 break; |
| 372 } | 371 } |
| 373 } | 372 } |
| 374 | 373 |
| 375 void LocalVideoCapturerSource::OnDeviceFormatsInUseReceived( | 374 void LocalVideoCapturerSource::OnDeviceFormatsInUseReceived( |
| 376 const media::VideoCaptureFormats& formats_in_use) { | 375 const media::VideoCaptureFormats& formats_in_use) { |
| 377 DVLOG(3) << __func__ << ", #formats received: " << formats_in_use.size(); | 376 DVLOG(3) << __func__ << ", #formats received: " << formats_in_use.size(); |
| 378 DCHECK(thread_checker_.CalledOnValidThread()); | 377 DCHECK(thread_checker_.CalledOnValidThread()); |
| 379 // StopCapture() might have destroyed |formats_enumerated_callback_| before | 378 // StopCapture() might have destroyed |formats_enumerated_callback_| before |
| 380 // arriving here. | 379 // arriving here. |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 485 source_->StartCapture(new_params, | 484 source_->StartCapture(new_params, |
| 486 frame_callback, | 485 frame_callback, |
| 487 base::Bind(&MediaStreamVideoCapturerSource::OnStarted, | 486 base::Bind(&MediaStreamVideoCapturerSource::OnStarted, |
| 488 base::Unretained(this))); | 487 base::Unretained(this))); |
| 489 } | 488 } |
| 490 | 489 |
| 491 void MediaStreamVideoCapturerSource::StopSourceImpl() { | 490 void MediaStreamVideoCapturerSource::StopSourceImpl() { |
| 492 source_->StopCapture(); | 491 source_->StopCapture(); |
| 493 } | 492 } |
| 494 | 493 |
| 495 void MediaStreamVideoCapturerSource::OnStarted(bool result) { | 494 void MediaStreamVideoCapturerSource::OnStarted(bool result) { |
|
miu
2016/10/18 22:22:30
The original bug was most likely caused because th
xjz
2016/10/19 18:12:09
Done.
| |
| 496 OnStartDone(result ? MEDIA_DEVICE_OK : MEDIA_DEVICE_TRACK_START_FAILURE); | 495 OnStartDone(result ? MEDIA_DEVICE_OK : MEDIA_DEVICE_TRACK_START_FAILURE); |
|
miu
2016/10/18 22:22:30
This is also misleading, but I think there's more
xjz
2016/10/19 18:12:09
Done.
| |
| 497 } | 496 } |
| 498 | 497 |
| 499 const char* | 498 const char* |
| 500 MediaStreamVideoCapturerSource::GetPowerLineFrequencyForTesting() const { | 499 MediaStreamVideoCapturerSource::GetPowerLineFrequencyForTesting() const { |
| 501 return kPowerLineFrequency; | 500 return kPowerLineFrequency; |
| 502 } | 501 } |
| 503 | 502 |
| 504 } // namespace content | 503 } // namespace content |
| OLD | NEW |