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, const void* target_interface); | 24 PPB_VideoCapture_Proxy(Dispatcher* dispatcher); |
25 virtual ~PPB_VideoCapture_Proxy(); | 25 virtual ~PPB_VideoCapture_Proxy(); |
26 | 26 |
27 static const Info* GetInfo(); | |
28 | |
29 static PP_Resource CreateProxyResource(PP_Instance instance); | 27 static PP_Resource CreateProxyResource(PP_Instance instance); |
30 | 28 |
31 const PPB_VideoCapture_Dev* ppb_video_capture_target() const { | |
32 return static_cast<const PPB_VideoCapture_Dev*>(target_interface()); | |
33 } | |
34 | |
35 // InterfaceProxy implementation. | 29 // InterfaceProxy implementation. |
36 virtual bool OnMessageReceived(const IPC::Message& msg); | 30 virtual bool OnMessageReceived(const IPC::Message& msg); |
37 | 31 |
| 32 static const InterfaceID kInterfaceID = INTERFACE_ID_PPB_VIDEO_CAPTURE_DEV; |
| 33 |
38 private: | 34 private: |
39 // Message handlers. | 35 // Message handlers. |
40 void OnMsgCreate(PP_Instance instance, ppapi::HostResource* result_resource); | 36 void OnMsgCreate(PP_Instance instance, ppapi::HostResource* result_resource); |
41 void OnMsgStartCapture(const ppapi::HostResource& resource, | 37 void OnMsgStartCapture(const ppapi::HostResource& resource, |
42 const PP_VideoCaptureDeviceInfo_Dev& info, | 38 const PP_VideoCaptureDeviceInfo_Dev& info, |
43 uint32_t buffers); | 39 uint32_t buffers); |
44 void OnMsgReuseBuffer(const ppapi::HostResource& resource, | 40 void OnMsgReuseBuffer(const ppapi::HostResource& resource, |
45 uint32_t buffer); | 41 uint32_t buffer); |
46 void OnMsgStopCapture(const ppapi::HostResource& resource); | 42 void OnMsgStopCapture(const ppapi::HostResource& resource); |
| 43 |
| 44 DISALLOW_COPY_AND_ASSIGN(PPB_VideoCapture_Proxy); |
47 }; | 45 }; |
48 | 46 |
49 class PPP_VideoCapture_Proxy : public InterfaceProxy { | 47 class PPP_VideoCapture_Proxy : public InterfaceProxy { |
50 public: | 48 public: |
51 PPP_VideoCapture_Proxy(Dispatcher* dispatcher, const void* target_interface); | 49 PPP_VideoCapture_Proxy(Dispatcher* dispatcher); |
52 virtual ~PPP_VideoCapture_Proxy(); | 50 virtual ~PPP_VideoCapture_Proxy(); |
53 | 51 |
54 static const Info* GetInfo(); | 52 static const Info* GetInfo(); |
55 | 53 |
56 const PPP_VideoCapture_Dev* ppp_video_capture_target() const { | |
57 return static_cast<const PPP_VideoCapture_Dev*>(target_interface()); | |
58 } | |
59 | |
60 // InterfaceProxy implementation. | 54 // InterfaceProxy implementation. |
61 virtual bool OnMessageReceived(const IPC::Message& msg); | 55 virtual bool OnMessageReceived(const IPC::Message& msg); |
62 | 56 |
| 57 static const InterfaceID kInterfaceID = INTERFACE_ID_PPP_VIDEO_CAPTURE_DEV; |
| 58 |
63 private: | 59 private: |
64 // Message handlers. | 60 // Message handlers. |
65 void OnMsgOnDeviceInfo(const ppapi::HostResource& video_capture, | 61 void OnMsgOnDeviceInfo(const ppapi::HostResource& video_capture, |
66 const PP_VideoCaptureDeviceInfo_Dev& info, | 62 const PP_VideoCaptureDeviceInfo_Dev& info, |
67 const std::vector<PPPVideoCapture_Buffer>& buffers); | 63 const std::vector<PPPVideoCapture_Buffer>& buffers); |
68 void OnMsgOnStatus(const ppapi::HostResource& video_capture, | 64 void OnMsgOnStatus(const ppapi::HostResource& video_capture, |
69 uint32_t status); | 65 uint32_t status); |
70 void OnMsgOnError(const ppapi::HostResource& video_capture, | 66 void OnMsgOnError(const ppapi::HostResource& video_capture, |
71 uint32_t error_code); | 67 uint32_t error_code); |
72 void OnMsgOnBufferReady(const ppapi::HostResource& video_capture, | 68 void OnMsgOnBufferReady(const ppapi::HostResource& video_capture, |
73 uint32_t buffer); | 69 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); |
74 }; | 77 }; |
75 | 78 |
76 } // namespace proxy | 79 } // namespace proxy |
77 } // namespace ppapi | 80 } // namespace ppapi |
78 | 81 |
79 #endif // PPAPI_PPB_VIDEO_CAPTURE_PROXY_H_ | 82 #endif // PPAPI_PPB_VIDEO_CAPTURE_PROXY_H_ |
OLD | NEW |