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 + Initialize | | 55 // | Create | |
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. Initialize() must be called afterwards to | 124 // Creates a video decoder with requested |decoder_config|. |
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. | |
134 // |input_format| in |decoder_config| specifies the format of input access | 125 // |input_format| in |decoder_config| specifies the format of input access |
135 // unit, with PP_VIDEOKEY_CODECID and PP_VIDEOKEY_PAYLOADFORMAT required. | 126 // unit, with PP_VIDEOKEY_CODECID and PP_VIDEOKEY_PAYLOADFORMAT required. |
136 // Plugin has the option to specify codec profile/level and other | 127 // Plugin has the option to specify codec profile/level and other |
137 // information such as PP_VIDEOKEY_ACCELERATION, to let browser choose | 128 // information such as PP_VIDEOKEY_ACCELERATION, to let browser choose |
138 // the most appropriate decoder. | 129 // the most appropriate decoder. |
139 // | 130 // |
140 // Parameters: | 131 // Parameters: |
141 // |video_decoder| is the previously created handle to the decoder resource. | 132 // |instance| pointer to the plugin instance. |
142 // |decoder_config| the configuration to use to initialize the decoder. | 133 // |dec_config| the configuration which to use to initialize the decoder. |
143 // |callback| called after initialization is complete. | 134 // |callback| called after initialize is complete. |
144 // | 135 // |
145 // Returns an error code from pp_errors.h. | 136 // The created decoder is returned as PP_Resource. NULL means failure. |
146 int32_t (*Initialize)(PP_Resource video_decoder, | 137 PP_Resource (*Create)(PP_Instance instance, |
147 const PP_VideoConfigElement* decoder_config, | 138 const PP_VideoConfigElement* dec_config, |
148 struct PP_CompletionCallback callback); | 139 struct PP_CompletionCallback callback); |
149 | 140 |
150 // Tests whether |resource| is a video decoder created through Create | 141 // Tests whether |resource| is a video decoder created through Create |
151 // function of this interface. | 142 // function of this interface. |
152 // | 143 // |
153 // Parameters: | 144 // Parameters: |
154 // |resource| is handle to resource to test. | 145 // |resource| is handle to resource to test. |
155 // | 146 // |
156 // Returns true if is a video decoder, false otherwise. | 147 // Returns true if is a video decoder, false otherwise. |
157 PP_Bool (*IsVideoDecoder)(PP_Resource resource); | 148 PP_Bool (*IsVideoDecoder)(PP_Resource resource); |
158 | 149 |
159 // Dispatches bitstream buffer to the decoder. This is asynchronous and | 150 // Dispatches bitstream buffer to the decoder. This is asynchronous and |
160 // non-blocking function. | 151 // non-blocking function. |
161 // | 152 // |
162 // Parameters: | 153 // Parameters: |
163 // |video_decoder| is the previously created handle to the decoder resource. | 154 // |video_decoder| is the previously created handle to the decoder instance. |
164 // |bitstream_buffer| is the bitstream buffer that contains the input data. | 155 // |bitstream_buffer| is the bitstream buffer that contains the input data. |
165 // |callback| will be called when |bitstream_buffer| has been processed by | 156 // |callback| will be called when |bitstream_buffer| has been processed by |
166 // the decoder. | 157 // the decoder. |
167 // | 158 // |
168 // Returns an error code from pp_errors.h. | 159 // Returns PP_TRUE on decoder successfully accepting buffer, PP_FALSE |
169 int32_t (*Decode)(PP_Resource video_decoder, | 160 // otherwise. |
| 161 PP_Bool (*Decode)(PP_Resource video_decoder, |
170 const struct PP_VideoBitstreamBuffer_Dev* bitstream_buffer, | 162 const struct PP_VideoBitstreamBuffer_Dev* bitstream_buffer, |
171 struct PP_CompletionCallback callback); | 163 struct PP_CompletionCallback callback); |
172 | 164 |
173 // Provides the decoder with picture buffers for video decoding. | 165 // Provides the decoder with picture buffers for video decoding. |
174 // AssignGLESBuffers provides texture-backed buffers, whereas | 166 // AssignGLESBuffers provides texture-backed buffers, whereas |
175 // AssignSysmemBuffers provides system memory-backed buffers. | 167 // AssignSysmemBuffers provides system memory-backed buffers. |
176 // | 168 // |
177 // This function should be called when decoder has issued the | 169 // This function should be called when decoder has issued the |
178 // ProvidePictureBuffers callback to the plugin with buffer requirements. | 170 // ProvidePictureBuffers callback to the plugin with buffer requirements. |
179 // | 171 // |
180 // It can also be called in advance or outside of ProvidePictureBuffers calls | 172 // It can also be called in advance or outside of ProvidePictureBuffers calls |
181 // to provide the decoder with additional buffers. Additional buffers will be | 173 // to provide the decoder with additional buffers. Additional buffers will be |
182 // added to the decoder's buffer pool. | 174 // added to the decoder's buffer pool. |
183 // | 175 // |
184 // The decoder will pause in decoding if it has not received enough buffers. | 176 // The decoder will pause in decoding if it has not received enough buffers. |
185 // | 177 // |
186 // If the buffer is invalid, the decoder will return the buffer and will issue | 178 // If the buffer is invalid, the decoder will return the buffer and will issue |
187 // ProvidePictureBuffers again. | 179 // ProvidePictureBuffers again. |
188 // | 180 // |
189 // TODO(vmr/vrk): Decide if the API is too flexible, i.e. stricter rules on | 181 // TODO(vmr/vrk): Decide if the API is too flexible, i.e. stricter rules on |
190 // errors/duplicates or requiring Assign*Buffers to only be called in response | 182 // errors/duplicates or requiring Assign*Buffers to only be called in response |
191 // to ProvidePictureBuffers... in which case the output buffers should be | 183 // to ProvidePictureBuffers... in which case the output buffers should be |
192 // callback parameters to ProvidePictureBuffers instead of being part of the | 184 // callback parameters to ProvidePictureBuffers instead of being part of the |
193 // PPB API. | 185 // PPB API. |
194 // | 186 // |
195 // Parameters: | 187 // Parameters: |
196 // |video_decoder| is the previously created handle to the decoder resource. | 188 // |video_decoder| is the previously created handle to the decoder instance. |
197 // |no_of_buffers| how many buffers are behind picture buffer pointer. | 189 // |no_of_buffers| how many buffers are behind picture buffer pointer. |
198 // |buffers| contains the reference to the picture buffer that was | 190 // |buffers| contains the reference to the picture buffer that was |
199 // allocated. | 191 // allocated. |
200 void (*AssignGLESBuffers)(PP_Resource video_decoder, | 192 void (*AssignGLESBuffers)(PP_Resource video_decoder, |
201 uint32_t no_of_buffers, | 193 uint32_t no_of_buffers, |
202 const struct PP_GLESBuffer_Dev* buffers); | 194 const struct PP_GLESBuffer_Dev* buffers); |
203 void (*AssignSysmemBuffers)(PP_Resource video_decoder, | 195 void (*AssignSysmemBuffers)(PP_Resource video_decoder, |
204 uint32_t no_of_buffers, | 196 uint32_t no_of_buffers, |
205 const struct PP_SysmemBuffer_Dev* buffers); | 197 const struct PP_SysmemBuffer_Dev* buffers); |
206 | 198 |
207 // Tells the decoder to reuse given picture buffer. Typical use of this | 199 // Tells the decoder to reuse given picture buffer. Typical use of this |
208 // function is to call from PictureReady callback to recycle picture buffer | 200 // function is to call from PictureReady callback to recycle picture buffer |
209 // back to the decoder after blitting the image so that decoder can use the | 201 // back to the decoder after blitting the image so that decoder can use the |
210 // image for output again. | 202 // image for output again. |
211 // | 203 // |
212 // The decoder will ignore any picture buffer not previously provided via | 204 // The decoder will ignore any picture buffer not previously provided via |
213 // AssignPictureBuffer. | 205 // AssignPictureBuffer. |
214 // | 206 // |
215 // TODO(vmr): figure out how the sync will be handled with command buffer as | 207 // TODO(vmr): figure out how the sync will be handled with command buffer as |
216 // there will be possibly lag due to command buffer implementation | 208 // there will be possibly lag due to command buffer implementation |
217 // to actual GL swap. At that moment decoder may have already taken | 209 // to actual GL swap. At that moment decoder may have already taken |
218 // the GL textures for writing output again. | 210 // the GL textures for writing output again. |
219 // | 211 // |
220 // Parameters: | 212 // Parameters: |
221 // |video_decoder| is the previously created handle to the decoder resource. | 213 // |video_decoder| is the previously created handle to the decoder instance. |
222 // |picture_buffer_id| contains the id of the picture buffer that was | 214 // |picture_buffer_id| contains the id of the picture buffer that was |
223 // processed. | 215 // processed. |
224 void (*ReusePictureBuffer)(PP_Resource video_decoder, | 216 void (*ReusePictureBuffer)(PP_Resource video_decoder, |
225 int32_t picture_buffer_id); | 217 int32_t picture_buffer_id); |
226 | 218 |
227 // Dispatches flushing request to the decoder to flush both input and output | 219 // Dispatches flushing request to the decoder to flush both input and output |
228 // buffers. Successful flushing will result in output of the pictures and | 220 // buffers. Successful flushing will result in output of the pictures and |
229 // buffers held inside the decoder and returning of bitstream buffers using | 221 // buffers held inside the decoder and returning of bitstream buffers using |
230 // the callbacks implemented by the plug-in. Once done with flushing, the | 222 // the callbacks implemented by the plug-in. Once done with flushing, the |
231 // decode will call the |callback|. | 223 // decode will call the |callback|. |
232 // | 224 // |
233 // Parameters: | 225 // Parameters: |
234 // |video_decoder| is the previously created handle to the decoder resource. | 226 // |video_decoder| is the previously created handle to the decoder instance. |
235 // |callback| is one-time callback that will be called once the flushing | 227 // |callback| is one-time callback that will be called once the flushing |
236 // request has been completed. | 228 // request has been completed. |
237 // | 229 // |
238 // Returns an error code from pp_errors.h. | 230 // Returns PP_TRUE on acceptance of flush request and PP_FALSE if request to |
239 int32_t (*Flush)(PP_Resource video_decoder, | 231 // flush is rejected by the decoder. |
| 232 PP_Bool (*Flush)(PP_Resource video_decoder, |
240 struct PP_CompletionCallback callback); | 233 struct PP_CompletionCallback callback); |
241 | 234 |
242 // Dispatches abortion request to the decoder to abort decoding as soon as | 235 // Dispatches abortion request to the decoder to abort decoding as soon as |
243 // possible and will not output anything or generate new callbacks. |callback| | 236 // possible and will not output anything or generate new callbacks. |callback| |
244 // will be called as soon as abortion has been finished. After abortion all | 237 // will be called as soon as abortion has been finished. After abortion all |
245 // buffers can be considered dismissed even when there has not been callbacks | 238 // buffers can be considered dismissed even when there has not been callbacks |
246 // to dismiss them. | 239 // to dismiss them. |
247 // | 240 // |
248 // Parameters: | 241 // Parameters: |
249 // |video_decoder| is the previously created handle to the decoder resource. | 242 // |video_decoder| is the previously created handle to the decoder instance. |
250 // |callback| is one-time callback that will be called once the abortion | 243 // |callback| is one-time callback that will be called once the abortion |
251 // request has been completed. | 244 // request has been completed. |
252 // | 245 // |
253 // Returns an error code from pp_errors.h. | 246 // Returns PP_TRUE on acceptance of abort request and PP_FALSE if request to |
254 int32_t (*Abort)(PP_Resource video_decoder, | 247 // abort is rejected by the decoder. |
| 248 PP_Bool (*Abort)(PP_Resource video_decoder, |
255 struct PP_CompletionCallback callback); | 249 struct PP_CompletionCallback callback); |
256 }; | 250 }; |
257 | 251 |
258 #endif /* PPAPI_C_DEV_PPB_VIDEO_DECODER_DEV_H_ */ | 252 #endif /* PPAPI_C_DEV_PPB_VIDEO_DECODER_DEV_H_ */ |
OLD | NEW |