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 WEBKIT_PLUGINS_PPAPI_PPB_VIDEO_CAPTURE_IMPL_H_ | |
6 #define WEBKIT_PLUGINS_PPAPI_PPB_VIDEO_CAPTURE_IMPL_H_ | |
7 | |
8 #include <vector> | |
9 | |
10 #include "base/basictypes.h" | |
11 #include "base/compiler_specific.h" | |
12 #include "base/memory/ref_counted.h" | |
13 #include "media/video/capture/video_capture.h" | |
14 #include "media/video/capture/video_capture_types.h" | |
15 #include "ppapi/c/dev/ppp_video_capture_dev.h" | |
16 #include "ppapi/shared_impl/ppb_video_capture_shared.h" | |
17 #include "ppapi/shared_impl/resource.h" | |
18 #include "webkit/plugins/ppapi/plugin_delegate.h" | |
19 #include "webkit/plugins/ppapi/ppb_buffer_impl.h" | |
20 | |
21 struct PP_VideoCaptureDeviceInfo_Dev; | |
22 | |
23 namespace webkit { | |
24 namespace ppapi { | |
25 | |
26 class PPB_VideoCapture_Impl | |
27 : public ::ppapi::PPB_VideoCapture_Shared, | |
28 public PluginDelegate::PlatformVideoCaptureEventHandler, | |
29 public base::SupportsWeakPtr<PPB_VideoCapture_Impl> { | |
30 public: | |
31 explicit PPB_VideoCapture_Impl(PP_Instance instance); | |
32 virtual ~PPB_VideoCapture_Impl(); | |
33 | |
34 bool Init(); | |
35 | |
36 // PluginDelegate::PlatformVideoCaptureEventHandler implementation. | |
37 virtual void OnStarted(media::VideoCapture* capture) OVERRIDE; | |
38 virtual void OnStopped(media::VideoCapture* capture) OVERRIDE; | |
39 virtual void OnPaused(media::VideoCapture* capture) OVERRIDE; | |
40 virtual void OnError(media::VideoCapture* capture, int error_code) OVERRIDE; | |
41 virtual void OnRemoved(media::VideoCapture* capture) OVERRIDE; | |
42 virtual void OnBufferReady( | |
43 media::VideoCapture* capture, | |
44 scoped_refptr<media::VideoCapture::VideoFrameBuffer> buffer) OVERRIDE; | |
45 virtual void OnDeviceInfoReceived( | |
46 media::VideoCapture* capture, | |
47 const media::VideoCaptureParams& device_info) OVERRIDE; | |
48 virtual void OnInitialized(media::VideoCapture* capture, | |
49 bool succeeded) OVERRIDE; | |
50 | |
51 private: | |
52 typedef std::vector< ::ppapi::DeviceRefData> DeviceRefDataVector; | |
53 | |
54 // PPB_VideoCapture_Shared implementation. | |
55 virtual int32_t InternalEnumerateDevices( | |
56 PP_Resource* devices, | |
57 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE; | |
58 virtual int32_t InternalOpen( | |
59 const std::string& device_id, | |
60 const PP_VideoCaptureDeviceInfo_Dev& requested_info, | |
61 uint32_t buffer_count, | |
62 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE; | |
63 virtual int32_t InternalStartCapture() OVERRIDE; | |
64 virtual int32_t InternalReuseBuffer(uint32_t buffer) OVERRIDE; | |
65 virtual int32_t InternalStopCapture() OVERRIDE; | |
66 virtual void InternalClose() OVERRIDE; | |
67 virtual int32_t InternalStartCapture0_1( | |
68 const PP_VideoCaptureDeviceInfo_Dev& requested_info, | |
69 uint32_t buffer_count) OVERRIDE; | |
70 virtual const DeviceRefDataVector& InternalGetDeviceRefData() const OVERRIDE; | |
71 | |
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(int request_id, | |
81 bool succeeded, | |
82 const DeviceRefDataVector& devices); | |
83 | |
84 scoped_refptr<PluginDelegate::PlatformVideoCapture> platform_video_capture_; | |
85 | |
86 size_t buffer_count_hint_; | |
87 struct BufferInfo { | |
88 BufferInfo(); | |
89 ~BufferInfo(); | |
90 | |
91 bool in_use; | |
92 void* data; | |
93 scoped_refptr<PPB_Buffer_Impl> buffer; | |
94 }; | |
95 std::vector<BufferInfo> buffers_; | |
96 | |
97 const PPP_VideoCapture_Dev* ppp_videocapture_; | |
98 | |
99 DeviceRefDataVector devices_data_; | |
100 | |
101 media::VideoCaptureCapability capability_; | |
102 | |
103 DISALLOW_COPY_AND_ASSIGN(PPB_VideoCapture_Impl); | |
104 }; | |
105 | |
106 } // namespace ppapi | |
107 } // namespace webkit | |
108 | |
109 #endif // WEBKIT_PLUGINS_PPAPI_PPB_VIDEO_CAPTURE_IMPL_H_ | |
OLD | NEW |