| 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_host.h" | 5 #include "content/browser/renderer_host/media/video_capture_host.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 | 101 |
| 102 void VideoCaptureHost::OnEnded(VideoCaptureControllerID controller_id) { | 102 void VideoCaptureHost::OnEnded(VideoCaptureControllerID controller_id) { |
| 103 DVLOG(1) << __func__; | 103 DVLOG(1) << __func__; |
| 104 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 104 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 105 BrowserThread::PostTask( | 105 BrowserThread::PostTask( |
| 106 BrowserThread::IO, FROM_HERE, | 106 BrowserThread::IO, FROM_HERE, |
| 107 base::Bind(&VideoCaptureHost::DoEnded, weak_factory_.GetWeakPtr(), | 107 base::Bind(&VideoCaptureHost::DoEnded, weak_factory_.GetWeakPtr(), |
| 108 controller_id)); | 108 controller_id)); |
| 109 } | 109 } |
| 110 | 110 |
| 111 void VideoCaptureHost::OnStarted(VideoCaptureControllerID controller_id) { |
| 112 DVLOG(1) << __func__; |
| 113 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 114 if (controllers_.find(controller_id) == controllers_.end()) |
| 115 return; |
| 116 |
| 117 if (base::ContainsKey(device_id_to_observer_map_, controller_id)) { |
| 118 device_id_to_observer_map_[controller_id]->OnStateChanged( |
| 119 mojom::VideoCaptureState::STARTED); |
| 120 } |
| 121 } |
| 122 |
| 111 void VideoCaptureHost::Start(int32_t device_id, | 123 void VideoCaptureHost::Start(int32_t device_id, |
| 112 int32_t session_id, | 124 int32_t session_id, |
| 113 const media::VideoCaptureParams& params, | 125 const media::VideoCaptureParams& params, |
| 114 mojom::VideoCaptureObserverPtr observer) { | 126 mojom::VideoCaptureObserverPtr observer) { |
| 115 DVLOG(1) << __func__ << " session_id=" << session_id | 127 DVLOG(1) << __func__ << " session_id=" << session_id |
| 116 << ", device_id=" << device_id << ", format=" | 128 << ", device_id=" << device_id << ", format=" |
| 117 << media::VideoCaptureFormat::ToString(params.requested_format); | 129 << media::VideoCaptureFormat::ToString(params.requested_format); |
| 118 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 130 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 119 | 131 |
| 120 DCHECK(!base::ContainsKey(device_id_to_observer_map_, device_id)); | 132 DCHECK(!base::ContainsKey(device_id_to_observer_map_, device_id)); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 | 301 |
| 290 if (!controller) { | 302 if (!controller) { |
| 291 if (base::ContainsKey(device_id_to_observer_map_, controller_id)) { | 303 if (base::ContainsKey(device_id_to_observer_map_, controller_id)) { |
| 292 device_id_to_observer_map_[device_id]->OnStateChanged( | 304 device_id_to_observer_map_[device_id]->OnStateChanged( |
| 293 mojom::VideoCaptureState::FAILED); | 305 mojom::VideoCaptureState::FAILED); |
| 294 } | 306 } |
| 295 controllers_.erase(controller_id); | 307 controllers_.erase(controller_id); |
| 296 return; | 308 return; |
| 297 } | 309 } |
| 298 | 310 |
| 299 if (base::ContainsKey(device_id_to_observer_map_, controller_id)) { | |
| 300 device_id_to_observer_map_[device_id]->OnStateChanged( | |
| 301 mojom::VideoCaptureState::STARTED); | |
| 302 } | |
| 303 | |
| 304 DCHECK(!it->second); | 311 DCHECK(!it->second); |
| 305 it->second = controller; | 312 it->second = controller; |
| 306 } | 313 } |
| 307 | 314 |
| 308 void VideoCaptureHost::DeleteVideoCaptureController( | 315 void VideoCaptureHost::DeleteVideoCaptureController( |
| 309 VideoCaptureControllerID controller_id, bool on_error) { | 316 VideoCaptureControllerID controller_id, bool on_error) { |
| 310 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 317 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 311 | 318 |
| 312 auto it = controllers_.find(controller_id); | 319 auto it = controllers_.find(controller_id); |
| 313 if (it == controllers_.end()) | 320 if (it == controllers_.end()) |
| 314 return; | 321 return; |
| 315 | 322 |
| 316 const base::WeakPtr<VideoCaptureController> controller = it->second; | 323 const base::WeakPtr<VideoCaptureController> controller = it->second; |
| 317 controllers_.erase(it); | 324 controllers_.erase(it); |
| 318 if (!controller) | 325 if (!controller) |
| 319 return; | 326 return; |
| 320 | 327 |
| 321 media_stream_manager_->video_capture_manager()->StopCaptureForClient( | 328 media_stream_manager_->video_capture_manager()->StopCaptureForClient( |
| 322 controller.get(), controller_id, this, on_error); | 329 controller.get(), controller_id, this, on_error); |
| 323 } | 330 } |
| 324 | 331 |
| 325 } // namespace content | 332 } // namespace content |
| OLD | NEW |