| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 WEBKIT_PLUGINS_PPAPI_PPB_VIDEO_CAPTURE_IMPL_H_ | 5 #ifndef WEBKIT_PLUGINS_PPAPI_PPB_VIDEO_CAPTURE_IMPL_H_ |
| 6 #define WEBKIT_PLUGINS_PPAPI_PPB_VIDEO_CAPTURE_IMPL_H_ | 6 #define WEBKIT_PLUGINS_PPAPI_PPB_VIDEO_CAPTURE_IMPL_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "media/video/capture/video_capture.h" | 13 #include "media/video/capture/video_capture.h" |
| 14 #include "ppapi/c/dev/ppp_video_capture_dev.h" | 14 #include "ppapi/c/dev/ppp_video_capture_dev.h" |
| 15 #include "ppapi/shared_impl/ppb_video_capture_shared.h" |
| 15 #include "ppapi/shared_impl/resource.h" | 16 #include "ppapi/shared_impl/resource.h" |
| 16 #include "ppapi/thunk/ppb_video_capture_api.h" | |
| 17 #include "webkit/plugins/ppapi/plugin_delegate.h" | 17 #include "webkit/plugins/ppapi/plugin_delegate.h" |
| 18 #include "webkit/plugins/ppapi/ppb_buffer_impl.h" | 18 #include "webkit/plugins/ppapi/ppb_buffer_impl.h" |
| 19 | 19 |
| 20 struct PP_VideoCaptureDeviceInfo_Dev; | 20 struct PP_VideoCaptureDeviceInfo_Dev; |
| 21 | 21 |
| 22 namespace webkit { | 22 namespace webkit { |
| 23 namespace ppapi { | 23 namespace ppapi { |
| 24 | 24 |
| 25 class PPB_VideoCapture_Impl : public ::ppapi::Resource, | 25 class PPB_VideoCapture_Impl |
| 26 public ::ppapi::thunk::PPB_VideoCapture_API, | 26 : public ::ppapi::PPB_VideoCapture_Shared, |
| 27 public media::VideoCapture::EventHandler { | 27 public PluginDelegate::PlatformVideoCaptureEventHandler, |
| 28 public base::SupportsWeakPtr<PPB_VideoCapture_Impl> { |
| 28 public: | 29 public: |
| 29 explicit PPB_VideoCapture_Impl(PP_Instance instance); | 30 explicit PPB_VideoCapture_Impl(PP_Instance instance); |
| 30 virtual ~PPB_VideoCapture_Impl(); | 31 virtual ~PPB_VideoCapture_Impl(); |
| 31 | 32 |
| 32 bool Init(); | 33 bool Init(); |
| 33 | 34 |
| 34 // Resource overrides. | 35 // PluginDelegate::PlatformVideoCaptureEventHandler implementation. |
| 35 virtual PPB_VideoCapture_API* AsPPB_VideoCapture_API() OVERRIDE; | |
| 36 virtual void LastPluginRefWasDeleted() OVERRIDE; | |
| 37 | |
| 38 // PPB_VideoCapture implementation. | |
| 39 virtual int32_t StartCapture( | |
| 40 const PP_VideoCaptureDeviceInfo_Dev& requested_info, | |
| 41 uint32_t buffer_count) OVERRIDE; | |
| 42 virtual int32_t ReuseBuffer(uint32_t buffer) OVERRIDE; | |
| 43 virtual int32_t StopCapture() OVERRIDE; | |
| 44 | |
| 45 // media::VideoCapture::EventHandler implementation. | |
| 46 virtual void OnStarted(media::VideoCapture* capture) OVERRIDE; | 36 virtual void OnStarted(media::VideoCapture* capture) OVERRIDE; |
| 47 virtual void OnStopped(media::VideoCapture* capture) OVERRIDE; | 37 virtual void OnStopped(media::VideoCapture* capture) OVERRIDE; |
| 48 virtual void OnPaused(media::VideoCapture* capture) OVERRIDE; | 38 virtual void OnPaused(media::VideoCapture* capture) OVERRIDE; |
| 49 virtual void OnError(media::VideoCapture* capture, int error_code) OVERRIDE; | 39 virtual void OnError(media::VideoCapture* capture, int error_code) OVERRIDE; |
| 50 virtual void OnRemoved(media::VideoCapture* capture) OVERRIDE; | 40 virtual void OnRemoved(media::VideoCapture* capture) OVERRIDE; |
| 51 virtual void OnBufferReady( | 41 virtual void OnBufferReady( |
| 52 media::VideoCapture* capture, | 42 media::VideoCapture* capture, |
| 53 scoped_refptr<media::VideoCapture::VideoFrameBuffer> buffer) OVERRIDE; | 43 scoped_refptr<media::VideoCapture::VideoFrameBuffer> buffer) OVERRIDE; |
| 54 virtual void OnDeviceInfoReceived( | 44 virtual void OnDeviceInfoReceived( |
| 55 media::VideoCapture* capture, | 45 media::VideoCapture* capture, |
| 56 const media::VideoCaptureParams& device_info) OVERRIDE; | 46 const media::VideoCaptureParams& device_info) OVERRIDE; |
| 47 virtual void OnInitialized(media::VideoCapture* capture, |
| 48 bool succeeded) OVERRIDE; |
| 57 | 49 |
| 58 private: | 50 private: |
| 51 typedef std::vector< ::ppapi::DeviceRefData> DeviceRefDataVector; |
| 52 |
| 53 // PPB_VideoCapture_Shared implementation. |
| 54 virtual int32_t InternalEnumerateDevices( |
| 55 PP_Resource* devices, |
| 56 PP_CompletionCallback callback) OVERRIDE; |
| 57 virtual int32_t InternalOpen( |
| 58 const std::string& device_id, |
| 59 const PP_VideoCaptureDeviceInfo_Dev& requested_info, |
| 60 uint32_t buffer_count, |
| 61 PP_CompletionCallback callback) OVERRIDE; |
| 62 virtual int32_t InternalStartCapture() OVERRIDE; |
| 63 virtual int32_t InternalReuseBuffer(uint32_t buffer) OVERRIDE; |
| 64 virtual int32_t InternalStopCapture() OVERRIDE; |
| 65 virtual void InternalClose() OVERRIDE; |
| 66 virtual int32_t InternalStartCapture0_1( |
| 67 const PP_VideoCaptureDeviceInfo_Dev& requested_info, |
| 68 uint32_t buffer_count) OVERRIDE; |
| 69 virtual const DeviceRefDataVector& InternalGetDeviceRefData() const OVERRIDE; |
| 70 |
| 59 void ReleaseBuffers(); | 71 void ReleaseBuffers(); |
| 60 void SendStatus(); | 72 void SendStatus(); |
| 61 | 73 |
| 62 scoped_ptr<PluginDelegate::PlatformVideoCapture> platform_video_capture_; | 74 void SetRequestedInfo(const PP_VideoCaptureDeviceInfo_Dev& device_info, |
| 75 uint32_t buffer_count); |
| 76 |
| 77 void DetachPlatformVideoCapture(); |
| 78 |
| 79 void EnumerateDevicesCallbackFunc(int request_id, |
| 80 bool succeeded, |
| 81 const DeviceRefDataVector& devices); |
| 82 |
| 83 scoped_refptr<PluginDelegate::PlatformVideoCapture> platform_video_capture_; |
| 63 | 84 |
| 64 size_t buffer_count_hint_; | 85 size_t buffer_count_hint_; |
| 65 struct BufferInfo { | 86 struct BufferInfo { |
| 66 BufferInfo(); | 87 BufferInfo(); |
| 67 ~BufferInfo(); | 88 ~BufferInfo(); |
| 68 | 89 |
| 69 bool in_use; | 90 bool in_use; |
| 70 void* data; | 91 void* data; |
| 71 scoped_refptr<PPB_Buffer_Impl> buffer; | 92 scoped_refptr<PPB_Buffer_Impl> buffer; |
| 72 }; | 93 }; |
| 73 std::vector<BufferInfo> buffers_; | 94 std::vector<BufferInfo> buffers_; |
| 74 | 95 |
| 75 const PPP_VideoCapture_Dev* ppp_videocapture_; | 96 const PPP_VideoCapture_Dev* ppp_videocapture_; |
| 76 PP_VideoCaptureStatus_Dev status_; | |
| 77 | 97 |
| 78 // Signifies that the plugin has given up all its refs, but the object is | 98 DeviceRefDataVector devices_data_; |
| 79 // still alive, possibly because the backend hasn't released the object as | 99 |
| 80 // |EventHandler| yet. It can be removed if/when |EventHandler| is made to be | 100 media::VideoCapture::VideoCaptureCapability capability_; |
| 81 // refcounted (and made into a "member" of this object instead). | |
| 82 bool is_dead_; | |
| 83 | 101 |
| 84 DISALLOW_COPY_AND_ASSIGN(PPB_VideoCapture_Impl); | 102 DISALLOW_COPY_AND_ASSIGN(PPB_VideoCapture_Impl); |
| 85 }; | 103 }; |
| 86 | 104 |
| 87 } // namespace ppapi | 105 } // namespace ppapi |
| 88 } // namespace webkit | 106 } // namespace webkit |
| 89 | 107 |
| 90 #endif // WEBKIT_PLUGINS_PPAPI_PPB_VIDEO_CAPTURE_IMPL_H_ | 108 #endif // WEBKIT_PLUGINS_PPAPI_PPB_VIDEO_CAPTURE_IMPL_H_ |
| OLD | NEW |