| 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_media_codec_video_decoder.idl modified Thu Apr 10 18:28:10 2014. */ |
| 7 |
| 8 #ifndef PPAPI_C_PPB_MEDIA_CODEC_VIDEO_DECODER_H_ |
| 9 #define PPAPI_C_PPB_MEDIA_CODEC_VIDEO_DECODER_H_ |
| 10 |
| 11 #include "ppapi/c/pp_bool.h" |
| 12 #include "ppapi/c/pp_completion_callback.h" |
| 13 #include "ppapi/c/pp_instance.h" |
| 14 #include "ppapi/c/pp_macros.h" |
| 15 #include "ppapi/c/pp_media_codec.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_MEDIACODECVIDEODECODER_INTERFACE_0_1 \ |
| 21 "PPB_MediaCodecVideoDecoder;0.1" /* dev */ |
| 22 /** |
| 23 * @file |
| 24 * This file defines the <code>PPB_MediaCodecVideoDecoder</code> interface. |
| 25 */ |
| 26 |
| 27 |
| 28 /** |
| 29 * @addtogroup Interfaces |
| 30 * @{ |
| 31 */ |
| 32 /** |
| 33 * Video decoder interface. |
| 34 * |
| 35 * Typical usage: |
| 36 * - Call Create() to create a new video decoder resource. |
| 37 * - Call Initialize() to initialize it with a 3d graphics context. |
| 38 * - Call Decode() to send a bitstream buffer to the decoder. |
| 39 * - Call GetPictureBuffer() to get the next decoded picture. |
| 40 * - To signal end of stream to the decoder: call Flush() and wait for the |
| 41 * callback. |
| 42 * - To reset the decoder (e.g. to implement Seek): call Reset() and wait for |
| 43 * the callback. |
| 44 */ |
| 45 struct PPB_MediaCodecVideoDecoder_0_1 { /* dev */ |
| 46 /** |
| 47 * Creates a new video decoder resource. |
| 48 * |
| 49 * @param[in] instance A <code>PP_Instance</code> identifying the instance |
| 50 * with the video decoder. |
| 51 * |
| 52 * @return A <code>PP_Resource</code> corresponding to a video decoder if |
| 53 * successful or 0 otherwise. |
| 54 */ |
| 55 PP_Resource (*Create)(PP_Instance instance); |
| 56 /** |
| 57 * Determines if the given resource is a video decoder. |
| 58 * |
| 59 * @param[in] resource A <code>PP_Resource</code> identifying a resource. |
| 60 * |
| 61 * @return <code>PP_TRUE</code> if the resource is a |
| 62 * <code>PPB_MediaCodecVideoDecoder</code>, <code>PP_FALSE</code> if the |
| 63 * resource is invalid or some other type. |
| 64 */ |
| 65 PP_Bool (*IsMediaCodecVideoDecoder)(PP_Resource resource); |
| 66 /** |
| 67 * Initializes a video decoder resource. This should only be called once, |
| 68 * after Create() and before any other functions. Video decoding is not |
| 69 * supported on all platforms. |
| 70 * |
| 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_MediaCodec_Profile</code> specifying the |
| 76 * video stream profile. |
| 77 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon |
| 78 * completion. |
| 79 * |
| 80 * @return An int32_t containing an error code from <code>pp_errors.h</code>. |
| 81 * Returns PP_ERROR_NOTSUPPORTED here or to the callback if video decoding is |
| 82 * not available. |
| 83 */ |
| 84 int32_t (*Initialize)(PP_Resource video_decoder, |
| 85 PP_Resource context, |
| 86 PP_MediaCodec_Profile profile, |
| 87 struct PP_CompletionCallback callback); |
| 88 /** |
| 89 * Decodes a bitstream buffer. Copies |size| bytes of data from the plugin's |
| 90 * |buffer|. The plugin should maintain the buffer until the callback is run. |
| 91 * If the bitstream buffer results in a picture, the |picture_id| parameter |
| 92 * will be copied into the picture buffer that is returned by |
| 93 * GetPictureBuffer(). This can be used to associate Decode calls with decoded |
| 94 * pictures (e.g. to associate timestamps with pictures.) The plugin can use |
| 95 * the callback to throttle calls to Decode to some constant number to avoid |
| 96 * over consuming system resources. |
| 97 * |
| 98 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video |
| 99 * decoder. |
| 100 * @param[in] picture_id An identifier that can be used to associate calls to |
| 101 * Decode() with decoded pictures returned by GetPictureBuffer(). |
| 102 * @param[in] size Buffer size in bytes. |
| 103 * @param[in] buffer Starting address of buffer. |
| 104 * @param[in] callback A <code>PP_CompletionCallback</code> to be called when |
| 105 * the decoder has finished reading the buffer. |
| 106 * |
| 107 * @return An int32_t containing an error code from <code>pp_errors.h</code>. |
| 108 */ |
| 109 int32_t (*Decode)(PP_Resource video_decoder, |
| 110 uint32_t picture_id, |
| 111 uint32_t size, |
| 112 const void* buffer, |
| 113 struct PP_CompletionCallback callback); |
| 114 /** |
| 115 * Gets the next picture buffer from the decoder. When the plugin is finished |
| 116 * with the picture, it should call RecyclePictureBuffer() to return it to the |
| 117 * system. The plugin can call GetPictureBuffer() again at any time after |
| 118 * |callback| is called. In particular, the plugin can call it from within |
| 119 * |callback| to request another picture. |
| 120 * |
| 121 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video |
| 122 * decoder. |
| 123 * @param[out] picture_buffer A <code>PP_MediaCodec_PictureBuffer</code> to |
| 124 * hold the decoded picture. |
| 125 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon |
| 126 * completion. |picture_buffer| will describe the buffer if successful. |
| 127 * |
| 128 * @return An int32_t containing an error code from <code>pp_errors.h</code>. |
| 129 */ |
| 130 int32_t (*GetPictureBuffer)( |
| 131 PP_Resource video_decoder, |
| 132 struct PP_MediaCodec_PictureBuffer* picture_buffer, |
| 133 struct PP_CompletionCallback callback); |
| 134 /** |
| 135 * Recycles a picture buffer that the plugin has received from the decoder. |
| 136 * The plugin should call this as soon as it has finished using the texture so |
| 137 * the system can decode more pictures. |
| 138 * |
| 139 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video |
| 140 * decoder. |
| 141 * @param[in] picture_buffer A <code>PP_MediaCodec_PictureBuffer</code> to |
| 142 * return to the system. |
| 143 */ |
| 144 void (*RecyclePictureBuffer)( |
| 145 PP_Resource video_decoder, |
| 146 const struct PP_MediaCodec_PictureBuffer* picture_buffer); |
| 147 /** |
| 148 * Flushes the decoder. Any pending calls to the decoder are completed, |
| 149 * including callbacks to the plugin. Once flushed, the decoder will call |
| 150 * |callback|. While flushing, the plugin should not make any calls to the |
| 151 * decoder. The plugin should call Flush() to signal end of stream to the |
| 152 * decoder. |
| 153 * |
| 154 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video |
| 155 * decoder. |
| 156 * @param[in] callback A <code>PP_CompletionCallback</code> to be called when |
| 157 * flushing is complete. |
| 158 * |
| 159 * @return An int32_t containing an error code from <code>pp_errors.h</code>. |
| 160 */ |
| 161 int32_t (*Flush)(PP_Resource video_decoder, |
| 162 struct PP_CompletionCallback callback); |
| 163 /** |
| 164 * Resets the decoder as quickly as possible. Pending calls are aborted, |
| 165 * causing callbacks to run with PP_ERROR_ABORTED. The decoder is put back |
| 166 * into a state ready to receive further Decode calls and |callback| is |
| 167 * called. While resetting, the plugin should not make any calls to the |
| 168 * decoder. The plugin can use Reset() when it needs to seek to a new position |
| 169 * in the stream. |
| 170 * |
| 171 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video |
| 172 * decoder. |
| 173 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon |
| 174 * completion. |
| 175 * |
| 176 * @return An int32_t containing an error code from <code>pp_errors.h</code>. |
| 177 */ |
| 178 int32_t (*Reset)(PP_Resource video_decoder, |
| 179 struct PP_CompletionCallback callback); |
| 180 }; |
| 181 /** |
| 182 * @} |
| 183 */ |
| 184 |
| 185 #endif /* PPAPI_C_PPB_MEDIA_CODEC_VIDEO_DECODER_H_ */ |
| 186 |
| OLD | NEW |