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 |
| 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 |
| 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 * How many buffers depends on usage. At least 2 to make sure latency doesn't |
| 59 * cause lost frames. If the plugin expects to hold on to more than one buffer |
| 60 * at a time (e.g. to do multi-frame processing, like video encoding), it |
| 61 * should request that many more. |
| 62 * |
| 63 * Returns PP_ERROR_FAILED if called when the capture was already started, or |
| 64 * PP_OK on success. |
| 65 */ |
| 66 int32_t (*StartCapture)( |
| 67 PP_Resource video_capture, |
| 68 const struct PP_VideoCaptureDeviceInfo_Dev* requested_info, |
| 69 uint32_t buffer_count); |
| 70 |
| 71 /** |
| 72 * Allows the browser to reuse a buffer that was previously sent by |
| 73 * PPP_VideoCapture_Dev.OnBufferReady. |buffer| is the index of the buffer in |
| 74 * the array returned by PPP_VideoCapture_Dev.OnDeviceInfo. |
| 75 * |
| 76 * Returns PP_ERROR_BADARGUMENT if buffer is out of range (greater than the |
| 77 * number of buffers returned by PPP_VideoCapture_Dev.OnDeviceInfo), or if it |
| 78 * is not currently owned by the plugin. Returns PP_OK otherwise. |
| 79 */ |
| 80 int32_t (*ReuseBuffer)(PP_Resource video_capture, uint32_t buffer); |
| 81 |
| 82 /** |
| 83 * Stops the capture. |
| 84 * |
| 85 * Returns PP_ERROR_FAILED if the capture wasn't already started, or PP_OK on |
| 86 * success. |
| 87 */ |
| 88 int32_t (*StopCapture)(PP_Resource video_capture); |
| 89 }; |
| 90 |
| 91 #endif /* PPAPI_C_DEV_PPB_VIDEO_CAPTURE_DEV_H_ */ |
OLD | NEW |