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

Side by Side Diff: ppapi/cpp/dev/video_capture_dev.h

Issue 9965080: Change the cpp wrappers of audio input/video capture to use CompletionCallbackWithOutput. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Avoid extra copies in Dispatcher*::operator(). Created 8 years, 8 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 | Annotate | Revision Log
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_CPP_DEV_VIDEO_CAPTURE_DEV_H_ 5 #ifndef PPAPI_CPP_DEV_VIDEO_CAPTURE_DEV_H_
6 #define PPAPI_CPP_DEV_VIDEO_CAPTURE_DEV_H_ 6 #define PPAPI_CPP_DEV_VIDEO_CAPTURE_DEV_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "ppapi/c/dev/pp_video_capture_dev.h" 10 #include "ppapi/c/dev/pp_video_capture_dev.h"
11 #include "ppapi/cpp/completion_callback.h"
12 #include "ppapi/cpp/dev/device_ref_dev.h"
11 #include "ppapi/cpp/resource.h" 13 #include "ppapi/cpp/resource.h"
12 14
13 namespace pp { 15 namespace pp {
14 16
15 class CompletionCallback;
16 class DeviceRef_Dev;
17 class InstanceHandle; 17 class InstanceHandle;
18 18
19 class VideoCapture_Dev : public Resource { 19 class VideoCapture_Dev : public Resource {
20 public: 20 public:
21 explicit VideoCapture_Dev(const InstanceHandle& instance); 21 explicit VideoCapture_Dev(const InstanceHandle& instance);
22 VideoCapture_Dev(PP_Resource resource); 22 VideoCapture_Dev(PP_Resource resource);
23 VideoCapture_Dev(const VideoCapture_Dev& other);
24 23
25 virtual ~VideoCapture_Dev(); 24 virtual ~VideoCapture_Dev();
26 25
27 VideoCapture_Dev& operator=(const VideoCapture_Dev& other);
28
29 // Returns true if the required interface is available. 26 // Returns true if the required interface is available.
30 static bool IsAvailable(); 27 static bool IsAvailable();
31 28
32 // |devices| must stay alive until either this VideoCapture_Dev object goes 29 int32_t EnumerateDevices(
33 // away or |callback| is run. 30 const CompletionCallbackWithOutput<std::vector<DeviceRef_Dev> >&
34 int32_t EnumerateDevices(std::vector<DeviceRef_Dev>* devices, 31 callback);
35 const CompletionCallback& callback);
36 int32_t Open(const DeviceRef_Dev& device_ref, 32 int32_t Open(const DeviceRef_Dev& device_ref,
37 const PP_VideoCaptureDeviceInfo_Dev& requested_info, 33 const PP_VideoCaptureDeviceInfo_Dev& requested_info,
38 uint32_t buffer_count, 34 uint32_t buffer_count,
39 const CompletionCallback& callback); 35 const CompletionCallback& callback);
40 int32_t StartCapture(); 36 int32_t StartCapture();
41 int32_t ReuseBuffer(uint32_t buffer); 37 int32_t ReuseBuffer(uint32_t buffer);
42 int32_t StopCapture(); 38 int32_t StopCapture();
43 void Close(); 39 void Close();
44 40
45 private: 41 private:
46 struct EnumerateDevicesState; 42 // Heap-allocated data passed to the CallbackConverter for backward
43 // compatibility.
44 struct EnumerateCallbackData0_2 {
45 PP_Resource devices;
46 PP_ArrayOutput output;
47 PP_CompletionCallback original_callback;
48 };
47 49
48 void AbortEnumerateDevices(); 50 // This is an adapter to convert the v0.2 EnumerateDevices oputput, which is a
49 51 // PPB_ResourceArray_Dev resource, to PP_ArrayOutput that the caller is
50 // |user_data| is an EnumerateDevicesState object. It is this method's 52 // expecting.
51 // responsibility to delete it. 53 //
52 static void OnEnumerateDevicesComplete(void* user_data, int32_t result); 54 // This takes a heap-allocated EnumerateCallbackData0_2 struct passed as the
53 55 // user data and deletes it when the call completes.
54 // Not owned by this object. 56 static void CallbackConverter(void* user_data, int32_t result);
55 EnumerateDevicesState* enum_state_;
56 57
57 // Used to store the arguments of Open() when using the v0.1 interface. 58 // Used to store the arguments of Open() when using the v0.1 interface.
58 PP_VideoCaptureDeviceInfo_Dev requested_info_; 59 PP_VideoCaptureDeviceInfo_Dev requested_info_;
59 uint32_t buffer_count_; 60 uint32_t buffer_count_;
60 }; 61 };
61 62
62 } // namespace pp 63 } // namespace pp
63 64
64 #endif // PPAPI_CPP_DEV_VIDEO_CAPTURE_DEV_H_ 65 #endif // PPAPI_CPP_DEV_VIDEO_CAPTURE_DEV_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698