| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 111 |
| 112 void VideoCaptureHost::OnEnded(VideoCaptureControllerID controller_id) { | 112 void VideoCaptureHost::OnEnded(VideoCaptureControllerID controller_id) { |
| 113 DVLOG(1) << __func__; | 113 DVLOG(1) << __func__; |
| 114 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 114 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 115 BrowserThread::PostTask( | 115 BrowserThread::PostTask( |
| 116 BrowserThread::IO, FROM_HERE, | 116 BrowserThread::IO, FROM_HERE, |
| 117 base::Bind(&VideoCaptureHost::DoEnded, weak_factory_.GetWeakPtr(), | 117 base::Bind(&VideoCaptureHost::DoEnded, weak_factory_.GetWeakPtr(), |
| 118 controller_id)); | 118 controller_id)); |
| 119 } | 119 } |
| 120 | 120 |
| 121 void VideoCaptureHost::OnStarted(VideoCaptureControllerID controller_id) { |
| 122 DVLOG(1) << __func__; |
| 123 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 124 if (controllers_.find(controller_id) == controllers_.end()) |
| 125 return; |
| 126 |
| 127 if (base::ContainsKey(device_id_to_observer_map_, controller_id)) { |
| 128 device_id_to_observer_map_[controller_id]->OnStateChanged( |
| 129 mojom::VideoCaptureState::STARTED); |
| 130 } |
| 131 } |
| 132 |
| 121 void VideoCaptureHost::Start(int32_t device_id, | 133 void VideoCaptureHost::Start(int32_t device_id, |
| 122 int32_t session_id, | 134 int32_t session_id, |
| 123 const media::VideoCaptureParams& params, | 135 const media::VideoCaptureParams& params, |
| 124 mojom::VideoCaptureObserverPtr observer) { | 136 mojom::VideoCaptureObserverPtr observer) { |
| 125 DVLOG(1) << __func__ << " session_id=" << session_id | 137 DVLOG(1) << __func__ << " session_id=" << session_id |
| 126 << ", device_id=" << device_id << ", format=" | 138 << ", device_id=" << device_id << ", format=" |
| 127 << media::VideoCaptureFormat::ToString(params.requested_format); | 139 << media::VideoCaptureFormat::ToString(params.requested_format); |
| 128 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 140 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 129 | 141 |
| 130 DCHECK(!base::ContainsKey(device_id_to_observer_map_, device_id)); | 142 DCHECK(!base::ContainsKey(device_id_to_observer_map_, device_id)); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 | 311 |
| 300 if (!controller) { | 312 if (!controller) { |
| 301 if (base::ContainsKey(device_id_to_observer_map_, controller_id)) { | 313 if (base::ContainsKey(device_id_to_observer_map_, controller_id)) { |
| 302 device_id_to_observer_map_[device_id]->OnStateChanged( | 314 device_id_to_observer_map_[device_id]->OnStateChanged( |
| 303 mojom::VideoCaptureState::FAILED); | 315 mojom::VideoCaptureState::FAILED); |
| 304 } | 316 } |
| 305 controllers_.erase(controller_id); | 317 controllers_.erase(controller_id); |
| 306 return; | 318 return; |
| 307 } | 319 } |
| 308 | 320 |
| 309 if (base::ContainsKey(device_id_to_observer_map_, controller_id)) { | |
| 310 device_id_to_observer_map_[device_id]->OnStateChanged( | |
| 311 mojom::VideoCaptureState::STARTED); | |
| 312 } | |
| 313 | |
| 314 DCHECK(!it->second); | 321 DCHECK(!it->second); |
| 315 it->second = controller; | 322 it->second = controller; |
| 316 } | 323 } |
| 317 | 324 |
| 318 void VideoCaptureHost::DeleteVideoCaptureController( | 325 void VideoCaptureHost::DeleteVideoCaptureController( |
| 319 VideoCaptureControllerID controller_id, bool on_error) { | 326 VideoCaptureControllerID controller_id, bool on_error) { |
| 320 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 327 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 321 | 328 |
| 322 auto it = controllers_.find(controller_id); | 329 auto it = controllers_.find(controller_id); |
| 323 if (it == controllers_.end()) | 330 if (it == controllers_.end()) |
| 324 return; | 331 return; |
| 325 | 332 |
| 326 const base::WeakPtr<VideoCaptureController> controller = it->second; | 333 const base::WeakPtr<VideoCaptureController> controller = it->second; |
| 327 controllers_.erase(it); | 334 controllers_.erase(it); |
| 328 if (!controller) | 335 if (!controller) |
| 329 return; | 336 return; |
| 330 | 337 |
| 331 media_stream_manager_->video_capture_manager()->StopCaptureForClient( | 338 media_stream_manager_->video_capture_manager()->StopCaptureForClient( |
| 332 controller.get(), controller_id, this, on_error); | 339 controller.get(), controller_id, this, on_error); |
| 333 } | 340 } |
| 334 | 341 |
| 335 } // namespace content | 342 } // namespace content |
| OLD | NEW |