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 // OnStarted can be forwarded directly, while OnError&OnEnded need to be | |
122 // scheduled to the end of message queue to guarantee some other clearing jobs | |
123 // are done before they are handled. | |
124 void VideoCaptureHost::OnStarted(VideoCaptureControllerID controller_id) { | |
chfremer
2017/02/16 01:00:50
Thanks. This piece of information is very useful t
braveyao
2017/02/17 20:37:21
Done.
| |
125 DVLOG(1) << __func__; | |
126 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
127 if (controllers_.find(controller_id) == controllers_.end()) | |
128 return; | |
129 | |
130 if (base::ContainsKey(device_id_to_observer_map_, controller_id)) { | |
131 device_id_to_observer_map_[controller_id]->OnStateChanged( | |
132 mojom::VideoCaptureState::STARTED); | |
133 } | |
134 } | |
135 | |
121 void VideoCaptureHost::Start(int32_t device_id, | 136 void VideoCaptureHost::Start(int32_t device_id, |
122 int32_t session_id, | 137 int32_t session_id, |
123 const media::VideoCaptureParams& params, | 138 const media::VideoCaptureParams& params, |
124 mojom::VideoCaptureObserverPtr observer) { | 139 mojom::VideoCaptureObserverPtr observer) { |
125 DVLOG(1) << __func__ << " session_id=" << session_id | 140 DVLOG(1) << __func__ << " session_id=" << session_id |
126 << ", device_id=" << device_id << ", format=" | 141 << ", device_id=" << device_id << ", format=" |
127 << media::VideoCaptureFormat::ToString(params.requested_format); | 142 << media::VideoCaptureFormat::ToString(params.requested_format); |
128 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 143 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
129 | 144 |
130 DCHECK(!base::ContainsKey(device_id_to_observer_map_, device_id)); | 145 DCHECK(!base::ContainsKey(device_id_to_observer_map_, device_id)); |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
299 | 314 |
300 if (!controller) { | 315 if (!controller) { |
301 if (base::ContainsKey(device_id_to_observer_map_, controller_id)) { | 316 if (base::ContainsKey(device_id_to_observer_map_, controller_id)) { |
302 device_id_to_observer_map_[device_id]->OnStateChanged( | 317 device_id_to_observer_map_[device_id]->OnStateChanged( |
303 mojom::VideoCaptureState::FAILED); | 318 mojom::VideoCaptureState::FAILED); |
304 } | 319 } |
305 controllers_.erase(controller_id); | 320 controllers_.erase(controller_id); |
306 return; | 321 return; |
307 } | 322 } |
308 | 323 |
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); | 324 DCHECK(!it->second); |
315 it->second = controller; | 325 it->second = controller; |
316 } | 326 } |
317 | 327 |
318 void VideoCaptureHost::DeleteVideoCaptureController( | 328 void VideoCaptureHost::DeleteVideoCaptureController( |
319 VideoCaptureControllerID controller_id, bool on_error) { | 329 VideoCaptureControllerID controller_id, bool on_error) { |
320 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 330 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
321 | 331 |
322 auto it = controllers_.find(controller_id); | 332 auto it = controllers_.find(controller_id); |
323 if (it == controllers_.end()) | 333 if (it == controllers_.end()) |
324 return; | 334 return; |
325 | 335 |
326 const base::WeakPtr<VideoCaptureController> controller = it->second; | 336 const base::WeakPtr<VideoCaptureController> controller = it->second; |
327 controllers_.erase(it); | 337 controllers_.erase(it); |
328 if (!controller) | 338 if (!controller) |
329 return; | 339 return; |
330 | 340 |
331 media_stream_manager_->video_capture_manager()->StopCaptureForClient( | 341 media_stream_manager_->video_capture_manager()->StopCaptureForClient( |
332 controller.get(), controller_id, this, on_error); | 342 controller.get(), controller_id, this, on_error); |
333 } | 343 } |
334 | 344 |
335 } // namespace content | 345 } // namespace content |
OLD | NEW |