Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: ppapi/shared_impl/ppb_video_capture_shared.h

Issue 11274036: Refactor video capture to new design (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 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 PPAPI_SHARED_IMPL_PPB_VIDEO_CAPTURE_SHARED_H_ 5 #ifndef PPAPI_SHARED_IMPL_PPB_VIDEO_CAPTURE_SHARED_H_
6 #define PPAPI_SHARED_IMPL_PPB_VIDEO_CAPTURE_SHARED_H_ 6 #define PPAPI_SHARED_IMPL_PPB_VIDEO_CAPTURE_SHARED_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/memory/ref_counted.h" 10 #include "ppapi/c/dev/pp_video_capture_dev.h"
11 #include "ppapi/shared_impl/ppapi_shared_export.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 12
16 namespace ppapi { 13 namespace ppapi {
17 14
18 class PPAPI_SHARED_EXPORT PPB_VideoCapture_Shared 15 class PPAPI_SHARED_EXPORT PPB_VideoCapture_Shared {
yzshen1 2012/10/25 20:41:05 I think this class is not very useful now. All it
victorhsieh 2012/10/26 02:34:54 The resource still uses open_state_ indirectly. F
yzshen1 2012/10/29 18:34:23 The reason why we needed the state machine on both
victorhsieh 2012/10/30 09:43:28 Done. Removed everything of 0.1 from IDL, api, th
victorhsieh 2012/11/02 04:28:47 Oops, I guess I missed this comment. The code is
19 : public Resource,
20 NON_EXPORTED_BASE(public thunk::PPB_VideoCapture_API) {
21 public: 16 public:
22 explicit PPB_VideoCapture_Shared(PP_Instance instance); 17 PPB_VideoCapture_Shared();
23 explicit PPB_VideoCapture_Shared(const HostResource& host_resource);
24 virtual ~PPB_VideoCapture_Shared(); 18 virtual ~PPB_VideoCapture_Shared();
25 19
26 // Resource implementation.
27 virtual thunk::PPB_VideoCapture_API* AsPPB_VideoCapture_API() OVERRIDE;
28
29 // PPB_VideoCapture_API implementation.
30 virtual int32_t EnumerateDevices(
31 PP_Resource* devices,
32 scoped_refptr<TrackedCallback> callback) OVERRIDE;
33 virtual int32_t Open(const std::string& device_id,
34 const PP_VideoCaptureDeviceInfo_Dev& requested_info,
35 uint32_t buffer_count,
36 scoped_refptr<TrackedCallback> callback) OVERRIDE;
37 virtual int32_t StartCapture() OVERRIDE; 20 virtual int32_t StartCapture() OVERRIDE;
38 virtual int32_t ReuseBuffer(uint32_t buffer) OVERRIDE;
39 virtual int32_t StopCapture() OVERRIDE; 21 virtual int32_t StopCapture() OVERRIDE;
40 virtual void Close() OVERRIDE;
41 virtual int32_t StartCapture0_1( 22 virtual int32_t StartCapture0_1(
42 const PP_VideoCaptureDeviceInfo_Dev& requested_info, 23 const PP_VideoCaptureDeviceInfo_Dev& requested_info,
43 uint32_t buffer_count) OVERRIDE; 24 uint32_t buffer_count) OVERRIDE;
44 virtual const std::vector<DeviceRefData>& GetDeviceRefData() const OVERRIDE;
45
46 void OnEnumerateDevicesComplete(int32_t result,
47 const std::vector<DeviceRefData>& devices);
48 void OnOpenComplete(int32_t result);
49 25
50 protected: 26 protected:
51 enum OpenState { 27 enum OpenState {
52 BEFORE_OPEN, 28 BEFORE_OPEN,
53 OPENED, 29 OPENED,
54 CLOSED 30 CLOSED
55 }; 31 };
56 32
57 // Subclasses should implement these methods to do impl- and proxy-specific 33 // Subclasses should implement these methods to do impl- and proxy-specific
58 // work. 34 // work.
59 virtual int32_t InternalEnumerateDevices(
60 PP_Resource* devices,
61 scoped_refptr<TrackedCallback> callback) = 0;
62 virtual int32_t InternalOpen(
63 const std::string& device_id,
64 const PP_VideoCaptureDeviceInfo_Dev& requested_info,
65 uint32_t buffer_count,
66 scoped_refptr<TrackedCallback> callback) = 0;
67 virtual int32_t InternalStartCapture() = 0; 35 virtual int32_t InternalStartCapture() = 0;
68 virtual int32_t InternalReuseBuffer(uint32_t buffer) = 0;
69 virtual int32_t InternalStopCapture() = 0; 36 virtual int32_t InternalStopCapture() = 0;
70 virtual void InternalClose() = 0;
71 virtual int32_t InternalStartCapture0_1( 37 virtual int32_t InternalStartCapture0_1(
72 const PP_VideoCaptureDeviceInfo_Dev& requested_info, 38 const PP_VideoCaptureDeviceInfo_Dev& requested_info,
73 uint32_t buffer_count) = 0; 39 uint32_t buffer_count) = 0;
74 virtual const std::vector<DeviceRefData>& InternalGetDeviceRefData(
75 ) const = 0;
76 40
77 // Checks whether |status| is expected and sets |status_| if yes. If |forced| 41 // Checks whether |status| is expected and sets |status_| if yes. If |forced|
78 // is set to true, this method will bypass sanity check and always set 42 // is set to true, this method will bypass sanity check and always set
79 // |status_|. 43 // |status_|.
80 bool SetStatus(PP_VideoCaptureStatus_Dev status, bool forced); 44 bool SetStatus(PP_VideoCaptureStatus_Dev status, bool forced);
81 45
82 OpenState open_state_; 46 OpenState open_state_;
83 PP_VideoCaptureStatus_Dev status_; 47 PP_VideoCaptureStatus_Dev status_;
84 48
85 scoped_refptr<TrackedCallback> enumerate_devices_callback_;
86 scoped_refptr<TrackedCallback> open_callback_;
87
88 // Output parameter of EnumerateDevices(). It should not be accessed after
89 // |enumerate_devices_callback_| is run.
90 PP_Resource* devices_;
91
92 ResourceObjectType resource_object_type_;
93
94 private: 49 private:
95 DISALLOW_COPY_AND_ASSIGN(PPB_VideoCapture_Shared); 50 DISALLOW_COPY_AND_ASSIGN(PPB_VideoCapture_Shared);
96 }; 51 };
97 52
98 } // namespace ppapi 53 } // namespace ppapi
99 54
100 #endif // PPAPI_SHARED_IMPL_PPB_VIDEO_CAPTURE_SHARED_H_ 55 #endif // PPAPI_SHARED_IMPL_PPB_VIDEO_CAPTURE_SHARED_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698