OLD | NEW |
---|---|
(Empty) | |
1 /* Copyright (c) 2011 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_C_DEV_PPB_VIDEO_CAPTURE_DEV_H_ | |
6 #define PPAPI_C_DEV_PPB_VIDEO_CAPTURE_DEV_H_ | |
7 | |
8 #include "ppapi/c/dev/pp_video_capture_dev.h" | |
9 #include "ppapi/c/pp_bool.h" | |
10 #include "ppapi/c/pp_instance.h" | |
11 #include "ppapi/c/pp_resource.h" | |
12 #include "ppapi/c/pp_stdint.h" | |
13 | |
14 #define PPB_VIDEO_CAPTURE_DEV_INTERFACE_0_1 "PPB_VideoCapture(Dev);0.1" | |
15 #define PPB_VIDEO_CAPTURE_DEV_INTERFACE PPB_VIDEO_CAPTURE_DEV_INTERFACE_0_1 | |
16 | |
17 /** | |
18 * Video capture interface. It goes hand-in-hand with PPP_VideoCapture_Dev. | |
19 * | |
20 * Theory of operation: | |
21 * 1- Create a VideoCapture resource using Create. | |
22 * 2- Start the capture using StartCapture. You pass in the requested info | |
23 * (resolution, frame rate), as well as suggest a number of buffers you will | |
24 * need. | |
25 * 3- Receive the OnDeviceInfo callback, in PPP_VideoCapture_Dev, which will | |
26 * give you the actual capture info (the requested one is not guaranteed), as | |
27 * well as an array of buffers allocated by the browser. | |
28 * 4- On every frame captured by the browser, OnBufferReady (in | |
29 * PPP_VideoCapture_Dev) is called with the index of the buffer from the array | |
30 * containing the new frame. The buffer is now "owned" by the plugin, and the | |
31 * browser won't reuse it until ReuseBuffer is called. | |
32 * 5- When the plugin is done with the buffer, call ReuseBuffer | |
33 * 6- Stop the capture using StopCapture. | |
34 * | |
35 * The browser may change the resolution based on the constraints of the system, | |
36 * in which case OnDeviceInfo will be called again, with new buffers. | |
37 * | |
38 * The buffers contain the pixel data for a frame. The format is planar YUV | |
39 * 4:2:0, one byte per pixel, tightly packed (width x height Y values, then | |
brettw
2011/08/02 17:17:44
4:2:0 -> doesn't this mean there's no V component?
piman
2011/08/03 00:44:41
Nope, 4:2:0 means 2/4 ratio of U and V to Y on eve
| |
40 * width/2 x height/2 U values, then width/2 x height/2 V values). | |
41 */ | |
42 struct PPB_VideoCapture_Dev { | |
43 /** | |
44 * Creates a new VideoCapture. | |
45 */ | |
46 PP_Resource (*Create)(PP_Instance instance); | |
47 | |
48 /** | |
49 * Returns PP_TRUE if the given resource is a VideoCapture. | |
50 */ | |
51 PP_Bool (*IsVideoCapture)(PP_Resource video_capture); | |
52 | |
53 /** | |
54 * Starts the capture. |requested_info| is a pointer to a structure containing | |
55 * the requested resolution and frame rate. |buffer_count| is the number of | |
brettw
2011/08/02 17:17:44
Can you give some guidance on how to pick the buff
piman
2011/08/03 00:44:41
Done.
| |
56 * buffers requested by the plugin. Note: it is only used as advisory, the | |
57 * browser may allocate more of fewer based on available resources. | |
58 * | |
59 * Returns PP_ERROR_FAILED if called when the capture was already started, or | |
60 * PP_OK on success. | |
61 */ | |
62 int32_t (*StartCapture)( | |
63 PP_Resource video_capture, | |
64 const struct PP_VideoCaptureDeviceInfo_Dev* requested_info, | |
65 uint32_t buffer_count); | |
66 | |
67 /** | |
68 * Allows the browser to reuse a buffer that was previously sent by | |
69 * PPP_VideoCapture_Dev.OnBufferReady. |buffer| is the index of the buffer in | |
70 * the array returned by PPP_VideoCapture_Dev.OnDeviceInfo. | |
71 * | |
72 * Returns PP_ERROR_BADARGUMENT if buffer is out of range (greater than the | |
73 * number of buffers returned by PPP_VideoCapture_Dev.OnDeviceInfo), or if it | |
74 * is not currently owned by the plugin. Returns PP_OK otherwise. | |
75 */ | |
76 int32_t (*ReuseBuffer)(PP_Resource video_capture, uint32_t buffer); | |
77 | |
78 /** | |
79 * Stops the capture. | |
80 * | |
81 * Returns PP_ERROR_FAILED if the capture wasn't already started, or PP_OK on | |
82 * success. | |
83 */ | |
84 int32_t (*StopCapture)(PP_Resource video_capture); | |
85 }; | |
86 | |
87 #endif /* PPAPI_C_DEV_PPB_VIDEO_CAPTURE_DEV_H_ */ | |
OLD | NEW |