| OLD | NEW |
| (Empty) | |
| 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 Tue May 6 05:19:45 2014. */ |
| 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" |
| 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" |
| 19 |
| 20 #define PPB_VIDEODECODER_INTERFACE_0_1 "PPB_VideoDecoder;0.1" /* dev */ |
| 21 /** |
| 22 * @file |
| 23 * This file defines the <code>PPB_VideoDecoder</code> interface. |
| 24 */ |
| 25 |
| 26 |
| 27 /** |
| 28 * @addtogroup Interfaces |
| 29 * @{ |
| 30 */ |
| 31 /** |
| 32 * Video decoder interface. |
| 33 * |
| 34 * Typical usage: |
| 35 * - Call Create() to create a new video decoder resource. |
| 36 * - Call Initialize() to initialize it with a 3d graphics context and the |
| 37 * desired codec profile. |
| 38 * - Call Decode() continuously (waiting for each previous call to complete) to |
| 39 * push bitstream buffers to the decoder. |
| 40 * - Call GetPicture() continuously (waiting for each previous call to complete) |
| 41 * to pull decoded pictures from the decoder. |
| 42 * - Call Flush() to signal end of stream to the decoder and perform shutdown |
| 43 * when it completes. |
| 44 * - Call Reset() to quickly stop the decoder (e.g. to implement Seek) and wait |
| 45 * for the callback before restarting decoding at another point. |
| 46 * - To destroy the decoder, the plugin should release all of its references to |
| 47 * it. Any pending callbacks will abort before the decoder is destroyed. |
| 48 * |
| 49 * Available video codecs vary by platform. |
| 50 * All: theora, vorbis, vp8. |
| 51 * Chrome and ChromeOS: aac, h264. |
| 52 * ChromeOS: mpeg4. |
| 53 */ |
| 54 struct PPB_VideoDecoder_0_1 { /* dev */ |
| 55 /** |
| 56 * Creates a new video decoder resource. |
| 57 * |
| 58 * @param[in] instance A <code>PP_Instance</code> identifying the instance |
| 59 * with the video decoder. |
| 60 * |
| 61 * @return A <code>PP_Resource</code> corresponding to a video decoder if |
| 62 * successful or 0 otherwise. |
| 63 */ |
| 64 PP_Resource (*Create)(PP_Instance instance); |
| 65 /** |
| 66 * Determines if the given resource is a video decoder. |
| 67 * |
| 68 * @param[in] resource A <code>PP_Resource</code> identifying a resource. |
| 69 * |
| 70 * @return <code>PP_TRUE</code> if the resource is a |
| 71 * <code>PPB_VideoDecoder</code>, <code>PP_FALSE</code> if the resource is |
| 72 * invalid or some other type. |
| 73 */ |
| 74 PP_Bool (*IsVideoDecoder)(PP_Resource resource); |
| 75 /** |
| 76 * Initializes a video decoder resource. This should be called after Create() |
| 77 * and before any other functions. |
| 78 * |
| 79 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video |
| 80 * decoder. |
| 81 * @param[in] graphics3d_context A <code>PPB_Graphics3D</code> resource to use |
| 82 * during decoding. |
| 83 * @param[in] profile A <code>PP_VideoProfile</code> specifying the video |
| 84 * codec profile. |
| 85 * @param[in] allow_software_fallback A <code>PP_Bool</code> specifying |
| 86 * whether the decoder can fall back to software decoding if a suitable |
| 87 * hardware decoder isn't available. |
| 88 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon |
| 89 * completion. |
| 90 * |
| 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. |
| 95 */ |
| 96 int32_t (*Initialize)(PP_Resource video_decoder, |
| 97 PP_Resource graphics3d_context, |
| 98 PP_VideoProfile profile, |
| 99 PP_Bool allow_software_fallback, |
| 100 struct PP_CompletionCallback callback); |
| 101 /** |
| 102 * Decodes a bitstream buffer. Copies |size| bytes of data from the plugin's |
| 103 * |buffer|. The plugin should maintain the buffer and not call Decode() again |
| 104 * until the decoder signals completion by returning PP_OK or by running |
| 105 * |callback|. |
| 106 * |
| 107 * In general, each bitstream buffer should contain a demuxed bitstream frame |
| 108 * for the selected video codec. For example, H264 decoders expect to receive |
| 109 * one AnnexB NAL unit, including the 4 byte start code prefix, while VP8 |
| 110 * decoders expect to receive a bitstream frame without the IVF frame header. |
| 111 * |
| 112 * If the call to Decode() eventually results in a picture, the |decode_id| |
| 113 * parameter is copied into the returned picture. The plugin can use this to |
| 114 * associate decoded pictures with Decode() calls (e.g. to assign timestamps |
| 115 * or frame numbers to pictures.) This value is opaque to the API so the |
| 116 * plugin is free to pass any value. |
| 117 * |
| 118 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video |
| 119 * decoder. |
| 120 * @param[in] decode_id An optional value, chosen by the plugin, that can be |
| 121 * used to associate calls to Decode() with decoded pictures returned by |
| 122 * GetPicture(). |
| 123 * @param[in] size Buffer size in bytes. |
| 124 * @param[in] buffer Starting address of buffer. |
| 125 * @param[in] callback A <code>PP_CompletionCallback</code> to be called on |
| 126 * completion. |
| 127 * |
| 128 * @return An int32_t containing an error code from <code>pp_errors.h</code>. |
| 129 */ |
| 130 int32_t (*Decode)(PP_Resource video_decoder, |
| 131 uint32_t decode_id, |
| 132 uint32_t size, |
| 133 const void* buffer, |
| 134 struct PP_CompletionCallback callback); |
| 135 /** |
| 136 * Gets the next picture from the decoder. The picture is valid after the |
| 137 * decoder signals completion by returning PP_OK or running |callback|. The |
| 138 * plugin can call GetPicture() again after the decoder signals completion. |
| 139 * When the plugin is finished using the picture, it should return it to the |
| 140 * system by calling RecyclePicture(). |
| 141 * |
| 142 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video |
| 143 * decoder. |
| 144 * @param[out] picture A <code>PP_VideoPicture</code> to hold the decoded |
| 145 * picture. |
| 146 * @param[in] callback A <code>PP_CompletionCallback</code> to be called on |
| 147 * completion. |
| 148 * |
| 149 * @return An int32_t containing an error code from <code>pp_errors.h</code>. |
| 150 * Returns PP_OK if a picture is available. |
| 151 * Returns PP_ERROR_ABORTED when Reset() is called, or if a call to Flush() |
| 152 * completes while GetPicture() is pending. |
| 153 */ |
| 154 int32_t (*GetPicture)(PP_Resource video_decoder, |
| 155 struct PP_VideoPicture* picture, |
| 156 struct PP_CompletionCallback callback); |
| 157 /** |
| 158 * Recycles a picture that the plugin has received from the decoder. |
| 159 * The plugin should call this as soon as it has finished using the texture so |
| 160 * the decoder can decode more pictures. |
| 161 * |
| 162 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video |
| 163 * decoder. |
| 164 * @param[in] picture A <code>PP_VideoPicture</code> to return to |
| 165 * the decoder. |
| 166 */ |
| 167 void (*RecyclePicture)(PP_Resource video_decoder, |
| 168 const struct PP_VideoPicture* picture); |
| 169 /** |
| 170 * Flushes the decoder. The plugin should call this when it reaches the end of |
| 171 * its video stream in order to stop cleanly. The decoder will run all pending |
| 172 * calls to completion. The plugin should make no further calls to the decoder |
| 173 * other than GetPicture() and RecyclePicture() until the decoder signals |
| 174 * completion by running the callback. Just before completion, any pending |
| 175 * GetPicture() call will complete by running the callback with result |
| 176 * PP_ERROR_ABORTED to signal that no more pictures are available. |
| 177 * |
| 178 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video |
| 179 * decoder. |
| 180 * @param[in] callback A <code>PP_CompletionCallback</code> to be called on |
| 181 * completion. |
| 182 * |
| 183 * @return An int32_t containing an error code from <code>pp_errors.h</code>. |
| 184 */ |
| 185 int32_t (*Flush)(PP_Resource video_decoder, |
| 186 struct PP_CompletionCallback callback); |
| 187 /** |
| 188 * Resets the decoder as quickly as possible. The plugin can call Reset() to |
| 189 * skip to another position in the video stream. Pending calls to Decode() and |
| 190 * GetPicture()) are immediately aborted, causing their callbacks to run with |
| 191 * PP_ERROR_ABORTED. The plugin should not make any further calls to the |
| 192 * decoder until the decoder signals completion by running |callback|. |
| 193 * |
| 194 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video |
| 195 * decoder. |
| 196 * @param[in] callback A <code>PP_CompletionCallback</code> to be called on |
| 197 * completion. |
| 198 * |
| 199 * @return An int32_t containing an error code from <code>pp_errors.h</code>. |
| 200 */ |
| 201 int32_t (*Reset)(PP_Resource video_decoder, |
| 202 struct PP_CompletionCallback callback); |
| 203 }; |
| 204 /** |
| 205 * @} |
| 206 */ |
| 207 |
| 208 #endif /* PPAPI_C_PPB_VIDEO_DECODER_H_ */ |
| 209 |
| OLD | NEW |