OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef PPAPI_PROXY_PPB_VIDEO_CAPTURE_PROXY_H_ | |
6 #define PPAPI_PROXY_PPB_VIDEO_CAPTURE_PROXY_H_ | |
7 | |
8 #include <string> | |
9 #include <vector> | |
10 | |
11 #include "ppapi/c/dev/ppp_video_capture_dev.h" | |
12 #include "ppapi/c/pp_instance.h" | |
13 #include "ppapi/proxy/interface_proxy.h" | |
14 #include "ppapi/proxy/proxy_completion_callback_factory.h" | |
15 #include "ppapi/proxy/serialized_structs.h" | |
16 #include "ppapi/shared_impl/ppb_device_ref_shared.h" | |
17 #include "ppapi/utility/completion_callback_factory.h" | |
18 | |
19 struct PP_VideoCaptureDeviceInfo_Dev; | |
20 | |
21 namespace ppapi { | |
22 | |
23 class HostResource; | |
24 | |
25 namespace proxy { | |
26 | |
27 class PPB_VideoCapture_Proxy : public InterfaceProxy { | |
28 public: | |
29 explicit PPB_VideoCapture_Proxy(Dispatcher* dispatcher); | |
30 virtual ~PPB_VideoCapture_Proxy(); | |
31 | |
32 static PP_Resource CreateProxyResource(PP_Instance instance); | |
33 | |
34 // InterfaceProxy implementation. | |
35 virtual bool OnMessageReceived(const IPC::Message& msg); | |
36 | |
37 static const ApiID kApiID = API_ID_PPB_VIDEO_CAPTURE_DEV; | |
38 | |
39 private: | |
40 // Message handlers in the renderer process. | |
41 void OnMsgCreate(PP_Instance instance, ppapi::HostResource* result_resource); | |
42 void OnMsgEnumerateDevices(const ppapi::HostResource& resource); | |
43 void OnMsgOpen(const ppapi::HostResource& resource, | |
44 const std::string& device_id, | |
45 const PP_VideoCaptureDeviceInfo_Dev& info, | |
46 uint32_t buffers); | |
47 void OnMsgStartCapture(const ppapi::HostResource& resource); | |
48 void OnMsgReuseBuffer(const ppapi::HostResource& resource, | |
49 uint32_t buffer); | |
50 void OnMsgStopCapture(const ppapi::HostResource& resource); | |
51 void OnMsgClose(const ppapi::HostResource& resource); | |
52 void OnMsgStartCapture0_1(const ppapi::HostResource& resource, | |
53 const PP_VideoCaptureDeviceInfo_Dev& info, | |
54 uint32_t buffers); | |
55 | |
56 // Message handlers in the plugin process. | |
57 void OnMsgEnumerateDevicesACK( | |
58 const ppapi::HostResource& resource, | |
59 int32_t result, | |
60 const std::vector<ppapi::DeviceRefData>& devices); | |
61 void OnMsgOpenACK(const ppapi::HostResource& resource, int32_t result); | |
62 | |
63 void EnumerateDevicesACKInHost(int32_t result, | |
64 const ppapi::HostResource& resource); | |
65 void OpenACKInHost(int32_t result, const ppapi::HostResource& resource); | |
66 | |
67 ProxyCompletionCallbackFactory<PPB_VideoCapture_Proxy> callback_factory_; | |
68 | |
69 DISALLOW_COPY_AND_ASSIGN(PPB_VideoCapture_Proxy); | |
70 }; | |
71 | |
72 class PPP_VideoCapture_Proxy : public InterfaceProxy { | |
73 public: | |
74 explicit PPP_VideoCapture_Proxy(Dispatcher* dispatcher); | |
75 virtual ~PPP_VideoCapture_Proxy(); | |
76 | |
77 static const Info* GetInfo(); | |
78 | |
79 // InterfaceProxy implementation. | |
80 virtual bool OnMessageReceived(const IPC::Message& msg); | |
81 | |
82 static const ApiID kApiID = API_ID_PPP_VIDEO_CAPTURE_DEV; | |
83 | |
84 private: | |
85 // Message handlers. | |
86 void OnMsgOnDeviceInfo(const ppapi::HostResource& video_capture, | |
87 const PP_VideoCaptureDeviceInfo_Dev& info, | |
88 const std::vector<PPPVideoCapture_Buffer>& buffers); | |
89 void OnMsgOnStatus(const ppapi::HostResource& video_capture, | |
90 uint32_t status); | |
91 void OnMsgOnError(const ppapi::HostResource& video_capture, | |
92 uint32_t error_code); | |
93 void OnMsgOnBufferReady(const ppapi::HostResource& video_capture, | |
94 uint32_t buffer); | |
95 | |
96 // When this proxy is in the plugin side, this value caches the interface | |
97 // pointer so we don't have to retrieve it from the dispatcher each time. | |
98 // In the host, this value is always NULL. | |
99 const PPP_VideoCapture_Dev* ppp_video_capture_impl_; | |
100 | |
101 DISALLOW_COPY_AND_ASSIGN(PPP_VideoCapture_Proxy); | |
102 }; | |
103 | |
104 } // namespace proxy | |
105 } // namespace ppapi | |
106 | |
107 #endif // PPAPI_PROXY_PPB_VIDEO_CAPTURE_PROXY_H_ | |
OLD | NEW |