Pepper_47_C_interfaces
ppb_video_decoder.h
Go to the documentation of this file.
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  */
5 
6 /* From ppb_video_decoder.idl modified Thu Oct 20 13:57:04 2016. */
7 
8 #ifndef PPAPI_C_PPB_VIDEO_DECODER_H_
9 #define PPAPI_C_PPB_VIDEO_DECODER_H_
10 
11 #include "ppapi/c/pp_bool.h"
12 #include "ppapi/c/pp_codecs.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"
21 
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
27 
28 /**
29  * @file
30  * This file defines the <code>PPB_VideoDecoder</code> interface.
31  */
32 
33 
34 /**
35  * @addtogroup Interfaces
36  * @{
37  */
38 /**
39  * Video decoder interface.
40  *
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.
55  *
56  * Available video codecs vary by platform.
57  * All: theora, vorbis, vp8.
58  * Chrome and ChromeOS: aac, h264.
59  * ChromeOS: mpeg4.
60  */
61 struct PPB_VideoDecoder_1_1 { /* dev */
62  /**
63  * Creates a new video decoder resource.
64  *
65  * @param[in] instance A <code>PP_Instance</code> identifying the instance
66  * with the video decoder.
67  *
68  * @return A <code>PP_Resource</code> corresponding to a video decoder if
69  * successful or 0 otherwise.
70  */
72  /**
73  * Determines if the given resource is a video decoder.
74  *
75  * @param[in] resource A <code>PP_Resource</code> identifying a resource.
76  *
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.
80  */
82  /**
83  * Initializes a video decoder resource. This should be called after Create()
84  * and before any other functions.
85  *
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.
102  *
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.
109  */
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);
116  /**
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.
120  *
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.
125  *
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.
131  *
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.
141  *
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.
148  */
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);
154  /**
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().
160  *
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.
167  *
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.
174  */
175  int32_t (*GetPicture)(PP_Resource video_decoder,
176  struct PP_VideoPicture* picture,
177  struct PP_CompletionCallback callback);
178  /**
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.
182  *
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.
187  */
188  void (*RecyclePicture)(PP_Resource video_decoder,
189  const struct PP_VideoPicture* picture);
190  /**
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.
200  *
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.
205  *
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.
208  */
209  int32_t (*Flush)(PP_Resource video_decoder,
210  struct PP_CompletionCallback callback);
211  /**
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.
220  *
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.
225  *
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.
228  */
229  int32_t (*Reset)(PP_Resource video_decoder,
230  struct PP_CompletionCallback callback);
231 };
232 
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);
255 };
256 
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);
279 };
280 
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);
303 };
304 
306 /**
307  * @}
308  */
309 
310 #endif /* PPAPI_C_PPB_VIDEO_DECODER_H_ */
311 
int32_t(* Decode)(PP_Resource video_decoder, uint32_t decode_id, uint32_t size, const void *buffer, struct PP_CompletionCallback callback)
int32_t(* Initialize)(PP_Resource video_decoder, PP_Resource graphics3d_context, PP_VideoProfile profile, PP_HardwareAcceleration acceleration, struct PP_CompletionCallback callback)
int32_t(* Flush)(PP_Resource video_decoder, struct PP_CompletionCallback callback)
int32_t(* GetPicture)(PP_Resource video_decoder, struct PP_VideoPicture_0_1 *picture, struct PP_CompletionCallback callback)
PP_VideoProfile
Definition: pp_codecs.h:28
PP_HardwareAcceleration
Definition: pp_codecs.h:56
void(* RecyclePicture)(PP_Resource video_decoder, const struct PP_VideoPicture *picture)
void(* RecyclePicture)(PP_Resource video_decoder, const struct PP_VideoPicture *picture)
int32_t(* Flush)(PP_Resource video_decoder, struct PP_CompletionCallback callback)
int32_t(* GetPicture)(PP_Resource video_decoder, struct PP_VideoPicture *picture, struct PP_CompletionCallback callback)
PP_Resource(* Create)(PP_Instance instance)
PP_Bool(* IsVideoDecoder)(PP_Resource resource)
int32_t(* Decode)(PP_Resource video_decoder, uint32_t decode_id, uint32_t size, const void *buffer, struct PP_CompletionCallback callback)
int32_t(* Flush)(PP_Resource video_decoder, struct PP_CompletionCallback callback)
PP_Resource(* Create)(PP_Instance instance)
int32_t PP_Resource
Definition: pp_resource.h:40
int32_t(* Initialize)(PP_Resource video_decoder, PP_Resource graphics3d_context, PP_VideoProfile profile, PP_HardwareAcceleration acceleration, struct PP_CompletionCallback callback)
PP_Bool(* IsVideoDecoder)(PP_Resource resource)
PP_Resource(* Create)(PP_Instance instance)
int32_t(* Flush)(PP_Resource video_decoder, struct PP_CompletionCallback callback)
int32_t(* Decode)(PP_Resource video_decoder, uint32_t decode_id, uint32_t size, const void *buffer, struct PP_CompletionCallback callback)
int32_t(* Reset)(PP_Resource video_decoder, struct PP_CompletionCallback callback)
int32_t(* Initialize)(PP_Resource video_decoder, PP_Resource graphics3d_context, PP_VideoProfile profile, PP_Bool allow_software_fallback, struct PP_CompletionCallback callback)
int32_t(* GetPicture)(PP_Resource video_decoder, struct PP_VideoPicture_0_1 *picture, struct PP_CompletionCallback callback)
PP_Bool(* IsVideoDecoder)(PP_Resource resource)
PP_Resource(* Create)(PP_Instance instance)
void(* RecyclePicture)(PP_Resource video_decoder, const struct PP_VideoPicture *picture)
void(* RecyclePicture)(PP_Resource video_decoder, const struct PP_VideoPicture *picture)
int32_t(* Initialize)(PP_Resource video_decoder, PP_Resource graphics3d_context, PP_VideoProfile profile, PP_HardwareAcceleration acceleration, uint32_t min_picture_count, struct PP_CompletionCallback callback)
int32_t(* Decode)(PP_Resource video_decoder, uint32_t decode_id, uint32_t size, const void *buffer, struct PP_CompletionCallback callback)
int32_t PP_Instance
Definition: pp_instance.h:34
int32_t(* Reset)(PP_Resource video_decoder, struct PP_CompletionCallback callback)
int32_t(* GetPicture)(PP_Resource video_decoder, struct PP_VideoPicture *picture, struct PP_CompletionCallback callback)
PP_Bool(* IsVideoDecoder)(PP_Resource resource)
PP_Bool
Definition: pp_bool.h:30
int32_t(* Reset)(PP_Resource video_decoder, struct PP_CompletionCallback callback)
int32_t(* Reset)(PP_Resource video_decoder, struct PP_CompletionCallback callback)