| 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 /** |
| 7 * This file defines the <code>PPB_MediaCodecVideoDecoder</code> interface. |
| 8 */ |
| 9 |
| 10 [generate_thunk] |
| 11 |
| 12 label Chrome { |
| 13 [channel=dev] M36 = 0.1 |
| 14 }; |
| 15 |
| 16 /** |
| 17 * Video decoder interface. |
| 18 * |
| 19 * Typical usage: |
| 20 * - Call Create() to create a new video decoder resource. |
| 21 * - Call Initialize() to initialize it with a 3d graphics context and the |
| 22 * desired codec profile. |
| 23 * - Call Decode() to send a bitstream buffer to the decoder. |
| 24 * - Call GetPicture() to get the next decoded picture. |
| 25 * - Call Flush() to signal end of stream to the decoder and perform shutdown |
| 26 * when it completes. |
| 27 * - To reset the decoder (e.g. to implement Seek), call Reset() and wait for |
| 28 * the callback. |
| 29 * - To destroy the decoder, the plugin should release all of its references to |
| 30 * it. To avoid receiving aborted callbacks, call Flush() and wait for |
| 31 * completion first. |
| 32 */ |
| 33 interface PPB_MediaCodecVideoDecoder { |
| 34 /** |
| 35 * Creates a new video decoder resource. |
| 36 * |
| 37 * @param[in] instance A <code>PP_Instance</code> identifying the instance |
| 38 * with the video decoder. |
| 39 * |
| 40 * @return A <code>PP_Resource</code> corresponding to a video decoder if |
| 41 * successful or 0 otherwise. |
| 42 */ |
| 43 PP_Resource Create( |
| 44 [in] PP_Instance instance); |
| 45 |
| 46 /** |
| 47 * Determines if the given resource is a video decoder. |
| 48 * |
| 49 * @param[in] resource A <code>PP_Resource</code> identifying a resource. |
| 50 * |
| 51 * @return <code>PP_TRUE</code> if the resource is a |
| 52 * <code>PPB_MediaCodecVideoDecoder</code>, <code>PP_FALSE</code> if the |
| 53 * resource is invalid or some other type. |
| 54 */ |
| 55 PP_Bool IsMediaCodecVideoDecoder( |
| 56 [in] PP_Resource resource); |
| 57 |
| 58 /** |
| 59 * Initializes a video decoder resource. This should only be called once, |
| 60 * after Create() and before any other functions. |
| 61 * |
| 62 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video |
| 63 * decoder. |
| 64 * @param[in] graphics3d_context A <code>PPB_Graphics3D</code> resource to use |
| 65 * during decoding. |
| 66 * @param[in] profile A <code>PP_MediaCodec_VideoProfile</code> specifying the |
| 67 * video's codec profile. |
| 68 * @param[in] allow_software_fallback A <code>PP_Bool</code> specifying |
| 69 * whether the decoder can fall back to software decoding if a suitable |
| 70 * hardware decoder isn't available. |
| 71 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon |
| 72 * completion. |
| 73 * |
| 74 * @return An int32_t containing an error code from <code>pp_errors.h</code>. |
| 75 * Returns PP_ERROR_NOTSUPPORTED if video decoding is not available, or the |
| 76 * requested profile is not supported. |
| 77 */ |
| 78 int32_t Initialize( |
| 79 [in] PP_Resource video_decoder, |
| 80 [in] PP_Resource graphics3d_context, |
| 81 [in] PP_MediaCodec_VideoProfile profile, |
| 82 [in] PP_Bool allow_software_fallback, |
| 83 [in] PP_CompletionCallback callback); |
| 84 |
| 85 /** |
| 86 * Decodes a bitstream buffer. Copies |size| bytes of data from the plugin's |
| 87 * |buffer|. The plugin should maintain the buffer and not call Decode() again |
| 88 * until the decoder signals completion by returning PP_OK or by running |
| 89 * |callback|. |
| 90 * If the call to Decode() eventually results in a picture, the |decode_id| |
| 91 * parameter is copied into the returned picture. The plugin can use this to |
| 92 * associate decoded pictures with Decode() calls (e.g. to assign timestamps |
| 93 * or frame numbers to pictures.) This value is opaque to the API so the |
| 94 * plugin is free to pass any value. |
| 95 * |
| 96 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video |
| 97 * decoder. |
| 98 * @param[in] decode_id An optional value, chosen by the plugin, that can be |
| 99 * used to associate calls to Decode() with decoded pictures returned by |
| 100 * GetPicture(). |
| 101 * @param[in] size Buffer size in bytes. |
| 102 * @param[in] buffer Starting address of buffer. |
| 103 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon |
| 104 * completion. |
| 105 * |
| 106 * @return An int32_t containing an error code from <code>pp_errors.h</code>. |
| 107 */ |
| 108 int32_t Decode( |
| 109 [in] PP_Resource video_decoder, |
| 110 [in] uint32_t decode_id, |
| 111 [in] uint32_t size, |
| 112 [in] mem_t buffer, |
| 113 [in] PP_CompletionCallback callback); |
| 114 |
| 115 /** |
| 116 * Gets the next picture from the decoder. The picture is valid after the |
| 117 * decoder signals completion by returning PP_OK or running |callback|. The |
| 118 * plugin can call GetPicture() again after the decoder signals completion. |
| 119 * When the plugin is finished using the picture, it should return it to the |
| 120 * system by calling RecyclePicture(). |
| 121 * |
| 122 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video |
| 123 * decoder. |
| 124 * @param[out] picture A <code>PP_MediaCodec_Picture</code> to hold the |
| 125 * decoded picture. |
| 126 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon |
| 127 * completion. |
| 128 * |
| 129 * @return An int32_t containing an error code from <code>pp_errors.h</code>. |
| 130 */ |
| 131 int32_t GetPicture( |
| 132 [in] PP_Resource video_decoder, |
| 133 [out] PP_MediaCodec_Picture picture, |
| 134 [in] PP_CompletionCallback callback); |
| 135 |
| 136 /** |
| 137 * Recycles a picture that the plugin has received from the decoder. |
| 138 * The plugin should call this as soon as it has finished using the texture so |
| 139 * the decoder can decode more pictures. |
| 140 * |
| 141 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video |
| 142 * decoder. |
| 143 * @param[in] picture A <code>PP_MediaCodec_Picture</code> to return to |
| 144 * the decoder. |
| 145 */ |
| 146 void RecyclePicture( |
| 147 [in] PP_Resource video_decoder, |
| 148 [in] PP_MediaCodec_Picture picture); |
| 149 |
| 150 /** |
| 151 * Flushes the decoder. The plugin should call this when it reaches the end of |
| 152 * its video stream in order to stop cleanly. The decoder will run all pending |
| 153 * calls to completion. The plugin should make no calls to the decoder other |
| 154 * than RecyclePicture() until the decoder signals completion by running the |
| 155 * callback. |
| 156 * |
| 157 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video |
| 158 * decoder. |
| 159 * @param[in] callback A <code>PP_CompletionCallback</code> to be called when |
| 160 * flushing is complete. |
| 161 * |
| 162 * @return An int32_t containing an error code from <code>pp_errors.h</code>. |
| 163 */ |
| 164 int32_t Flush( |
| 165 [in] PP_Resource video_decoder, |
| 166 [in] PP_CompletionCallback callback); |
| 167 |
| 168 /** |
| 169 * Resets the decoder as quickly as possible. The plugin can call Reset to |
| 170 * skip to another position in the video stream. Pending calls to Decode() and |
| 171 * GetPicture()) are aborted, causing their callbacks to run with |
| 172 * PP_ERROR_ABORTED. The plugin should not make any further calls to the |
| 173 * decoder until the decoder signals completion by running |callback|. |
| 174 * |
| 175 * @param[in] video_decoder A <code>PP_Resource</code> identifying the video |
| 176 * decoder. |
| 177 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon |
| 178 * completion. |
| 179 * |
| 180 * @return An int32_t containing an error code from <code>pp_errors.h</code>. |
| 181 */ |
| 182 int32_t Reset( |
| 183 [in] PP_Resource video_decoder, |
| 184 [in] PP_CompletionCallback callback); |
| 185 }; |
| OLD | NEW |