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

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

Issue 83793004: Implement IPCs and VideoCapture::Client interfaces for texture capture (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 5744a8bbb Nits. Created 6 years, 11 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/browser/renderer_host/media/video_capture_host.h" 5 #include "content/browser/renderer_host/media/video_capture_host.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "content/browser/browser_main_loop.h" 9 #include "content/browser/browser_main_loop.h"
10 #include "content/browser/renderer_host/media/media_stream_manager.h" 10 #include "content/browser/renderer_host/media/media_stream_manager.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 int buffer_id) { 62 int buffer_id) {
63 BrowserThread::PostTask( 63 BrowserThread::PostTask(
64 BrowserThread::IO, FROM_HERE, 64 BrowserThread::IO, FROM_HERE,
65 base::Bind(&VideoCaptureHost::DoSendFreeBufferOnIOThread, 65 base::Bind(&VideoCaptureHost::DoSendFreeBufferOnIOThread,
66 this, controller_id, buffer_id)); 66 this, controller_id, buffer_id));
67 } 67 }
68 68
69 void VideoCaptureHost::OnBufferReady( 69 void VideoCaptureHost::OnBufferReady(
70 const VideoCaptureControllerID& controller_id, 70 const VideoCaptureControllerID& controller_id,
71 int buffer_id, 71 int buffer_id,
72 base::TimeTicks timestamp, 72 const media::VideoCaptureFormat& frame_format,
73 const media::VideoCaptureFormat& frame_format) { 73 base::TimeTicks timestamp) {
74 BrowserThread::PostTask( 74 BrowserThread::PostTask(
75 BrowserThread::IO, FROM_HERE, 75 BrowserThread::IO,
76 FROM_HERE,
76 base::Bind(&VideoCaptureHost::DoSendFilledBufferOnIOThread, 77 base::Bind(&VideoCaptureHost::DoSendFilledBufferOnIOThread,
77 this, controller_id, buffer_id, timestamp, 78 this,
78 frame_format)); 79 controller_id,
80 buffer_id,
81 frame_format,
82 timestamp));
83 }
84
85 void VideoCaptureHost::OnMailboxBufferReady(
86 const VideoCaptureControllerID& controller_id,
87 int buffer_id,
88 const gpu::MailboxHolder& mailbox_holder,
89 const media::VideoCaptureFormat& frame_format,
90 base::TimeTicks timestamp) {
91 BrowserThread::PostTask(
92 BrowserThread::IO,
93 FROM_HERE,
94 base::Bind(&VideoCaptureHost::DoSendFilledMailboxBufferOnIOThread,
mcasas 2014/01/21 14:34:02 If the call to VideoCaptureHost::OnMailboxBufferRe
sheu 2014/01/29 01:19:20 Most of the trampolining seems unnecessary here, b
95 this,
96 controller_id,
97 buffer_id,
98 mailbox_holder,
99 frame_format,
100 timestamp));
79 } 101 }
80 102
81 void VideoCaptureHost::OnEnded(const VideoCaptureControllerID& controller_id) { 103 void VideoCaptureHost::OnEnded(const VideoCaptureControllerID& controller_id) {
82 DVLOG(1) << "VideoCaptureHost::OnEnded"; 104 DVLOG(1) << "VideoCaptureHost::OnEnded";
83 BrowserThread::PostTask( 105 BrowserThread::PostTask(
84 BrowserThread::IO, FROM_HERE, 106 BrowserThread::IO, FROM_HERE,
85 base::Bind(&VideoCaptureHost::DoEndedOnIOThread, this, controller_id)); 107 base::Bind(&VideoCaptureHost::DoEndedOnIOThread, this, controller_id));
86 } 108 }
87 109
88 void VideoCaptureHost::DoSendNewBufferOnIOThread( 110 void VideoCaptureHost::DoSendNewBufferOnIOThread(
(...skipping 17 matching lines...) Expand all
106 128
107 if (entries_.find(controller_id) == entries_.end()) 129 if (entries_.find(controller_id) == entries_.end())
108 return; 130 return;
109 131
110 Send(new VideoCaptureMsg_FreeBuffer(controller_id.device_id, buffer_id)); 132 Send(new VideoCaptureMsg_FreeBuffer(controller_id.device_id, buffer_id));
111 } 133 }
112 134
113 void VideoCaptureHost::DoSendFilledBufferOnIOThread( 135 void VideoCaptureHost::DoSendFilledBufferOnIOThread(
114 const VideoCaptureControllerID& controller_id, 136 const VideoCaptureControllerID& controller_id,
115 int buffer_id, 137 int buffer_id,
116 base::TimeTicks timestamp, 138 const media::VideoCaptureFormat& format,
117 const media::VideoCaptureFormat& format) { 139 base::TimeTicks timestamp) {
118 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 140 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
119 141
120 if (entries_.find(controller_id) == entries_.end()) 142 if (entries_.find(controller_id) == entries_.end())
121 return; 143 return;
122 144
123 Send(new VideoCaptureMsg_BufferReady(controller_id.device_id, buffer_id, 145 Send(new VideoCaptureMsg_BufferReady(
124 timestamp, format)); 146 controller_id.device_id, buffer_id, format, timestamp));
147 }
148
149 void VideoCaptureHost::DoSendFilledMailboxBufferOnIOThread(
150 const VideoCaptureControllerID& controller_id,
151 int buffer_id,
152 const gpu::MailboxHolder& mailbox_holder,
153 const media::VideoCaptureFormat& format,
154 base::TimeTicks timestamp) {
155 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
156
157 if (entries_.find(controller_id) == entries_.end())
158 return;
159
160 Send(new VideoCaptureMsg_MailboxBufferReady(
161 controller_id.device_id, buffer_id, mailbox_holder, format, timestamp));
125 } 162 }
126 163
127 void VideoCaptureHost::DoHandleErrorOnIOThread( 164 void VideoCaptureHost::DoHandleErrorOnIOThread(
128 const VideoCaptureControllerID& controller_id) { 165 const VideoCaptureControllerID& controller_id) {
129 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 166 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
130 167
131 if (entries_.find(controller_id) == entries_.end()) 168 if (entries_.find(controller_id) == entries_.end())
132 return; 169 return;
133 170
134 Send(new VideoCaptureMsg_StateChanged(controller_id.device_id, 171 Send(new VideoCaptureMsg_StateChanged(controller_id.device_id,
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 DeleteVideoCaptureControllerOnIOThread(controller_id); 273 DeleteVideoCaptureControllerOnIOThread(controller_id);
237 } 274 }
238 275
239 void VideoCaptureHost::OnPauseCapture(int device_id) { 276 void VideoCaptureHost::OnPauseCapture(int device_id) {
240 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 277 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
241 DVLOG(1) << "VideoCaptureHost::OnPauseCapture, device_id " << device_id; 278 DVLOG(1) << "VideoCaptureHost::OnPauseCapture, device_id " << device_id;
242 // Not used. 279 // Not used.
243 Send(new VideoCaptureMsg_StateChanged(device_id, VIDEO_CAPTURE_STATE_ERROR)); 280 Send(new VideoCaptureMsg_StateChanged(device_id, VIDEO_CAPTURE_STATE_ERROR));
244 } 281 }
245 282
246 void VideoCaptureHost::OnReceiveEmptyBuffer(int device_id, int buffer_id) { 283 void VideoCaptureHost::OnReceiveEmptyBuffer(int device_id,
284 int buffer_id,
285 uint32 sync_point) {
247 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 286 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
248 287
249 VideoCaptureControllerID controller_id(device_id); 288 VideoCaptureControllerID controller_id(device_id);
250 EntryMap::iterator it = entries_.find(controller_id); 289 EntryMap::iterator it = entries_.find(controller_id);
251 if (it != entries_.end()) { 290 if (it != entries_.end()) {
252 const base::WeakPtr<VideoCaptureController>& controller = it->second; 291 const base::WeakPtr<VideoCaptureController>& controller = it->second;
253 if (controller) 292 if (controller)
254 controller->ReturnBuffer(controller_id, this, buffer_id); 293 controller->ReturnBuffer(controller_id, this, buffer_id, sync_point);
255 } 294 }
256 } 295 }
257 296
258 void VideoCaptureHost::DeleteVideoCaptureControllerOnIOThread( 297 void VideoCaptureHost::DeleteVideoCaptureControllerOnIOThread(
259 const VideoCaptureControllerID& controller_id) { 298 const VideoCaptureControllerID& controller_id) {
260 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 299 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
261 300
262 EntryMap::iterator it = entries_.find(controller_id); 301 EntryMap::iterator it = entries_.find(controller_id);
263 if (it == entries_.end()) 302 if (it == entries_.end())
264 return; 303 return;
265 304
266 if (it->second) { 305 if (it->second) {
267 media_stream_manager_->video_capture_manager()->StopCaptureForClient( 306 media_stream_manager_->video_capture_manager()->StopCaptureForClient(
268 it->second.get(), controller_id, this); 307 it->second.get(), controller_id, this);
269 } 308 }
270 entries_.erase(it); 309 entries_.erase(it);
271 } 310 }
272 311
273 } // namespace content 312 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698