1 /*
2  * Copyright (C) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 /**
17  * @addtogroup VideoDecoder
18  * @{
19  *
20  * @brief The VideoDecoder module provides interfaces for video decoding.
21  *
22  * @syscap SystemCapability.Multimedia.Media.VideoDecoder
23  * @since 9
24  * @version 1.0
25  */
26 
27 /**
28  * @file native_avcodec_videodecoder.h
29  *
30  * @brief Declare the Native API used for video decoding.
31  *
32  * @kit AVCodecKit
33  * @library libnative_media_vdec.so
34  * @syscap SystemCapability.Multimedia.Media.VideoDecoder
35  * @since 9
36  */
37 
38 #ifndef NATIVE_AVCODEC_VIDEODECODER_H
39 #define NATIVE_AVCODEC_VIDEODECODER_H
40 
41 #include <stdint.h>
42 #include <stdio.h>
43 #include "native_avcodec_base.h"
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
49 typedef struct MediaKeySession MediaKeySession;
50 
51 /**
52  * @brief Creates a video decoder instance from the mime type, which is recommended in most cases.
53  * @syscap SystemCapability.Multimedia.Media.VideoDecoder
54  * @param mime mime type description string, refer to {@link AVCODEC_MIME_TYPE}
55  * @return Returns a Pointer to an OH_AVCodec instance.
56  * Return NULL if memory ran out or the mime type is not supported.
57  * @since 9
58  * @version 1.0
59  */
60 OH_AVCodec *OH_VideoDecoder_CreateByMime(const char *mime);
61 
62 /**
63  * @brief Create a video decoder instance through the video decoder name.
64  * The premise of using this interface is to know the exact name of the decoder.
65  * @syscap SystemCapability.Multimedia.Media.VideoDecoder
66  * @param name video codec name
67  * @return Returns a Pointer to an OH_AVCodec instance.
68  * Return NULL if memory ran out or the decoder name is not supported.
69  * @since 9
70  * @version 1.0
71  */
72 OH_AVCodec *OH_VideoDecoder_CreateByName(const char *name);
73 
74 /**
75  * @brief Clear the internal resources of the decoder and destroy the decoder instance
76  * @syscap SystemCapability.Multimedia.Media.VideoDecoder
77  * @param codec Pointer to an OH_AVCodec instance
78  * @return Returns AV_ERR_OK if succeed,
79  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
80  * {@link AV_ERR_NO_MEMORY}, inner resource has already released.
81  * {@link AV_ERR_INVALID_VAL}, the decoder is NULL or invalid.
82  * {@link AV_ERR_UNKNOWN}, unknown error.
83  * {@link AV_ERR_SERVICE_DIED}, avcodec service is died.
84  * @since 9
85  * @version 1.0
86  */
87 OH_AVErrCode OH_VideoDecoder_Destroy(OH_AVCodec *codec);
88 
89 /**
90  * @brief Set the asynchronous callback function so that your application can respond to the events
91  * generated by the video decoder. This interface must be called before Prepare is called.
92  * @syscap SystemCapability.Multimedia.Media.VideoDecoder
93  * @param codec Pointer to an OH_AVCodec instance
94  * @param callback A collection of all callback functions, see {@link OH_AVCodecAsyncCallback}
95  * @param userData User specific data
96  * @return Returns AV_ERR_OK if the execution is successful,
97  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
98  * {@link AV_ERR_NO_MEMORY}, inner resource has already released.
99  * {@link AV_ERR_INVALID_VAL}, the decoder is NULL or invalid.
100  * {@link AV_ERR_UNKNOWN}, unknown error.
101  * {@link AV_ERR_SERVICE_DIED}, avcodec service is died.
102  * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state, must be called before Prepare.
103  * @deprecated since 11
104  * @useinstead OH_VideoDecoder_RegisterCallback
105  * @since 9
106  * @version 1.0
107  */
108 OH_AVErrCode OH_VideoDecoder_SetCallback(OH_AVCodec *codec, OH_AVCodecAsyncCallback callback, void *userData);
109 
110 /**
111  * @brief Set the asynchronous callback function so that your application can respond to the events
112  * generated by the video decoder. This interface must be called before Prepare is called.
113  * @syscap SystemCapability.Multimedia.Media.VideoDecoder
114  * @param codec Pointer to an OH_AVCodec instance
115  * @param callback A collection of all callback functions, see {@link OH_AVCodecCallback}
116  * @param userData User specific data
117  * @return Returns AV_ERR_OK if the execution is successful,
118  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
119  * {@link AV_ERR_NO_MEMORY}, inner resource has already released.
120  * {@link AV_ERR_INVALID_VAL}, the decoder is NULL or invalid.
121  * {@link AV_ERR_UNKNOWN}, unknown error.
122  * {@link AV_ERR_SERVICE_DIED}, avcodec service is died.
123  * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state, must be called before Prepare.
124  * @since 11
125  */
126 OH_AVErrCode OH_VideoDecoder_RegisterCallback(OH_AVCodec *codec, OH_AVCodecCallback callback, void *userData);
127 
128 /**
129  * @brief Specify the output Surface to provide video decoding output,
130  * this interface must be called before Prepare is called
131  * @syscap SystemCapability.Multimedia.Media.VideoDecoder
132  * @param codec Pointer to an OH_AVCodec instance
133  * @param window A pointer to a OHNativeWindow instance, see {@link OHNativeWindow}
134  * @return Returns AV_ERR_OK if the execution is successful,
135  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
136  * {@link AV_ERR_NO_MEMORY}, inner resource has already released.
137  * {@link AV_ERR_OPERATE_NOT_PERMIT}, not permit to call the interface in buffer mode.
138  * {@link AV_ERR_INVALID_VAL}, the decoder is NULL or invalid.
139  * {@link AV_ERR_UNKNOWN}, unknown error.
140  * {@link AV_ERR_SERVICE_DIED}, avcodec service is died.
141  * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state.
142  * @since 9
143  * @version 1.0
144  */
145 OH_AVErrCode OH_VideoDecoder_SetSurface(OH_AVCodec *codec, OHNativeWindow *window);
146 
147 /**
148  * @brief To configure the video decoder, typically, you need to configure the description information of the decoded
149  * video track, which can be extracted from the OH_AVSource. This interface must be called before Prepare is called.
150  * @syscap SystemCapability.Multimedia.Media.VideoDecoder
151  * @param codec Pointer to an OH_AVCodec instance
152  * @param format A pointer to an OH_AVFormat to give the description of the video track to be decoded
153  * @return Returns AV_ERR_OK if the execution is successful,
154  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
155  * {@link AV_ERR_NO_MEMORY}, instance has already released.
156  * {@link AV_ERR_INVALID_VAL}, the decoder is NULL or invalid. Invalid param in format.
157  * {@link AV_ERR_UNKNOWN}, unknown error.
158  * {@link AV_ERR_SERVICE_DIED}, avcodec service is died.
159  * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state, must be called before Prepare.
160  * {@link AV_ERR_UNSUPPORT}, unsupported features.
161  * {@link AV_ERR_VIDEO_UNSUPPORTED_COLOR_SPACE_CONVERSION}, video unsupported color space conversion.
162  * @since 9
163  * @version 1.0
164  */
165 OH_AVErrCode OH_VideoDecoder_Configure(OH_AVCodec *codec, OH_AVFormat *format);
166 
167 /**
168  * @brief To prepare the internal resources of the decoder, the Configure interface must be called before
169  * calling this interface.
170  * @syscap SystemCapability.Multimedia.Media.VideoDecoder
171  * @param codec Pointer to an OH_AVCodec instance
172  * @return Returns AV_ERR_OK if the execution is successful,
173  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
174  * {@link AV_ERR_NO_MEMORY}, instance has already released.
175  * {@link AV_ERR_INVALID_VAL}, the decoder is NULL or invalid.
176  * {@link AV_ERR_UNKNOWN}, unknown error.
177  * {@link AV_ERR_SERVICE_DIED}, avcodec service is died.
178  * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state.
179  * {@link AV_ERR_OPERATE_NOT_PERMIT}, decoder is in buffer mode and color space conversion is configured.
180  * @since 9
181  * @version 1.0
182  */
183 OH_AVErrCode OH_VideoDecoder_Prepare(OH_AVCodec *codec);
184 
185 /**
186  * @brief Start the decoder, this interface must be called after the Prepare is successful.
187  * After being successfully started, the decoder will start reporting NeedInputData events.
188  * @syscap SystemCapability.Multimedia.Media.VideoDecoder
189  * @param codec Pointer to an OH_AVCodec instance
190  * @return Returns AV_ERR_OK if the execution is successful,
191  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
192  * {@link AV_ERR_NO_MEMORY}, instance has already released.
193  * {@link AV_ERR_INVALID_VAL}, the decoder is NULL or invalid.
194  * {@link AV_ERR_UNKNOWN}, unknown error.
195  * {@link AV_ERR_SERVICE_DIED}, avcodec service is died.
196  * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state.
197  * {@link AV_ERR_OPERATE_NOT_PERMIT}, video color space conversion is configured but decoder is not prepared.
198  * @since 9
199  * @version 1.0
200  */
201 OH_AVErrCode OH_VideoDecoder_Start(OH_AVCodec *codec);
202 
203 /**
204  * @brief Stop the decoder. After stopping, you can re-enter the Started state through Start,
205  * but it should be noted that if Codec-Specific-Data has been input to the decoder before, it needs to be input again.
206  * @syscap SystemCapability.Multimedia.Media.VideoDecoder
207  * @param codec Pointer to an OH_AVCodec instance
208  * @return Returns AV_ERR_OK if the execution is successful,
209  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
210  * {@link AV_ERR_NO_MEMORY}, instance has already released.
211  * {@link AV_ERR_INVALID_VAL}, the decoder is NULL or invalid.
212  * {@link AV_ERR_UNKNOWN}, unknown error.
213  * {@link AV_ERR_SERVICE_DIED}, avcodec service is died.
214  * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state.
215  * @since 9
216  * @version 1.0
217  */
218 OH_AVErrCode OH_VideoDecoder_Stop(OH_AVCodec *codec);
219 
220 /**
221  * @brief Clear the input and output data buffered in the decoder. After this interface is called, all the Buffer
222  * indexes previously reported through the asynchronous callback will be invalidated, make sure not to access
223  * the Buffers corresponding to these indexes.
224  * @syscap SystemCapability.Multimedia.Media.VideoDecoder
225  * @param codec Pointer to an OH_AVCodec instance
226  * @return Returns AV_ERR_OK if the execution is successful,
227  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
228  * {@link AV_ERR_NO_MEMORY}, instance has already released.
229  * {@link AV_ERR_INVALID_VAL}, the decoder is NULL or invalid.
230  * {@link AV_ERR_UNKNOWN}, unknown error.
231  * {@link AV_ERR_SERVICE_DIED}, avcodec service is died.
232  * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state.
233  * @since 9
234  * @version 1.0
235  */
236 OH_AVErrCode OH_VideoDecoder_Flush(OH_AVCodec *codec);
237 
238 /**
239  * @brief Reset the decoder. To continue decoding, you need to call the Configure interface again
240  * to configure the decoder instance.
241  * @syscap SystemCapability.Multimedia.Media.VideoDecoder
242  * @param codec Pointer to an OH_AVCodec instance
243  * @return Returns AV_ERR_OK if the execution is successful,
244  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
245  * {@link AV_ERR_NO_MEMORY}, instance has already released.
246  * {@link AV_ERR_INVALID_VAL}, the decoder is NULL or invalid.
247  * {@link AV_ERR_UNKNOWN}, unknown error.
248  * {@link AV_ERR_SERVICE_DIED}, avcodec service is died.
249  * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state.
250  * @since 9
251  * @version 1.0
252  */
253 OH_AVErrCode OH_VideoDecoder_Reset(OH_AVCodec *codec);
254 
255 /**
256  * @brief Get the description information of the output data of the decoder, refer to {@link OH_AVFormat}
257  * It should be noted that the life cycle of the OH_AVFormat instance pointed to by the return value * needs
258  * to be manually released by the caller.
259  * @syscap SystemCapability.Multimedia.Media.VideoDecoder
260  * @param codec Pointer to an OH_AVCodec instance
261  * @return Returns a pointer to an OH_AVFormat instance.
262  * Return NULL if the decoder is NULL or invaild.
263  * @since 9
264  * @version 1.0
265  */
266 OH_AVFormat *OH_VideoDecoder_GetOutputDescription(OH_AVCodec *codec);
267 
268 /**
269  * @brief Set dynamic parameters to the decoder. Note: This interface can only be called after the decoder is started.
270  * At the same time, incorrect parameter settings may cause decoding failure.
271  * @syscap SystemCapability.Multimedia.Media.VideoDecoder
272  * @param codec Pointer to an OH_AVCodec instance
273  * @param format pointer to an OH_AVFormat instance
274  * @return Returns AV_ERR_OK if the execution is successful,
275  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
276  * {@link AV_ERR_NO_MEMORY}, instance has already released.
277  * {@link AV_ERR_INVALID_VAL}, the decoder is NULL or invalid. Invalid param in format.
278  * {@link AV_ERR_UNKNOWN}, unknown error.
279  * {@link AV_ERR_SERVICE_DIED}, avcodec service is died.
280  * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state.
281  * @since 9
282  * @version 1.0
283  */
284 OH_AVErrCode OH_VideoDecoder_SetParameter(OH_AVCodec *codec, OH_AVFormat *format);
285 
286 /**
287  * @brief Submit the input buffer filled with data to the video decoder. The {@link OH_AVCodecOnNeedInputData} callback
288  * will report the available input buffer and the corresponding index value. Once the buffer with the specified index
289  * is submitted to the video decoder, the buffer cannot be accessed again until the {@link OH_AVCodecOnNeedInputData}
290  * callback is received again reporting that the buffer with the same index is available. In addition, for some
291  * decoders, it is required to input Codec-Specific-Data to the decoder at the beginning to initialize the decoding
292  * process of the decoder, such as PPS/SPS data in H264 format.
293  * @syscap SystemCapability.Multimedia.Media.VideoDecoder
294  * @param codec Pointer to an OH_AVCodec instance
295  * @param index Enter the index value corresponding to the Buffer
296  * @param attr Information describing the data contained in the Buffer
297  * @return Returns AV_ERR_OK if the execution is successful,
298  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
299  * {@link AV_ERR_NO_MEMORY}, instance has already released.
300  * {@link AV_ERR_INVALID_VAL}, the decoder is NULL or invalid.
301  * Buffer index should be given by {@link OH_AVCodecOnNeedInputData}.
302  * {@link AV_ERR_UNKNOWN}, unknown error.
303  * {@link AV_ERR_SERVICE_DIED}, avcodec service is died.
304  * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state.
305  * @deprecated since 11
306  * @useinstead OH_VideoDecoder_PushInputBuffer
307  * @since 9
308  * @version 1.0
309  */
310 OH_AVErrCode OH_VideoDecoder_PushInputData(OH_AVCodec *codec, uint32_t index, OH_AVCodecBufferAttr attr);
311 
312 /**
313  * @brief Return the processed output Buffer to the decoder, and notify the decoder to finish rendering the
314  * decoded data contained in the Buffer on the output Surface. If the output surface is not configured before,
315  * calling this interface only returns the output buffer corresponding to the specified index to the decoder.
316  * @syscap SystemCapability.Multimedia.Media.VideoDecoder
317  * @param codec Pointer to an OH_AVCodec instance
318  * @param index The index value corresponding to the output Buffer
319  * @return Returns AV_ERR_OK if the execution is successful,
320  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
321  * {@link AV_ERR_NO_MEMORY}, instance has already released.
322  * {@link AV_ERR_INVALID_VAL}, the decoder is NULL or invalid.
323  * Buffer index should be given by {@link OH_AVCodecOnNewOutputData}.
324  * {@link AV_ERR_UNKNOWN}, unknown error.
325  * {@link AV_ERR_SERVICE_DIED}, avcodec service is died.
326  * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state.
327  * @deprecated since 11
328  * @useinstead OH_VideoDecoder_RenderOutputBuffer
329  * @since 9
330  * @version 1.0
331  */
332 OH_AVErrCode OH_VideoDecoder_RenderOutputData(OH_AVCodec *codec, uint32_t index);
333 
334 /**
335  * @brief Return the processed output Buffer to the decoder.
336  * @syscap SystemCapability.Multimedia.Media.VideoDecoder
337  * @param codec Pointer to an OH_AVCodec instance
338  * @param index The index value corresponding to the output Buffer
339  * @return Returns AV_ERR_OK if the execution is successful,
340  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
341  * {@link AV_ERR_NO_MEMORY}, instance has already released.
342  * {@link AV_ERR_INVALID_VAL}, the decoder is NULL or invalid.
343  * Buffer index should be given by {@link OH_AVCodecOnNewOutputData}.
344  * {@link AV_ERR_UNKNOWN}, unknown error.
345  * {@link AV_ERR_SERVICE_DIED}, avcodec service is died.
346  * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state.
347  * @deprecated since 11
348  * @useinstead OH_VideoDecoder_FreeOutputBuffer
349  * @since 9
350  * @version 1.0
351  */
352 OH_AVErrCode OH_VideoDecoder_FreeOutputData(OH_AVCodec *codec, uint32_t index);
353 
354 /**
355  * @brief Submit the input buffer filled with data to the video decoder. The {@link OH_AVCodecOnNeedInputBuffer}
356  * callback will report the available input buffer and the corresponding index value. Once the buffer with the
357  * specified index is submitted to the video decoder, the buffer cannot be accessed again until the
358  * {@link OH_AVCodecOnNeedInputBuffer} callback is received again reporting that the buffer with the same index is
359  * available. In addition, for some decoders, it is required to input Codec-Specific-Data to the decoder at the
360  * beginning to initialize the decoding process of the decoder, such as PPS/SPS data in H264 format.
361  * @syscap SystemCapability.Multimedia.Media.VideoDecoder
362  * @param codec Pointer to an OH_AVCodec instance
363  * @param index The index of the input buffer.
364  * @return Returns AV_ERR_OK if the execution is successful,
365  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
366  * {@link AV_ERR_NO_MEMORY}, instance has already released.
367  * {@link AV_ERR_INVALID_VAL}, the decoder is NULL or invalid.
368  * Buffer index should be given by {@link OH_AVCodecOnNeedInputBuffer}.
369  * {@link AV_ERR_UNKNOWN}, unknown error.
370  * {@link AV_ERR_SERVICE_DIED}, avcodec service is died.
371  * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state.
372  * {@link AV_ERR_DRM_DECRYPT_FAILED}, the drm-protected video buffer is decrypted failed,
373  * it is recommended to check the logs.
374  * @since 11
375  */
376 OH_AVErrCode OH_VideoDecoder_PushInputBuffer(OH_AVCodec *codec, uint32_t index);
377 
378 /**
379  * @brief Return the processed output Buffer to the decoder, and notify the decoder to finish rendering the
380  * decoded data contained in the Buffer on the output Surface. If the output surface is not configured before,
381  * calling this interface only returns the output buffer corresponding to the specified index to the decoder.
382  * @syscap SystemCapability.Multimedia.Media.VideoDecoder
383  * @param codec Pointer to an OH_AVCodec instance
384  * @param index The index value corresponding to the output Buffer
385  * @return Returns AV_ERR_OK if the execution is successful,
386  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
387  * {@link AV_ERR_NO_MEMORY}, instance has already released.
388  * {@link AV_ERR_INVALID_VAL}, the decoder is NULL or invalid.
389  * Buffer index should be given by {@link OH_AVCodecOnNewOutputBuffer}.
390  * {@link AV_ERR_UNKNOWN}, unknown error.
391  * {@link AV_ERR_SERVICE_DIED}, avcodec service is died.
392  * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state.
393  * @since 11
394  */
395 OH_AVErrCode OH_VideoDecoder_RenderOutputBuffer(OH_AVCodec *codec, uint32_t index);
396 
397 /**
398  * @brief Return the processed output buffer with render timestamp to the decoder, and notify the decoder to finish
399  * rendering the decoded data contained in the buffer on the output surface. If the output surface is not configured
400  * before, calling this interface only returns the output buffer corresponding to the specified index to the decoder.
401  * The timestamp may have special meaning depending on the destination surface.
402  * Invoker can use the timestamp to render the buffer at a specific time (at the VSYNC at or after the buffer
403  * timestamp). For this to work, the timestamp needs to be reasonably close to the current SystemNanoTime. A few notes:
404  * 1. The buffer will not be returned to the codec until the timestamp has passed and the buffer is no longer used by
405  *    the surface.
406  * 2. Buffers are processed sequentially, so you may block subsequent buffers to be displayed on the surface.
407  *    This is important if you want to react to user action, e.g. stop the video or seek.
408  * 3. If multiple buffers are sent to the surface to be rendered at the same VSYNC, the last one will be shown, and the
409  *    other ones will be dropped.
410  * 4. If the timestamp is not "reasonably close" to the current system time, the Surface will
411  *    ignore the timestamp, and display the buffer at the earliest feasible time. In this mode it will not drop frames.
412  * @syscap SystemCapability.Multimedia.Media.VideoDecoder
413  * @param codec Pointer to an OH_AVCodec instance
414  * @param index The index value corresponding to the output buffer, should be given by {@link
415  * OH_AVCodecOnNewOutputBuffer}
416  * @param renderTimestampNs The timestamp is associated with the output buffer when it is sent to the surface. The unit
417  * is nanosecond
418  * @return Returns AV_ERR_OK if the execution is successful,
419  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
420  * {@link AV_ERR_NO_MEMORY}, the codec has already released.
421  * {@link AV_ERR_INVALID_VAL}, the parameter is invalid.
422  * {@link AV_ERR_UNKNOWN}, unknown error.
423  * {@link AV_ERR_SERVICE_DIED}, avcodec service is died.
424  * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state.
425  * @since 12
426  */
427 OH_AVErrCode OH_VideoDecoder_RenderOutputBufferAtTime(OH_AVCodec *codec, uint32_t index, int64_t renderTimestampNs);
428 
429 /**
430  * @brief Return the processed output Buffer to the decoder.
431  * @syscap SystemCapability.Multimedia.Media.VideoDecoder
432  * @param codec Pointer to an OH_AVCodec instance
433  * @param index The index value corresponding to the output Buffer
434  * @return Returns AV_ERR_OK if the execution is successful,
435  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
436  * {@link AV_ERR_NO_MEMORY}, instance has already released.
437  * {@link AV_ERR_INVALID_VAL}, the decoder is NULL or invalid.
438  * Buffer index should be given by {@link OH_AVCodecOnNewOutputBuffer}.
439  * {@link AV_ERR_UNKNOWN}, unknown error.
440  * {@link AV_ERR_SERVICE_DIED}, avcodec service is died.
441  * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state.
442  * @since 11
443  */
444 OH_AVErrCode OH_VideoDecoder_FreeOutputBuffer(OH_AVCodec *codec, uint32_t index);
445 
446 /**
447  * @brief Check whether the current codec instance is valid. It can be used fault recovery or app
448  * switchback from the background.
449  * @syscap SystemCapability.Multimedia.Media.VideoDecoder
450  * @param codec Pointer to an OH_AVCodec instance
451  * @param isValid Output parameter. A pointer to a boolean instance, it is true if the codec instance is valid,
452  * false if the codec instance is invalid
453  * @return Returns AV_ERR_OK if the execution is successful,
454  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
455  * {@link AV_ERR_NO_MEMORY}, instance has already released.
456  * {@link AV_ERR_INVALID_VAL}, the decoder is NULL or invalid.
457  * {@link AV_ERR_UNKNOWN}, unknown error.
458  * {@link AV_ERR_SERVICE_DIED}, avcodec service is died.
459  * @since 10
460  */
461 OH_AVErrCode OH_VideoDecoder_IsValid(OH_AVCodec *codec, bool *isValid);
462 
463 /**
464  * @brief Set decryption info.
465  *
466  * @syscap SystemCapability.Multimedia.Media.VideoDecoder
467  * @param codec Pointer to an OH_AVCodec instance
468  * @param mediaKeySession A media key session instance with decryption function.
469  * @param secureVideoPath Require secure decoder or not.
470  * @return {@link AV_ERR_OK} 0 - Success
471  *         {@link AV_ERR_OPERATE_NOT_PERMIT} 2 - If the codec service or the media key session
472  *         service is in wrong status.
473  *         {@link AV_ERR_NO_MEMORY}, instance has already released or no memory.
474  *         {@link AV_ERR_INVALID_VAL} 3 - If the codec instance is NULL or invalid,
475  *         the mediaKeySession is NULL or invalid.
476  * @since 11
477  * @version 1.0
478 */
479 OH_AVErrCode OH_VideoDecoder_SetDecryptionConfig(OH_AVCodec *codec, MediaKeySession *mediaKeySession,
480     bool secureVideoPath);
481 
482 #ifdef __cplusplus
483 }
484 #endif
485 
486 #endif // NATIVE_AVCODEC_VIDEODECODER_H
487 /** @} */