OLD | NEW |
---|---|
1 // Copyright (c) 2011 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 "ppapi/proxy/ppb_video_capture_proxy.h" | 5 #include "ppapi/proxy/ppb_video_capture_proxy.h" |
6 | 6 |
7 #include <vector> | 7 #include "base/compiler_specific.h" |
8 | |
9 #include "base/logging.h" | 8 #include "base/logging.h" |
10 #include "build/build_config.h" | 9 #include "build/build_config.h" |
11 #include "ppapi/c/pp_errors.h" | 10 #include "ppapi/c/pp_errors.h" |
12 #include "ppapi/c/pp_resource.h" | 11 #include "ppapi/c/pp_resource.h" |
13 #include "ppapi/c/ppb_core.h" | 12 #include "ppapi/c/ppb_core.h" |
14 #include "ppapi/c/dev/ppb_video_capture_dev.h" | 13 #include "ppapi/c/dev/ppb_video_capture_dev.h" |
15 #include "ppapi/c/dev/ppp_video_capture_dev.h" | 14 #include "ppapi/c/dev/ppp_video_capture_dev.h" |
16 #include "ppapi/proxy/enter_proxy.h" | 15 #include "ppapi/proxy/enter_proxy.h" |
17 #include "ppapi/proxy/host_dispatcher.h" | 16 #include "ppapi/proxy/host_dispatcher.h" |
18 #include "ppapi/proxy/plugin_dispatcher.h" | 17 #include "ppapi/proxy/plugin_dispatcher.h" |
19 #include "ppapi/proxy/ppapi_messages.h" | 18 #include "ppapi/proxy/ppapi_messages.h" |
20 #include "ppapi/proxy/ppb_buffer_proxy.h" | 19 #include "ppapi/proxy/ppb_buffer_proxy.h" |
20 #include "ppapi/shared_impl/ppapi_globals.h" | |
21 #include "ppapi/shared_impl/ppb_video_capture_shared.h" | |
22 #include "ppapi/shared_impl/resource_tracker.h" | |
23 #include "ppapi/shared_impl/tracked_callback.h" | |
21 #include "ppapi/thunk/ppb_buffer_api.h" | 24 #include "ppapi/thunk/ppb_buffer_api.h" |
22 #include "ppapi/thunk/ppb_buffer_trusted_api.h" | 25 #include "ppapi/thunk/ppb_buffer_trusted_api.h" |
23 #include "ppapi/thunk/ppb_video_capture_api.h" | 26 #include "ppapi/thunk/ppb_video_capture_api.h" |
24 #include "ppapi/thunk/resource_creation_api.h" | 27 #include "ppapi/thunk/resource_creation_api.h" |
25 #include "ppapi/thunk/thunk.h" | 28 #include "ppapi/thunk/thunk.h" |
26 | 29 |
27 using ppapi::thunk::EnterResourceNoLock; | 30 using ppapi::thunk::EnterResourceNoLock; |
28 using ppapi::thunk::PPB_Buffer_API; | 31 using ppapi::thunk::PPB_Buffer_API; |
29 using ppapi::thunk::PPB_BufferTrusted_API; | 32 using ppapi::thunk::PPB_BufferTrusted_API; |
30 using ppapi::thunk::PPB_VideoCapture_API; | 33 using ppapi::thunk::PPB_VideoCapture_API; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
130 | 133 |
131 PPP_VideoCapture_Dev ppp_video_capture = { | 134 PPP_VideoCapture_Dev ppp_video_capture = { |
132 OnDeviceInfo, | 135 OnDeviceInfo, |
133 OnStatus, | 136 OnStatus, |
134 OnError, | 137 OnError, |
135 OnBufferReady | 138 OnBufferReady |
136 }; | 139 }; |
137 | 140 |
138 } // namespace | 141 } // namespace |
139 | 142 |
140 class VideoCapture : public ppapi::thunk::PPB_VideoCapture_API, | 143 class VideoCapture : public PPB_VideoCapture_Shared { |
141 public Resource { | |
142 public: | 144 public: |
143 VideoCapture(const HostResource& resource); | 145 explicit VideoCapture(const HostResource& resource); |
144 virtual ~VideoCapture(); | 146 virtual ~VideoCapture(); |
145 | 147 |
146 // Resource overrides. | 148 bool OnStatus(PP_VideoCaptureStatus_Dev status); |
147 virtual ppapi::thunk::PPB_VideoCapture_API* AsPPB_VideoCapture_API() OVERRIDE; | |
148 | 149 |
149 // PPB_VideoCapture_API implementation. | 150 void set_status(PP_VideoCaptureStatus_Dev status) { |
150 virtual int32_t StartCapture( | 151 SetStatus(status, true); |
151 const PP_VideoCaptureDeviceInfo_Dev& requested_info, | |
152 uint32_t buffer_count) { | |
153 switch (status_) { | |
154 case PP_VIDEO_CAPTURE_STATUS_STARTING: | |
155 case PP_VIDEO_CAPTURE_STATUS_STARTED: | |
156 case PP_VIDEO_CAPTURE_STATUS_PAUSED: | |
157 default: | |
158 return PP_ERROR_FAILED; | |
159 case PP_VIDEO_CAPTURE_STATUS_STOPPED: | |
160 case PP_VIDEO_CAPTURE_STATUS_STOPPING: | |
161 break; | |
162 } | |
163 status_ = PP_VIDEO_CAPTURE_STATUS_STARTING; | |
164 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_StartCapture( | |
165 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource(), | |
166 requested_info, buffer_count)); | |
167 return PP_OK; | |
168 } | 152 } |
169 | 153 |
170 virtual int32_t ReuseBuffer(uint32_t buffer) { | |
171 if (buffer >= buffer_in_use_.size() || !buffer_in_use_[buffer]) | |
172 return PP_ERROR_BADARGUMENT; | |
173 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_ReuseBuffer( | |
174 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource(), buffer)); | |
175 return PP_OK; | |
176 } | |
177 | |
178 virtual int32_t StopCapture() { | |
179 switch (status_) { | |
180 case PP_VIDEO_CAPTURE_STATUS_STOPPED: | |
181 case PP_VIDEO_CAPTURE_STATUS_STOPPING: | |
182 default: | |
183 return PP_ERROR_FAILED; | |
184 case PP_VIDEO_CAPTURE_STATUS_STARTING: | |
185 case PP_VIDEO_CAPTURE_STATUS_STARTED: | |
186 case PP_VIDEO_CAPTURE_STATUS_PAUSED: | |
187 break; | |
188 } | |
189 buffer_in_use_.clear(); | |
190 status_ = PP_VIDEO_CAPTURE_STATUS_STOPPING; | |
191 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_StopCapture( | |
192 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource())); | |
193 return PP_OK; | |
194 } | |
195 | |
196 bool OnStatus(uint32_t status) { | |
197 switch (status) { | |
198 case PP_VIDEO_CAPTURE_STATUS_STARTING: | |
199 case PP_VIDEO_CAPTURE_STATUS_STOPPING: | |
200 default: | |
201 // Those states are not sent by the browser. | |
202 NOTREACHED(); | |
203 return false; | |
204 case PP_VIDEO_CAPTURE_STATUS_STARTED: | |
205 switch (status_) { | |
206 case PP_VIDEO_CAPTURE_STATUS_STARTING: | |
207 case PP_VIDEO_CAPTURE_STATUS_PAUSED: | |
208 break; | |
209 default: | |
210 return false; | |
211 } | |
212 break; | |
213 case PP_VIDEO_CAPTURE_STATUS_PAUSED: | |
214 switch (status_) { | |
215 case PP_VIDEO_CAPTURE_STATUS_STARTING: | |
216 case PP_VIDEO_CAPTURE_STATUS_STARTED: | |
217 break; | |
218 default: | |
219 return false; | |
220 } | |
221 break; | |
222 case PP_VIDEO_CAPTURE_STATUS_STOPPED: | |
223 if (status_ != PP_VIDEO_CAPTURE_STATUS_STOPPING) | |
224 return false; | |
225 break; | |
226 } | |
227 status_ = status; | |
228 return true; | |
229 } | |
230 | |
231 void set_status(uint32_t status) { status_ = status; } | |
232 | |
233 void SetBufferCount(size_t count) { | 154 void SetBufferCount(size_t count) { |
234 buffer_in_use_ = std::vector<bool>(count); | 155 buffer_in_use_ = std::vector<bool>(count); |
235 } | 156 } |
157 | |
236 void SetBufferInUse(uint32_t buffer) { | 158 void SetBufferInUse(uint32_t buffer) { |
237 DCHECK(buffer < buffer_in_use_.size()); | 159 DCHECK(buffer < buffer_in_use_.size()); |
238 buffer_in_use_[buffer] = true; | 160 buffer_in_use_[buffer] = true; |
239 } | 161 } |
240 | 162 |
241 private: | 163 private: |
164 // PPB_VideoCapture_Shared implementation. | |
165 virtual int32_t InternalEnumerateDevices( | |
166 PP_Resource* devices, | |
167 PP_CompletionCallback callback) OVERRIDE; | |
168 virtual int32_t InternalOpen( | |
169 const std::string& device_id, | |
170 const PP_VideoCaptureDeviceInfo_Dev& requested_info, | |
171 uint32_t buffer_count, | |
172 PP_CompletionCallback callback) OVERRIDE; | |
173 virtual int32_t InternalStartCapture() OVERRIDE; | |
174 virtual int32_t InternalReuseBuffer(uint32_t buffer) OVERRIDE; | |
175 virtual int32_t InternalStopCapture() OVERRIDE; | |
176 virtual void InternalClose() OVERRIDE; | |
177 virtual int32_t InternalStartCapture0_1( | |
178 const PP_VideoCaptureDeviceInfo_Dev& requested_info, | |
179 uint32_t buffer_count) OVERRIDE; | |
180 virtual const std::vector<DeviceRefData>& InternalGetDeviceRefData( | |
viettrungluu
2012/02/15 18:40:28
Nit: This is a very unusual way to break the line
yzshen1
2012/02/15 21:17:54
Done.
| |
181 ) const OVERRIDE; | |
182 | |
242 PluginDispatcher* GetDispatcher() const { | 183 PluginDispatcher* GetDispatcher() const { |
243 return PluginDispatcher::GetForResource(this); | 184 return PluginDispatcher::GetForResource(this); |
244 } | 185 } |
245 | 186 |
246 uint32_t status_; | |
247 std::vector<bool> buffer_in_use_; | 187 std::vector<bool> buffer_in_use_; |
188 | |
248 DISALLOW_COPY_AND_ASSIGN(VideoCapture); | 189 DISALLOW_COPY_AND_ASSIGN(VideoCapture); |
249 }; | 190 }; |
250 | 191 |
251 VideoCapture::VideoCapture(const HostResource& resource) | 192 VideoCapture::VideoCapture(const HostResource& resource) |
252 : Resource(resource), | 193 : PPB_VideoCapture_Shared(resource) { |
253 status_(PP_VIDEO_CAPTURE_STATUS_STOPPED) { | |
254 } | 194 } |
255 | 195 |
256 VideoCapture::~VideoCapture() { | 196 VideoCapture::~VideoCapture() { |
197 Close(); | |
257 } | 198 } |
258 | 199 |
259 ppapi::thunk::PPB_VideoCapture_API* VideoCapture::AsPPB_VideoCapture_API() { | 200 bool VideoCapture::OnStatus(PP_VideoCaptureStatus_Dev status) { |
260 return this; | 201 switch (status) { |
202 case PP_VIDEO_CAPTURE_STATUS_STARTED: | |
203 case PP_VIDEO_CAPTURE_STATUS_PAUSED: | |
204 case PP_VIDEO_CAPTURE_STATUS_STOPPED: | |
205 return SetStatus(status, false); | |
206 case PP_VIDEO_CAPTURE_STATUS_STARTING: | |
207 case PP_VIDEO_CAPTURE_STATUS_STOPPING: | |
208 default: | |
viettrungluu
2012/02/15 18:40:28
Nit: I have a preference for not having default ca
yzshen1
2012/02/15 21:17:54
Thanks for pointing this out. Done.
On 2012/02/15
| |
209 // Those states are not sent by the browser. | |
210 NOTREACHED(); | |
211 return false; | |
212 } | |
213 } | |
214 | |
215 int32_t VideoCapture::InternalEnumerateDevices(PP_Resource* devices, | |
216 PP_CompletionCallback callback) { | |
217 devices_ = devices; | |
218 enumerate_devices_callback_ = new TrackedCallback(this, callback); | |
219 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_EnumerateDevices( | |
220 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource())); | |
221 return PP_OK_COMPLETIONPENDING; | |
222 } | |
223 | |
224 int32_t VideoCapture::InternalOpen( | |
225 const std::string& device_id, | |
226 const PP_VideoCaptureDeviceInfo_Dev& requested_info, | |
227 uint32_t buffer_count, | |
228 PP_CompletionCallback callback) { | |
229 // Disallow blocking call. The base class doesn't check this. | |
230 if (!callback.func) | |
231 return PP_ERROR_BLOCKS_MAIN_THREAD; | |
232 | |
233 open_callback_ = new TrackedCallback(this, callback); | |
234 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_Open( | |
235 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource(), device_id, requested_info, | |
236 buffer_count)); | |
237 return PP_OK_COMPLETIONPENDING; | |
238 } | |
239 | |
240 int32_t VideoCapture::InternalStartCapture() { | |
241 buffer_in_use_.clear(); | |
242 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_StartCapture( | |
243 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource())); | |
244 return PP_OK; | |
245 } | |
246 | |
247 int32_t VideoCapture::InternalReuseBuffer(uint32_t buffer) { | |
248 if (buffer >= buffer_in_use_.size() || !buffer_in_use_[buffer]) | |
249 return PP_ERROR_BADARGUMENT; | |
250 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_ReuseBuffer( | |
251 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource(), buffer)); | |
252 return PP_OK; | |
253 } | |
254 | |
255 int32_t VideoCapture::InternalStopCapture() { | |
256 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_StopCapture( | |
257 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource())); | |
258 return PP_OK; | |
259 } | |
260 | |
261 void VideoCapture::InternalClose() { | |
262 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_Close( | |
263 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource())); | |
264 } | |
265 | |
266 int32_t VideoCapture::InternalStartCapture0_1( | |
267 const PP_VideoCaptureDeviceInfo_Dev& requested_info, | |
268 uint32_t buffer_count) { | |
269 buffer_in_use_.clear(); | |
270 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_StartCapture0_1( | |
271 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource(), requested_info, | |
272 buffer_count)); | |
273 return PP_OK; | |
274 } | |
275 | |
276 const std::vector<DeviceRefData>& VideoCapture::InternalGetDeviceRefData( | |
277 ) const { | |
278 // This should never be called at the plugin side. | |
279 NOTREACHED(); | |
280 static std::vector<DeviceRefData> result; | |
281 return result; | |
261 } | 282 } |
262 | 283 |
263 PPB_VideoCapture_Proxy::PPB_VideoCapture_Proxy(Dispatcher* dispatcher) | 284 PPB_VideoCapture_Proxy::PPB_VideoCapture_Proxy(Dispatcher* dispatcher) |
264 : InterfaceProxy(dispatcher) { | 285 : InterfaceProxy(dispatcher), |
286 ALLOW_THIS_IN_INITIALIZER_LIST(callback_factory_(this)) { | |
265 } | 287 } |
266 | 288 |
267 PPB_VideoCapture_Proxy::~PPB_VideoCapture_Proxy() { | 289 PPB_VideoCapture_Proxy::~PPB_VideoCapture_Proxy() { |
268 } | 290 } |
269 | 291 |
270 // static | 292 // static |
271 PP_Resource PPB_VideoCapture_Proxy::CreateProxyResource(PP_Instance instance) { | 293 PP_Resource PPB_VideoCapture_Proxy::CreateProxyResource(PP_Instance instance) { |
272 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | 294 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
273 if (!dispatcher) | 295 if (!dispatcher) |
274 return 0; | 296 return 0; |
275 | 297 |
276 HostResource result; | 298 HostResource result; |
277 dispatcher->Send(new PpapiHostMsg_PPBVideoCapture_Create( | 299 dispatcher->Send(new PpapiHostMsg_PPBVideoCapture_Create( |
278 API_ID_PPB_VIDEO_CAPTURE_DEV, instance, &result)); | 300 API_ID_PPB_VIDEO_CAPTURE_DEV, instance, &result)); |
279 if (result.is_null()) | 301 if (result.is_null()) |
280 return 0; | 302 return 0; |
281 return (new VideoCapture(result))->GetReference(); | 303 return (new VideoCapture(result))->GetReference(); |
282 } | 304 } |
283 | 305 |
284 bool PPB_VideoCapture_Proxy::OnMessageReceived(const IPC::Message& msg) { | 306 bool PPB_VideoCapture_Proxy::OnMessageReceived(const IPC::Message& msg) { |
285 bool handled = true; | 307 bool handled = true; |
286 IPC_BEGIN_MESSAGE_MAP(PPB_VideoCapture_Proxy, msg) | 308 IPC_BEGIN_MESSAGE_MAP(PPB_VideoCapture_Proxy, msg) |
287 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_Create, OnMsgCreate) | 309 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_Create, OnMsgCreate) |
310 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_EnumerateDevices, | |
311 OnMsgEnumerateDevices) | |
312 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_Open, OnMsgOpen) | |
288 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_StartCapture, | 313 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_StartCapture, |
289 OnMsgStartCapture) | 314 OnMsgStartCapture) |
290 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_ReuseBuffer, | 315 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_ReuseBuffer, |
291 OnMsgReuseBuffer) | 316 OnMsgReuseBuffer) |
292 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_StopCapture, | 317 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_StopCapture, |
293 OnMsgStopCapture) | 318 OnMsgStopCapture) |
319 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_Close, OnMsgClose) | |
320 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_StartCapture0_1, | |
321 OnMsgStartCapture0_1) | |
322 | |
323 IPC_MESSAGE_HANDLER(PpapiMsg_PPBVideoCapture_EnumerateDevicesACK, | |
324 OnMsgEnumerateDevicesACK) | |
325 IPC_MESSAGE_HANDLER(PpapiMsg_PPBVideoCapture_OpenACK, | |
326 OnMsgOpenACK) | |
294 IPC_MESSAGE_UNHANDLED(handled = false) | 327 IPC_MESSAGE_UNHANDLED(handled = false) |
295 IPC_END_MESSAGE_MAP() | 328 IPC_END_MESSAGE_MAP() |
296 // TODO(brettw) handle bad messages! | 329 // TODO(brettw) handle bad messages! |
297 return handled; | 330 return handled; |
298 } | 331 } |
299 | 332 |
300 void PPB_VideoCapture_Proxy::OnMsgCreate(PP_Instance instance, | 333 void PPB_VideoCapture_Proxy::OnMsgCreate(PP_Instance instance, |
301 HostResource* result_resource) { | 334 HostResource* result_resource) { |
302 thunk::EnterResourceCreation enter(instance); | 335 thunk::EnterResourceCreation enter(instance); |
303 if (enter.succeeded()) { | 336 if (enter.succeeded()) { |
304 result_resource->SetHostResource( | 337 result_resource->SetHostResource( |
305 instance, | 338 instance, |
306 enter.functions()->CreateVideoCapture(instance)); | 339 enter.functions()->CreateVideoCapture(instance)); |
307 } | 340 } |
308 } | 341 } |
309 | 342 |
310 void PPB_VideoCapture_Proxy::OnMsgStartCapture( | 343 void PPB_VideoCapture_Proxy::OnMsgEnumerateDevices( |
311 const HostResource& resource, | 344 const HostResource& resource) { |
345 EnterHostFromHostResourceForceCallback<PPB_VideoCapture_API> enter( | |
346 resource, callback_factory_, | |
347 &PPB_VideoCapture_Proxy::EnumerateDevicesACKInHost, resource); | |
348 | |
349 if (enter.succeeded()) | |
350 enter.SetResult(enter.object()->EnumerateDevices(NULL, enter.callback())); | |
351 } | |
352 | |
353 void PPB_VideoCapture_Proxy::OnMsgOpen( | |
354 const ppapi::HostResource& resource, | |
355 const std::string& device_id, | |
312 const PP_VideoCaptureDeviceInfo_Dev& info, | 356 const PP_VideoCaptureDeviceInfo_Dev& info, |
313 uint32_t buffers) { | 357 uint32_t buffers) { |
358 EnterHostFromHostResourceForceCallback<PPB_VideoCapture_API> enter( | |
359 resource, callback_factory_, &PPB_VideoCapture_Proxy::OpenACKInHost, | |
360 resource); | |
361 | |
362 if (enter.succeeded()) { | |
363 enter.SetResult(enter.object()->Open(device_id, info, buffers, | |
364 enter.callback())); | |
365 } | |
366 } | |
367 | |
368 void PPB_VideoCapture_Proxy::OnMsgStartCapture(const HostResource& resource) { | |
314 EnterHostFromHostResource<PPB_VideoCapture_API> enter(resource); | 369 EnterHostFromHostResource<PPB_VideoCapture_API> enter(resource); |
315 if (enter.succeeded()) | 370 if (enter.succeeded()) |
316 enter.object()->StartCapture(info, buffers); | 371 enter.object()->StartCapture(); |
317 } | 372 } |
318 | 373 |
319 void PPB_VideoCapture_Proxy::OnMsgReuseBuffer(const HostResource& resource, | 374 void PPB_VideoCapture_Proxy::OnMsgReuseBuffer(const HostResource& resource, |
320 uint32_t buffer) { | 375 uint32_t buffer) { |
321 EnterHostFromHostResource<PPB_VideoCapture_API> enter(resource); | 376 EnterHostFromHostResource<PPB_VideoCapture_API> enter(resource); |
322 if (enter.succeeded()) | 377 if (enter.succeeded()) |
323 enter.object()->ReuseBuffer(buffer); | 378 enter.object()->ReuseBuffer(buffer); |
324 } | 379 } |
325 | 380 |
326 void PPB_VideoCapture_Proxy::OnMsgStopCapture(const HostResource& resource) { | 381 void PPB_VideoCapture_Proxy::OnMsgStopCapture(const HostResource& resource) { |
327 EnterHostFromHostResource<PPB_VideoCapture_API> enter(resource); | 382 EnterHostFromHostResource<PPB_VideoCapture_API> enter(resource); |
328 if (enter.succeeded()) | 383 if (enter.succeeded()) |
329 enter.object()->StopCapture(); | 384 enter.object()->StopCapture(); |
330 } | 385 } |
331 | 386 |
387 void PPB_VideoCapture_Proxy::OnMsgClose(const HostResource& resource) { | |
388 EnterHostFromHostResource<PPB_VideoCapture_API> enter(resource); | |
389 if (enter.succeeded()) | |
390 enter.object()->Close(); | |
391 } | |
392 | |
393 void PPB_VideoCapture_Proxy::OnMsgStartCapture0_1( | |
394 const HostResource& resource, | |
395 const PP_VideoCaptureDeviceInfo_Dev& info, | |
396 uint32_t buffers) { | |
397 EnterHostFromHostResource<PPB_VideoCapture_API> enter(resource); | |
398 if (enter.succeeded()) | |
399 enter.object()->StartCapture0_1(info, buffers); | |
400 } | |
401 | |
402 void PPB_VideoCapture_Proxy::OnMsgEnumerateDevicesACK( | |
403 const HostResource& resource, | |
404 int32_t result, | |
405 const std::vector<ppapi::DeviceRefData>& devices) { | |
406 EnterPluginFromHostResource<PPB_VideoCapture_API> enter(resource); | |
407 if (enter.succeeded()) { | |
408 static_cast<VideoCapture*>(enter.object())->OnEnumerateDevicesComplete( | |
409 result, devices); | |
410 } | |
411 } | |
412 | |
413 void PPB_VideoCapture_Proxy::OnMsgOpenACK( | |
414 const HostResource& resource, | |
415 int32_t result) { | |
416 EnterPluginFromHostResource<PPB_VideoCapture_API> enter(resource); | |
417 if (enter.succeeded()) | |
418 static_cast<VideoCapture*>(enter.object())->OnOpenComplete(result); | |
419 } | |
420 | |
421 void PPB_VideoCapture_Proxy::EnumerateDevicesACKInHost( | |
422 int32_t result, | |
423 const HostResource& resource) { | |
424 EnterHostFromHostResource<PPB_VideoCapture_API> enter(resource); | |
425 dispatcher()->Send(new PpapiMsg_PPBVideoCapture_EnumerateDevicesACK( | |
426 API_ID_PPB_VIDEO_CAPTURE_DEV, resource, result, | |
427 enter.succeeded() && result == PP_OK ? | |
428 enter.object()->GetDeviceRefData() : std::vector<DeviceRefData>())); | |
429 } | |
430 | |
431 void PPB_VideoCapture_Proxy::OpenACKInHost(int32_t result, | |
432 const HostResource& resource) { | |
433 dispatcher()->Send(new PpapiMsg_PPBVideoCapture_OpenACK( | |
434 API_ID_PPB_VIDEO_CAPTURE_DEV, resource, result)); | |
435 } | |
436 | |
332 PPP_VideoCapture_Proxy::PPP_VideoCapture_Proxy(Dispatcher* dispatcher) | 437 PPP_VideoCapture_Proxy::PPP_VideoCapture_Proxy(Dispatcher* dispatcher) |
333 : InterfaceProxy(dispatcher), | 438 : InterfaceProxy(dispatcher), |
334 ppp_video_capture_impl_(NULL) { | 439 ppp_video_capture_impl_(NULL) { |
335 if (dispatcher->IsPlugin()) { | 440 if (dispatcher->IsPlugin()) { |
336 ppp_video_capture_impl_ = static_cast<const PPP_VideoCapture_Dev*>( | 441 ppp_video_capture_impl_ = static_cast<const PPP_VideoCapture_Dev*>( |
337 dispatcher->local_get_interface()(PPP_VIDEO_CAPTURE_DEV_INTERFACE)); | 442 dispatcher->local_get_interface()(PPP_VIDEO_CAPTURE_DEV_INTERFACE)); |
338 } | 443 } |
339 } | 444 } |
340 | 445 |
341 PPP_VideoCapture_Proxy::~PPP_VideoCapture_Proxy() { | 446 PPP_VideoCapture_Proxy::~PPP_VideoCapture_Proxy() { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
399 tracker->ReleaseResource(resources[i]); | 504 tracker->ReleaseResource(resources[i]); |
400 } | 505 } |
401 | 506 |
402 void PPP_VideoCapture_Proxy::OnMsgOnStatus(const HostResource& host_resource, | 507 void PPP_VideoCapture_Proxy::OnMsgOnStatus(const HostResource& host_resource, |
403 uint32_t status) { | 508 uint32_t status) { |
404 EnterPluginFromHostResource<PPB_VideoCapture_API> enter(host_resource); | 509 EnterPluginFromHostResource<PPB_VideoCapture_API> enter(host_resource); |
405 if (enter.failed() || !ppp_video_capture_impl_) | 510 if (enter.failed() || !ppp_video_capture_impl_) |
406 return; | 511 return; |
407 | 512 |
408 VideoCapture* capture = static_cast<VideoCapture*>(enter.object()); | 513 VideoCapture* capture = static_cast<VideoCapture*>(enter.object()); |
409 if (!capture->OnStatus(status)) | 514 if (!capture->OnStatus(static_cast<PP_VideoCaptureStatus_Dev>(status))) |
410 return; | 515 return; |
411 ppp_video_capture_impl_->OnStatus( | 516 ppp_video_capture_impl_->OnStatus( |
412 host_resource.instance(), capture->pp_resource(), status); | 517 host_resource.instance(), capture->pp_resource(), status); |
413 } | 518 } |
414 | 519 |
415 void PPP_VideoCapture_Proxy::OnMsgOnError(const HostResource& host_resource, | 520 void PPP_VideoCapture_Proxy::OnMsgOnError(const HostResource& host_resource, |
416 uint32_t error_code) { | 521 uint32_t error_code) { |
417 EnterPluginFromHostResource<PPB_VideoCapture_API> enter(host_resource); | 522 EnterPluginFromHostResource<PPB_VideoCapture_API> enter(host_resource); |
418 if (enter.failed() || !ppp_video_capture_impl_) | 523 if (enter.failed() || !ppp_video_capture_impl_) |
419 return; | 524 return; |
(...skipping 11 matching lines...) Expand all Loading... | |
431 return; | 536 return; |
432 | 537 |
433 VideoCapture* capture = static_cast<VideoCapture*>(enter.object()); | 538 VideoCapture* capture = static_cast<VideoCapture*>(enter.object()); |
434 capture->SetBufferInUse(buffer); | 539 capture->SetBufferInUse(buffer); |
435 ppp_video_capture_impl_->OnBufferReady( | 540 ppp_video_capture_impl_->OnBufferReady( |
436 host_resource.instance(), capture->pp_resource(), buffer); | 541 host_resource.instance(), capture->pp_resource(), buffer); |
437 } | 542 } |
438 | 543 |
439 } // namespace proxy | 544 } // namespace proxy |
440 } // namespace ppapi | 545 } // namespace ppapi |
OLD | NEW |