Delete unused downloads page asset.
[chromium-blink-merge.git] / ppapi / c / ppb_video_decoder.h
blobf2c4f18e399e10531f1be870d856fcee4c36d000
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 /* From ppb_video_decoder.idl modified Thu Aug 6 14:15:48 2015. */
8 #ifndef PPAPI_C_PPB_VIDEO_DECODER_H_
9 #define PPAPI_C_PPB_VIDEO_DECODER_H_
11 #include "ppapi/c/pp_bool.h"
12 #include "ppapi/c/pp_codecs.h"
13 #include "ppapi/c/pp_completion_callback.h"
14 #include "ppapi/c/pp_instance.h"
15 #include "ppapi/c/pp_macros.h"
16 #include "ppapi/c/pp_point.h"
17 #include "ppapi/c/pp_rect.h"
18 #include "ppapi/c/pp_resource.h"
19 #include "ppapi/c/pp_size.h"
20 #include "ppapi/c/pp_stdint.h"
22 #define PPB_VIDEODECODER_INTERFACE_0_1 "PPB_VideoDecoder;0.1"
23 #define PPB_VIDEODECODER_INTERFACE_0_2 "PPB_VideoDecoder;0.2"
24 #define PPB_VIDEODECODER_INTERFACE_1_0 "PPB_VideoDecoder;1.0"
25 #define PPB_VIDEODECODER_INTERFACE_1_1 "PPB_VideoDecoder;1.1" /* dev */
26 #define PPB_VIDEODECODER_INTERFACE PPB_VIDEODECODER_INTERFACE_1_0
28 /**
29 * @file
30 * This file defines the <code>PPB_VideoDecoder</code> interface.
34 /**
35 * @addtogroup Interfaces
36 * @{
38 /**
39 * Video decoder interface.
41 * Typical usage:
42 * - Call Create() to create a new video decoder resource.
43 * - Call Initialize() to initialize it with a 3d graphics context and the
44 * desired codec profile.
45 * - Call Decode() continuously (waiting for each previous call to complete) to
46 * push bitstream buffers to the decoder.
47 * - Call GetPicture() continuously (waiting for each previous call to complete)
48 * to pull decoded pictures from the decoder.
49 * - Call Flush() to signal end of stream to the decoder and perform shutdown
50 * when it completes.
51 * - Call Reset() to quickly stop the decoder (e.g. to implement Seek) and wait
52 * for the callback before restarting decoding at another point.
53 * - To destroy the decoder, the plugin should release all of its references to
54 * it. Any pending callbacks will abort before the decoder is destroyed.
56 * Available video codecs vary by platform.
57 * All: theora, vorbis, vp8.
58 * Chrome and ChromeOS: aac, h264.
59 * ChromeOS: mpeg4.
61 struct PPB_VideoDecoder_1_1 { /* dev */
62 /**
63 * Creates a new video decoder resource.
65 * @param[in] instance A <code>PP_Instance</code> identifying the instance
66 * with the video decoder.
68 * @return A <code>PP_Resource</code> corresponding to a video decoder if
69 * successful or 0 otherwise.
71 PP_Resource (*Create)(PP_Instance instance);
72 /**
73 * Determines if the given resource is a video decoder.
75 * @param[in] resource A <code>PP_Resource</code> identifying a resource.
77 * @return <code>PP_TRUE</code> if the resource is a
78 * <code>PPB_VideoDecoder</code>, <code>PP_FALSE</code> if the resource is
79 * invalid or some other type.
81 PP_Bool (*IsVideoDecoder)(PP_Resource resource);
82 /**
83 * Initializes a video decoder resource. This should be called after Create()
84 * and before any other functions.
86 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video
87 * decoder.
88 * @param[in] graphics3d_context A <code>PPB_Graphics3D</code> resource to use
89 * during decoding.
90 * @param[in] profile A <code>PP_VideoProfile</code> specifying the video
91 * codec profile.
92 * @param[in] acceleration A <code>PP_HardwareAcceleration</code> specifying
93 * whether to use a hardware accelerated or a software implementation.
94 * @param[in] min_picture_count A count of pictures the plugin would like to
95 * have in flight. This is effectively the number of times the plugin can
96 * call GetPicture() and get a decoded frame without calling
97 * RecyclePicture(). The decoder has its own internal minimum count, and will
98 * take the larger of its internal and this value. A client that doesn't care
99 * can therefore just pass in zero for this argument.
100 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
101 * completion.
103 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
104 * Returns PP_ERROR_NOTSUPPORTED if video decoding is not available, or the
105 * requested profile is not supported. In this case, the client may call
106 * Initialize() again with different parameters to find a good configuration.
107 * Returns PP_ERROR_BADARGUMENT if the requested minimum picture count is
108 * unreasonably large.
110 int32_t (*Initialize)(PP_Resource video_decoder,
111 PP_Resource graphics3d_context,
112 PP_VideoProfile profile,
113 PP_HardwareAcceleration acceleration,
114 uint32_t min_picture_count,
115 struct PP_CompletionCallback callback);
117 * Decodes a bitstream buffer. Copies |size| bytes of data from the plugin's
118 * |buffer|. The plugin should wait until the decoder signals completion by
119 * returning PP_OK or by running |callback| before calling Decode() again.
121 * In general, each bitstream buffer should contain a demuxed bitstream frame
122 * for the selected video codec. For example, H264 decoders expect to receive
123 * one AnnexB NAL unit, including the 4 byte start code prefix, while VP8
124 * decoders expect to receive a bitstream frame without the IVF frame header.
126 * If the call to Decode() eventually results in a picture, the |decode_id|
127 * parameter is copied into the returned picture. The plugin can use this to
128 * associate decoded pictures with Decode() calls (e.g. to assign timestamps
129 * or frame numbers to pictures.) This value is opaque to the API so the
130 * plugin is free to pass any value.
132 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video
133 * decoder.
134 * @param[in] decode_id An optional value, chosen by the plugin, that can be
135 * used to associate calls to Decode() with decoded pictures returned by
136 * GetPicture().
137 * @param[in] size Buffer size in bytes.
138 * @param[in] buffer Starting address of buffer.
139 * @param[in] callback A <code>PP_CompletionCallback</code> to be called on
140 * completion.
142 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
143 * Returns PP_ERROR_FAILED if the decoder isn't initialized or if a Flush()
144 * or Reset() call is pending.
145 * Returns PP_ERROR_INPROGRESS if there is another Decode() call pending.
146 * Returns PP_ERROR_NOMEMORY if a bitstream buffer can't be created.
147 * Returns PP_ERROR_ABORTED when Reset() is called while Decode() is pending.
149 int32_t (*Decode)(PP_Resource video_decoder,
150 uint32_t decode_id,
151 uint32_t size,
152 const void* buffer,
153 struct PP_CompletionCallback callback);
155 * Gets the next picture from the decoder. The picture is valid after the
156 * decoder signals completion by returning PP_OK or running |callback|. The
157 * plugin can call GetPicture() again after the decoder signals completion.
158 * When the plugin is finished using the picture, it should return it to the
159 * system by calling RecyclePicture().
161 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video
162 * decoder.
163 * @param[out] picture A <code>PP_VideoPicture</code> to hold the decoded
164 * picture.
165 * @param[in] callback A <code>PP_CompletionCallback</code> to be called on
166 * completion.
168 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
169 * Returns PP_ERROR_FAILED if the decoder isn't initialized or if a Reset()
170 * call is pending.
171 * Returns PP_ERROR_INPROGRESS if there is another GetPicture() call pending.
172 * Returns PP_ERROR_ABORTED when Reset() is called, or if a call to Flush()
173 * completes while GetPicture() is pending.
175 int32_t (*GetPicture)(PP_Resource video_decoder,
176 struct PP_VideoPicture* picture,
177 struct PP_CompletionCallback callback);
179 * Recycles a picture that the plugin has received from the decoder.
180 * The plugin should call this as soon as it has finished using the texture so
181 * the decoder can decode more pictures.
183 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video
184 * decoder.
185 * @param[in] picture A <code>PP_VideoPicture</code> to return to
186 * the decoder.
188 void (*RecyclePicture)(PP_Resource video_decoder,
189 const struct PP_VideoPicture* picture);
191 * Flushes the decoder. The plugin should call Flush() when it reaches the
192 * end of its video stream in order to stop cleanly. The decoder will run any
193 * pending Decode() call to completion. The plugin should make no further
194 * calls to the decoder other than GetPicture() and RecyclePicture() until
195 * the decoder signals completion by running |callback|. Just before
196 * completion, any pending GetPicture() call will complete by running its
197 * callback with result PP_ERROR_ABORTED to signal that no more pictures are
198 * available. Any pictures held by the plugin remain valid during and after
199 * the flush and should be recycled back to the decoder.
201 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video
202 * decoder.
203 * @param[in] callback A <code>PP_CompletionCallback</code> to be called on
204 * completion.
206 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
207 * Returns PP_ERROR_FAILED if the decoder isn't initialized.
209 int32_t (*Flush)(PP_Resource video_decoder,
210 struct PP_CompletionCallback callback);
212 * Resets the decoder as quickly as possible. The plugin can call Reset() to
213 * skip to another position in the video stream. After Reset() returns, any
214 * pending calls to Decode() and GetPicture()) abort, causing their callbacks
215 * to run with PP_ERROR_ABORTED. The plugin should not make further calls to
216 * the decoder other than RecyclePicture() until the decoder signals
217 * completion by running |callback|. Any pictures held by the plugin remain
218 * valid during and after the reset and should be recycled back to the
219 * decoder.
221 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video
222 * decoder.
223 * @param[in] callback A <code>PP_CompletionCallback</code> to be called on
224 * completion.
226 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
227 * Returns PP_ERROR_FAILED if the decoder isn't initialized.
229 int32_t (*Reset)(PP_Resource video_decoder,
230 struct PP_CompletionCallback callback);
233 struct PPB_VideoDecoder_0_1 {
234 PP_Resource (*Create)(PP_Instance instance);
235 PP_Bool (*IsVideoDecoder)(PP_Resource resource);
236 int32_t (*Initialize)(PP_Resource video_decoder,
237 PP_Resource graphics3d_context,
238 PP_VideoProfile profile,
239 PP_Bool allow_software_fallback,
240 struct PP_CompletionCallback callback);
241 int32_t (*Decode)(PP_Resource video_decoder,
242 uint32_t decode_id,
243 uint32_t size,
244 const void* buffer,
245 struct PP_CompletionCallback callback);
246 int32_t (*GetPicture)(PP_Resource video_decoder,
247 struct PP_VideoPicture_0_1* picture,
248 struct PP_CompletionCallback callback);
249 void (*RecyclePicture)(PP_Resource video_decoder,
250 const struct PP_VideoPicture* picture);
251 int32_t (*Flush)(PP_Resource video_decoder,
252 struct PP_CompletionCallback callback);
253 int32_t (*Reset)(PP_Resource video_decoder,
254 struct PP_CompletionCallback callback);
257 struct PPB_VideoDecoder_0_2 {
258 PP_Resource (*Create)(PP_Instance instance);
259 PP_Bool (*IsVideoDecoder)(PP_Resource resource);
260 int32_t (*Initialize)(PP_Resource video_decoder,
261 PP_Resource graphics3d_context,
262 PP_VideoProfile profile,
263 PP_HardwareAcceleration acceleration,
264 struct PP_CompletionCallback callback);
265 int32_t (*Decode)(PP_Resource video_decoder,
266 uint32_t decode_id,
267 uint32_t size,
268 const void* buffer,
269 struct PP_CompletionCallback callback);
270 int32_t (*GetPicture)(PP_Resource video_decoder,
271 struct PP_VideoPicture_0_1* picture,
272 struct PP_CompletionCallback callback);
273 void (*RecyclePicture)(PP_Resource video_decoder,
274 const struct PP_VideoPicture* picture);
275 int32_t (*Flush)(PP_Resource video_decoder,
276 struct PP_CompletionCallback callback);
277 int32_t (*Reset)(PP_Resource video_decoder,
278 struct PP_CompletionCallback callback);
281 struct PPB_VideoDecoder_1_0 {
282 PP_Resource (*Create)(PP_Instance instance);
283 PP_Bool (*IsVideoDecoder)(PP_Resource resource);
284 int32_t (*Initialize)(PP_Resource video_decoder,
285 PP_Resource graphics3d_context,
286 PP_VideoProfile profile,
287 PP_HardwareAcceleration acceleration,
288 struct PP_CompletionCallback callback);
289 int32_t (*Decode)(PP_Resource video_decoder,
290 uint32_t decode_id,
291 uint32_t size,
292 const void* buffer,
293 struct PP_CompletionCallback callback);
294 int32_t (*GetPicture)(PP_Resource video_decoder,
295 struct PP_VideoPicture* picture,
296 struct PP_CompletionCallback callback);
297 void (*RecyclePicture)(PP_Resource video_decoder,
298 const struct PP_VideoPicture* picture);
299 int32_t (*Flush)(PP_Resource video_decoder,
300 struct PP_CompletionCallback callback);
301 int32_t (*Reset)(PP_Resource video_decoder,
302 struct PP_CompletionCallback callback);
305 typedef struct PPB_VideoDecoder_1_0 PPB_VideoDecoder;
307 * @}
310 #endif /* PPAPI_C_PPB_VIDEO_DECODER_H_ */