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.
7 * This file defines the <code>PPB_VideoDecoder</code> interface.
13 /** Though not labeled 'channel=dev', 0.1 is a still a 'Dev' only API. */
17 [channel
=dev
] M46
= 1.1
21 * Video decoder interface.
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
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.
43 interface PPB_VideoDecoder
{
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.
54 [in] PP_Instance instance
);
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
);
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
74 * @param[in] graphics3d_context A <code>PPB_Graphics3D</code> resource to use
76 * @param[in] profile A <code>PP_VideoProfile</code> specifying the video
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
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.
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);
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
102 * @param[in] graphics3d_context A <code>PPB_Graphics3D</code> resource to use
104 * @param[in] profile A <code>PP_VideoProfile</code> specifying the video
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
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.
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
130 * @param[in] graphics3d_context A <code>PPB_Graphics3D</code> resource to use
132 * @param[in] profile A <code>PP_VideoProfile</code> specifying the video
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
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.
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
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
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
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.
195 [in] PP_Resource video_decoder
,
196 [in] uint32_t decode_id
,
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
210 * @param[out] picture A <code>PP_VideoPicture</code> to hold the decoded
212 * @param[in] callback A <code>PP_CompletionCallback</code> to be called on
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()
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.
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
236 * @param[out] picture A <code>PP_VideoPicture</code> to hold the decoded
238 * @param[in] callback A <code>PP_CompletionCallback</code> to be called on
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()
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.
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
261 * @param[in] picture A <code>PP_VideoPicture</code> to return to
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
281 * @param[in] callback A <code>PP_CompletionCallback</code> to be called on
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.
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
301 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video
303 * @param[in] callback A <code>PP_CompletionCallback</code> to be called on
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.
310 [in] PP_Resource video_decoder
,
311 [in] PP_CompletionCallback
callback);