| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/renderer_host/media/video_capture_manager.h" | 5 #include "content/browser/renderer_host/media/video_capture_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 int serial_id, | 320 int serial_id, |
| 321 media::VideoCaptureSessionId session_id, | 321 media::VideoCaptureSessionId session_id, |
| 322 const media::VideoCaptureParams& params) | 322 const media::VideoCaptureParams& params) |
| 323 : serial_id_(serial_id), | 323 : serial_id_(serial_id), |
| 324 session_id_(session_id), | 324 session_id_(session_id), |
| 325 params_(params), | 325 params_(params), |
| 326 abort_start_(false) { | 326 abort_start_(false) { |
| 327 } | 327 } |
| 328 | 328 |
| 329 VideoCaptureManager::VideoCaptureManager( | 329 VideoCaptureManager::VideoCaptureManager( |
| 330 std::unique_ptr<media::VideoCaptureDeviceFactory> factory) | 330 std::unique_ptr<media::VideoCaptureDeviceFactory> factory, |
| 331 : listener_(nullptr), | 331 scoped_refptr<base::SingleThreadTaskRunner> device_task_runner) |
| 332 : device_task_runner_(std::move(device_task_runner)), |
| 333 listener_(nullptr), |
| 332 new_capture_session_id_(1), | 334 new_capture_session_id_(1), |
| 333 video_capture_device_factory_(std::move(factory)) {} | 335 video_capture_device_factory_(std::move(factory)) {} |
| 334 | 336 |
| 335 VideoCaptureManager::~VideoCaptureManager() { | 337 VideoCaptureManager::~VideoCaptureManager() { |
| 336 DCHECK(devices_.empty()); | 338 DCHECK(devices_.empty()); |
| 337 DCHECK(device_start_queue_.empty()); | 339 DCHECK(device_start_queue_.empty()); |
| 338 } | 340 } |
| 339 | 341 |
| 340 void VideoCaptureManager::Register( | 342 void VideoCaptureManager::RegisterListener( |
| 341 MediaStreamProviderListener* listener, | 343 MediaStreamProviderListener* listener) { |
| 342 const scoped_refptr<base::SingleThreadTaskRunner>& device_task_runner) { | |
| 343 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 344 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 344 DCHECK(!listener_); | 345 DCHECK(!listener_); |
| 345 DCHECK(!device_task_runner_.get()); | 346 DCHECK(device_task_runner_); |
| 346 listener_ = listener; | 347 listener_ = listener; |
| 347 device_task_runner_ = device_task_runner; | |
| 348 #if defined(OS_ANDROID) | 348 #if defined(OS_ANDROID) |
| 349 application_state_has_running_activities_ = true; | 349 application_state_has_running_activities_ = true; |
| 350 app_status_listener_.reset(new base::android::ApplicationStatusListener( | 350 app_status_listener_.reset(new base::android::ApplicationStatusListener( |
| 351 base::Bind(&VideoCaptureManager::OnApplicationStateChange, | 351 base::Bind(&VideoCaptureManager::OnApplicationStateChange, |
| 352 base::Unretained(this)))); | 352 base::Unretained(this)))); |
| 353 #endif | 353 #endif |
| 354 } | 354 } |
| 355 | 355 |
| 356 void VideoCaptureManager::Unregister() { | 356 void VideoCaptureManager::UnregisterListener() { |
| 357 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 357 DCHECK(listener_); | 358 DCHECK(listener_); |
| 358 listener_ = nullptr; | 359 listener_ = nullptr; |
| 359 } | 360 } |
| 360 | 361 |
| 361 void VideoCaptureManager::EnumerateDevices( | 362 void VideoCaptureManager::EnumerateDevices( |
| 362 const EnumerationCallback& client_callback) { | 363 const EnumerationCallback& client_callback) { |
| 363 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 364 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 364 DVLOG(1) << "VideoCaptureManager::EnumerateDevices"; | 365 DVLOG(1) << "VideoCaptureManager::EnumerateDevices"; |
| 365 | 366 |
| 366 // Bind a callback to ConsolidateDevicesInfoOnDeviceThread() with an argument | 367 // Bind a callback to ConsolidateDevicesInfoOnDeviceThread() with an argument |
| (...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1349 if (!device_in_queue) { | 1350 if (!device_in_queue) { |
| 1350 // Session ID is only valid for Screen capture. So we can fake it to | 1351 // Session ID is only valid for Screen capture. So we can fake it to |
| 1351 // resume video capture devices here. | 1352 // resume video capture devices here. |
| 1352 QueueStartDevice(kFakeSessionId, entry.get(), entry->parameters); | 1353 QueueStartDevice(kFakeSessionId, entry.get(), entry->parameters); |
| 1353 } | 1354 } |
| 1354 } | 1355 } |
| 1355 } | 1356 } |
| 1356 #endif // defined(OS_ANDROID) | 1357 #endif // defined(OS_ANDROID) |
| 1357 | 1358 |
| 1358 } // namespace content | 1359 } // namespace content |
| OLD | NEW |