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 PPAPI_SHARED_IMPL_PPB_VIDEO_CAPTURE_SHARED_H_ |
| 6 #define PPAPI_SHARED_IMPL_PPB_VIDEO_CAPTURE_SHARED_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/ref_counted.h" |
| 11 #include "ppapi/shared_impl/ppapi_shared_export.h" |
| 12 #include "ppapi/shared_impl/resource.h" |
| 13 #include "ppapi/shared_impl/tracked_callback.h" |
| 14 #include "ppapi/thunk/ppb_video_capture_api.h" |
| 15 |
| 16 namespace ppapi { |
| 17 |
| 18 class PPAPI_SHARED_EXPORT PPB_VideoCapture_Shared |
| 19 : public Resource, |
| 20 NON_EXPORTED_BASE(public thunk::PPB_VideoCapture_API) { |
| 21 public: |
| 22 explicit PPB_VideoCapture_Shared(PP_Instance instance); |
| 23 explicit PPB_VideoCapture_Shared(const HostResource& host_resource); |
| 24 virtual ~PPB_VideoCapture_Shared(); |
| 25 |
| 26 // Resource overrides. |
| 27 virtual thunk::PPB_VideoCapture_API* AsPPB_VideoCapture_API() OVERRIDE; |
| 28 |
| 29 // PPB_VideoCapture_API implementation. |
| 30 virtual int32_t EnumerateDevices(PP_Resource* devices, |
| 31 PP_CompletionCallback callback) OVERRIDE; |
| 32 virtual int32_t Open(const std::string& device_id, |
| 33 const PP_VideoCaptureDeviceInfo_Dev& requested_info, |
| 34 uint32_t buffer_count, |
| 35 PP_CompletionCallback callback) OVERRIDE; |
| 36 virtual int32_t StartCapture() OVERRIDE; |
| 37 virtual int32_t ReuseBuffer(uint32_t buffer) OVERRIDE; |
| 38 virtual int32_t StopCapture() OVERRIDE; |
| 39 virtual void Close() OVERRIDE; |
| 40 virtual int32_t StartCapture0_1( |
| 41 const PP_VideoCaptureDeviceInfo_Dev& requested_info, |
| 42 uint32_t buffer_count) OVERRIDE; |
| 43 virtual const std::vector<DeviceRefData>& GetDeviceRefData() const OVERRIDE; |
| 44 |
| 45 void OnEnumerateDevicesComplete(int32_t result, |
| 46 const std::vector<DeviceRefData>& devices); |
| 47 void OnOpenComplete(int32_t result); |
| 48 |
| 49 protected: |
| 50 enum OpenState { |
| 51 BEFORE_OPEN, |
| 52 OPENED, |
| 53 CLOSED |
| 54 }; |
| 55 |
| 56 // Subclasses should implement these methods to do impl- and proxy-specific |
| 57 // work. |
| 58 virtual int32_t InternalEnumerateDevices(PP_Resource* devices, |
| 59 PP_CompletionCallback callback) = 0; |
| 60 virtual int32_t InternalOpen( |
| 61 const std::string& device_id, |
| 62 const PP_VideoCaptureDeviceInfo_Dev& requested_info, |
| 63 uint32_t buffer_count, |
| 64 PP_CompletionCallback callback) = 0; |
| 65 virtual int32_t InternalStartCapture() = 0; |
| 66 virtual int32_t InternalReuseBuffer(uint32_t buffer) = 0; |
| 67 virtual int32_t InternalStopCapture() = 0; |
| 68 virtual void InternalClose() = 0; |
| 69 virtual int32_t InternalStartCapture0_1( |
| 70 const PP_VideoCaptureDeviceInfo_Dev& requested_info, |
| 71 uint32_t buffer_count) = 0; |
| 72 virtual const std::vector<DeviceRefData>& InternalGetDeviceRefData( |
| 73 ) const = 0; |
| 74 |
| 75 // Checks whether |status| is expected and sets |status_| if yes. If |forced| |
| 76 // is set to true, this method will bypass sanity check and always set |
| 77 // |status_|. |
| 78 bool SetStatus(PP_VideoCaptureStatus_Dev status, bool forced); |
| 79 |
| 80 OpenState open_state_; |
| 81 PP_VideoCaptureStatus_Dev status_; |
| 82 |
| 83 scoped_refptr<TrackedCallback> enumerate_devices_callback_; |
| 84 scoped_refptr<TrackedCallback> open_callback_; |
| 85 |
| 86 // Output parameter of EnumerateDevices(). It should not be accessed after |
| 87 // |enumerate_devices_callback_| is run. |
| 88 PP_Resource* devices_; |
| 89 |
| 90 ResourceObjectType resource_object_type_; |
| 91 |
| 92 private: |
| 93 DISALLOW_COPY_AND_ASSIGN(PPB_VideoCapture_Shared); |
| 94 }; |
| 95 |
| 96 } // namespace ppapi |
| 97 |
| 98 #endif // PPAPI_SHARED_IMPL_PPB_VIDEO_CAPTURE_SHARED_H_ |
OLD | NEW |