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

Side by Side Diff: content/browser/renderer_host/media/web_contents_video_capture_device.cc

Issue 12258042: Rewrite WebContentsVideoCaptureDeviceTest. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Style fixes. Created 7 years, 10 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 // Implementation notes: This needs to work on a variety of hardware 5 // Implementation notes: This needs to work on a variety of hardware
6 // configurations where the speed of the CPU and GPU greatly affect overall 6 // configurations where the speed of the CPU and GPU greatly affect overall
7 // performance. Therefore, the process of capturing has been split up into a 7 // performance. Therefore, the process of capturing has been split up into a
8 // pipeline of three stages. Each stage executes on its own thread: 8 // pipeline of three stages. Each stage executes on its own thread:
9 // 9 //
10 // 1. Capture: A bitmap is snapshotted/copied from the RenderView's backing 10 // 1. Capture: A bitmap is snapshotted/copied from the RenderView's backing
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 #include "content/public/browser/web_contents_observer.h" 66 #include "content/public/browser/web_contents_observer.h"
67 #include "media/base/bind_to_loop.h" 67 #include "media/base/bind_to_loop.h"
68 #include "media/base/video_frame.h" 68 #include "media/base/video_frame.h"
69 #include "media/video/capture/video_capture_types.h" 69 #include "media/video/capture/video_capture_types.h"
70 #include "skia/ext/image_operations.h" 70 #include "skia/ext/image_operations.h"
71 #include "third_party/skia/include/core/SkBitmap.h" 71 #include "third_party/skia/include/core/SkBitmap.h"
72 #include "third_party/skia/include/core/SkColor.h" 72 #include "third_party/skia/include/core/SkColor.h"
73 #include "ui/gfx/rect.h" 73 #include "ui/gfx/rect.h"
74 #include "ui/gfx/skia_util.h" 74 #include "ui/gfx/skia_util.h"
75 75
76 // Used to self-trampoline invocation of methods to the approprate thread. This 76 // Used to self-trampoline invocation of methods to the appropriate thread. This
77 // should be used sparingly, only when it's not clear which thread is invoking a 77 // should be used sparingly, only when it's not clear which thread is invoking a
78 // method. 78 // method.
79 #define ENSURE_INVOKED_ON_THREAD(thread, ...) { \ 79 #define ENSURE_INVOKED_ON_THREAD(thread, ...) { \
80 DCHECK(thread.IsRunning()); \ 80 DCHECK(thread.IsRunning()); \
81 if (MessageLoop::current() != thread.message_loop()) { \ 81 if (MessageLoop::current() != thread.message_loop()) { \
82 thread.message_loop()->PostTask(FROM_HERE, base::Bind(__VA_ARGS__)); \ 82 thread.message_loop()->PostTask(FROM_HERE, base::Bind(__VA_ARGS__)); \
83 return; \ 83 return; \
84 } \ 84 } \
85 } 85 }
86 86
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 } 139 }
140 140
141 // Keeps track of the RenderView to be sourced, and executes copying of the 141 // Keeps track of the RenderView to be sourced, and executes copying of the
142 // backing store on the UI BrowserThread. 142 // backing store on the UI BrowserThread.
143 class BackingStoreCopier : public WebContentsObserver { 143 class BackingStoreCopier : public WebContentsObserver {
144 public: 144 public:
145 BackingStoreCopier(int render_process_id, int render_view_id); 145 BackingStoreCopier(int render_process_id, int render_view_id);
146 146
147 virtual ~BackingStoreCopier(); 147 virtual ~BackingStoreCopier();
148 148
149 // If non-NULL, use the given |override| to access the backing store.
150 // This is used for unit testing.
151 void SetRenderWidgetHostForTesting(RenderWidgetHost* override);
152
153 // Starts the copy from the backing store. Must be run on the UI 149 // Starts the copy from the backing store. Must be run on the UI
154 // BrowserThread. Resulting frame is conveyed back to |consumer|. 150 // BrowserThread. Resulting frame is conveyed back to |consumer|.
155 void StartCopy(const scoped_refptr<CaptureMachine>& consumer, 151 void StartCopy(const scoped_refptr<CaptureMachine>& consumer,
156 int frame_number, 152 int frame_number,
157 int desired_width, 153 int desired_width,
158 int desired_height); 154 int desired_height);
159 155
160 // Stops observing an existing WebContents instance, if any. This must be 156 // Stops observing an existing WebContents instance, if any. This must be
161 // called before BackingStoreCopier is destroyed. Must be run on the UI 157 // called before BackingStoreCopier is destroyed. Must be run on the UI
162 // BrowserThread. 158 // BrowserThread.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 const int render_process_id_; 194 const int render_process_id_;
199 const int render_view_id_; 195 const int render_view_id_;
200 196
201 // Routing ID of any active fullscreen render widget or MSG_ROUTING_NONE 197 // Routing ID of any active fullscreen render widget or MSG_ROUTING_NONE
202 // otherwise. 198 // otherwise.
203 int fullscreen_widget_id_; 199 int fullscreen_widget_id_;
204 200
205 // Last known RenderView size. 201 // Last known RenderView size.
206 gfx::Size last_view_size_; 202 gfx::Size last_view_size_;
207 203
208 // If the following is NULL (normal behavior), the implementation should
209 // access RenderWidgetHost via web_contents().
210 RenderWidgetHost* rwh_for_testing_;
211
212 DISALLOW_COPY_AND_ASSIGN(BackingStoreCopier); 204 DISALLOW_COPY_AND_ASSIGN(BackingStoreCopier);
213 }; 205 };
214 206
215 // Renders captures (from the backing store) into video frame buffers on a 207 // Renders captures (from the backing store) into video frame buffers on a
216 // separate thread. Manages use of internally-owned video frame buffers. 208 // separate thread. Manages use of internally-owned video frame buffers.
217 class VideoFrameRenderer { 209 class VideoFrameRenderer {
218 public: 210 public:
219 typedef base::Callback<void(const SkBitmap*)> DoneCB; 211 typedef base::Callback<void(const SkBitmap*)> DoneCB;
220 212
221 VideoFrameRenderer(); 213 VideoFrameRenderer();
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 // deliver stage) whenever verbose logging is turned on. 304 // deliver stage) whenever verbose logging is turned on.
313 base::Time last_frame_rate_log_time_; 305 base::Time last_frame_rate_log_time_;
314 int count_frames_rendered_; 306 int count_frames_rendered_;
315 int last_frame_number_; 307 int last_frame_number_;
316 308
317 DISALLOW_COPY_AND_ASSIGN(VideoFrameDeliverer); 309 DISALLOW_COPY_AND_ASSIGN(VideoFrameDeliverer);
318 }; 310 };
319 311
320 BackingStoreCopier::BackingStoreCopier(int render_process_id, 312 BackingStoreCopier::BackingStoreCopier(int render_process_id,
321 int render_view_id) 313 int render_view_id)
322 : render_process_id_(render_process_id), render_view_id_(render_view_id), 314 : render_process_id_(render_process_id),
323 fullscreen_widget_id_(MSG_ROUTING_NONE), rwh_for_testing_(NULL) {} 315 render_view_id_(render_view_id),
316 fullscreen_widget_id_(MSG_ROUTING_NONE) {}
324 317
325 BackingStoreCopier::~BackingStoreCopier() { 318 BackingStoreCopier::~BackingStoreCopier() {
326 DCHECK(!web_contents()); 319 DCHECK(!web_contents());
327 } 320 }
328 321
329 void BackingStoreCopier::StopObservingWebContents() { 322 void BackingStoreCopier::StopObservingWebContents() {
330 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 323 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
331 324
332 if (web_contents()) { 325 if (web_contents()) {
333 web_contents()->DecrementCapturerCount(); 326 web_contents()->DecrementCapturerCount();
(...skipping 28 matching lines...) Expand all
362 Observe(rvh ? WebContents::FromRenderViewHost(rvh) : NULL); 355 Observe(rvh ? WebContents::FromRenderViewHost(rvh) : NULL);
363 WebContentsImpl* contents = static_cast<WebContentsImpl*>(web_contents()); 356 WebContentsImpl* contents = static_cast<WebContentsImpl*>(web_contents());
364 if (contents) { 357 if (contents) {
365 contents->IncrementCapturerCount(); 358 contents->IncrementCapturerCount();
366 fullscreen_widget_id_ = contents->GetFullscreenWidgetRoutingID(); 359 fullscreen_widget_id_ = contents->GetFullscreenWidgetRoutingID();
367 } else { 360 } else {
368 DVLOG(1) << "WebContents::FromRenderViewHost(" << rvh << ") returned NULL."; 361 DVLOG(1) << "WebContents::FromRenderViewHost(" << rvh << ") returned NULL.";
369 } 362 }
370 } 363 }
371 364
372 void BackingStoreCopier::SetRenderWidgetHostForTesting(
373 RenderWidgetHost* override) {
374 rwh_for_testing_ = override;
375 }
376
377 VideoFrameRenderer::VideoFrameRenderer() 365 VideoFrameRenderer::VideoFrameRenderer()
378 : render_thread_("WebContentsVideo_RenderThread") { 366 : render_thread_("WebContentsVideo_RenderThread") {
379 output_[0].in_use = false; 367 output_[0].in_use = false;
380 output_[1].in_use = false; 368 output_[1].in_use = false;
381 render_thread_.Start(); 369 render_thread_.Start();
382 } 370 }
383 371
384 void VideoFrameRenderer::Render(int frame_number, 372 void VideoFrameRenderer::Render(int frame_number,
385 const SkBitmap& capture, 373 const SkBitmap& capture,
386 int frame_width, int frame_height, 374 int frame_width, int frame_height,
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 class CaptureMachine 654 class CaptureMachine
667 : public base::RefCountedThreadSafe<CaptureMachine, CaptureMachine> { 655 : public base::RefCountedThreadSafe<CaptureMachine, CaptureMachine> {
668 public: 656 public:
669 enum SnapshotError { 657 enum SnapshotError {
670 NO_SOURCE, 658 NO_SOURCE,
671 TRANSIENT_ERROR 659 TRANSIENT_ERROR
672 }; 660 };
673 661
674 CaptureMachine(int render_process_id, int render_view_id); 662 CaptureMachine(int render_process_id, int render_view_id);
675 663
676 // Sets the capture source to the given |override| for unit testing.
677 // Also, |destroy_cb| will be invoked after CaptureMachine is fully destroyed
678 // (to synchronize tear-down).
679 void InitializeForTesting(RenderWidgetHost* override,
miu 2013/02/20 06:45:10 For the tests, how can you be sure CaptureMachine
ncarter (slow) 2013/02/22 02:16:11 This is moot now, but the old code did reliably ru
680 const base::Closure& destroy_cb);
681
682 // Synchronously sets/unsets the consumer. Pass |consumer| as NULL to remove 664 // Synchronously sets/unsets the consumer. Pass |consumer| as NULL to remove
683 // the reference to the consumer; then, once this method returns, 665 // the reference to the consumer; then, once this method returns,
684 // CaptureMachine will no longer invoke callbacks on the old consumer from any 666 // CaptureMachine will no longer invoke callbacks on the old consumer from any
685 // thread. 667 // thread.
686 void SetConsumer(media::VideoCaptureDevice::EventHandler* consumer); 668 void SetConsumer(media::VideoCaptureDevice::EventHandler* consumer);
687 669
688 // Asynchronous requests to change CaptureMachine state. 670 // Asynchronous requests to change CaptureMachine state.
689 void Allocate(int width, int height, int frame_rate); 671 void Allocate(int width, int height, int frame_rate);
690 void Start(); 672 void Start();
691 void Stop(); 673 void Stop();
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 base::TimeDelta capture_period_; // Time between frames. 748 base::TimeDelta capture_period_; // Time between frames.
767 749
768 bool is_snapshotting_; // True while taking a snapshot with copier_. 750 bool is_snapshotting_; // True while taking a snapshot with copier_.
769 int num_renders_pending_; // The number of renders enqueued. 751 int num_renders_pending_; // The number of renders enqueued.
770 752
771 // The three pipeline stages. 753 // The three pipeline stages.
772 BackingStoreCopier copier_; 754 BackingStoreCopier copier_;
773 VideoFrameRenderer renderer_; 755 VideoFrameRenderer renderer_;
774 VideoFrameDeliverer deliverer_; 756 VideoFrameDeliverer deliverer_;
775 757
776 base::Closure destroy_cb_; // Invoked once CaptureMachine is destroyed.
777
778 DISALLOW_COPY_AND_ASSIGN(CaptureMachine); 758 DISALLOW_COPY_AND_ASSIGN(CaptureMachine);
779 }; 759 };
780 760
781 CaptureMachine::CaptureMachine(int render_process_id, int render_view_id) 761 CaptureMachine::CaptureMachine(int render_process_id, int render_view_id)
782 : manager_thread_("WebContentsVideo_ManagerThread"), 762 : manager_thread_("WebContentsVideo_ManagerThread"),
783 state_(kIdle), 763 state_(kIdle),
784 is_snapshotting_(false), 764 is_snapshotting_(false),
785 num_renders_pending_(0), 765 num_renders_pending_(0),
786 copier_(render_process_id, render_view_id), 766 copier_(render_process_id, render_view_id),
787 deliverer_(&consumer_) { 767 deliverer_(&consumer_) {
788 manager_thread_.Start(); 768 manager_thread_.Start();
789 } 769 }
790 770
791 void CaptureMachine::InitializeForTesting(RenderWidgetHost* override,
792 const base::Closure& destroy_cb) {
793 copier_.SetRenderWidgetHostForTesting(override);
794 destroy_cb_ = destroy_cb;
795 }
796
797 void CaptureMachine::SetConsumer( 771 void CaptureMachine::SetConsumer(
798 media::VideoCaptureDevice::EventHandler* consumer) { 772 media::VideoCaptureDevice::EventHandler* consumer) {
799 consumer_.SetConsumer(consumer); 773 consumer_.SetConsumer(consumer);
800 } 774 }
801 775
802 void CaptureMachine::Allocate(int width, int height, int frame_rate) { 776 void CaptureMachine::Allocate(int width, int height, int frame_rate) {
803 ENSURE_INVOKED_ON_THREAD(manager_thread_, 777 ENSURE_INVOKED_ON_THREAD(manager_thread_,
804 &CaptureMachine::Allocate, this, 778 &CaptureMachine::Allocate, this,
805 width, height, frame_rate); 779 width, height, frame_rate);
806 780
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 // ~CaptureMachine() is called, it will attempt to join with the 872 // ~CaptureMachine() is called, it will attempt to join with the
899 // CaptureMachine-owned threads, including itself. Since it's illegal for a 873 // CaptureMachine-owned threads, including itself. Since it's illegal for a
900 // thread to join with itself, we need to trampoline the destructor call to 874 // thread to join with itself, we need to trampoline the destructor call to
901 // another thread. 875 // another thread.
902 BrowserThread::PostBlockingPoolTask( 876 BrowserThread::PostBlockingPoolTask(
903 FROM_HERE, base::Bind(&DeleteFromOutsideThread, x)); 877 FROM_HERE, base::Bind(&DeleteFromOutsideThread, x));
904 } 878 }
905 879
906 // static 880 // static
907 void CaptureMachine::DeleteFromOutsideThread(const CaptureMachine* x) { 881 void CaptureMachine::DeleteFromOutsideThread(const CaptureMachine* x) {
908 const base::Closure run_after_delete = x->destroy_cb_;
909 // Note: Thread joins are about to happen here (in ~CaptureThread()).
miu 2013/02/20 06:45:10 This comment should be retained (it's not related
ncarter (slow) 2013/02/22 02:16:11 Done.
910 delete x; 882 delete x;
911 if (!run_after_delete.is_null()) {
912 run_after_delete.Run();
913 }
914 } 883 }
915 884
916 void CaptureMachine::TransitionStateTo(State next_state) { 885 void CaptureMachine::TransitionStateTo(State next_state) {
917 DCHECK_EQ(manager_thread_.message_loop(), MessageLoop::current()); 886 DCHECK_EQ(manager_thread_.message_loop(), MessageLoop::current());
918 887
919 #ifndef NDEBUG 888 #ifndef NDEBUG
920 static const char* kStateNames[] = { 889 static const char* kStateNames[] = {
921 "Idle", "Allocated", "Capturing", "Error", "Destroyed" 890 "Idle", "Allocated", "Capturing", "Error", "Destroyed"
922 }; 891 };
923 DVLOG(1) << "State change: " << kStateNames[state_] 892 DVLOG(1) << "State change: " << kStateNames[state_]
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1094 copier_.StopObservingWebContents(); 1063 copier_.StopObservingWebContents();
1095 } 1064 }
1096 1065
1097 void BackingStoreCopier::StartCopy( 1066 void BackingStoreCopier::StartCopy(
1098 const scoped_refptr<CaptureMachine>& consumer, 1067 const scoped_refptr<CaptureMachine>& consumer,
1099 int frame_number, 1068 int frame_number,
1100 int desired_width, 1069 int desired_width,
1101 int desired_height) { 1070 int desired_height) {
1102 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1071 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1103 1072
1104 RenderWidgetHost* rwh; 1073 if (!web_contents()) { // No source yet.
1105 if (rwh_for_testing_) { 1074 LookUpAndObserveWebContents();
1106 rwh = rwh_for_testing_; 1075 if (!web_contents()) { // No source ever.
1107 } else { 1076 consumer->OnSnapshotFailed(CaptureMachine::NO_SOURCE, frame_number);
1108 if (!web_contents()) { // No source yet.
1109 LookUpAndObserveWebContents();
1110 if (!web_contents()) { // No source ever.
1111 consumer->OnSnapshotFailed(CaptureMachine::NO_SOURCE, frame_number);
1112 return;
1113 }
1114 }
1115
1116 if (fullscreen_widget_id_ != MSG_ROUTING_NONE) {
1117 RenderProcessHost* process = web_contents()->GetRenderProcessHost();
1118 rwh = process ? process->GetRenderWidgetHostByID(fullscreen_widget_id_)
1119 : NULL;
1120 } else {
1121 rwh = web_contents()->GetRenderViewHost();
1122 }
1123
1124 if (!rwh) {
1125 // Transient failure state (e.g., a RenderView is being replaced).
1126 consumer->OnSnapshotFailed(CaptureMachine::TRANSIENT_ERROR, frame_number);
1127 return; 1077 return;
1128 } 1078 }
1129 } 1079 }
1130 1080
1081 RenderWidgetHost* rwh;
1082 if (fullscreen_widget_id_ != MSG_ROUTING_NONE) {
1083 RenderProcessHost* process = web_contents()->GetRenderProcessHost();
1084 rwh = process ? process->GetRenderWidgetHostByID(fullscreen_widget_id_)
1085 : NULL;
1086 } else {
1087 rwh = web_contents()->GetRenderViewHost();
1088 }
1089
1090 if (!rwh) {
1091 // Transient failure state (e.g., a RenderView is being replaced).
1092 consumer->OnSnapshotFailed(CaptureMachine::TRANSIENT_ERROR, frame_number);
1093 return;
1094 }
1095
1131 RenderWidgetHostViewPort* view = 1096 RenderWidgetHostViewPort* view =
1132 RenderWidgetHostViewPort::FromRWHV(rwh->GetView()); 1097 RenderWidgetHostViewPort::FromRWHV(rwh->GetView());
1133 1098
1134 gfx::Size fitted_size; 1099 gfx::Size fitted_size;
1135 if (view) { 1100 if (view) {
1136 gfx::Size view_size = view->GetViewBounds().size(); 1101 gfx::Size view_size = view->GetViewBounds().size();
1137 if (!view_size.IsEmpty()) { 1102 if (!view_size.IsEmpty()) {
1138 CalculateFittedSize(view_size.width(), view_size.height(), 1103 CalculateFittedSize(view_size.width(), view_size.height(),
1139 desired_width, desired_height, 1104 desired_width, desired_height,
1140 &fitted_size); 1105 &fitted_size);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1225 CaptureMachine::TRANSIENT_ERROR, frame_number); 1190 CaptureMachine::TRANSIENT_ERROR, frame_number);
1226 } 1191 }
1227 } 1192 }
1228 1193
1229 WebContentsVideoCaptureDevice::WebContentsVideoCaptureDevice( 1194 WebContentsVideoCaptureDevice::WebContentsVideoCaptureDevice(
1230 const media::VideoCaptureDevice::Name& name, 1195 const media::VideoCaptureDevice::Name& name,
1231 int render_process_id, int render_view_id) 1196 int render_process_id, int render_view_id)
1232 : device_name_(name), 1197 : device_name_(name),
1233 capturer_(new CaptureMachine(render_process_id, render_view_id)) {} 1198 capturer_(new CaptureMachine(render_process_id, render_view_id)) {}
1234 1199
1235 WebContentsVideoCaptureDevice::WebContentsVideoCaptureDevice(
1236 RenderWidgetHost* test_source, const base::Closure& destroy_cb)
1237 : capturer_(new CaptureMachine(-1, -1)) {
1238 device_name_.device_name = "WebContentsForTesting";
1239 device_name_.unique_id = "-1:-1";
1240 capturer_->InitializeForTesting(test_source, destroy_cb);
1241 }
1242
1243 WebContentsVideoCaptureDevice::~WebContentsVideoCaptureDevice() { 1200 WebContentsVideoCaptureDevice::~WebContentsVideoCaptureDevice() {
1244 DVLOG(2) << "WebContentsVideoCaptureDevice@" << this << " destroying."; 1201 DVLOG(2) << "WebContentsVideoCaptureDevice@" << this << " destroying.";
1245 } 1202 }
1246 1203
1247 // static 1204 // static
1248 media::VideoCaptureDevice* WebContentsVideoCaptureDevice::Create( 1205 media::VideoCaptureDevice* WebContentsVideoCaptureDevice::Create(
1249 const std::string& device_id) { 1206 const std::string& device_id) {
1250 // Parse device_id into render_process_id and render_view_id. 1207 // Parse device_id into render_process_id and render_view_id.
1251 int render_process_id = -1; 1208 int render_process_id = -1;
1252 int render_view_id = -1; 1209 int render_view_id = -1;
1253 if (!WebContentsCaptureUtil::ExtractTabCaptureTarget(device_id, 1210 if (!WebContentsCaptureUtil::ExtractTabCaptureTarget(device_id,
1254 &render_process_id, 1211 &render_process_id,
1255 &render_view_id)) 1212 &render_view_id))
1256 return NULL; 1213 return NULL;
1257 1214
1258 media::VideoCaptureDevice::Name name; 1215 media::VideoCaptureDevice::Name name;
1259 base::SStringPrintf(&name.device_name, 1216 base::SStringPrintf(&name.device_name,
1260 "WebContents[%.*s]", 1217 "WebContents[%.*s]",
1261 static_cast<int>(device_id.size()), device_id.data()); 1218 static_cast<int>(device_id.size()), device_id.data());
1262 name.unique_id = device_id; 1219 name.unique_id = device_id;
1263 1220
1264 return new WebContentsVideoCaptureDevice( 1221 return new WebContentsVideoCaptureDevice(
1265 name, render_process_id, render_view_id); 1222 name, render_process_id, render_view_id);
1266 } 1223 }
1267 1224
1268 // static
1269 media::VideoCaptureDevice* WebContentsVideoCaptureDevice::CreateForTesting(
1270 RenderWidgetHost* test_source, const base::Closure& destroy_cb) {
1271 return new WebContentsVideoCaptureDevice(test_source, destroy_cb);
1272 }
1273
1274 void WebContentsVideoCaptureDevice::Allocate( 1225 void WebContentsVideoCaptureDevice::Allocate(
1275 int width, int height, int frame_rate, 1226 int width, int height, int frame_rate,
1276 VideoCaptureDevice::EventHandler* consumer) { 1227 VideoCaptureDevice::EventHandler* consumer) {
1277 DCHECK(capturer_); 1228 DCHECK(capturer_);
1278 capturer_->SetConsumer(consumer); 1229 capturer_->SetConsumer(consumer);
1279 capturer_->Allocate(width, height, frame_rate); 1230 capturer_->Allocate(width, height, frame_rate);
1280 } 1231 }
1281 1232
1282 void WebContentsVideoCaptureDevice::Start() { 1233 void WebContentsVideoCaptureDevice::Start() {
1283 DCHECK(capturer_); 1234 DCHECK(capturer_);
(...skipping 10 matching lines...) Expand all
1294 capturer_->SetConsumer(NULL); 1245 capturer_->SetConsumer(NULL);
1295 capturer_->DeAllocate(); 1246 capturer_->DeAllocate();
1296 } 1247 }
1297 1248
1298 const media::VideoCaptureDevice::Name& 1249 const media::VideoCaptureDevice::Name&
1299 WebContentsVideoCaptureDevice::device_name() { 1250 WebContentsVideoCaptureDevice::device_name() {
1300 return device_name_; 1251 return device_name_;
1301 } 1252 }
1302 1253
1303 } // namespace content 1254 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698