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

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

Issue 16320005: Define EncodedVideoSource and RtcCapturedEncodingVideoCapturer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressing Ami's comments - part 5. Created 7 years, 6 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/rtc_encoding_video_capturer_factory.h"
9 #include "content/renderer/media/video_capture_impl.h" 10 #include "content/renderer/media/video_capture_impl.h"
10 #include "content/renderer/media/video_capture_message_filter.h" 11 #include "content/renderer/media/video_capture_message_filter.h"
11 12
12 namespace content { 13 namespace content {
13 14
14 VideoCaptureImplManager::VideoCaptureImplManager() 15 VideoCaptureImplManager::VideoCaptureImplManager()
15 : thread_("VC manager") { 16 : thread_("VC manager") {
16 thread_.Start(); 17 thread_.Start();
17 message_loop_proxy_ = thread_.message_loop_proxy(); 18 message_loop_proxy_ = thread_.message_loop_proxy();
18 filter_ = new VideoCaptureMessageFilter(); 19 filter_ = new VideoCaptureMessageFilter();
20
21 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL)
22 encoding_capturer_factory_ = new RtcEncodingVideoCapturerFactory();
Ami GONE FROM CHROMIUM 2013/06/12 01:44:06 Are you planning to hold off landing this CL until
hshi1 2013/06/12 17:52:39 Theoretically this wouldn't "break" cros/arm, beca
23 #endif
19 } 24 }
20 25
21 media::VideoCapture* VideoCaptureImplManager::AddDevice( 26 media::VideoCapture* VideoCaptureImplManager::AddDevice(
22 media::VideoCaptureSessionId id, 27 media::VideoCaptureSessionId id,
23 media::VideoCapture::EventHandler* handler) { 28 media::VideoCapture::EventHandler* handler) {
24 DCHECK(handler); 29 DCHECK(handler);
25 30
26 base::AutoLock auto_lock(lock_); 31 base::AutoLock auto_lock(lock_);
27 Devices::iterator it = devices_.find(id); 32 Devices::iterator it = devices_.find(id);
28 if (it == devices_.end()) { 33 if (it == devices_.end()) {
29 VideoCaptureImpl* vc = 34 VideoCaptureImpl* vc =
30 new VideoCaptureImpl(id, message_loop_proxy_.get(), filter_.get()); 35 new VideoCaptureImpl(id, message_loop_proxy_.get(), filter_.get());
31 devices_[id] = new Device(vc, handler); 36 devices_[id] = new Device(vc, handler);
32 vc->Init(); 37 vc->Init();
38 if (encoding_capturer_factory_)
39 encoding_capturer_factory_->OnEncodedVideoSourceAdded(vc);
33 return vc; 40 return vc;
34 } 41 }
35 42
36 devices_[id]->clients.push_front(handler); 43 devices_[id]->clients.push_front(handler);
37 return it->second->vc; 44 return it->second->vc;
38 } 45 }
39 46
40 void VideoCaptureImplManager::SuspendDevices(bool suspend) { 47 void VideoCaptureImplManager::SuspendDevices(bool suspend) {
41 base::AutoLock auto_lock(lock_); 48 base::AutoLock auto_lock(lock_);
42 for (Devices::iterator it = devices_.begin(); it != devices_.end(); ++it) 49 for (Devices::iterator it = devices_.begin(); it != devices_.end(); ++it)
43 it->second->vc->SuspendCapture(suspend); 50 it->second->vc->SuspendCapture(suspend);
44 } 51 }
45 52
46 void VideoCaptureImplManager::RemoveDevice( 53 void VideoCaptureImplManager::RemoveDevice(
47 media::VideoCaptureSessionId id, 54 media::VideoCaptureSessionId id,
48 media::VideoCapture::EventHandler* handler) { 55 media::VideoCapture::EventHandler* handler) {
49 DCHECK(handler); 56 DCHECK(handler);
50 57
51 base::AutoLock auto_lock(lock_); 58 base::AutoLock auto_lock(lock_);
52 Devices::iterator it = devices_.find(id); 59 Devices::iterator it = devices_.find(id);
53 if (it == devices_.end()) 60 if (it == devices_.end())
54 return; 61 return;
55 62
56 size_t size = it->second->clients.size(); 63 size_t size = it->second->clients.size();
57 it->second->clients.remove(handler); 64 it->second->clients.remove(handler);
58 65
59 if (size == it->second->clients.size() || size > 1) 66 if (size == it->second->clients.size() || size > 1)
60 return; 67 return;
61 68
69 if (encoding_capturer_factory_)
70 encoding_capturer_factory_->OnEncodedVideoSourceRemoved(devices_[id]->vc);
71
62 devices_[id]->vc->DeInit(base::Bind(&VideoCaptureImplManager::FreeDevice, 72 devices_[id]->vc->DeInit(base::Bind(&VideoCaptureImplManager::FreeDevice,
63 this, devices_[id]->vc)); 73 this, devices_[id]->vc));
64 delete devices_[id]; 74 delete devices_[id];
65 devices_.erase(id); 75 devices_.erase(id);
66 } 76 }
67 77
68 void VideoCaptureImplManager::FreeDevice(VideoCaptureImpl* vc) { 78 void VideoCaptureImplManager::FreeDevice(VideoCaptureImpl* vc) {
69 delete vc; 79 delete vc;
70 } 80 }
71 81
72 VideoCaptureImplManager::~VideoCaptureImplManager() { 82 VideoCaptureImplManager::~VideoCaptureImplManager() {
73 thread_.Stop(); 83 thread_.Stop();
74 // TODO(wjia): uncomment the line below after collecting enough info for 84 // TODO(wjia): uncomment the line below after collecting enough info for
75 // crbug.com/152418. 85 // crbug.com/152418.
76 // STLDeleteContainerPairSecondPointers(devices_.begin(), devices_.end()); 86 // STLDeleteContainerPairSecondPointers(devices_.begin(), devices_.end());
77 } 87 }
78 88
79 VideoCaptureImplManager::Device::Device( 89 VideoCaptureImplManager::Device::Device(
80 VideoCaptureImpl* device, 90 VideoCaptureImpl* device,
81 media::VideoCapture::EventHandler* handler) 91 media::VideoCapture::EventHandler* handler)
82 : vc(device) { 92 : vc(device) {
83 clients.push_front(handler); 93 clients.push_front(handler);
84 } 94 }
85 95
86 VideoCaptureImplManager::Device::~Device() {} 96 VideoCaptureImplManager::Device::~Device() {}
87 97
88 } // namespace content 98 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698