OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef PPAPI_PPB_VIDEO_CAPTURE_PROXY_H_ | 5 #ifndef PPAPI_PPB_VIDEO_CAPTURE_PROXY_H_ |
6 #define PPAPI_PPB_VIDEO_CAPTURE_PROXY_H_ | 6 #define PPAPI_PPB_VIDEO_CAPTURE_PROXY_H_ |
7 | 7 |
8 #include "ppapi/c/pp_instance.h" | 8 #include "ppapi/c/pp_instance.h" |
9 #include "ppapi/proxy/interface_proxy.h" | 9 #include "ppapi/proxy/interface_proxy.h" |
10 #include "ppapi/proxy/serialized_structs.h" | 10 #include "ppapi/proxy/serialized_structs.h" |
11 | 11 |
12 struct PPB_VideoCapture_Dev; | 12 struct PPB_VideoCapture_Dev; |
13 struct PPP_VideoCapture_Dev; | 13 struct PPP_VideoCapture_Dev; |
14 struct PP_VideoCaptureDeviceInfo_Dev; | 14 struct PP_VideoCaptureDeviceInfo_Dev; |
15 | 15 |
16 namespace ppapi { | 16 namespace ppapi { |
17 | 17 |
18 class HostResource; | 18 class HostResource; |
19 | 19 |
20 namespace proxy { | 20 namespace proxy { |
21 | 21 |
22 class PPB_VideoCapture_Proxy : public InterfaceProxy { | 22 class PPB_VideoCapture_Proxy : public InterfaceProxy { |
23 public: | 23 public: |
24 PPB_VideoCapture_Proxy(Dispatcher* dispatcher); | 24 PPB_VideoCapture_Proxy(Dispatcher* dispatcher, const void* target_interface); |
25 virtual ~PPB_VideoCapture_Proxy(); | 25 virtual ~PPB_VideoCapture_Proxy(); |
26 | 26 |
| 27 static const Info* GetInfo(); |
| 28 |
27 static PP_Resource CreateProxyResource(PP_Instance instance); | 29 static PP_Resource CreateProxyResource(PP_Instance instance); |
28 | 30 |
| 31 const PPB_VideoCapture_Dev* ppb_video_capture_target() const { |
| 32 return static_cast<const PPB_VideoCapture_Dev*>(target_interface()); |
| 33 } |
| 34 |
29 // InterfaceProxy implementation. | 35 // InterfaceProxy implementation. |
30 virtual bool OnMessageReceived(const IPC::Message& msg); | 36 virtual bool OnMessageReceived(const IPC::Message& msg); |
31 | 37 |
32 static const InterfaceID kInterfaceID = INTERFACE_ID_PPB_VIDEO_CAPTURE_DEV; | |
33 | |
34 private: | 38 private: |
35 // Message handlers. | 39 // Message handlers. |
36 void OnMsgCreate(PP_Instance instance, ppapi::HostResource* result_resource); | 40 void OnMsgCreate(PP_Instance instance, ppapi::HostResource* result_resource); |
37 void OnMsgStartCapture(const ppapi::HostResource& resource, | 41 void OnMsgStartCapture(const ppapi::HostResource& resource, |
38 const PP_VideoCaptureDeviceInfo_Dev& info, | 42 const PP_VideoCaptureDeviceInfo_Dev& info, |
39 uint32_t buffers); | 43 uint32_t buffers); |
40 void OnMsgReuseBuffer(const ppapi::HostResource& resource, | 44 void OnMsgReuseBuffer(const ppapi::HostResource& resource, |
41 uint32_t buffer); | 45 uint32_t buffer); |
42 void OnMsgStopCapture(const ppapi::HostResource& resource); | 46 void OnMsgStopCapture(const ppapi::HostResource& resource); |
43 | |
44 DISALLOW_COPY_AND_ASSIGN(PPB_VideoCapture_Proxy); | |
45 }; | 47 }; |
46 | 48 |
47 class PPP_VideoCapture_Proxy : public InterfaceProxy { | 49 class PPP_VideoCapture_Proxy : public InterfaceProxy { |
48 public: | 50 public: |
49 PPP_VideoCapture_Proxy(Dispatcher* dispatcher); | 51 PPP_VideoCapture_Proxy(Dispatcher* dispatcher, const void* target_interface); |
50 virtual ~PPP_VideoCapture_Proxy(); | 52 virtual ~PPP_VideoCapture_Proxy(); |
51 | 53 |
52 static const Info* GetInfo(); | 54 static const Info* GetInfo(); |
53 | 55 |
| 56 const PPP_VideoCapture_Dev* ppp_video_capture_target() const { |
| 57 return static_cast<const PPP_VideoCapture_Dev*>(target_interface()); |
| 58 } |
| 59 |
54 // InterfaceProxy implementation. | 60 // InterfaceProxy implementation. |
55 virtual bool OnMessageReceived(const IPC::Message& msg); | 61 virtual bool OnMessageReceived(const IPC::Message& msg); |
56 | 62 |
57 static const InterfaceID kInterfaceID = INTERFACE_ID_PPP_VIDEO_CAPTURE_DEV; | |
58 | |
59 private: | 63 private: |
60 // Message handlers. | 64 // Message handlers. |
61 void OnMsgOnDeviceInfo(const ppapi::HostResource& video_capture, | 65 void OnMsgOnDeviceInfo(const ppapi::HostResource& video_capture, |
62 const PP_VideoCaptureDeviceInfo_Dev& info, | 66 const PP_VideoCaptureDeviceInfo_Dev& info, |
63 const std::vector<PPPVideoCapture_Buffer>& buffers); | 67 const std::vector<PPPVideoCapture_Buffer>& buffers); |
64 void OnMsgOnStatus(const ppapi::HostResource& video_capture, | 68 void OnMsgOnStatus(const ppapi::HostResource& video_capture, |
65 uint32_t status); | 69 uint32_t status); |
66 void OnMsgOnError(const ppapi::HostResource& video_capture, | 70 void OnMsgOnError(const ppapi::HostResource& video_capture, |
67 uint32_t error_code); | 71 uint32_t error_code); |
68 void OnMsgOnBufferReady(const ppapi::HostResource& video_capture, | 72 void OnMsgOnBufferReady(const ppapi::HostResource& video_capture, |
69 uint32_t buffer); | 73 uint32_t buffer); |
70 | |
71 // When this proxy is in the plugin side, this value caches the interface | |
72 // pointer so we don't have to retrieve it from the dispatcher each time. | |
73 // In the host, this value is always NULL. | |
74 const PPP_VideoCapture_Dev* ppp_video_capture_impl_; | |
75 | |
76 DISALLOW_COPY_AND_ASSIGN(PPP_VideoCapture_Proxy); | |
77 }; | 74 }; |
78 | 75 |
79 } // namespace proxy | 76 } // namespace proxy |
80 } // namespace ppapi | 77 } // namespace ppapi |
81 | 78 |
82 #endif // PPAPI_PPB_VIDEO_CAPTURE_PROXY_H_ | 79 #endif // PPAPI_PPB_VIDEO_CAPTURE_PROXY_H_ |
OLD | NEW |