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