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

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: . 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"),
17 encoding_capturer_factory_(new RtcEncodingVideoCapturerFactory()) {
Ami GONE FROM CHROMIUM 2013/06/08 00:18:01 flag-protect?
hshi1 2013/06/11 17:49:42 Per discussion with Zel I'm guarding this with #if
16 thread_.Start(); 18 thread_.Start();
17 message_loop_proxy_ = thread_.message_loop_proxy(); 19 message_loop_proxy_ = thread_.message_loop_proxy();
18 filter_ = new VideoCaptureMessageFilter(); 20 filter_ = new VideoCaptureMessageFilter();
19 } 21 }
20 22
21 media::VideoCapture* VideoCaptureImplManager::AddDevice( 23 media::VideoCapture* VideoCaptureImplManager::AddDevice(
22 media::VideoCaptureSessionId id, 24 media::VideoCaptureSessionId id,
23 media::VideoCapture::EventHandler* handler) { 25 media::VideoCapture::EventHandler* handler) {
24 DCHECK(handler); 26 DCHECK(handler);
25 27
26 base::AutoLock auto_lock(lock_); 28 base::AutoLock auto_lock(lock_);
27 Devices::iterator it = devices_.find(id); 29 Devices::iterator it = devices_.find(id);
28 if (it == devices_.end()) { 30 if (it == devices_.end()) {
29 VideoCaptureImpl* vc = 31 VideoCaptureImpl* vc =
30 new VideoCaptureImpl(id, message_loop_proxy_.get(), filter_.get()); 32 new VideoCaptureImpl(id, message_loop_proxy_.get(), filter_.get());
31 devices_[id] = new Device(vc, handler); 33 devices_[id] = new Device(vc, handler);
32 vc->Init(); 34 vc->Init();
35 media::EncodedVideoSource* evs = vc->GetEncodedVideoSource();
36 if (encoding_capturer_factory_ && evs)
Ami GONE FROM CHROMIUM 2013/06/08 00:18:01 how can encoding_capturer_factory_ be false?
hshi1 2013/06/11 17:49:42 Since I'm guarding encoding_capturer_factory_ with
37 encoding_capturer_factory_->OnEncodedVideoSourceAdded(evs);
33 return vc; 38 return vc;
34 } 39 }
35 40
36 devices_[id]->clients.push_front(handler); 41 devices_[id]->clients.push_front(handler);
37 return it->second->vc; 42 return it->second->vc;
38 } 43 }
39 44
40 void VideoCaptureImplManager::SuspendDevices(bool suspend) { 45 void VideoCaptureImplManager::SuspendDevices(bool suspend) {
41 base::AutoLock auto_lock(lock_); 46 base::AutoLock auto_lock(lock_);
42 for (Devices::iterator it = devices_.begin(); it != devices_.end(); ++it) 47 for (Devices::iterator it = devices_.begin(); it != devices_.end(); ++it)
43 it->second->vc->SuspendCapture(suspend); 48 it->second->vc->SuspendCapture(suspend);
44 } 49 }
45 50
46 void VideoCaptureImplManager::RemoveDevice( 51 void VideoCaptureImplManager::RemoveDevice(
47 media::VideoCaptureSessionId id, 52 media::VideoCaptureSessionId id,
48 media::VideoCapture::EventHandler* handler) { 53 media::VideoCapture::EventHandler* handler) {
49 DCHECK(handler); 54 DCHECK(handler);
50 55
51 base::AutoLock auto_lock(lock_); 56 base::AutoLock auto_lock(lock_);
52 Devices::iterator it = devices_.find(id); 57 Devices::iterator it = devices_.find(id);
53 if (it == devices_.end()) 58 if (it == devices_.end())
54 return; 59 return;
55 60
56 size_t size = it->second->clients.size(); 61 size_t size = it->second->clients.size();
57 it->second->clients.remove(handler); 62 it->second->clients.remove(handler);
58 63
59 if (size == it->second->clients.size() || size > 1) 64 if (size == it->second->clients.size() || size > 1)
60 return; 65 return;
61 66
67 media::EncodedVideoSource* evs = devices_[id]->vc->GetEncodedVideoSource();
68 if (encoding_capturer_factory_ && evs)
Ami GONE FROM CHROMIUM 2013/06/08 00:18:01 ditto encoding_capturer_factory_ is never NULL
hshi1 2013/06/11 17:49:42 ditto (NULL on non-ARM-CrOS platform).
69 encoding_capturer_factory_->OnEncodedVideoSourceRemoved(evs);
70
62 devices_[id]->vc->DeInit(base::Bind(&VideoCaptureImplManager::FreeDevice, 71 devices_[id]->vc->DeInit(base::Bind(&VideoCaptureImplManager::FreeDevice,
63 this, devices_[id]->vc)); 72 this, devices_[id]->vc));
64 delete devices_[id]; 73 delete devices_[id];
65 devices_.erase(id); 74 devices_.erase(id);
66 } 75 }
67 76
68 void VideoCaptureImplManager::FreeDevice(VideoCaptureImpl* vc) { 77 void VideoCaptureImplManager::FreeDevice(VideoCaptureImpl* vc) {
69 delete vc; 78 delete vc;
70 } 79 }
71 80
72 VideoCaptureImplManager::~VideoCaptureImplManager() { 81 VideoCaptureImplManager::~VideoCaptureImplManager() {
73 thread_.Stop(); 82 thread_.Stop();
74 // TODO(wjia): uncomment the line below after collecting enough info for 83 // TODO(wjia): uncomment the line below after collecting enough info for
75 // crbug.com/152418. 84 // crbug.com/152418.
76 // STLDeleteContainerPairSecondPointers(devices_.begin(), devices_.end()); 85 // STLDeleteContainerPairSecondPointers(devices_.begin(), devices_.end());
77 } 86 }
78 87
79 VideoCaptureImplManager::Device::Device( 88 VideoCaptureImplManager::Device::Device(
80 VideoCaptureImpl* device, 89 VideoCaptureImpl* device,
81 media::VideoCapture::EventHandler* handler) 90 media::VideoCapture::EventHandler* handler)
82 : vc(device) { 91 : vc(device) {
83 clients.push_front(handler); 92 clients.push_front(handler);
84 } 93 }
85 94
86 VideoCaptureImplManager::Device::~Device() {} 95 VideoCaptureImplManager::Device::~Device() {}
87 96
88 } // namespace content 97 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698