Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / ppapi / c / ppb_video_decoder.h
blobc3ebf8be19e7c33fb398b41c95d6d54fea59ed7b
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 Fri Aug 22 13:42:35 2014. */
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_resource.h"
17 #include "ppapi/c/pp_size.h"
18 #include "ppapi/c/pp_stdint.h"
20 #define PPB_VIDEODECODER_INTERFACE_0_1 "PPB_VideoDecoder;0.1" /* dev */
21 #define PPB_VIDEODECODER_INTERFACE_0_2 "PPB_VideoDecoder;0.2" /* dev */
22 /**
23 * @file
24 * This file defines the <code>PPB_VideoDecoder</code> interface.
28 /**
29 * @addtogroup Interfaces
30 * @{
32 /**
33 * Video decoder interface.
35 * Typical usage:
36 * - Call Create() to create a new video decoder resource.
37 * - Call Initialize() to initialize it with a 3d graphics context and the
38 * desired codec profile.
39 * - Call Decode() continuously (waiting for each previous call to complete) to
40 * push bitstream buffers to the decoder.
41 * - Call GetPicture() continuously (waiting for each previous call to complete)
42 * to pull decoded pictures from the decoder.
43 * - Call Flush() to signal end of stream to the decoder and perform shutdown
44 * when it completes.
45 * - Call Reset() to quickly stop the decoder (e.g. to implement Seek) and wait
46 * for the callback before restarting decoding at another point.
47 * - To destroy the decoder, the plugin should release all of its references to
48 * it. Any pending callbacks will abort before the decoder is destroyed.
50 * Available video codecs vary by platform.
51 * All: theora, vorbis, vp8.
52 * Chrome and ChromeOS: aac, h264.
53 * ChromeOS: mpeg4.
55 struct PPB_VideoDecoder_0_2 { /* dev */
56 /**
57 * Creates a new video decoder resource.
59 * @param[in] instance A <code>PP_Instance</code> identifying the instance
60 * with the video decoder.
62 * @return A <code>PP_Resource</code> corresponding to a video decoder if
63 * successful or 0 otherwise.
65 PP_Resource (*Create)(PP_Instance instance);
66 /**
67 * Determines if the given resource is a video decoder.
69 * @param[in] resource A <code>PP_Resource</code> identifying a resource.
71 * @return <code>PP_TRUE</code> if the resource is a
72 * <code>PPB_VideoDecoder</code>, <code>PP_FALSE</code> if the resource is
73 * invalid or some other type.
75 PP_Bool (*IsVideoDecoder)(PP_Resource resource);
76 /**
77 * Initializes a video decoder resource. This should be called after Create()
78 * and before any other functions.
80 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video
81 * decoder.
82 * @param[in] graphics3d_context A <code>PPB_Graphics3D</code> resource to use
83 * during decoding.
84 * @param[in] profile A <code>PP_VideoProfile</code> specifying the video
85 * codec profile.
86 * @param[in] acceleration A <code>PP_HardwareAcceleration</code> specifying
87 * whether to use a hardware accelerated or a software implementation.
88 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
89 * completion.
91 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
92 * Returns PP_ERROR_NOTSUPPORTED if video decoding is not available, or the
93 * requested profile is not supported. In this case, the client may call
94 * Initialize() again with different parameters to find a good configuration.
96 int32_t (*Initialize)(PP_Resource video_decoder,
97 PP_Resource graphics3d_context,
98 PP_VideoProfile profile,
99 PP_HardwareAcceleration acceleration,
100 struct PP_CompletionCallback callback);
102 * Decodes a bitstream buffer. Copies |size| bytes of data from the plugin's
103 * |buffer|. The plugin should wait until the decoder signals completion by
104 * returning PP_OK or by running |callback| before calling Decode() again.
106 * In general, each bitstream buffer should contain a demuxed bitstream frame
107 * for the selected video codec. For example, H264 decoders expect to receive
108 * one AnnexB NAL unit, including the 4 byte start code prefix, while VP8
109 * decoders expect to receive a bitstream frame without the IVF frame header.
111 * If the call to Decode() eventually results in a picture, the |decode_id|
112 * parameter is copied into the returned picture. The plugin can use this to
113 * associate decoded pictures with Decode() calls (e.g. to assign timestamps
114 * or frame numbers to pictures.) This value is opaque to the API so the
115 * plugin is free to pass any value.
117 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video
118 * decoder.
119 * @param[in] decode_id An optional value, chosen by the plugin, that can be
120 * used to associate calls to Decode() with decoded pictures returned by
121 * GetPicture().
122 * @param[in] size Buffer size in bytes.
123 * @param[in] buffer Starting address of buffer.
124 * @param[in] callback A <code>PP_CompletionCallback</code> to be called on
125 * completion.
127 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
128 * Returns PP_ERROR_FAILED if the decoder isn't initialized or if a Flush()
129 * or Reset() call is pending.
130 * Returns PP_ERROR_INPROGRESS if there is another Decode() call pending.
131 * Returns PP_ERROR_NOMEMORY if a bitstream buffer can't be created.
132 * Returns PP_ERROR_ABORTED when Reset() is called while Decode() is pending.
134 int32_t (*Decode)(PP_Resource video_decoder,
135 uint32_t decode_id,
136 uint32_t size,
137 const void* buffer,
138 struct PP_CompletionCallback callback);
140 * Gets the next picture from the decoder. The picture is valid after the
141 * decoder signals completion by returning PP_OK or running |callback|. The
142 * plugin can call GetPicture() again after the decoder signals completion.
143 * When the plugin is finished using the picture, it should return it to the
144 * system by calling RecyclePicture().
146 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video
147 * decoder.
148 * @param[out] picture A <code>PP_VideoPicture</code> to hold the decoded
149 * picture.
150 * @param[in] callback A <code>PP_CompletionCallback</code> to be called on
151 * completion.
153 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
154 * Returns PP_ERROR_FAILED if the decoder isn't initialized or if a Reset()
155 * call is pending.
156 * Returns PP_ERROR_INPROGRESS if there is another GetPicture() call pending.
157 * Returns PP_ERROR_ABORTED when Reset() is called, or if a call to Flush()
158 * completes while GetPicture() is pending.
160 int32_t (*GetPicture)(PP_Resource video_decoder,
161 struct PP_VideoPicture* picture,
162 struct PP_CompletionCallback callback);
164 * Recycles a picture that the plugin has received from the decoder.
165 * The plugin should call this as soon as it has finished using the texture so
166 * the decoder can decode more pictures.
168 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video
169 * decoder.
170 * @param[in] picture A <code>PP_VideoPicture</code> to return to
171 * the decoder.
173 void (*RecyclePicture)(PP_Resource video_decoder,
174 const struct PP_VideoPicture* picture);
176 * Flushes the decoder. The plugin should call Flush() when it reaches the
177 * end of its video stream in order to stop cleanly. The decoder will run any
178 * pending Decode() call to completion. The plugin should make no further
179 * calls to the decoder other than GetPicture() and RecyclePicture() until
180 * the decoder signals completion by running |callback|. Just before
181 * completion, any pending GetPicture() call will complete by running its
182 * callback with result PP_ERROR_ABORTED to signal that no more pictures are
183 * available. Any pictures held by the plugin remain valid during and after
184 * the flush and should be recycled back to the decoder.
186 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video
187 * decoder.
188 * @param[in] callback A <code>PP_CompletionCallback</code> to be called on
189 * completion.
191 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
192 * Returns PP_ERROR_FAILED if the decoder isn't initialized.
194 int32_t (*Flush)(PP_Resource video_decoder,
195 struct PP_CompletionCallback callback);
197 * Resets the decoder as quickly as possible. The plugin can call Reset() to
198 * skip to another position in the video stream. After Reset() returns, any
199 * pending calls to Decode() and GetPicture()) abort, causing their callbacks
200 * to run with PP_ERROR_ABORTED. The plugin should not make further calls to
201 * the decoder other than RecyclePicture() until the decoder signals
202 * completion by running |callback|. Any pictures held by the plugin remain
203 * valid during and after the reset and should be recycled back to the
204 * decoder.
206 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video
207 * decoder.
208 * @param[in] callback A <code>PP_CompletionCallback</code> to be called on
209 * completion.
211 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
212 * Returns PP_ERROR_FAILED if the decoder isn't initialized.
214 int32_t (*Reset)(PP_Resource video_decoder,
215 struct PP_CompletionCallback callback);
218 struct PPB_VideoDecoder_0_1 { /* dev */
219 PP_Resource (*Create)(PP_Instance instance);
220 PP_Bool (*IsVideoDecoder)(PP_Resource resource);
221 int32_t (*Initialize)(PP_Resource video_decoder,
222 PP_Resource graphics3d_context,
223 PP_VideoProfile profile,
224 PP_Bool allow_software_fallback,
225 struct PP_CompletionCallback callback);
226 int32_t (*Decode)(PP_Resource video_decoder,
227 uint32_t decode_id,
228 uint32_t size,
229 const void* buffer,
230 struct PP_CompletionCallback callback);
231 int32_t (*GetPicture)(PP_Resource video_decoder,
232 struct PP_VideoPicture* picture,
233 struct PP_CompletionCallback callback);
234 void (*RecyclePicture)(PP_Resource video_decoder,
235 const struct PP_VideoPicture* picture);
236 int32_t (*Flush)(PP_Resource video_decoder,
237 struct PP_CompletionCallback callback);
238 int32_t (*Reset)(PP_Resource video_decoder,
239 struct PP_CompletionCallback callback);
242 * @}
245 #endif /* PPAPI_C_PPB_VIDEO_DECODER_H_ */