Roll src/third_party/WebKit dbf9be3:8d6c3d5 (svn 202308:202312)
[chromium-blink-merge.git] / ppapi / api / ppb_video_decoder.idl
blobe879c20c68824c2094eed737a5198ffa6afcf35b
1 /* Copyright (c) 2014 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 */
6 /**
7 * This file defines the <code>PPB_VideoDecoder</code> interface.
8 */
10 [generate_thunk]
12 label Chrome {
13 /** Though not labeled 'channel=dev', 0.1 is a still a 'Dev' only API. */
14 M36 = 0.1,
15 M39 = 0.2,
16 M40 = 1.0,
17 [channel=dev] M46 = 1.1
20 /**
21 * Video decoder interface.
23 * Typical usage:
24 * - Call Create() to create a new video decoder resource.
25 * - Call Initialize() to initialize it with a 3d graphics context and the
26 * desired codec profile.
27 * - Call Decode() continuously (waiting for each previous call to complete) to
28 * push bitstream buffers to the decoder.
29 * - Call GetPicture() continuously (waiting for each previous call to complete)
30 * to pull decoded pictures from the decoder.
31 * - Call Flush() to signal end of stream to the decoder and perform shutdown
32 * when it completes.
33 * - Call Reset() to quickly stop the decoder (e.g. to implement Seek) and wait
34 * for the callback before restarting decoding at another point.
35 * - To destroy the decoder, the plugin should release all of its references to
36 * it. Any pending callbacks will abort before the decoder is destroyed.
38 * Available video codecs vary by platform.
39 * All: theora, vorbis, vp8.
40 * Chrome and ChromeOS: aac, h264.
41 * ChromeOS: mpeg4.
43 interface PPB_VideoDecoder {
44 /**
45 * Creates a new video decoder resource.
47 * @param[in] instance A <code>PP_Instance</code> identifying the instance
48 * with the video decoder.
50 * @return A <code>PP_Resource</code> corresponding to a video decoder if
51 * successful or 0 otherwise.
53 PP_Resource Create(
54 [in] PP_Instance instance);
56 /**
57 * Determines if the given resource is a video decoder.
59 * @param[in] resource A <code>PP_Resource</code> identifying a resource.
61 * @return <code>PP_TRUE</code> if the resource is a
62 * <code>PPB_VideoDecoder</code>, <code>PP_FALSE</code> if the resource is
63 * invalid or some other type.
65 PP_Bool IsVideoDecoder(
66 [in] PP_Resource resource);
68 /**
69 * Initializes a video decoder resource. This should be called after Create()
70 * and before any other functions.
72 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video
73 * decoder.
74 * @param[in] graphics3d_context A <code>PPB_Graphics3D</code> resource to use
75 * during decoding.
76 * @param[in] profile A <code>PP_VideoProfile</code> specifying the video
77 * codec profile.
78 * @param[in] allow_software_fallback A <code>PP_Bool</code> specifying
79 * whether the decoder can fall back to software decoding if a suitable
80 * hardware decoder isn't available.
81 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
82 * completion.
84 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
85 * Returns PP_ERROR_NOTSUPPORTED if video decoding is not available, or the
86 * requested profile is not supported. In this case, the client may call
87 * Initialize() again with different parameters to find a good configuration.
89 int32_t Initialize(
90 [in] PP_Resource video_decoder,
91 [in] PP_Resource graphics3d_context,
92 [in] PP_VideoProfile profile,
93 [in] PP_Bool allow_software_fallback,
94 [in] PP_CompletionCallback callback);
96 /**
97 * Initializes a video decoder resource. This should be called after Create()
98 * and before any other functions.
100 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video
101 * decoder.
102 * @param[in] graphics3d_context A <code>PPB_Graphics3D</code> resource to use
103 * during decoding.
104 * @param[in] profile A <code>PP_VideoProfile</code> specifying the video
105 * codec profile.
106 * @param[in] acceleration A <code>PP_HardwareAcceleration</code> specifying
107 * whether to use a hardware accelerated or a software implementation.
108 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
109 * completion.
111 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
112 * Returns PP_ERROR_NOTSUPPORTED if video decoding is not available, or the
113 * requested profile is not supported. In this case, the client may call
114 * Initialize() again with different parameters to find a good configuration.
116 [version = 0.2]
117 int32_t Initialize(
118 [in] PP_Resource video_decoder,
119 [in] PP_Resource graphics3d_context,
120 [in] PP_VideoProfile profile,
121 [in] PP_HardwareAcceleration acceleration,
122 [in] PP_CompletionCallback callback);
125 * Initializes a video decoder resource. This should be called after Create()
126 * and before any other functions.
128 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video
129 * decoder.
130 * @param[in] graphics3d_context A <code>PPB_Graphics3D</code> resource to use
131 * during decoding.
132 * @param[in] profile A <code>PP_VideoProfile</code> specifying the video
133 * codec profile.
134 * @param[in] acceleration A <code>PP_HardwareAcceleration</code> specifying
135 * whether to use a hardware accelerated or a software implementation.
136 * @param[in] min_picture_count A count of pictures the plugin would like to
137 * have in flight. This is effectively the number of times the plugin can
138 * call GetPicture() and get a decoded frame without calling
139 * RecyclePicture(). The decoder has its own internal minimum count, and will
140 * take the larger of its internal and this value. A client that doesn't care
141 * can therefore just pass in zero for this argument.
142 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
143 * completion.
145 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
146 * Returns PP_ERROR_NOTSUPPORTED if video decoding is not available, or the
147 * requested profile is not supported. In this case, the client may call
148 * Initialize() again with different parameters to find a good configuration.
149 * Returns PP_ERROR_BADARGUMENT if the requested minimum picture count is
150 * unreasonably large.
152 [version = 1.1]
153 int32_t Initialize(
154 [in] PP_Resource video_decoder,
155 [in] PP_Resource graphics3d_context,
156 [in] PP_VideoProfile profile,
157 [in] PP_HardwareAcceleration acceleration,
158 [in] uint32_t min_picture_count,
159 [in] PP_CompletionCallback callback);
162 * Decodes a bitstream buffer. Copies |size| bytes of data from the plugin's
163 * |buffer|. The plugin should wait until the decoder signals completion by
164 * returning PP_OK or by running |callback| before calling Decode() again.
166 * In general, each bitstream buffer should contain a demuxed bitstream frame
167 * for the selected video codec. For example, H264 decoders expect to receive
168 * one AnnexB NAL unit, including the 4 byte start code prefix, while VP8
169 * decoders expect to receive a bitstream frame without the IVF frame header.
171 * If the call to Decode() eventually results in a picture, the |decode_id|
172 * parameter is copied into the returned picture. The plugin can use this to
173 * associate decoded pictures with Decode() calls (e.g. to assign timestamps
174 * or frame numbers to pictures.) This value is opaque to the API so the
175 * plugin is free to pass any value.
177 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video
178 * decoder.
179 * @param[in] decode_id An optional value, chosen by the plugin, that can be
180 * used to associate calls to Decode() with decoded pictures returned by
181 * GetPicture().
182 * @param[in] size Buffer size in bytes.
183 * @param[in] buffer Starting address of buffer.
184 * @param[in] callback A <code>PP_CompletionCallback</code> to be called on
185 * completion.
187 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
188 * Returns PP_ERROR_FAILED if the decoder isn't initialized or if a Flush()
189 * or Reset() call is pending.
190 * Returns PP_ERROR_INPROGRESS if there is another Decode() call pending.
191 * Returns PP_ERROR_NOMEMORY if a bitstream buffer can't be created.
192 * Returns PP_ERROR_ABORTED when Reset() is called while Decode() is pending.
194 int32_t Decode(
195 [in] PP_Resource video_decoder,
196 [in] uint32_t decode_id,
197 [in] uint32_t size,
198 [in] mem_t buffer,
199 [in] PP_CompletionCallback callback);
202 * Gets the next picture from the decoder. The picture is valid after the
203 * decoder signals completion by returning PP_OK or running |callback|. The
204 * plugin can call GetPicture() again after the decoder signals completion.
205 * When the plugin is finished using the picture, it should return it to the
206 * system by calling RecyclePicture().
208 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video
209 * decoder.
210 * @param[out] picture A <code>PP_VideoPicture</code> to hold the decoded
211 * picture.
212 * @param[in] callback A <code>PP_CompletionCallback</code> to be called on
213 * completion.
215 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
216 * Returns PP_ERROR_FAILED if the decoder isn't initialized or if a Reset()
217 * call is pending.
218 * Returns PP_ERROR_INPROGRESS if there is another GetPicture() call pending.
219 * Returns PP_ERROR_ABORTED when Reset() is called, or if a call to Flush()
220 * completes while GetPicture() is pending.
222 int32_t GetPicture(
223 [in] PP_Resource video_decoder,
224 [out] PP_VideoPicture_0_1 picture,
225 [in] PP_CompletionCallback callback);
228 * Gets the next picture from the decoder. The picture is valid after the
229 * decoder signals completion by returning PP_OK or running |callback|. The
230 * plugin can call GetPicture() again after the decoder signals completion.
231 * When the plugin is finished using the picture, it should return it to the
232 * system by calling RecyclePicture().
234 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video
235 * decoder.
236 * @param[out] picture A <code>PP_VideoPicture</code> to hold the decoded
237 * picture.
238 * @param[in] callback A <code>PP_CompletionCallback</code> to be called on
239 * completion.
241 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
242 * Returns PP_ERROR_FAILED if the decoder isn't initialized or if a Reset()
243 * call is pending.
244 * Returns PP_ERROR_INPROGRESS if there is another GetPicture() call pending.
245 * Returns PP_ERROR_ABORTED when Reset() is called, or if a call to Flush()
246 * completes while GetPicture() is pending.
248 [version = 1.0]
249 int32_t GetPicture(
250 [in] PP_Resource video_decoder,
251 [out] PP_VideoPicture picture,
252 [in] PP_CompletionCallback callback);
255 * Recycles a picture that the plugin has received from the decoder.
256 * The plugin should call this as soon as it has finished using the texture so
257 * the decoder can decode more pictures.
259 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video
260 * decoder.
261 * @param[in] picture A <code>PP_VideoPicture</code> to return to
262 * the decoder.
264 void RecyclePicture(
265 [in] PP_Resource video_decoder,
266 [in] PP_VideoPicture picture);
269 * Flushes the decoder. The plugin should call Flush() when it reaches the
270 * end of its video stream in order to stop cleanly. The decoder will run any
271 * pending Decode() call to completion. The plugin should make no further
272 * calls to the decoder other than GetPicture() and RecyclePicture() until
273 * the decoder signals completion by running |callback|. Just before
274 * completion, any pending GetPicture() call will complete by running its
275 * callback with result PP_ERROR_ABORTED to signal that no more pictures are
276 * available. Any pictures held by the plugin remain valid during and after
277 * the flush and should be recycled back to the decoder.
279 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video
280 * decoder.
281 * @param[in] callback A <code>PP_CompletionCallback</code> to be called on
282 * completion.
284 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
285 * Returns PP_ERROR_FAILED if the decoder isn't initialized.
287 int32_t Flush(
288 [in] PP_Resource video_decoder,
289 [in] PP_CompletionCallback callback);
292 * Resets the decoder as quickly as possible. The plugin can call Reset() to
293 * skip to another position in the video stream. After Reset() returns, any
294 * pending calls to Decode() and GetPicture()) abort, causing their callbacks
295 * to run with PP_ERROR_ABORTED. The plugin should not make further calls to
296 * the decoder other than RecyclePicture() until the decoder signals
297 * completion by running |callback|. Any pictures held by the plugin remain
298 * valid during and after the reset and should be recycled back to the
299 * decoder.
301 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video
302 * decoder.
303 * @param[in] callback A <code>PP_CompletionCallback</code> to be called on
304 * completion.
306 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
307 * Returns PP_ERROR_FAILED if the decoder isn't initialized.
309 int32_t Reset(
310 [in] PP_Resource video_decoder,
311 [in] PP_CompletionCallback callback);