Chromium Code Reviews| 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/resource.h" | 15 #include "ppapi/shared_impl/resource.h" |
| 16 #include "ppapi/shared_impl/tracked_callback.h" | |
| 16 #include "ppapi/thunk/ppb_video_capture_api.h" | 17 #include "ppapi/thunk/ppb_video_capture_api.h" |
| 17 #include "webkit/plugins/ppapi/plugin_delegate.h" | 18 #include "webkit/plugins/ppapi/plugin_delegate.h" |
| 18 #include "webkit/plugins/ppapi/ppb_buffer_impl.h" | 19 #include "webkit/plugins/ppapi/ppb_buffer_impl.h" |
| 19 | 20 |
| 20 struct PP_VideoCaptureDeviceInfo_Dev; | 21 struct PP_VideoCaptureDeviceInfo_Dev; |
| 21 | 22 |
| 22 namespace webkit { | 23 namespace webkit { |
| 23 namespace ppapi { | 24 namespace ppapi { |
| 24 | 25 |
| 25 class PPB_VideoCapture_Impl : public ::ppapi::Resource, | 26 class PPB_VideoCapture_Impl |
| 26 public ::ppapi::thunk::PPB_VideoCapture_API, | 27 : public ::ppapi::Resource, |
| 27 public media::VideoCapture::EventHandler { | 28 public ::ppapi::thunk::PPB_VideoCapture_API, |
| 29 public PluginDelegate::PlatformVideoCaptureEventHandler, | |
| 30 public base::SupportsWeakPtr<PPB_VideoCapture_Impl> { | |
| 28 public: | 31 public: |
| 29 explicit PPB_VideoCapture_Impl(PP_Instance instance); | 32 explicit PPB_VideoCapture_Impl(PP_Instance instance); |
| 30 virtual ~PPB_VideoCapture_Impl(); | 33 virtual ~PPB_VideoCapture_Impl(); |
| 31 | 34 |
| 32 bool Init(); | 35 bool Init(); |
| 33 | 36 |
| 34 // Resource overrides. | 37 // Resource overrides. |
| 35 virtual PPB_VideoCapture_API* AsPPB_VideoCapture_API() OVERRIDE; | 38 virtual PPB_VideoCapture_API* AsPPB_VideoCapture_API() OVERRIDE; |
| 36 virtual void LastPluginRefWasDeleted() OVERRIDE; | |
| 37 | 39 |
| 38 // PPB_VideoCapture implementation. | 40 // PPB_VideoCapture_API implementation. |
| 41 virtual int32_t EnumerateDevices(PP_CompletionCallback callback) OVERRIDE; | |
| 42 virtual PP_Resource GetDevices() OVERRIDE; | |
| 39 virtual int32_t StartCapture( | 43 virtual int32_t StartCapture( |
| 44 const std::string& device_id, | |
| 40 const PP_VideoCaptureDeviceInfo_Dev& requested_info, | 45 const PP_VideoCaptureDeviceInfo_Dev& requested_info, |
| 41 uint32_t buffer_count) OVERRIDE; | 46 uint32_t buffer_count) OVERRIDE; |
| 42 virtual int32_t ReuseBuffer(uint32_t buffer) OVERRIDE; | 47 virtual int32_t ReuseBuffer(uint32_t buffer) OVERRIDE; |
| 43 virtual int32_t StopCapture() OVERRIDE; | 48 virtual int32_t StopCapture() OVERRIDE; |
| 49 virtual const std::vector<::ppapi::DeviceRefData>& GetDeviceRefData( | |
| 50 ) const OVERRIDE; | |
| 44 | 51 |
| 45 // media::VideoCapture::EventHandler implementation. | 52 // PluginDelegate::PlatformVideoCaptureEventHandler implementation. |
| 46 virtual void OnStarted(media::VideoCapture* capture) OVERRIDE; | 53 virtual void OnStarted(media::VideoCapture* capture) OVERRIDE; |
| 47 virtual void OnStopped(media::VideoCapture* capture) OVERRIDE; | 54 virtual void OnStopped(media::VideoCapture* capture) OVERRIDE; |
| 48 virtual void OnPaused(media::VideoCapture* capture) OVERRIDE; | 55 virtual void OnPaused(media::VideoCapture* capture) OVERRIDE; |
| 49 virtual void OnError(media::VideoCapture* capture, int error_code) OVERRIDE; | 56 virtual void OnError(media::VideoCapture* capture, int error_code) OVERRIDE; |
| 50 virtual void OnRemoved(media::VideoCapture* capture) OVERRIDE; | 57 virtual void OnRemoved(media::VideoCapture* capture) OVERRIDE; |
| 51 virtual void OnBufferReady( | 58 virtual void OnBufferReady( |
| 52 media::VideoCapture* capture, | 59 media::VideoCapture* capture, |
| 53 scoped_refptr<media::VideoCapture::VideoFrameBuffer> buffer) OVERRIDE; | 60 scoped_refptr<media::VideoCapture::VideoFrameBuffer> buffer) OVERRIDE; |
| 54 virtual void OnDeviceInfoReceived( | 61 virtual void OnDeviceInfoReceived( |
| 55 media::VideoCapture* capture, | 62 media::VideoCapture* capture, |
| 56 const media::VideoCaptureParams& device_info) OVERRIDE; | 63 const media::VideoCaptureParams& device_info) OVERRIDE; |
| 64 virtual void OnInitialized(media::VideoCapture* capture, | |
| 65 bool succeeded) OVERRIDE; | |
| 57 | 66 |
| 58 private: | 67 private: |
| 59 void ReleaseBuffers(); | 68 void ReleaseBuffers(); |
| 60 void SendStatus(); | 69 void SendStatus(); |
| 61 | 70 |
| 62 scoped_ptr<PluginDelegate::PlatformVideoCapture> platform_video_capture_; | 71 void ClearCachedDeviceResourceArray(); |
| 72 void DetachPlatformVideoCapture(); | |
| 73 | |
| 74 void OnEnumerateDevicesComplete( | |
| 75 int request_id, | |
| 76 bool succeeded, | |
| 77 const std::vector<::ppapi::DeviceRefData>& devices); | |
|
brettw
2012/02/06 21:51:52
You'll need a space before the :: to make GCC happ
yzshen1
2012/02/10 07:10:44
Done.
| |
| 78 | |
| 79 scoped_refptr<PluginDelegate::PlatformVideoCapture> platform_video_capture_; | |
| 63 | 80 |
| 64 size_t buffer_count_hint_; | 81 size_t buffer_count_hint_; |
| 65 struct BufferInfo { | 82 struct BufferInfo { |
| 66 BufferInfo(); | 83 BufferInfo(); |
| 67 ~BufferInfo(); | 84 ~BufferInfo(); |
| 68 | 85 |
| 69 bool in_use; | 86 bool in_use; |
| 70 void* data; | 87 void* data; |
| 71 scoped_refptr<PPB_Buffer_Impl> buffer; | 88 scoped_refptr<PPB_Buffer_Impl> buffer; |
| 72 }; | 89 }; |
| 73 std::vector<BufferInfo> buffers_; | 90 std::vector<BufferInfo> buffers_; |
| 74 | 91 |
| 75 const PPP_VideoCapture_Dev* ppp_videocapture_; | 92 const PPP_VideoCapture_Dev* ppp_videocapture_; |
| 76 PP_VideoCaptureStatus_Dev status_; | 93 PP_VideoCaptureStatus_Dev status_; |
| 77 | 94 |
| 78 // Signifies that the plugin has given up all its refs, but the object is | 95 scoped_refptr<::ppapi::TrackedCallback> enumerate_devices_callback_; |
| 79 // still alive, possibly because the backend hasn't released the object as | 96 |
| 80 // |EventHandler| yet. It can be removed if/when |EventHandler| is made to be | 97 // A resource array holding the enumeration result. When nonzero, we're |
| 81 // refcounted (and made into a "member" of this object instead). | 98 // holding a reference to it. |
| 82 bool is_dead_; | 99 PP_Resource devices_; |
| 100 std::vector<::ppapi::DeviceRefData> devices_data_; | |
|
brettw
2012/02/06 21:51:52
Ditto.
yzshen1
2012/02/10 07:10:44
Done.
| |
| 101 | |
| 102 media::VideoCapture::VideoCaptureCapability capability_; | |
| 83 | 103 |
| 84 DISALLOW_COPY_AND_ASSIGN(PPB_VideoCapture_Impl); | 104 DISALLOW_COPY_AND_ASSIGN(PPB_VideoCapture_Impl); |
| 85 }; | 105 }; |
| 86 | 106 |
| 87 } // namespace ppapi | 107 } // namespace ppapi |
| 88 } // namespace webkit | 108 } // namespace webkit |
| 89 | 109 |
| 90 #endif // WEBKIT_PLUGINS_PPAPI_PPB_VIDEO_CAPTURE_IMPL_H_ | 110 #endif // WEBKIT_PLUGINS_PPAPI_PPB_VIDEO_CAPTURE_IMPL_H_ |
| OLD | NEW |