Move implementation of load methods to chromium layer
[chromium-blink-merge.git] / ppapi / api / ppb_video_decoder.idl
blobc8c69454f1582eed8d36d9f27fc94c856a6b30ea
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
19 /**
20 * Video decoder interface.
22 * Typical usage:
23 * - Call Create() to create a new video decoder resource.
24 * - Call Initialize() to initialize it with a 3d graphics context and the
25 * desired codec profile.
26 * - Call Decode() continuously (waiting for each previous call to complete) to
27 * push bitstream buffers to the decoder.
28 * - Call GetPicture() continuously (waiting for each previous call to complete)
29 * to pull decoded pictures from the decoder.
30 * - Call Flush() to signal end of stream to the decoder and perform shutdown
31 * when it completes.
32 * - Call Reset() to quickly stop the decoder (e.g. to implement Seek) and wait
33 * for the callback before restarting decoding at another point.
34 * - To destroy the decoder, the plugin should release all of its references to
35 * it. Any pending callbacks will abort before the decoder is destroyed.
37 * Available video codecs vary by platform.
38 * All: theora, vorbis, vp8.
39 * Chrome and ChromeOS: aac, h264.
40 * ChromeOS: mpeg4.
42 interface PPB_VideoDecoder {
43 /**
44 * Creates a new video decoder resource.
46 * @param[in] instance A <code>PP_Instance</code> identifying the instance
47 * with the video decoder.
49 * @return A <code>PP_Resource</code> corresponding to a video decoder if
50 * successful or 0 otherwise.
52 PP_Resource Create(
53 [in] PP_Instance instance);
55 /**
56 * Determines if the given resource is a video decoder.
58 * @param[in] resource A <code>PP_Resource</code> identifying a resource.
60 * @return <code>PP_TRUE</code> if the resource is a
61 * <code>PPB_VideoDecoder</code>, <code>PP_FALSE</code> if the resource is
62 * invalid or some other type.
64 PP_Bool IsVideoDecoder(
65 [in] PP_Resource resource);
67 /**
68 * Initializes a video decoder resource. This should be called after Create()
69 * and before any other functions.
71 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video
72 * decoder.
73 * @param[in] graphics3d_context A <code>PPB_Graphics3D</code> resource to use
74 * during decoding.
75 * @param[in] profile A <code>PP_VideoProfile</code> specifying the video
76 * codec profile.
77 * @param[in] allow_software_fallback A <code>PP_Bool</code> specifying
78 * whether the decoder can fall back to software decoding if a suitable
79 * hardware decoder isn't available.
80 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
81 * completion.
83 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
84 * Returns PP_ERROR_NOTSUPPORTED if video decoding is not available, or the
85 * requested profile is not supported. In this case, the client may call
86 * Initialize() again with different parameters to find a good configuration.
88 int32_t Initialize(
89 [in] PP_Resource video_decoder,
90 [in] PP_Resource graphics3d_context,
91 [in] PP_VideoProfile profile,
92 [in] PP_Bool allow_software_fallback,
93 [in] PP_CompletionCallback callback);
95 /**
96 * Initializes a video decoder resource. This should be called after Create()
97 * and before any other functions.
99 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video
100 * decoder.
101 * @param[in] graphics3d_context A <code>PPB_Graphics3D</code> resource to use
102 * during decoding.
103 * @param[in] profile A <code>PP_VideoProfile</code> specifying the video
104 * codec profile.
105 * @param[in] acceleration A <code>PP_HardwareAcceleration</code> specifying
106 * whether to use a hardware accelerated or a software implementation.
107 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
108 * completion.
110 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
111 * Returns PP_ERROR_NOTSUPPORTED if video decoding is not available, or the
112 * requested profile is not supported. In this case, the client may call
113 * Initialize() again with different parameters to find a good configuration.
115 [version = 0.2]
116 int32_t Initialize(
117 [in] PP_Resource video_decoder,
118 [in] PP_Resource graphics3d_context,
119 [in] PP_VideoProfile profile,
120 [in] PP_HardwareAcceleration acceleration,
121 [in] PP_CompletionCallback callback);
124 * Decodes a bitstream buffer. Copies |size| bytes of data from the plugin's
125 * |buffer|. The plugin should wait until the decoder signals completion by
126 * returning PP_OK or by running |callback| before calling Decode() again.
128 * In general, each bitstream buffer should contain a demuxed bitstream frame
129 * for the selected video codec. For example, H264 decoders expect to receive
130 * one AnnexB NAL unit, including the 4 byte start code prefix, while VP8
131 * decoders expect to receive a bitstream frame without the IVF frame header.
133 * If the call to Decode() eventually results in a picture, the |decode_id|
134 * parameter is copied into the returned picture. The plugin can use this to
135 * associate decoded pictures with Decode() calls (e.g. to assign timestamps
136 * or frame numbers to pictures.) This value is opaque to the API so the
137 * plugin is free to pass any value.
139 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video
140 * decoder.
141 * @param[in] decode_id An optional value, chosen by the plugin, that can be
142 * used to associate calls to Decode() with decoded pictures returned by
143 * GetPicture().
144 * @param[in] size Buffer size in bytes.
145 * @param[in] buffer Starting address of buffer.
146 * @param[in] callback A <code>PP_CompletionCallback</code> to be called on
147 * completion.
149 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
150 * Returns PP_ERROR_FAILED if the decoder isn't initialized or if a Flush()
151 * or Reset() call is pending.
152 * Returns PP_ERROR_INPROGRESS if there is another Decode() call pending.
153 * Returns PP_ERROR_NOMEMORY if a bitstream buffer can't be created.
154 * Returns PP_ERROR_ABORTED when Reset() is called while Decode() is pending.
156 int32_t Decode(
157 [in] PP_Resource video_decoder,
158 [in] uint32_t decode_id,
159 [in] uint32_t size,
160 [in] mem_t buffer,
161 [in] PP_CompletionCallback callback);
164 * Gets the next picture from the decoder. The picture is valid after the
165 * decoder signals completion by returning PP_OK or running |callback|. The
166 * plugin can call GetPicture() again after the decoder signals completion.
167 * When the plugin is finished using the picture, it should return it to the
168 * system by calling RecyclePicture().
170 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video
171 * decoder.
172 * @param[out] picture A <code>PP_VideoPicture</code> to hold the decoded
173 * picture.
174 * @param[in] callback A <code>PP_CompletionCallback</code> to be called on
175 * completion.
177 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
178 * Returns PP_ERROR_FAILED if the decoder isn't initialized or if a Reset()
179 * call is pending.
180 * Returns PP_ERROR_INPROGRESS if there is another GetPicture() call pending.
181 * Returns PP_ERROR_ABORTED when Reset() is called, or if a call to Flush()
182 * completes while GetPicture() is pending.
184 int32_t GetPicture(
185 [in] PP_Resource video_decoder,
186 [out] PP_VideoPicture_0_1 picture,
187 [in] PP_CompletionCallback callback);
190 * Gets the next picture from the decoder. The picture is valid after the
191 * decoder signals completion by returning PP_OK or running |callback|. The
192 * plugin can call GetPicture() again after the decoder signals completion.
193 * When the plugin is finished using the picture, it should return it to the
194 * system by calling RecyclePicture().
196 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video
197 * decoder.
198 * @param[out] picture A <code>PP_VideoPicture</code> to hold the decoded
199 * picture.
200 * @param[in] callback A <code>PP_CompletionCallback</code> to be called on
201 * completion.
203 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
204 * Returns PP_ERROR_FAILED if the decoder isn't initialized or if a Reset()
205 * call is pending.
206 * Returns PP_ERROR_INPROGRESS if there is another GetPicture() call pending.
207 * Returns PP_ERROR_ABORTED when Reset() is called, or if a call to Flush()
208 * completes while GetPicture() is pending.
210 [version = 1.0]
211 int32_t GetPicture(
212 [in] PP_Resource video_decoder,
213 [out] PP_VideoPicture picture,
214 [in] PP_CompletionCallback callback);
217 * Recycles a picture that the plugin has received from the decoder.
218 * The plugin should call this as soon as it has finished using the texture so
219 * the decoder can decode more pictures.
221 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video
222 * decoder.
223 * @param[in] picture A <code>PP_VideoPicture</code> to return to
224 * the decoder.
226 void RecyclePicture(
227 [in] PP_Resource video_decoder,
228 [in] PP_VideoPicture picture);
231 * Flushes the decoder. The plugin should call Flush() when it reaches the
232 * end of its video stream in order to stop cleanly. The decoder will run any
233 * pending Decode() call to completion. The plugin should make no further
234 * calls to the decoder other than GetPicture() and RecyclePicture() until
235 * the decoder signals completion by running |callback|. Just before
236 * completion, any pending GetPicture() call will complete by running its
237 * callback with result PP_ERROR_ABORTED to signal that no more pictures are
238 * available. Any pictures held by the plugin remain valid during and after
239 * the flush and should be recycled back to the decoder.
241 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video
242 * decoder.
243 * @param[in] callback A <code>PP_CompletionCallback</code> to be called on
244 * completion.
246 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
247 * Returns PP_ERROR_FAILED if the decoder isn't initialized.
249 int32_t Flush(
250 [in] PP_Resource video_decoder,
251 [in] PP_CompletionCallback callback);
254 * Resets the decoder as quickly as possible. The plugin can call Reset() to
255 * skip to another position in the video stream. After Reset() returns, any
256 * pending calls to Decode() and GetPicture()) abort, causing their callbacks
257 * to run with PP_ERROR_ABORTED. The plugin should not make further calls to
258 * the decoder other than RecyclePicture() until the decoder signals
259 * completion by running |callback|. Any pictures held by the plugin remain
260 * valid during and after the reset and should be recycled back to the
261 * decoder.
263 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video
264 * decoder.
265 * @param[in] callback A <code>PP_CompletionCallback</code> to be called on
266 * completion.
268 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
269 * Returns PP_ERROR_FAILED if the decoder isn't initialized.
271 int32_t Reset(
272 [in] PP_Resource video_decoder,
273 [in] PP_CompletionCallback callback);