| OLD | NEW |
| 1 /* Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 /* Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 * Use of this source code is governed by a BSD-style license that can be | 2 * Use of this source code is governed by a BSD-style license that can be |
| 3 * found in the LICENSE file. | 3 * found in the LICENSE file. |
| 4 */ | 4 */ |
| 5 #ifndef PPAPI_C_DEV_PPB_VIDEO_DECODER_DEV_H_ | 5 #ifndef PPAPI_C_DEV_PPB_VIDEO_DECODER_DEV_H_ |
| 6 #define PPAPI_C_DEV_PPB_VIDEO_DECODER_DEV_H_ | 6 #define PPAPI_C_DEV_PPB_VIDEO_DECODER_DEV_H_ |
| 7 | 7 |
| 8 #include "ppapi/c/dev/pp_video_dev.h" | 8 #include "ppapi/c/dev/pp_video_dev.h" |
| 9 #include "ppapi/c/pp_completion_callback.h" | 9 #include "ppapi/c/pp_completion_callback.h" |
| 10 #include "ppapi/c/pp_var.h" | 10 #include "ppapi/c/pp_var.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 // stream marker in the stream. Calls from left to right are functions that are | 45 // stream marker in the stream. Calls from left to right are functions that are |
| 46 // in PPB_VideoDecoder_Dev and calls from right to left are functions that are | 46 // in PPB_VideoDecoder_Dev and calls from right to left are functions that are |
| 47 // in PPP_VideoDecoder_Dev interface. | 47 // in PPP_VideoDecoder_Dev interface. |
| 48 // | 48 // |
| 49 // Plugin VideoDecoder | 49 // Plugin VideoDecoder |
| 50 // |###########################| | 50 // |###########################| |
| 51 // | Configuration | | 51 // | Configuration | |
| 52 // |###########################| | 52 // |###########################| |
| 53 // | GetConfigs | | 53 // | GetConfigs | |
| 54 // |-------------------------->| | 54 // |-------------------------->| |
| 55 // | Create | | 55 // | Create + Initialize | |
| 56 // |-------------------------->| Decoder will ask for certain number | 56 // |-------------------------->| Decoder will ask for certain number |
| 57 // | (Decode) | of PictureBuffers. This may happen | 57 // | (Decode) | of PictureBuffers. This may happen |
| 58 // |- - - - - - - - - - - - - >| either directly after constructor or | 58 // |- - - - - - - - - - - - - >| either directly after constructor or |
| 59 // | ProvidePictureBuffers | after Decode has decoded some of the | 59 // | ProvidePictureBuffers | after Decode has decoded some of the |
| 60 // |<--------------------------| bitstream. Once resources have been | 60 // |<--------------------------| bitstream. Once resources have been |
| 61 // | AssignPictureBuffer | acquired decoder calls | 61 // | AssignPictureBuffer | acquired decoder calls |
| 62 // |-------------------------->| NotifyResourcesAcquired. | 62 // |-------------------------->| NotifyResourcesAcquired. |
| 63 // | NotifyResourcesAcquired | | 63 // | NotifyResourcesAcquired | |
| 64 // |<--------------------------| | 64 // |<--------------------------| |
| 65 // | | | 65 // | | |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 // configurations are returned, but the total number of PP_VideoConfig_Devs | 114 // configurations are returned, but the total number of PP_VideoConfig_Devs |
| 115 // available will be returned in |num_of_matching_configs|. | 115 // available will be returned in |num_of_matching_configs|. |
| 116 // | 116 // |
| 117 // Returns PP_TRUE on success, PP_FALSE otherwise. | 117 // Returns PP_TRUE on success, PP_FALSE otherwise. |
| 118 PP_Bool (*GetConfigs)(PP_Instance instance, | 118 PP_Bool (*GetConfigs)(PP_Instance instance, |
| 119 const PP_VideoConfigElement* proto_config, | 119 const PP_VideoConfigElement* proto_config, |
| 120 PP_VideoConfigElement* matching_configs, | 120 PP_VideoConfigElement* matching_configs, |
| 121 uint32_t matching_configs_size, | 121 uint32_t matching_configs_size, |
| 122 uint32_t* num_of_matching_configs); | 122 uint32_t* num_of_matching_configs); |
| 123 | 123 |
| 124 // Creates a video decoder with requested |decoder_config|. | 124 // Creates a video decoder. Initialize() must be called afterwards to |
| 125 // set its configuration. |
| 126 // |
| 127 // Parameters: |
| 128 // |instance| pointer to the plugin instance. |
| 129 // |
| 130 // The created decoder is returned as PP_Resource. 0 means failure. |
| 131 PP_Resource (*Create)(PP_Instance instance); |
| 132 |
| 133 // Initializes the video decoder with requested configuration. |
| 125 // |input_format| in |decoder_config| specifies the format of input access | 134 // |input_format| in |decoder_config| specifies the format of input access |
| 126 // unit, with PP_VIDEOKEY_CODECID and PP_VIDEOKEY_PAYLOADFORMAT required. | 135 // unit, with PP_VIDEOKEY_CODECID and PP_VIDEOKEY_PAYLOADFORMAT required. |
| 127 // Plugin has the option to specify codec profile/level and other | 136 // Plugin has the option to specify codec profile/level and other |
| 128 // information such as PP_VIDEOKEY_ACCELERATION, to let browser choose | 137 // information such as PP_VIDEOKEY_ACCELERATION, to let browser choose |
| 129 // the most appropriate decoder. | 138 // the most appropriate decoder. |
| 130 // | 139 // |
| 131 // Parameters: | 140 // Parameters: |
| 132 // |instance| pointer to the plugin instance. | 141 // |video_decoder| is the previously created handle to the decoder resource. |
| 133 // |dec_config| the configuration which to use to initialize the decoder. | 142 // |decoder_config| the configuration to use to initialize the decoder. |
| 134 // |callback| called after initialize is complete. | 143 // |callback| called after initialization is complete. |
| 135 // | 144 // |
| 136 // The created decoder is returned as PP_Resource. NULL means failure. | 145 // Returns an error code from pp_errors.h. |
| 137 PP_Resource (*Create)(PP_Instance instance, | 146 int32_t (*Initialize)(PP_Resource video_decoder, |
| 138 const PP_VideoConfigElement* dec_config, | 147 const PP_VideoConfigElement* decoder_config, |
| 139 struct PP_CompletionCallback callback); | 148 struct PP_CompletionCallback callback); |
| 140 | 149 |
| 141 // Tests whether |resource| is a video decoder created through Create | 150 // Tests whether |resource| is a video decoder created through Create |
| 142 // function of this interface. | 151 // function of this interface. |
| 143 // | 152 // |
| 144 // Parameters: | 153 // Parameters: |
| 145 // |resource| is handle to resource to test. | 154 // |resource| is handle to resource to test. |
| 146 // | 155 // |
| 147 // Returns true if is a video decoder, false otherwise. | 156 // Returns true if is a video decoder, false otherwise. |
| 148 PP_Bool (*IsVideoDecoder)(PP_Resource resource); | 157 PP_Bool (*IsVideoDecoder)(PP_Resource resource); |
| 149 | 158 |
| 150 // Dispatches bitstream buffer to the decoder. This is asynchronous and | 159 // Dispatches bitstream buffer to the decoder. This is asynchronous and |
| 151 // non-blocking function. | 160 // non-blocking function. |
| 152 // | 161 // |
| 153 // Parameters: | 162 // Parameters: |
| 154 // |video_decoder| is the previously created handle to the decoder instance. | 163 // |video_decoder| is the previously created handle to the decoder resource. |
| 155 // |bitstream_buffer| is the bitstream buffer that contains the input data. | 164 // |bitstream_buffer| is the bitstream buffer that contains the input data. |
| 156 // |callback| will be called when |bitstream_buffer| has been processed by | 165 // |callback| will be called when |bitstream_buffer| has been processed by |
| 157 // the decoder. | 166 // the decoder. |
| 158 // | 167 // |
| 159 // Returns PP_TRUE on decoder successfully accepting buffer, PP_FALSE | 168 // Returns an error code from pp_errors.h. |
| 160 // otherwise. | 169 int32_t (*Decode)(PP_Resource video_decoder, |
| 161 PP_Bool (*Decode)(PP_Resource video_decoder, | |
| 162 const struct PP_VideoBitstreamBuffer_Dev* bitstream_buffer, | 170 const struct PP_VideoBitstreamBuffer_Dev* bitstream_buffer, |
| 163 struct PP_CompletionCallback callback); | 171 struct PP_CompletionCallback callback); |
| 164 | 172 |
| 165 // Provides the decoder with picture buffers for video decoding. | 173 // Provides the decoder with picture buffers for video decoding. |
| 166 // AssignGLESBuffers provides texture-backed buffers, whereas | 174 // AssignGLESBuffers provides texture-backed buffers, whereas |
| 167 // AssignSysmemBuffers provides system memory-backed buffers. | 175 // AssignSysmemBuffers provides system memory-backed buffers. |
| 168 // | 176 // |
| 169 // This function should be called when decoder has issued the | 177 // This function should be called when decoder has issued the |
| 170 // ProvidePictureBuffers callback to the plugin with buffer requirements. | 178 // ProvidePictureBuffers callback to the plugin with buffer requirements. |
| 171 // | 179 // |
| 172 // It can also be called in advance or outside of ProvidePictureBuffers calls | 180 // It can also be called in advance or outside of ProvidePictureBuffers calls |
| 173 // to provide the decoder with additional buffers. Additional buffers will be | 181 // to provide the decoder with additional buffers. Additional buffers will be |
| 174 // added to the decoder's buffer pool. | 182 // added to the decoder's buffer pool. |
| 175 // | 183 // |
| 176 // The decoder will pause in decoding if it has not received enough buffers. | 184 // The decoder will pause in decoding if it has not received enough buffers. |
| 177 // | 185 // |
| 178 // If the buffer is invalid, the decoder will return the buffer and will issue | 186 // If the buffer is invalid, the decoder will return the buffer and will issue |
| 179 // ProvidePictureBuffers again. | 187 // ProvidePictureBuffers again. |
| 180 // | 188 // |
| 181 // TODO(vmr/vrk): Decide if the API is too flexible, i.e. stricter rules on | 189 // TODO(vmr/vrk): Decide if the API is too flexible, i.e. stricter rules on |
| 182 // errors/duplicates or requiring Assign*Buffers to only be called in response | 190 // errors/duplicates or requiring Assign*Buffers to only be called in response |
| 183 // to ProvidePictureBuffers... in which case the output buffers should be | 191 // to ProvidePictureBuffers... in which case the output buffers should be |
| 184 // callback parameters to ProvidePictureBuffers instead of being part of the | 192 // callback parameters to ProvidePictureBuffers instead of being part of the |
| 185 // PPB API. | 193 // PPB API. |
| 186 // | 194 // |
| 187 // Parameters: | 195 // Parameters: |
| 188 // |video_decoder| is the previously created handle to the decoder instance. | 196 // |video_decoder| is the previously created handle to the decoder resource. |
| 189 // |no_of_buffers| how many buffers are behind picture buffer pointer. | 197 // |no_of_buffers| how many buffers are behind picture buffer pointer. |
| 190 // |buffers| contains the reference to the picture buffer that was | 198 // |buffers| contains the reference to the picture buffer that was |
| 191 // allocated. | 199 // allocated. |
| 192 void (*AssignGLESBuffers)(PP_Resource video_decoder, | 200 void (*AssignGLESBuffers)(PP_Resource video_decoder, |
| 193 uint32_t no_of_buffers, | 201 uint32_t no_of_buffers, |
| 194 const struct PP_GLESBuffer_Dev* buffers); | 202 const struct PP_GLESBuffer_Dev* buffers); |
| 195 void (*AssignSysmemBuffers)(PP_Resource video_decoder, | 203 void (*AssignSysmemBuffers)(PP_Resource video_decoder, |
| 196 uint32_t no_of_buffers, | 204 uint32_t no_of_buffers, |
| 197 const struct PP_SysmemBuffer_Dev* buffers); | 205 const struct PP_SysmemBuffer_Dev* buffers); |
| 198 | 206 |
| 199 // Tells the decoder to reuse given picture buffer. Typical use of this | 207 // Tells the decoder to reuse given picture buffer. Typical use of this |
| 200 // function is to call from PictureReady callback to recycle picture buffer | 208 // function is to call from PictureReady callback to recycle picture buffer |
| 201 // back to the decoder after blitting the image so that decoder can use the | 209 // back to the decoder after blitting the image so that decoder can use the |
| 202 // image for output again. | 210 // image for output again. |
| 203 // | 211 // |
| 204 // The decoder will ignore any picture buffer not previously provided via | 212 // The decoder will ignore any picture buffer not previously provided via |
| 205 // AssignPictureBuffer. | 213 // AssignPictureBuffer. |
| 206 // | 214 // |
| 207 // TODO(vmr): figure out how the sync will be handled with command buffer as | 215 // TODO(vmr): figure out how the sync will be handled with command buffer as |
| 208 // there will be possibly lag due to command buffer implementation | 216 // there will be possibly lag due to command buffer implementation |
| 209 // to actual GL swap. At that moment decoder may have already taken | 217 // to actual GL swap. At that moment decoder may have already taken |
| 210 // the GL textures for writing output again. | 218 // the GL textures for writing output again. |
| 211 // | 219 // |
| 212 // Parameters: | 220 // Parameters: |
| 213 // |video_decoder| is the previously created handle to the decoder instance. | 221 // |video_decoder| is the previously created handle to the decoder resource. |
| 214 // |picture_buffer_id| contains the id of the picture buffer that was | 222 // |picture_buffer_id| contains the id of the picture buffer that was |
| 215 // processed. | 223 // processed. |
| 216 void (*ReusePictureBuffer)(PP_Resource video_decoder, | 224 void (*ReusePictureBuffer)(PP_Resource video_decoder, |
| 217 int32_t picture_buffer_id); | 225 int32_t picture_buffer_id); |
| 218 | 226 |
| 219 // Dispatches flushing request to the decoder to flush both input and output | 227 // Dispatches flushing request to the decoder to flush both input and output |
| 220 // buffers. Successful flushing will result in output of the pictures and | 228 // buffers. Successful flushing will result in output of the pictures and |
| 221 // buffers held inside the decoder and returning of bitstream buffers using | 229 // buffers held inside the decoder and returning of bitstream buffers using |
| 222 // the callbacks implemented by the plug-in. Once done with flushing, the | 230 // the callbacks implemented by the plug-in. Once done with flushing, the |
| 223 // decode will call the |callback|. | 231 // decode will call the |callback|. |
| 224 // | 232 // |
| 225 // Parameters: | 233 // Parameters: |
| 226 // |video_decoder| is the previously created handle to the decoder instance. | 234 // |video_decoder| is the previously created handle to the decoder resource. |
| 227 // |callback| is one-time callback that will be called once the flushing | 235 // |callback| is one-time callback that will be called once the flushing |
| 228 // request has been completed. | 236 // request has been completed. |
| 229 // | 237 // |
| 230 // Returns PP_TRUE on acceptance of flush request and PP_FALSE if request to | 238 // Returns an error code from pp_errors.h. |
| 231 // flush is rejected by the decoder. | 239 int32_t (*Flush)(PP_Resource video_decoder, |
| 232 PP_Bool (*Flush)(PP_Resource video_decoder, | |
| 233 struct PP_CompletionCallback callback); | 240 struct PP_CompletionCallback callback); |
| 234 | 241 |
| 235 // Dispatches abortion request to the decoder to abort decoding as soon as | 242 // Dispatches abortion request to the decoder to abort decoding as soon as |
| 236 // possible and will not output anything or generate new callbacks. |callback| | 243 // possible and will not output anything or generate new callbacks. |callback| |
| 237 // will be called as soon as abortion has been finished. After abortion all | 244 // will be called as soon as abortion has been finished. After abortion all |
| 238 // buffers can be considered dismissed even when there has not been callbacks | 245 // buffers can be considered dismissed even when there has not been callbacks |
| 239 // to dismiss them. | 246 // to dismiss them. |
| 240 // | 247 // |
| 241 // Parameters: | 248 // Parameters: |
| 242 // |video_decoder| is the previously created handle to the decoder instance. | 249 // |video_decoder| is the previously created handle to the decoder resource. |
| 243 // |callback| is one-time callback that will be called once the abortion | 250 // |callback| is one-time callback that will be called once the abortion |
| 244 // request has been completed. | 251 // request has been completed. |
| 245 // | 252 // |
| 246 // Returns PP_TRUE on acceptance of abort request and PP_FALSE if request to | 253 // Returns an error code from pp_errors.h. |
| 247 // abort is rejected by the decoder. | 254 int32_t (*Abort)(PP_Resource video_decoder, |
| 248 PP_Bool (*Abort)(PP_Resource video_decoder, | |
| 249 struct PP_CompletionCallback callback); | 255 struct PP_CompletionCallback callback); |
| 250 }; | 256 }; |
| 251 | 257 |
| 252 #endif /* PPAPI_C_DEV_PPB_VIDEO_DECODER_DEV_H_ */ | 258 #endif /* PPAPI_C_DEV_PPB_VIDEO_DECODER_DEV_H_ */ |
| OLD | NEW |