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 <set> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
9 #include "content/browser/renderer_host/media/video_capture_controller.h" | 11 #include "content/browser/renderer_host/media/video_capture_controller.h" |
10 #include "content/browser/renderer_host/media/video_capture_controller_event_han
dler.h" | 12 #include "content/browser/renderer_host/media/video_capture_controller_event_han
dler.h" |
11 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
12 #include "media/video/capture/fake_video_capture_device.h" | 14 #include "media/video/capture/fake_video_capture_device.h" |
13 #include "media/video/capture/video_capture_device.h" | 15 #include "media/video/capture/video_capture_device.h" |
14 | 16 |
15 using content::BrowserThread; | 17 using content::BrowserThread; |
16 | 18 |
(...skipping 27 matching lines...) Expand all Loading... |
44 vc_device_thread_.Start(); | 46 vc_device_thread_.Start(); |
45 } | 47 } |
46 | 48 |
47 VideoCaptureManager::~VideoCaptureManager() { | 49 VideoCaptureManager::~VideoCaptureManager() { |
48 vc_device_thread_.Stop(); | 50 vc_device_thread_.Stop(); |
49 // TODO(mflodman) Remove this temporary solution when shut-down issue is | 51 // TODO(mflodman) Remove this temporary solution when shut-down issue is |
50 // resolved, i.e. all code below this comment. | 52 // resolved, i.e. all code below this comment. |
51 // Temporary solution: close all open devices and delete them, after the | 53 // Temporary solution: close all open devices and delete them, after the |
52 // thread is stopped. | 54 // thread is stopped. |
53 DLOG_IF(ERROR, !devices_.empty()) << "VideoCaptureManager: Open devices!"; | 55 DLOG_IF(ERROR, !devices_.empty()) << "VideoCaptureManager: Open devices!"; |
| 56 std::set<media::VideoCaptureDevice*> devices_to_delete; |
54 for (VideoCaptureDevices::iterator it = devices_.begin(); | 57 for (VideoCaptureDevices::iterator it = devices_.begin(); |
55 it != devices_.end(); | 58 it != devices_.end(); |
56 ++it) { | 59 ++it) { |
57 it->second->DeAllocate(); | 60 it->second->DeAllocate(); |
58 delete it->second; | 61 devices_to_delete.insert(it->second); |
59 } | 62 } |
| 63 STLDeleteElements(&devices_to_delete); |
60 STLDeleteValues(&controllers_); | 64 STLDeleteValues(&controllers_); |
61 } | 65 } |
62 | 66 |
63 void VideoCaptureManager::Register(MediaStreamProviderListener* listener) { | 67 void VideoCaptureManager::Register(MediaStreamProviderListener* listener) { |
64 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 68 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
65 DCHECK(!listener_); | 69 DCHECK(!listener_); |
66 listener_ = listener; | 70 listener_ = listener; |
67 } | 71 } |
68 | 72 |
69 void VideoCaptureManager::Unregister() { | 73 void VideoCaptureManager::Unregister() { |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 | 500 |
497 VideoCaptureDevices::iterator dit = devices_.find(capture_session_id); | 501 VideoCaptureDevices::iterator dit = devices_.find(capture_session_id); |
498 if (dit != devices_.end()) { | 502 if (dit != devices_.end()) { |
499 return dit->second; | 503 return dit->second; |
500 } | 504 } |
501 } | 505 } |
502 return NULL; | 506 return NULL; |
503 } | 507 } |
504 | 508 |
505 } // namespace media_stream | 509 } // namespace media_stream |
OLD | NEW |