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, it is recommended to use. 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 * The decoder name can be obtained through capability query. 66 * @syscap SystemCapability.Multimedia.Media.VideoDecoder 67 * @param name video codec name 68 * @return Returns a Pointer to an OH_AVCodec instance. 69 * Return NULL if memory ran out or the decoder name is not supported. 70 * @since 9 71 * @version 1.0 72 */ 73 OH_AVCodec *OH_VideoDecoder_CreateByName(const char *name); 74 75 /** 76 * @brief Clear the internal resources of the decoder and destroy the decoder instance. 77 * Can not be destoryed repeatedly. 78 * @syscap SystemCapability.Multimedia.Media.VideoDecoder 79 * @param codec Pointer to an OH_AVCodec instance 80 * @return Returns AV_ERR_OK if succeed, 81 * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. 82 * {@link AV_ERR_NO_MEMORY}, instance has already destoryed. 83 * {@link AV_ERR_INVALID_VAL}, the input codec pointer is non decoder instance or NULL. 84 * {@link AV_ERR_UNKNOWN}, unknown error. 85 * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error. 86 * @since 9 87 * @version 1.0 88 */ 89 OH_AVErrCode OH_VideoDecoder_Destroy(OH_AVCodec *codec); 90 91 /** 92 * @brief Set the asynchronous callback function so that your application can respond to the events 93 * generated by the video decoder. This interface must be called before Prepare is called. 94 * @syscap SystemCapability.Multimedia.Media.VideoDecoder 95 * @param codec Pointer to an OH_AVCodec instance 96 * @param callback A collection of all callback functions, see {@link OH_AVCodecAsyncCallback} 97 * @param userData The data that the user rely on to execute the callback 98 * @return Returns AV_ERR_OK if the execution is successful, 99 * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. 100 * {@link AV_ERR_NO_MEMORY}, instance has already destoryed. 101 * {@link AV_ERR_INVALID_VAL}, the input codec pointer is non decoder instance or NULL. 102 * {@link AV_ERR_UNKNOWN}, unknown error. 103 * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error. 104 * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state, must be called before Prepare. 105 * @deprecated since 11 106 * @useinstead OH_VideoDecoder_RegisterCallback 107 * @since 9 108 * @version 1.0 109 */ 110 OH_AVErrCode OH_VideoDecoder_SetCallback(OH_AVCodec *codec, OH_AVCodecAsyncCallback callback, void *userData); 111 112 /** 113 * @brief Set the asynchronous callback function so that your application can respond to the events 114 * generated by the video decoder. This interface must be called before Prepare is called. 115 * @syscap SystemCapability.Multimedia.Media.VideoDecoder 116 * @param codec Pointer to an OH_AVCodec instance 117 * @param callback A collection of all callback functions, see {@link OH_AVCodecCallback} 118 * @param userData The data that the user rely on to execute the callback 119 * @return Returns AV_ERR_OK if the execution is successful, 120 * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. 121 * {@link AV_ERR_NO_MEMORY}, instance has already destoryed. 122 * {@link AV_ERR_INVALID_VAL}, the input codec pointer is non decoder instance or NULL. 123 * {@link AV_ERR_UNKNOWN}, unknown error. 124 * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error. 125 * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state, must be called before Prepare. 126 * @since 11 127 */ 128 OH_AVErrCode OH_VideoDecoder_RegisterCallback(OH_AVCodec *codec, OH_AVCodecCallback callback, void *userData); 129 130 /** 131 * @brief Specify the output surface to provide video decoding output, 132 * this interface must be called before Prepare is called. 133 * This interface can be directly called in the Executing state. 134 * @syscap SystemCapability.Multimedia.Media.VideoDecoder 135 * @param codec Pointer to an OH_AVCodec instance 136 * @param window A pointer to a OHNativeWindow instance, see {@link OHNativeWindow} 137 * @return Returns AV_ERR_OK if the execution is successful, 138 * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. 139 * {@link AV_ERR_NO_MEMORY}, instance has already destoryed. 140 * {@link AV_ERR_OPERATE_NOT_PERMIT}, not permit to call the interface in Buffer mode. 141 * {@link AV_ERR_INVALID_VAL} 142 * 1. the input codec pointer is non decoder instance or NULL; 143 * 2. window is NULL. 144 * {@link AV_ERR_UNKNOWN}, unknown error. 145 * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. 146 * @since 9 147 * @version 1.0 148 */ 149 OH_AVErrCode OH_VideoDecoder_SetSurface(OH_AVCodec *codec, OHNativeWindow *window); 150 151 /** 152 * @brief To configure the video decoder, typically, you need to configure the description information of the decoded 153 * video, which can be extracted from the OH_AVSource. This interface must be called before Prepare is called. 154 * @syscap SystemCapability.Multimedia.Media.VideoDecoder 155 * @param codec Pointer to an OH_AVCodec instance 156 * @param format A pointer to an OH_AVFormat to give the description of the video track to be decoded 157 * @return Returns AV_ERR_OK if the execution is successful, 158 * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. 159 * {@link AV_ERR_NO_MEMORY}, instance has already destoryed. 160 * {@link AV_ERR_INVALID_VAL} 161 * 1. the input codec pointer is non decoder instance or NULL; 162 * 2. Invalid param in format. 163 * {@link AV_ERR_UNKNOWN}, unknown error. 164 * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error. 165 * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state, must be called before Prepare. 166 * {@link AV_ERR_VIDEO_UNSUPPORTED_COLOR_SPACE_CONVERSION}, video unsupported color space conversion. 167 * @since 9 168 * @version 1.0 169 */ 170 OH_AVErrCode OH_VideoDecoder_Configure(OH_AVCodec *codec, OH_AVFormat *format); 171 172 /** 173 * @brief Prepare the internal resources of the decoder, the Configure interface must be called before 174 * calling this interface. 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 destoryed. 180 * {@link AV_ERR_INVALID_VAL}, the input codec pointer is non decoder instance or NULL. 181 * {@link AV_ERR_UNKNOWN}, unknown error. 182 * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. 183 * {@link AV_ERR_OPERATE_NOT_PERMIT} 184 * 1. internal execution error; 185 * 2. decoder is in Buffer mode and color space conversion is configured. 186 * @since 9 187 * @version 1.0 188 */ 189 OH_AVErrCode OH_VideoDecoder_Prepare(OH_AVCodec *codec); 190 191 /** 192 * @brief Start the decoder, this interface must be called after the Prepare is successful. 193 * After being successfully started, the decoder will start reporting NeedInputData events. 194 * @syscap SystemCapability.Multimedia.Media.VideoDecoder 195 * @param codec Pointer to an OH_AVCodec instance 196 * @return Returns AV_ERR_OK if the execution is successful, 197 * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. 198 * {@link AV_ERR_NO_MEMORY}, instance has already destoryed. 199 * {@link AV_ERR_INVALID_VAL}, the input codec pointer is non decoder instance or NULL. 200 * {@link AV_ERR_UNKNOWN}, unknown error. 201 * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. 202 * {@link AV_ERR_OPERATE_NOT_PERMIT} 203 * 1. internal execution error; 204 * 2. video color space conversion is configured but decoder is not Prepared. 205 * @since 9 206 * @version 1.0 207 */ 208 OH_AVErrCode OH_VideoDecoder_Start(OH_AVCodec *codec); 209 210 /** 211 * @brief Stop the decoder and release the input and output buffer. After stopping, 212 * you can re-enter the Running state through Start, but it should be noted that 213 * if Codec-Specific-Data has been input to the decoder before, it needs to be input again. 214 * @syscap SystemCapability.Multimedia.Media.VideoDecoder 215 * @param codec Pointer to an OH_AVCodec instance 216 * @return Returns AV_ERR_OK if the execution is successful, 217 * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. 218 * {@link AV_ERR_NO_MEMORY}, instance has already destoryed. 219 * {@link AV_ERR_INVALID_VAL}, the input codec pointer is non decoder instance or NULL. 220 * {@link AV_ERR_UNKNOWN}, unknown error. 221 * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. 222 * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error. 223 * @since 9 224 * @version 1.0 225 */ 226 OH_AVErrCode OH_VideoDecoder_Stop(OH_AVCodec *codec); 227 228 /** 229 * @brief Clear the input and output data buffered and parameters in the decoder, for example, PPS/SPS in H264 format. 230 * After this interface is called, all the buffer indexes previously reported through the asynchronous callback 231 * will be invalidated, make sure not to access the buffers corresponding to these indexes. 232 * @syscap SystemCapability.Multimedia.Media.VideoDecoder 233 * @param codec Pointer to an OH_AVCodec instance 234 * @return Returns AV_ERR_OK if the execution is successful, 235 * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. 236 * {@link AV_ERR_NO_MEMORY}, instance has already destoryed. 237 * {@link AV_ERR_INVALID_VAL}, the input codec pointer is non decoder instance or NULL. 238 * {@link AV_ERR_UNKNOWN}, unknown error. 239 * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error. 240 * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. 241 * @since 9 242 * @version 1.0 243 */ 244 OH_AVErrCode OH_VideoDecoder_Flush(OH_AVCodec *codec); 245 246 /** 247 * @brief Reset the decoder, the decoder returns to the Initialized state. 248 * To continue decoding, you need to call the Configure interface again to configure the decoder instance. 249 * @syscap SystemCapability.Multimedia.Media.VideoDecoder 250 * @param codec Pointer to an OH_AVCodec instance 251 * @return Returns AV_ERR_OK if the execution is successful, 252 * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. 253 * {@link AV_ERR_NO_MEMORY}, instance has already destoryed. 254 * {@link AV_ERR_INVALID_VAL}, the input codec pointer is non decoder instance or NULL. 255 * {@link AV_ERR_UNKNOWN}, unknown error. 256 * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error. 257 * @since 9 258 * @version 1.0 259 */ 260 OH_AVErrCode OH_VideoDecoder_Reset(OH_AVCodec *codec); 261 262 /** 263 * @brief Get the description information of the output data of the decoder, refer to {@link OH_AVFormat} 264 * It should be noted that the life cycle of the OH_AVFormat instance pointed to by the return value * needs 265 * to be released by {@link OH_AVFormat_Destroy}. 266 * @syscap SystemCapability.Multimedia.Media.VideoDecoder 267 * @param codec Pointer to an OH_AVCodec instance 268 * @return Returns a pointer to an OH_AVFormat instance. 269 * Return NULL if the decoder is NULL or invaild. 270 * @since 9 271 * @version 1.0 272 */ 273 OH_AVFormat *OH_VideoDecoder_GetOutputDescription(OH_AVCodec *codec); 274 275 /** 276 * @brief Set dynamic parameters to the decoder. Note: This interface can only be called after the decoder is started. 277 * At the same time, incorrect parameter settings may cause decoding failure. 278 * @syscap SystemCapability.Multimedia.Media.VideoDecoder 279 * @param codec Pointer to an OH_AVCodec instance 280 * @param format pointer to an OH_AVFormat instance 281 * @return Returns AV_ERR_OK if the execution is successful, 282 * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. 283 * {@link AV_ERR_NO_MEMORY}, instance has already destoryed. 284 * {@link AV_ERR_INVALID_VAL} 285 * 1. the input codec pointer is non decoder instance or NULL; 286 * 2. invalid param in format. 287 * {@link AV_ERR_UNKNOWN}, unknown error. 288 * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error. 289 * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. 290 * @since 9 291 * @version 1.0 292 */ 293 OH_AVErrCode OH_VideoDecoder_SetParameter(OH_AVCodec *codec, OH_AVFormat *format); 294 295 /** 296 * @brief Submit the input buffer filled with data to the video decoder. The {@link OH_AVCodecOnNeedInputData} callback 297 * will report the available input buffer and the corresponding index value. Once the buffer with the specified index 298 * is submitted to the video decoder, the buffer cannot be accessed again until the {@link OH_AVCodecOnNeedInputData} 299 * callback is received again reporting that the buffer with the same index is available. In addition, for some 300 * decoders, it is required to input Codec-Specific-Data to the decoder at the beginning to initialize the decoding 301 * process of the decoder, such as PPS/SPS data in H264 format. 302 * @syscap SystemCapability.Multimedia.Media.VideoDecoder 303 * @param codec Pointer to an OH_AVCodec instance 304 * @param index Enter the index value corresponding to the buffer, should be given by {@link OH_AVCodecOnNeedInputData}. 305 * @param attr Information describing the data contained in the buffer 306 * @return Returns AV_ERR_OK if the execution is successful, 307 * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. 308 * {@link AV_ERR_NO_MEMORY}, instance has already destoryed. 309 * {@link AV_ERR_INVALID_VAL}, the input codec pointer is non decoder instance or NULL. 310 * {@link AV_ERR_UNKNOWN}, unknown error. 311 * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error. 312 * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. 313 * @deprecated since 11 314 * @useinstead OH_VideoDecoder_PushInputBuffer 315 * @since 9 316 * @version 1.0 317 */ 318 OH_AVErrCode OH_VideoDecoder_PushInputData(OH_AVCodec *codec, uint32_t index, OH_AVCodecBufferAttr attr); 319 320 /** 321 * @brief Return the processed output buffer to the decoder, and notify the decoder to finish rendering the 322 * decoded data contained in the buffer on the output surface. If the output surface is not configured before, 323 * calling this interface only returns the output buffer corresponding to the specified index to the decoder. 324 * @syscap SystemCapability.Multimedia.Media.VideoDecoder 325 * @param codec Pointer to an OH_AVCodec instance 326 * @param index The index value corresponding to the output buffer, should be given by {@link OH_AVCodecOnNewOutputData} 327 * @return Returns AV_ERR_OK if the execution is successful, 328 * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. 329 * {@link AV_ERR_NO_MEMORY}, instance has already destoryed. 330 * {@link AV_ERR_INVALID_VAL}, the input codec pointer is non decoder instance or NULL. 331 * {@link AV_ERR_UNKNOWN}, unknown error. 332 * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error. 333 * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. 334 * @deprecated since 11 335 * @useinstead OH_VideoDecoder_RenderOutputBuffer 336 * @since 9 337 * @version 1.0 338 */ 339 OH_AVErrCode OH_VideoDecoder_RenderOutputData(OH_AVCodec *codec, uint32_t index); 340 341 /** 342 * @brief Return the processed output buffer to the decoder. 343 * @syscap SystemCapability.Multimedia.Media.VideoDecoder 344 * @param codec Pointer to an OH_AVCodec instance 345 * @param index The index value corresponding to the output buffer, 346 * should be given by {@link OH_AVCodecOnNewOutputData}. 347 * @return Returns AV_ERR_OK if the execution is successful, 348 * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. 349 * {@link AV_ERR_NO_MEMORY}, instance has already destoryed. 350 * {@link AV_ERR_INVALID_VAL}, the input codec pointer is non decoder instance or NULL. 351 * {@link AV_ERR_UNKNOWN}, unknown error. 352 * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error. 353 * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. 354 * @deprecated since 11 355 * @useinstead OH_VideoDecoder_FreeOutputBuffer 356 * @since 9 357 * @version 1.0 358 */ 359 OH_AVErrCode OH_VideoDecoder_FreeOutputData(OH_AVCodec *codec, uint32_t index); 360 361 /** 362 * @brief Notify the video decoder that the buffer corresponding to the index has been filled with input data. 363 * {@link OH_AVCodecOnNeedInputBuffer} callback will report the available input buffer and 364 * the corresponding index value. Once the buffer with the specified index is submitted to the video decoder, 365 * the buffer cannot be accessed again until the {@link OH_AVCodecOnNeedInputBuffer} callback is received again 366 * reporting that the buffer with the same index is available. In addition, for some decoders, it is required 367 * to input Codec-Specific-Data to the decoder at the beginning to initialize the decoding process of the decoder, 368 * such as PPS/SPS data in H264 format. The invoker can use this interface to transfer the parameters required 369 * for decoding to the decoder, such as PPS/SPS data in H264 format. 370 * The parameters can be sent to the decoder independently or together with the data to be decoded. 371 * @syscap SystemCapability.Multimedia.Media.VideoDecoder 372 * @param codec Pointer to an OH_AVCodec instance 373 * @param index The index of the input buffer, should be given by {@link OH_AVCodecOnNeedInputBuffer}. 374 * @return Returns AV_ERR_OK if the execution is successful, 375 * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. 376 * {@link AV_ERR_NO_MEMORY}, instance has already destoryed. 377 * {@link AV_ERR_INVALID_VAL}, the input codec pointer is non decoder instance or NULL. 378 * {@link AV_ERR_UNKNOWN}, unknown error. 379 * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error. 380 * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. 381 * @since 11 382 */ 383 OH_AVErrCode OH_VideoDecoder_PushInputBuffer(OH_AVCodec *codec, uint32_t index); 384 385 /** 386 * @brief Return the processed output buffer to the decoder, and notify the decoder to finish rendering the 387 * decoded data contained in the buffer on the output surface. If the output surface is not configured before, 388 * calling this interface only returns the output buffer corresponding to the specified index to the decoder. 389 * @syscap SystemCapability.Multimedia.Media.VideoDecoder 390 * @param codec Pointer to an OH_AVCodec instance 391 * @param index The index value corresponding to the output buffer, 392 * should be given by {@link OH_AVCodecOnNewOutputBuffer}. 393 * @return Returns AV_ERR_OK if the execution is successful, 394 * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. 395 * {@link AV_ERR_NO_MEMORY}, instance has already destoryed. 396 * {@link AV_ERR_INVALID_VAL}, the input codec pointer is non decoder instance or NULL. 397 * {@link AV_ERR_UNKNOWN}, unknown error. 398 * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error. 399 * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. 400 * @since 11 401 */ 402 OH_AVErrCode OH_VideoDecoder_RenderOutputBuffer(OH_AVCodec *codec, uint32_t index); 403 404 /** 405 * @brief Return the processed output buffer with render timestamp to the decoder, and notify the decoder to finish 406 * rendering the decoded data contained in the buffer on the output surface. If the output surface is not configured 407 * before, calling this interface only returns the output buffer corresponding to the specified index to the decoder. 408 * The timestamp may have special meaning depending on the destination surface. 409 * Invoker can use the timestamp to render the buffer at a specific time (at the VSYNC at or after the buffer 410 * timestamp). For this to work, the timestamp needs to be reasonably close to the current SystemNanoTime. A few notes: 411 * 1. The buffer will not be returned to the codec until the timestamp has passed and the buffer is no longer used by 412 * the surface. 413 * 2. buffers are processed sequentially, so you may block subsequent buffers to be displayed on the surface. 414 * This is important if you want to react to user action, e.g. stop the video or seek. 415 * 3. If multiple buffers are sent to the surface to be rendered at the same VSYNC, the last one will be shown, and the 416 * other ones will be dropped. 417 * 4. If the timestamp is not "reasonably close" to the current system time, the surface will 418 * ignore the timestamp, and display the buffer at the earliest feasible time. In this mode it will not drop frames. 419 * @syscap SystemCapability.Multimedia.Media.VideoDecoder 420 * @param codec Pointer to an OH_AVCodec instance 421 * @param index The index value corresponding to the output buffer, should be given by {@link 422 * OH_AVCodecOnNewOutputBuffer} 423 * @param renderTimestampNs The timestamp is associated with the output buffer when it is sent to the surface. The unit 424 * is nanosecond 425 * @return Returns AV_ERR_OK if the execution is successful, 426 * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. 427 * {@link AV_ERR_NO_MEMORY}, instance has already destoryed. 428 * {@link AV_ERR_INVALID_VAL}, the parameter is invalid. 429 * {@link AV_ERR_UNKNOWN}, unknown error. 430 * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error. 431 * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. 432 * @since 12 433 */ 434 OH_AVErrCode OH_VideoDecoder_RenderOutputBufferAtTime(OH_AVCodec *codec, uint32_t index, int64_t renderTimestampNs); 435 436 /** 437 * @brief Return the processed output buffer to the decoder. 438 * Need to call this interface to release output buffer immediately after using. 439 * Otherwise, the decoding process will be blocked. 440 * @syscap SystemCapability.Multimedia.Media.VideoDecoder 441 * @param codec Pointer to an OH_AVCodec instance 442 * @param index The index value corresponding to the output buffer, 443 * should be given by {@link OH_AVCodecOnNewOutputBuffer}. 444 * @return Returns AV_ERR_OK if the execution is successful, 445 * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. 446 * {@link AV_ERR_NO_MEMORY}, instance has already destoryed. 447 * {@link AV_ERR_INVALID_VAL} 448 * 1. the input codec pointer is non decoder instance or NULL; 449 * 2. the index is vaild or consecutively assigned to the same index, 450 * the error do not affect the subsequent decode process. 451 * {@link AV_ERR_UNKNOWN}, unknown error. 452 * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error. 453 * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. 454 * @since 11 455 */ 456 OH_AVErrCode OH_VideoDecoder_FreeOutputBuffer(OH_AVCodec *codec, uint32_t index); 457 458 /** 459 * @brief Check whether the current codec instance is valid. It can be used fault recovery or app 460 * switchback from the background. 461 * @syscap SystemCapability.Multimedia.Media.VideoDecoder 462 * @param codec Pointer to an OH_AVCodec instance 463 * @param isValid Output parameter. A pointer to a bool instance, it is true if the codec instance is valid, 464 * false if the codec instance is invalid. It is recommend that the invoker initialize isValid to false 465 * @return Returns AV_ERR_OK if the execution is successful, 466 * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. 467 * {@link AV_ERR_INVALID_VAL}, the input codec pointer is non decoder instance or NULL. 468 * @since 10 469 */ 470 OH_AVErrCode OH_VideoDecoder_IsValid(OH_AVCodec *codec, bool *isValid); 471 472 /** 473 * @brief Set decryption configuration. Call this interface before calling the Prepare interface. 474 * 475 * @syscap SystemCapability.Multimedia.Media.VideoDecoder 476 * @param codec Pointer to an OH_AVCodec instance 477 * @param mediaKeySession A media key session instance with decryption function. 478 * @param secureVideoPath Secure video Path. Set the secure video path as true and the non secure video path as false. 479 * In Surface mode, both secure and non secure video Path are supported. 480 * In Buffer mode, only non secure video Path are supported. 481 * @return {@link AV_ERR_OK}, execution is successful 482 * {@link AV_ERR_OPERATE_NOT_PERMIT} 483 * 1. internal execution error; 484 * 2. the decode service process is abnormal; 485 * 3. the media key session service is in an wrong state. 486 * {@link AV_ERR_NO_MEMORY}, instance has already destoryed or no memory. 487 * {@link AV_ERR_INVALID_VAL} 488 * 1. the input codec pointer is non decoder instance or NULL; 489 * 2. mediaKeySession is NULL or invalid. 490 * @since 11 491 */ 492 OH_AVErrCode OH_VideoDecoder_SetDecryptionConfig(OH_AVCodec *codec, MediaKeySession *mediaKeySession, 493 bool secureVideoPath); 494 495 #ifdef __cplusplus 496 } 497 #endif 498 499 #endif // NATIVE_AVCODEC_VIDEODECODER_H 500 /** @} */