| 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 <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 | 187 |
| 188 void VideoCaptureManager::OnClose(int capture_session_id) { | 188 void VideoCaptureManager::OnClose(int capture_session_id) { |
| 189 DCHECK(IsOnCaptureDeviceThread()); | 189 DCHECK(IsOnCaptureDeviceThread()); |
| 190 DVLOG(1) << "VideoCaptureManager::OnClose, id " << capture_session_id; | 190 DVLOG(1) << "VideoCaptureManager::OnClose, id " << capture_session_id; |
| 191 | 191 |
| 192 media::VideoCaptureDevice* video_capture_device = NULL; | 192 media::VideoCaptureDevice* video_capture_device = NULL; |
| 193 VideoCaptureDevices::iterator device_it = devices_.find(capture_session_id); | 193 VideoCaptureDevices::iterator device_it = devices_.find(capture_session_id); |
| 194 if (device_it != devices_.end()) { | 194 if (device_it != devices_.end()) { |
| 195 video_capture_device = device_it->second; | 195 video_capture_device = device_it->second; |
| 196 devices_.erase(device_it); | 196 devices_.erase(device_it); |
| 197 |
| 198 Controllers::iterator cit = controllers_.find(video_capture_device); |
| 199 if (cit != controllers_.end()) { |
| 200 BrowserThread::PostTask( |
| 201 BrowserThread::IO, FROM_HERE, |
| 202 base::Bind(&VideoCaptureController::StopSession, |
| 203 cit->second->controller, capture_session_id)); |
| 204 } |
| 205 |
| 197 if (!DeviceInUse(video_capture_device)) { | 206 if (!DeviceInUse(video_capture_device)) { |
| 198 // No other users of this device, deallocate (if not done already) and | 207 // No other users of this device, deallocate (if not done already) and |
| 199 // delete the device. No need to take care of the controller, that is done | 208 // delete the device. No need to take care of the controller, that is done |
| 200 // by |OnStop|. | 209 // by |OnStop|. |
| 201 video_capture_device->DeAllocate(); | 210 video_capture_device->DeAllocate(); |
| 202 Controllers::iterator cit = controllers_.find(video_capture_device); | 211 Controllers::iterator cit = controllers_.find(video_capture_device); |
| 203 if (cit != controllers_.end()) { | 212 if (cit != controllers_.end()) { |
| 204 delete cit->second; | 213 delete cit->second; |
| 205 controllers_.erase(cit); | 214 controllers_.erase(cit); |
| 206 } | 215 } |
| 207 delete video_capture_device; | 216 delete video_capture_device; |
| 208 } else { | |
| 209 Controllers::iterator cit = controllers_.find(video_capture_device); | |
| 210 if (cit != controllers_.end()) { | |
| 211 BrowserThread::PostTask( | |
| 212 BrowserThread::IO, FROM_HERE, | |
| 213 base::Bind(&VideoCaptureController::StopSession, | |
| 214 cit->second->controller, capture_session_id)); | |
| 215 } | |
| 216 } | 217 } |
| 217 } | 218 } |
| 218 PostOnClosed(capture_session_id); | 219 PostOnClosed(capture_session_id); |
| 219 } | 220 } |
| 220 | 221 |
| 221 void VideoCaptureManager::OnStart( | 222 void VideoCaptureManager::OnStart( |
| 222 const media::VideoCaptureParams capture_params, | 223 const media::VideoCaptureParams capture_params, |
| 223 media::VideoCaptureDevice::EventHandler* video_capture_receiver) { | 224 media::VideoCaptureDevice::EventHandler* video_capture_receiver) { |
| 224 DCHECK(IsOnCaptureDeviceThread()); | 225 DCHECK(IsOnCaptureDeviceThread()); |
| 225 DCHECK(video_capture_receiver != NULL); | 226 DCHECK(video_capture_receiver != NULL); |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 | 509 |
| 509 VideoCaptureDevices::iterator dit = devices_.find(capture_session_id); | 510 VideoCaptureDevices::iterator dit = devices_.find(capture_session_id); |
| 510 if (dit != devices_.end()) { | 511 if (dit != devices_.end()) { |
| 511 return dit->second; | 512 return dit->second; |
| 512 } | 513 } |
| 513 } | 514 } |
| 514 return NULL; | 515 return NULL; |
| 515 } | 516 } |
| 516 | 517 |
| 517 } // namespace media_stream | 518 } // namespace media_stream |
| OLD | NEW |