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 CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_CAPTURE_HOST_H_ | |
6 #define CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_CAPTURE_HOST_H_ | |
7 | |
8 #include "base/compiler_specific.h" | |
9 #include "base/memory/ref_counted.h" | |
10 #include "content/common/content_export.h" | |
11 #include "content/public/renderer/renderer_ppapi_host.h" | |
12 #include "media/video/capture/video_capture.h" | |
13 #include "media/video/capture/video_capture_types.h" | |
14 #include "ppapi/c/dev/ppp_video_capture_dev.h" | |
15 #include "ppapi/host/host_message_context.h" | |
16 #include "ppapi/host/resource_host.h" | |
17 #include "ppapi/shared_impl/ppb_device_ref_shared.h" | |
18 #include "webkit/plugins/ppapi/plugin_delegate.h" | |
19 #include "webkit/plugins/ppapi/ppb_buffer_impl.h" | |
20 | |
21 namespace content { | |
22 | |
23 class CONTENT_EXPORT PepperVideoCaptureHost | |
yzshen1
2012/11/06 21:56:23
I don't think we need to export it. (and please re
victorhsieh
2012/11/08 09:20:18
Done.
| |
24 : public ppapi::host::ResourceHost, | |
25 public webkit::ppapi::PluginDelegate::PlatformVideoCaptureEventHandler, | |
26 public base::SupportsWeakPtr<PepperVideoCaptureHost> { | |
27 public: | |
28 PepperVideoCaptureHost(RendererPpapiHost* host, | |
29 PP_Instance instance, | |
30 PP_Resource resource); | |
31 | |
32 ~PepperVideoCaptureHost(); | |
yzshen1
2012/11/06 21:56:23
nit: please add 'virtual'.
victorhsieh
2012/11/08 09:20:18
Done.
| |
33 | |
34 bool Init(); | |
35 | |
36 virtual int32_t OnResourceMessageReceived( | |
37 const IPC::Message& msg, | |
38 ppapi::host::HostMessageContext* context) OVERRIDE; | |
39 | |
40 // PluginDelegate::PlatformVideoCaptureEventHandler | |
41 virtual void OnInitialized(media::VideoCapture* capture, | |
42 bool succeeded) OVERRIDE; | |
43 virtual void OnStarted(media::VideoCapture* capture) OVERRIDE; | |
44 virtual void OnStopped(media::VideoCapture* capture) OVERRIDE; | |
45 virtual void OnPaused(media::VideoCapture* capture) OVERRIDE; | |
46 virtual void OnError(media::VideoCapture* capture, int error_code) OVERRIDE; | |
47 virtual void OnRemoved(media::VideoCapture* capture) OVERRIDE; | |
48 virtual void OnBufferReady( | |
49 media::VideoCapture* capture, | |
50 scoped_refptr<media::VideoCapture::VideoFrameBuffer> buffer) OVERRIDE; | |
51 virtual void OnDeviceInfoReceived( | |
52 media::VideoCapture* capture, | |
53 const media::VideoCaptureParams& device_info) OVERRIDE; | |
54 | |
55 private: | |
56 webkit::ppapi::PluginInstance* GetPluginInstance() const; | |
57 | |
58 int32_t OnEnumerateDevices( | |
59 ppapi::host::HostMessageContext* context); | |
60 int32_t OnOpen(ppapi::host::HostMessageContext* context, | |
61 const std::string& device_id, | |
62 const PP_VideoCaptureDeviceInfo_Dev& requested_info, | |
63 uint32_t buffer_count); | |
64 int32_t OnStartCapture(ppapi::host::HostMessageContext* context); | |
65 int32_t OnReuseBuffer(ppapi::host::HostMessageContext* context, | |
66 uint32_t buffer); | |
67 int32_t OnStopCapture(ppapi::host::HostMessageContext* context); | |
68 int32_t OnClose(ppapi::host::HostMessageContext* context); | |
69 | |
70 int32_t StopCapture(); | |
71 int32_t Close(); | |
72 void ReleaseBuffers(); | |
73 void SendStatus(); | |
74 | |
75 void SetRequestedInfo(const PP_VideoCaptureDeviceInfo_Dev& device_info, | |
76 uint32_t buffer_count); | |
77 | |
78 void DetachPlatformVideoCapture(); | |
79 | |
80 void EnumerateDevicesCallbackFunc( | |
81 int request_id, | |
82 bool succeeded, | |
83 const std::vector<ppapi::DeviceRefData>& devices); | |
84 | |
85 bool SetStatus(PP_VideoCaptureStatus_Dev status, bool forced); | |
86 | |
87 scoped_refptr<webkit::ppapi::PluginDelegate::PlatformVideoCapture> | |
88 platform_video_capture_; | |
89 | |
90 // Buffers of video frame. | |
91 struct BufferInfo { | |
92 BufferInfo(); | |
93 ~BufferInfo(); | |
94 | |
95 bool in_use; | |
96 void* data; | |
97 scoped_refptr<webkit::ppapi::PPB_Buffer_Impl> buffer; | |
98 }; | |
99 | |
100 std::vector<BufferInfo> buffers_; | |
101 size_t buffer_count_hint_; | |
102 | |
103 media::VideoCaptureCapability capability_; | |
104 | |
105 PP_VideoCaptureStatus_Dev status_; | |
106 | |
107 ppapi::host::ReplyMessageContext open_reply_context_; | |
108 ppapi::host::ReplyMessageContext enum_reply_context_; | |
109 | |
110 DISALLOW_COPY_AND_ASSIGN(PepperVideoCaptureHost); | |
111 }; | |
112 | |
113 } // namespace content | |
114 | |
115 #endif // CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_CAPTURE_HOST_H_ | |
OLD | NEW |