Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(832)

Side by Side Diff: content/renderer/media/video_capture_impl_manager.cc

Issue 21421002: Revert EVS revisions 209760, 298753, 213143. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased at 216225, prepare to land Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/renderer/media/video_capture_impl_manager.h" 5 #include "content/renderer/media/video_capture_impl_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "content/renderer/media/video_capture_impl.h" 9 #include "content/renderer/media/video_capture_impl.h"
10 #include "content/renderer/media/video_capture_message_filter.h" 10 #include "content/renderer/media/video_capture_message_filter.h"
11 11
12 #if defined(ENABLE_WEBRTC)
13 #include "content/renderer/media/rtc_encoding_video_capturer_factory.h"
14 #endif
15
16 namespace content { 12 namespace content {
17 13
18 VideoCaptureImplManager::VideoCaptureImplManager() 14 VideoCaptureImplManager::VideoCaptureImplManager()
19 : thread_("VC manager") { 15 : thread_("VC manager") {
20 thread_.Start(); 16 thread_.Start();
21 message_loop_proxy_ = thread_.message_loop_proxy(); 17 message_loop_proxy_ = thread_.message_loop_proxy();
22 filter_ = new VideoCaptureMessageFilter(); 18 filter_ = new VideoCaptureMessageFilter();
23 } 19 }
24 20
25 media::VideoCapture* VideoCaptureImplManager::AddDevice( 21 media::VideoCapture* VideoCaptureImplManager::AddDevice(
26 media::VideoCaptureSessionId id, 22 media::VideoCaptureSessionId id,
27 media::VideoCapture::EventHandler* handler) { 23 media::VideoCapture::EventHandler* handler) {
28 DCHECK(handler); 24 DCHECK(handler);
29 25
30 base::AutoLock auto_lock(lock_); 26 base::AutoLock auto_lock(lock_);
31 Devices::iterator it = devices_.find(id); 27 Devices::iterator it = devices_.find(id);
32 if (it == devices_.end()) { 28 if (it == devices_.end()) {
33 VideoCaptureImpl* vc = 29 VideoCaptureImpl* vc =
34 new VideoCaptureImpl(id, message_loop_proxy_.get(), filter_.get()); 30 new VideoCaptureImpl(id, message_loop_proxy_.get(), filter_.get());
35 devices_[id] = new Device(vc, handler); 31 devices_[id] = new Device(vc, handler);
36 vc->Init(); 32 vc->Init();
37
38 #if defined(ENABLE_WEBRTC)
39 if (encoding_capturer_factory_)
40 encoding_capturer_factory_->OnEncodedVideoSourceAdded(vc);
41 #endif
42
43 return vc; 33 return vc;
44 } 34 }
45 35
46 devices_[id]->clients.push_front(handler); 36 devices_[id]->clients.push_front(handler);
47 return it->second->vc; 37 return it->second->vc;
48 } 38 }
49 39
50 void VideoCaptureImplManager::SuspendDevices(bool suspend) { 40 void VideoCaptureImplManager::SuspendDevices(bool suspend) {
51 base::AutoLock auto_lock(lock_); 41 base::AutoLock auto_lock(lock_);
52 for (Devices::iterator it = devices_.begin(); it != devices_.end(); ++it) 42 for (Devices::iterator it = devices_.begin(); it != devices_.end(); ++it)
53 it->second->vc->SuspendCapture(suspend); 43 it->second->vc->SuspendCapture(suspend);
54 } 44 }
55 45
56 void VideoCaptureImplManager::RemoveDevice( 46 void VideoCaptureImplManager::RemoveDevice(
57 media::VideoCaptureSessionId id, 47 media::VideoCaptureSessionId id,
58 media::VideoCapture::EventHandler* handler) { 48 media::VideoCapture::EventHandler* handler) {
59 DCHECK(handler); 49 DCHECK(handler);
60 50
61 base::AutoLock auto_lock(lock_); 51 base::AutoLock auto_lock(lock_);
62 Devices::iterator it = devices_.find(id); 52 Devices::iterator it = devices_.find(id);
63 if (it == devices_.end()) 53 if (it == devices_.end())
64 return; 54 return;
65 55
66 size_t size = it->second->clients.size(); 56 size_t size = it->second->clients.size();
67 it->second->clients.remove(handler); 57 it->second->clients.remove(handler);
68 58
69 if (size == it->second->clients.size() || size > 1) 59 if (size == it->second->clients.size() || size > 1)
70 return; 60 return;
71 61
72 #if defined(ENABLE_WEBRTC)
73 if (encoding_capturer_factory_)
74 encoding_capturer_factory_->OnEncodedVideoSourceRemoved(devices_[id]->vc);
75 #endif
76
77 devices_[id]->vc->DeInit(base::Bind(&VideoCaptureImplManager::FreeDevice, 62 devices_[id]->vc->DeInit(base::Bind(&VideoCaptureImplManager::FreeDevice,
78 this, devices_[id]->vc)); 63 this, devices_[id]->vc));
79 delete devices_[id]; 64 delete devices_[id];
80 devices_.erase(id); 65 devices_.erase(id);
81 } 66 }
82 67
83 void VideoCaptureImplManager::FreeDevice(VideoCaptureImpl* vc) { 68 void VideoCaptureImplManager::FreeDevice(VideoCaptureImpl* vc) {
84 delete vc; 69 delete vc;
85 } 70 }
86 71
87 VideoCaptureImplManager::~VideoCaptureImplManager() { 72 VideoCaptureImplManager::~VideoCaptureImplManager() {
88 thread_.Stop(); 73 thread_.Stop();
89 // TODO(wjia): uncomment the line below after collecting enough info for 74 // TODO(wjia): uncomment the line below after collecting enough info for
90 // crbug.com/152418. 75 // crbug.com/152418.
91 // STLDeleteContainerPairSecondPointers(devices_.begin(), devices_.end()); 76 // STLDeleteContainerPairSecondPointers(devices_.begin(), devices_.end());
92 } 77 }
93 78
94 VideoCaptureImplManager::Device::Device( 79 VideoCaptureImplManager::Device::Device(
95 VideoCaptureImpl* device, 80 VideoCaptureImpl* device,
96 media::VideoCapture::EventHandler* handler) 81 media::VideoCapture::EventHandler* handler)
97 : vc(device) { 82 : vc(device) {
98 clients.push_front(handler); 83 clients.push_front(handler);
99 } 84 }
100 85
101 VideoCaptureImplManager::Device::~Device() {} 86 VideoCaptureImplManager::Device::~Device() {}
102 87
103 } // namespace content 88 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/video_capture_impl_manager.h ('k') | content/renderer/media/video_capture_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698