Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 /** | 6 /** |
| 7 * This file defines the <code>PPB_VideoCapture_Dev</code> interface. | 7 * This file defines the <code>PPB_VideoCapture_Dev</code> interface. |
| 8 */ | 8 */ |
| 9 label Chrome { | 9 label Chrome { |
| 10 M14 = 0.1 | 10 M14 = 0.1, |
| 11 M18 = 0.2 | |
| 11 }; | 12 }; |
| 12 | 13 |
| 13 /** | 14 /** |
| 14 * Video capture interface. It goes hand-in-hand with PPP_VideoCapture_Dev. | 15 * Video capture interface. It goes hand-in-hand with PPP_VideoCapture_Dev. |
| 15 * | 16 * |
| 16 * Theory of operation: | 17 * Theory of operation: |
| 17 * 1- Create a VideoCapture resource using Create. | 18 * 1- Create a VideoCapture resource using Create. |
| 18 * 2- Start the capture using StartCapture. You pass in the requested info | 19 * 2- Find out available video capture devices using EnumerateDevices. |
|
viettrungluu
2012/02/15 18:40:28
English nit: s/out //
yzshen1
2012/02/15 21:17:54
Done.
| |
| 20 * 3- Open a video capture device. In addition to a device reference (0 can be | |
| 21 * used to indicate the default device), you pass in the requested info | |
| 19 * (resolution, frame rate), as well as suggest a number of buffers you will | 22 * (resolution, frame rate), as well as suggest a number of buffers you will |
| 20 * need. | 23 * need. |
| 21 * 3- Receive the OnDeviceInfo callback, in PPP_VideoCapture_Dev, which will | 24 * 4- Start the capture using StartCapture. |
| 25 * 5- Receive the OnDeviceInfo callback, in PPP_VideoCapture_Dev, which will | |
| 22 * give you the actual capture info (the requested one is not guaranteed), as | 26 * give you the actual capture info (the requested one is not guaranteed), as |
| 23 * well as an array of buffers allocated by the browser. | 27 * well as an array of buffers allocated by the browser. |
| 24 * 4- On every frame captured by the browser, OnBufferReady (in | 28 * 6- On every frame captured by the browser, OnBufferReady (in |
| 25 * PPP_VideoCapture_Dev) is called with the index of the buffer from the array | 29 * PPP_VideoCapture_Dev) is called with the index of the buffer from the array |
| 26 * containing the new frame. The buffer is now "owned" by the plugin, and the | 30 * containing the new frame. The buffer is now "owned" by the plugin, and the |
| 27 * browser won't reuse it until ReuseBuffer is called. | 31 * browser won't reuse it until ReuseBuffer is called. |
| 28 * 5- When the plugin is done with the buffer, call ReuseBuffer | 32 * 7- When the plugin is done with the buffer, call ReuseBuffer. |
| 29 * 6- Stop the capture using StopCapture. | 33 * 8- Stop the capture using StopCapture. |
| 34 * 9- Close the device. | |
| 30 * | 35 * |
| 31 * The browser may change the resolution based on the constraints of the system, | 36 * The browser may change the resolution based on the constraints of the system, |
| 32 * in which case OnDeviceInfo will be called again, with new buffers. | 37 * in which case OnDeviceInfo will be called again, with new buffers. |
| 33 * | 38 * |
| 34 * The buffers contain the pixel data for a frame. The format is planar YUV | 39 * The buffers contain the pixel data for a frame. The format is planar YUV |
| 35 * 4:2:0, one byte per pixel, tightly packed (width x height Y values, then | 40 * 4:2:0, one byte per pixel, tightly packed (width x height Y values, then |
| 36 * width/2 x height/2 U values, then width/2 x height/2 V values). | 41 * width/2 x height/2 U values, then width/2 x height/2 V values). |
| 37 */ | 42 */ |
| 38 interface PPB_VideoCapture_Dev { | 43 interface PPB_VideoCapture_Dev { |
| 39 /** | 44 /** |
| 40 * Creates a new VideoCapture. | 45 * Creates a new VideoCapture. |
| 41 */ | 46 */ |
| 42 PP_Resource Create( | 47 PP_Resource Create( |
| 43 [in] PP_Instance instance); | 48 [in] PP_Instance instance); |
| 44 | 49 |
| 45 /** | 50 /** |
| 46 * Returns PP_TRUE if the given resource is a VideoCapture. | 51 * Returns PP_TRUE if the given resource is a VideoCapture. |
| 47 */ | 52 */ |
| 48 PP_Bool IsVideoCapture( | 53 PP_Bool IsVideoCapture( |
| 49 [in] PP_Resource video_capture); | 54 [in] PP_Resource video_capture); |
| 50 | 55 |
| 51 /** | 56 /** |
| 52 * Starts the capture. |requested_info| is a pointer to a structure containing | 57 * Starts the capture. |requested_info| is a pointer to a structure containing |
| 53 * the requested resolution and frame rate. |buffer_count| is the number of | 58 * the requested resolution and frame rate. |buffer_count| is the number of |
| 54 * buffers requested by the plugin. Note: it is only used as advisory, the | 59 * buffers requested by the plugin. Note: it is only used as advisory, the |
| 55 * browser may allocate more of fewer based on available resources. | 60 * browser may allocate more or fewer based on available resources. |
| 56 * How many buffers depends on usage. At least 2 to make sure latency doesn't | 61 * How many buffers depends on usage. At least 2 to make sure latency doesn't |
| 57 * cause lost frames. If the plugin expects to hold on to more than one buffer | 62 * cause lost frames. If the plugin expects to hold on to more than one buffer |
| 58 * at a time (e.g. to do multi-frame processing, like video encoding), it | 63 * at a time (e.g. to do multi-frame processing, like video encoding), it |
| 59 * should request that many more. | 64 * should request that many more. |
| 60 * | 65 * |
| 61 * Returns PP_ERROR_FAILED if called when the capture was already started, or | 66 * Returns PP_ERROR_FAILED if called when the capture was already started, or |
| 62 * PP_OK on success. | 67 * PP_OK on success. |
| 63 */ | 68 */ |
| 69 [version=0.1] | |
| 64 int32_t StartCapture( | 70 int32_t StartCapture( |
| 65 [in] PP_Resource video_capture, | 71 [in] PP_Resource video_capture, |
| 66 [in] PP_VideoCaptureDeviceInfo_Dev requested_info, | 72 [in] PP_VideoCaptureDeviceInfo_Dev requested_info, |
| 67 [in] uint32_t buffer_count); | 73 [in] uint32_t buffer_count); |
| 68 | 74 |
| 69 /** | 75 /** |
| 76 * Enumerates video capture devices. Once the operation is completed | |
| 77 * successfully, |devices| will be set to a PPB_ResourceArray_Dev resource, | |
| 78 * which holds a list of PPB_DeviceRef_Dev resources. | |
| 79 * | |
| 80 * Please note that: | |
| 81 * - this method ignores the previous value pointed to by |devices| (won't | |
|
viettrungluu
2012/02/15 18:40:28
This is a good warning, though I wonder if it'd be
yzshen1
2012/02/15 21:17:54
We usually don't have restrictions about the previ
| |
| 82 * release reference even if it is not 0); | |
| 83 * - |devices| must be valid until |callback| is called, if the method | |
| 84 * returns PP_OK_COMPLETIONPENDING; | |
| 85 * - the ref count of the returned |devices| has already been increased by 1 | |
| 86 * for the caller. | |
| 87 */ | |
| 88 [version=0.2] | |
| 89 int32_t EnumerateDevices( | |
| 90 [in] PP_Resource video_capture, | |
| 91 [out] PP_Resource devices, | |
| 92 [in] PP_CompletionCallback callback); | |
| 93 | |
| 94 /** | |
| 95 * Opens a video capture device. |device_ref| identifies a video capture | |
| 96 * device. It could be one of the resource in the array returned by | |
| 97 * |EnumerateDevices()|, or 0 which means the default device. | |
| 98 * |requested_info| is a pointer to a structure containing the requested | |
| 99 * resolution and frame rate. |buffer_count| is the number of buffers | |
| 100 * requested by the plugin. Note: it is only used as advisory, the browser may | |
| 101 * allocate more or fewer based on available resources. How many buffers | |
| 102 * depends on usage. At least 2 to make sure latency doesn't cause lost | |
| 103 * frames. If the plugin expects to hold on to more than one buffer at a time | |
| 104 * (e.g. to do multi-frame processing, like video encoding), it should request | |
| 105 * that many more. | |
| 106 */ | |
| 107 [version=0.2] | |
| 108 int32_t Open( | |
| 109 [in] PP_Resource video_capture, | |
| 110 [in] PP_Resource device_ref, | |
| 111 [in] PP_VideoCaptureDeviceInfo_Dev requested_info, | |
| 112 [in] uint32_t buffer_count, | |
| 113 [in] PP_CompletionCallback callback); | |
| 114 | |
| 115 /** | |
| 116 * Starts the capture. | |
| 117 * | |
| 118 * Returns PP_ERROR_FAILED if called when the capture was already started, or | |
| 119 * PP_OK on success. | |
| 120 */ | |
| 121 [version=0.2] | |
| 122 int32_t StartCapture( | |
| 123 [in] PP_Resource video_capture); | |
| 124 | |
| 125 /** | |
| 70 * Allows the browser to reuse a buffer that was previously sent by | 126 * Allows the browser to reuse a buffer that was previously sent by |
| 71 * PPP_VideoCapture_Dev.OnBufferReady. |buffer| is the index of the buffer in | 127 * PPP_VideoCapture_Dev.OnBufferReady. |buffer| is the index of the buffer in |
| 72 * the array returned by PPP_VideoCapture_Dev.OnDeviceInfo. | 128 * the array returned by PPP_VideoCapture_Dev.OnDeviceInfo. |
| 73 * | 129 * |
| 74 * Returns PP_ERROR_BADARGUMENT if buffer is out of range (greater than the | 130 * Returns PP_ERROR_BADARGUMENT if buffer is out of range (greater than the |
| 75 * number of buffers returned by PPP_VideoCapture_Dev.OnDeviceInfo), or if it | 131 * number of buffers returned by PPP_VideoCapture_Dev.OnDeviceInfo), or if it |
| 76 * is not currently owned by the plugin. Returns PP_OK otherwise. | 132 * is not currently owned by the plugin. Returns PP_OK otherwise. |
| 77 */ | 133 */ |
| 78 int32_t ReuseBuffer( | 134 int32_t ReuseBuffer( |
| 79 [in] PP_Resource video_capture, | 135 [in] PP_Resource video_capture, |
| 80 [in] uint32_t buffer); | 136 [in] uint32_t buffer); |
| 81 | 137 |
| 82 /** | 138 /** |
| 83 * Stops the capture. | 139 * Stops the capture. |
| 84 * | 140 * |
| 85 * Returns PP_ERROR_FAILED if the capture wasn't already started, or PP_OK on | 141 * Returns PP_ERROR_FAILED if the capture wasn't already started, or PP_OK on |
| 86 * success. | 142 * success. |
| 87 */ | 143 */ |
| 88 int32_t StopCapture( | 144 int32_t StopCapture( |
| 89 [in] PP_Resource video_capture); | 145 [in] PP_Resource video_capture); |
| 146 | |
| 147 /** | |
| 148 * Closes the video capture device, and stops capturing if necessary. It is | |
| 149 * not valid to call |Open()| again after a call to this method. | |
| 150 * If a video capture resource is destroyed while a device is still open, then | |
| 151 * it will be implicitly closed, so you are not required to call this method. | |
| 152 */ | |
| 153 [version=0.2] | |
| 154 void Close( | |
| 155 [in] PP_Resource video_capture); | |
| 90 }; | 156 }; |
| OLD | NEW |