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

Side by Side Diff: ppapi/c/dev/ppb_video_capture_dev.h

Issue 9234064: Implement device enumeration for PPB_VideoCapture_Dev. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 10 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
« no previous file with comments | « ppapi/api/dev/ppb_video_capture_dev.idl ('k') | ppapi/cpp/dev/video_capture_dev.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 5
6 /* From dev/ppb_video_capture_dev.idl modified Tue Oct 11 10:01:39 2011. */ 6 /* From dev/ppb_video_capture_dev.idl modified Wed Feb 15 12:15:46 2012. */
7 7
8 #ifndef PPAPI_C_DEV_PPB_VIDEO_CAPTURE_DEV_H_ 8 #ifndef PPAPI_C_DEV_PPB_VIDEO_CAPTURE_DEV_H_
9 #define PPAPI_C_DEV_PPB_VIDEO_CAPTURE_DEV_H_ 9 #define PPAPI_C_DEV_PPB_VIDEO_CAPTURE_DEV_H_
10 10
11 #include "ppapi/c/dev/pp_video_capture_dev.h" 11 #include "ppapi/c/dev/pp_video_capture_dev.h"
12 #include "ppapi/c/pp_bool.h" 12 #include "ppapi/c/pp_bool.h"
13 #include "ppapi/c/pp_completion_callback.h"
13 #include "ppapi/c/pp_instance.h" 14 #include "ppapi/c/pp_instance.h"
14 #include "ppapi/c/pp_macros.h" 15 #include "ppapi/c/pp_macros.h"
15 #include "ppapi/c/pp_resource.h" 16 #include "ppapi/c/pp_resource.h"
16 #include "ppapi/c/pp_stdint.h" 17 #include "ppapi/c/pp_stdint.h"
17 18
18 #define PPB_VIDEOCAPTURE_DEV_INTERFACE_0_1 "PPB_VideoCapture(Dev);0.1" 19 #define PPB_VIDEOCAPTURE_DEV_INTERFACE_0_1 "PPB_VideoCapture(Dev);0.1"
19 #define PPB_VIDEOCAPTURE_DEV_INTERFACE PPB_VIDEOCAPTURE_DEV_INTERFACE_0_1 20 #define PPB_VIDEOCAPTURE_DEV_INTERFACE_0_2 "PPB_VideoCapture(Dev);0.2"
21 #define PPB_VIDEOCAPTURE_DEV_INTERFACE PPB_VIDEOCAPTURE_DEV_INTERFACE_0_2
20 22
21 /** 23 /**
22 * @file 24 * @file
23 * This file defines the <code>PPB_VideoCapture_Dev</code> interface. 25 * This file defines the <code>PPB_VideoCapture_Dev</code> interface.
24 */ 26 */
25 27
26 28
27 /** 29 /**
28 * @addtogroup Interfaces 30 * @addtogroup Interfaces
29 * @{ 31 * @{
30 */ 32 */
31 /** 33 /**
32 * Video capture interface. It goes hand-in-hand with PPP_VideoCapture_Dev. 34 * Video capture interface. It goes hand-in-hand with PPP_VideoCapture_Dev.
33 * 35 *
34 * Theory of operation: 36 * Theory of operation:
35 * 1- Create a VideoCapture resource using Create. 37 * 1- Create a VideoCapture resource using Create.
36 * 2- Start the capture using StartCapture. You pass in the requested info 38 * 2- Find available video capture devices using EnumerateDevices.
39 * 3- Open a video capture device. In addition to a device reference (0 can be
40 * used to indicate the default device), you pass in the requested info
37 * (resolution, frame rate), as well as suggest a number of buffers you will 41 * (resolution, frame rate), as well as suggest a number of buffers you will
38 * need. 42 * need.
39 * 3- Receive the OnDeviceInfo callback, in PPP_VideoCapture_Dev, which will 43 * 4- Start the capture using StartCapture.
44 * 5- Receive the OnDeviceInfo callback, in PPP_VideoCapture_Dev, which will
40 * give you the actual capture info (the requested one is not guaranteed), as 45 * give you the actual capture info (the requested one is not guaranteed), as
41 * well as an array of buffers allocated by the browser. 46 * well as an array of buffers allocated by the browser.
42 * 4- On every frame captured by the browser, OnBufferReady (in 47 * 6- On every frame captured by the browser, OnBufferReady (in
43 * PPP_VideoCapture_Dev) is called with the index of the buffer from the array 48 * PPP_VideoCapture_Dev) is called with the index of the buffer from the array
44 * containing the new frame. The buffer is now "owned" by the plugin, and the 49 * containing the new frame. The buffer is now "owned" by the plugin, and the
45 * browser won't reuse it until ReuseBuffer is called. 50 * browser won't reuse it until ReuseBuffer is called.
46 * 5- When the plugin is done with the buffer, call ReuseBuffer 51 * 7- When the plugin is done with the buffer, call ReuseBuffer.
47 * 6- Stop the capture using StopCapture. 52 * 8- Stop the capture using StopCapture.
53 * 9- Close the device.
48 * 54 *
49 * The browser may change the resolution based on the constraints of the system, 55 * The browser may change the resolution based on the constraints of the system,
50 * in which case OnDeviceInfo will be called again, with new buffers. 56 * in which case OnDeviceInfo will be called again, with new buffers.
51 * 57 *
52 * The buffers contain the pixel data for a frame. The format is planar YUV 58 * The buffers contain the pixel data for a frame. The format is planar YUV
53 * 4:2:0, one byte per pixel, tightly packed (width x height Y values, then 59 * 4:2:0, one byte per pixel, tightly packed (width x height Y values, then
54 * width/2 x height/2 U values, then width/2 x height/2 V values). 60 * width/2 x height/2 U values, then width/2 x height/2 V values).
55 */ 61 */
56 struct PPB_VideoCapture_Dev_0_1 { 62 struct PPB_VideoCapture_Dev_0_2 {
57 /** 63 /**
58 * Creates a new VideoCapture. 64 * Creates a new VideoCapture.
59 */ 65 */
60 PP_Resource (*Create)(PP_Instance instance); 66 PP_Resource (*Create)(PP_Instance instance);
61 /** 67 /**
62 * Returns PP_TRUE if the given resource is a VideoCapture. 68 * Returns PP_TRUE if the given resource is a VideoCapture.
63 */ 69 */
64 PP_Bool (*IsVideoCapture)(PP_Resource video_capture); 70 PP_Bool (*IsVideoCapture)(PP_Resource video_capture);
65 /** 71 /**
66 * Starts the capture. |requested_info| is a pointer to a structure containing 72 * Enumerates video capture devices. Once the operation is completed
67 * the requested resolution and frame rate. |buffer_count| is the number of 73 * successfully, |devices| will be set to a PPB_ResourceArray_Dev resource,
68 * buffers requested by the plugin. Note: it is only used as advisory, the 74 * which holds a list of PPB_DeviceRef_Dev resources.
69 * browser may allocate more of fewer based on available resources. 75 *
70 * How many buffers depends on usage. At least 2 to make sure latency doesn't 76 * Please note that:
71 * cause lost frames. If the plugin expects to hold on to more than one buffer 77 * - this method ignores the previous value pointed to by |devices| (won't
72 * at a time (e.g. to do multi-frame processing, like video encoding), it 78 * release reference even if it is not 0);
73 * should request that many more. 79 * - |devices| must be valid until |callback| is called, if the method
80 * returns PP_OK_COMPLETIONPENDING;
81 * - the ref count of the returned |devices| has already been increased by 1
82 * for the caller.
83 */
84 int32_t (*EnumerateDevices)(PP_Resource video_capture,
85 PP_Resource* devices,
86 struct PP_CompletionCallback callback);
87 /**
88 * Opens a video capture device. |device_ref| identifies a video capture
89 * device. It could be one of the resource in the array returned by
90 * |EnumerateDevices()|, or 0 which means the default device.
91 * |requested_info| is a pointer to a structure containing the requested
92 * resolution and frame rate. |buffer_count| is the number of buffers
93 * requested by the plugin. Note: it is only used as advisory, the browser may
94 * allocate more or fewer based on available resources. How many buffers
95 * depends on usage. At least 2 to make sure latency doesn't cause lost
96 * frames. If the plugin expects to hold on to more than one buffer at a time
97 * (e.g. to do multi-frame processing, like video encoding), it should request
98 * that many more.
99 */
100 int32_t (*Open)(PP_Resource video_capture,
101 PP_Resource device_ref,
102 const struct PP_VideoCaptureDeviceInfo_Dev* requested_info,
103 uint32_t buffer_count,
104 struct PP_CompletionCallback callback);
105 /**
106 * Starts the capture.
74 * 107 *
75 * Returns PP_ERROR_FAILED if called when the capture was already started, or 108 * Returns PP_ERROR_FAILED if called when the capture was already started, or
76 * PP_OK on success. 109 * PP_OK on success.
77 */ 110 */
78 int32_t (*StartCapture)( 111 int32_t (*StartCapture)(PP_Resource video_capture);
79 PP_Resource video_capture,
80 const struct PP_VideoCaptureDeviceInfo_Dev* requested_info,
81 uint32_t buffer_count);
82 /** 112 /**
83 * Allows the browser to reuse a buffer that was previously sent by 113 * Allows the browser to reuse a buffer that was previously sent by
84 * PPP_VideoCapture_Dev.OnBufferReady. |buffer| is the index of the buffer in 114 * PPP_VideoCapture_Dev.OnBufferReady. |buffer| is the index of the buffer in
85 * the array returned by PPP_VideoCapture_Dev.OnDeviceInfo. 115 * the array returned by PPP_VideoCapture_Dev.OnDeviceInfo.
86 * 116 *
87 * Returns PP_ERROR_BADARGUMENT if buffer is out of range (greater than the 117 * Returns PP_ERROR_BADARGUMENT if buffer is out of range (greater than the
88 * number of buffers returned by PPP_VideoCapture_Dev.OnDeviceInfo), or if it 118 * number of buffers returned by PPP_VideoCapture_Dev.OnDeviceInfo), or if it
89 * is not currently owned by the plugin. Returns PP_OK otherwise. 119 * is not currently owned by the plugin. Returns PP_OK otherwise.
90 */ 120 */
91 int32_t (*ReuseBuffer)(PP_Resource video_capture, uint32_t buffer); 121 int32_t (*ReuseBuffer)(PP_Resource video_capture, uint32_t buffer);
92 /** 122 /**
93 * Stops the capture. 123 * Stops the capture.
94 * 124 *
95 * Returns PP_ERROR_FAILED if the capture wasn't already started, or PP_OK on 125 * Returns PP_ERROR_FAILED if the capture wasn't already started, or PP_OK on
96 * success. 126 * success.
97 */ 127 */
98 int32_t (*StopCapture)(PP_Resource video_capture); 128 int32_t (*StopCapture)(PP_Resource video_capture);
129 /**
130 * Closes the video capture device, and stops capturing if necessary. It is
131 * not valid to call |Open()| again after a call to this method.
132 * If a video capture resource is destroyed while a device is still open, then
133 * it will be implicitly closed, so you are not required to call this method.
134 */
135 void (*Close)(PP_Resource video_capture);
99 }; 136 };
100 137
101 typedef struct PPB_VideoCapture_Dev_0_1 PPB_VideoCapture_Dev; 138 typedef struct PPB_VideoCapture_Dev_0_2 PPB_VideoCapture_Dev;
139
140 struct PPB_VideoCapture_Dev_0_1 {
141 PP_Resource (*Create)(PP_Instance instance);
142 PP_Bool (*IsVideoCapture)(PP_Resource video_capture);
143 int32_t (*StartCapture)(
144 PP_Resource video_capture,
145 const struct PP_VideoCaptureDeviceInfo_Dev* requested_info,
146 uint32_t buffer_count);
147 int32_t (*ReuseBuffer)(PP_Resource video_capture, uint32_t buffer);
148 int32_t (*StopCapture)(PP_Resource video_capture);
149 };
102 /** 150 /**
103 * @} 151 * @}
104 */ 152 */
105 153
106 #endif /* PPAPI_C_DEV_PPB_VIDEO_CAPTURE_DEV_H_ */ 154 #endif /* PPAPI_C_DEV_PPB_VIDEO_CAPTURE_DEV_H_ */
107 155
OLDNEW
« no previous file with comments | « ppapi/api/dev/ppb_video_capture_dev.idl ('k') | ppapi/cpp/dev/video_capture_dev.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698