OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "content/browser/browser_thread.h" | 8 #include "content/browser/browser_thread.h" |
9 #include "media/video/capture/fake_video_capture_device.h" | 9 #include "media/video/capture/fake_video_capture_device.h" |
10 #include "media/video/capture/video_capture_device.h" | 10 #include "media/video/capture/video_capture_device.h" |
11 | 11 |
12 namespace media_stream { | 12 namespace media_stream { |
13 | 13 |
14 // Starting id for the first capture session. | 14 // Starting id for the first capture session. |
15 // VideoCaptureManager::kStartOpenSessionId is used as default id without | 15 // VideoCaptureManager::kStartOpenSessionId is used as default id without |
16 // explicitly calling open device. | 16 // explicitly calling open device. |
17 enum { kFirstSessionId = VideoCaptureManager::kStartOpenSessionId + 1 }; | 17 enum { kFirstSessionId = VideoCaptureManager::kStartOpenSessionId + 1 }; |
18 | 18 |
19 VideoCaptureManager::VideoCaptureManager() | 19 VideoCaptureManager::VideoCaptureManager() |
20 : vc_device_thread_("VideoCaptureManagerThread"), | 20 : vc_device_thread_("VideoCaptureManagerThread"), |
21 listener_(NULL), | 21 listener_(NULL), |
22 new_capture_session_id_(kFirstSessionId), | 22 new_capture_session_id_(kFirstSessionId), |
23 use_fake_device_(false) { | 23 use_fake_device_(false) { |
24 vc_device_thread_.Start(); | 24 vc_device_thread_.Start(); |
25 } | 25 } |
26 | 26 |
27 VideoCaptureManager::~VideoCaptureManager() { | 27 VideoCaptureManager::~VideoCaptureManager() { |
28 DCHECK(devices_.empty()); | |
29 vc_device_thread_.Stop(); | 28 vc_device_thread_.Stop(); |
| 29 // TODO(mflodman) Remove this temporary solution when shut-down issue is |
| 30 // resolved, i.e. all code below this comment. |
| 31 // Temporary solution: close all open devices and delete them, after the |
| 32 // thread is stopped. |
| 33 DLOG_IF(ERROR, !devices_.empty()) << "VideoCaptureManager: Open devices!"; |
| 34 for (VideoCaptureDevices::iterator it = devices_.begin(); |
| 35 it != devices_.end(); |
| 36 ++it) { |
| 37 it->second->DeAllocate(); |
| 38 delete it->second; |
| 39 } |
30 } | 40 } |
31 | 41 |
32 void VideoCaptureManager::Register(MediaStreamProviderListener* listener) { | 42 void VideoCaptureManager::Register(MediaStreamProviderListener* listener) { |
33 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 43 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
34 DCHECK(!listener_); | 44 DCHECK(!listener_); |
35 listener_ = listener; | 45 listener_ = listener; |
36 } | 46 } |
37 | 47 |
38 void VideoCaptureManager::Unregister() { | 48 void VideoCaptureManager::Unregister() { |
39 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 49 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 it != devices_.end(); | 375 it != devices_.end(); |
366 it++) { | 376 it++) { |
367 if (device_info.device_id == it->second->device_name().unique_id) { | 377 if (device_info.device_id == it->second->device_name().unique_id) { |
368 return true; | 378 return true; |
369 } | 379 } |
370 } | 380 } |
371 return false; | 381 return false; |
372 } | 382 } |
373 | 383 |
374 } // namespace media_stream | 384 } // namespace media_stream |
OLD | NEW |