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 #ifndef NATIVE_AVCODEC_VIDEODECODER_H 17 #define NATIVE_AVCODEC_VIDEODECODER_H 18 19 #include <stdint.h> 20 #include <stdio.h> 21 #include "native_avcodec_base.h" 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 typedef struct MediaKeySession MediaKeySession; 28 29 /** 30 * @brief Creates a video decoder instance from the mime type, which is recommended in most cases. 31 * @syscap SystemCapability.Multimedia.Media.VideoDecoder 32 * @param mime mime type description string, refer to {@link AVCODEC_MIME_TYPE} 33 * @return Returns a Pointer to an OH_AVCodec instance. 34 * Return nullptr if memory ran out or the mime type is not supported. 35 * @since 9 36 * @version 1.0 37 */ 38 OH_AVCodec *OH_VideoDecoder_CreateByMime(const char *mime); 39 40 /** 41 * @brief Create a video decoder instance through the video decoder name. 42 * The premise of using this interface is to know the exact name of the decoder. 43 * @syscap SystemCapability.Multimedia.Media.VideoDecoder 44 * @param name video codec name 45 * @return Returns a Pointer to an OH_AVCodec instance. 46 * Return nullptr if memory ran out or the decoder name is not supported. 47 * @since 9 48 * @version 1.0 49 */ 50 OH_AVCodec *OH_VideoDecoder_CreateByName(const char *name); 51 52 /** 53 * @brief Clear the internal resources of the decoder and destroy the decoder instance 54 * @syscap SystemCapability.Multimedia.Media.VideoDecoder 55 * @param codec Pointer to an OH_AVCodec instance 56 * @return Returns AV_ERR_OK if succeed, 57 * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. 58 * {@link AV_ERR_NO_MEMORY}, inner resource has already released. 59 * {@link AV_ERR_INVALID_VAL}, the decoder is nullptr or invalid. 60 * {@link AV_ERR_UNKNOWN}, unknown error. 61 * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. 62 * @since 9 63 * @version 1.0 64 */ 65 OH_AVErrCode OH_VideoDecoder_Destroy(OH_AVCodec *codec); 66 67 /** 68 * @brief Set the asynchronous callback function so that your application can respond to the events 69 * generated by the video decoder. This interface must be called before Prepare is called. 70 * @syscap SystemCapability.Multimedia.Media.VideoDecoder 71 * @param codec Pointer to an OH_AVCodec instance 72 * @param callback A collection of all callback functions, see {@link OH_AVCodecAsyncCallback} 73 * @param userData User specific data 74 * @return Returns AV_ERR_OK if the execution is successful, 75 * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. 76 * {@link AV_ERR_NO_MEMORY}, inner resource has already released. 77 * {@link AV_ERR_INVALID_VAL}, the decoder is nullptr or invalid. 78 * {@link AV_ERR_UNKNOWN}, unknown error. 79 * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. 80 * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state, must be called before Prepare. 81 * @deprecated since 11 82 * @useinstead OH_VideoDecoder_RegisterCallback 83 * @since 9 84 * @version 1.0 85 */ 86 OH_AVErrCode OH_VideoDecoder_SetCallback(OH_AVCodec *codec, OH_AVCodecAsyncCallback callback, void *userData); 87 88 /** 89 * @brief Set the asynchronous callback function so that your application can respond to the events 90 * generated by the video decoder. This interface must be called before Prepare is called. 91 * @syscap SystemCapability.Multimedia.Media.VideoDecoder 92 * @param codec Pointer to an OH_AVCodec instance 93 * @param callback A collection of all callback functions, see {@link OH_AVCodecCallback} 94 * @param userData User specific data 95 * @return Returns AV_ERR_OK if the execution is successful, 96 * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. 97 * {@link AV_ERR_NO_MEMORY}, inner resource has already released. 98 * {@link AV_ERR_INVALID_VAL}, the decoder is nullptr or invalid. 99 * {@link AV_ERR_UNKNOWN}, unknown error. 100 * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. 101 * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state, must be called before Prepare. 102 * @since 11 103 */ 104 OH_AVErrCode OH_VideoDecoder_RegisterCallback(OH_AVCodec *codec, OH_AVCodecCallback callback, void *userData); 105 106 /** 107 * @brief Specify the output Surface to provide video decoding output, 108 * this interface must be called before Prepare is called 109 * @syscap SystemCapability.Multimedia.Media.VideoDecoder 110 * @param codec Pointer to an OH_AVCodec instance 111 * @param window A pointer to a OHNativeWindow instance, see {@link OHNativeWindow} 112 * @return Returns AV_ERR_OK if the execution is successful, 113 * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. 114 * {@link AV_ERR_NO_MEMORY}, inner resource has already released. 115 * {@link AV_ERR_OPERATE_NOT_PERMIT}, not permit to call the interface in buffer mode. 116 * {@link AV_ERR_INVALID_VAL}, the decoder is nullptr or invalid. 117 * {@link AV_ERR_UNKNOWN}, unknown error. 118 * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. 119 * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. 120 * @since 9 121 * @version 1.0 122 */ 123 OH_AVErrCode OH_VideoDecoder_SetSurface(OH_AVCodec *codec, OHNativeWindow *window); 124 125 /** 126 * @brief To configure the video decoder, typically, you need to configure the description information of the decoded 127 * video track, which can be extracted from the OH_AVSource. This interface must be called before Prepare is called. 128 * @syscap SystemCapability.Multimedia.Media.VideoDecoder 129 * @param codec Pointer to an OH_AVCodec instance 130 * @param format A pointer to an OH_AVFormat to give the description of the video track to be decoded 131 * @return Returns AV_ERR_OK if the execution is successful, 132 * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. 133 * {@link AV_ERR_NO_MEMORY}, instance has already released. 134 * {@link AV_ERR_INVALID_VAL}, the decoder is nullptr or invalid. Invalid param in format. 135 * {@link AV_ERR_UNKNOWN}, unknown error. 136 * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. 137 * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state, must be called before Prepare. 138 * {@link AV_ERR_UNSUPPORT}, unsupported features. 139 * {@link AV_ERR_VIDEO_UNSUPPORTED_COLOR_SPACE_CONVERSION}, video unsupported color space conversion. 140 * @since 9 141 * @version 1.0 142 */ 143 OH_AVErrCode OH_VideoDecoder_Configure(OH_AVCodec *codec, OH_AVFormat *format); 144 145 /** 146 * @brief To prepare the internal resources of the decoder, the Configure interface must be called before 147 * calling this interface. 148 * @syscap SystemCapability.Multimedia.Media.VideoDecoder 149 * @param codec Pointer to an OH_AVCodec instance 150 * @return Returns AV_ERR_OK if the execution is successful, 151 * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. 152 * {@link AV_ERR_NO_MEMORY}, instance has already released. 153 * {@link AV_ERR_INVALID_VAL}, the decoder is nullptr or invalid. 154 * {@link AV_ERR_UNKNOWN}, unknown error. 155 * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. 156 * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. 157 * {@link AV_ERR_OPERATE_NOT_PERMIT}, decoder is in buffer mode and color space conversion is configured. 158 * @since 9 159 * @version 1.0 160 */ 161 OH_AVErrCode OH_VideoDecoder_Prepare(OH_AVCodec *codec); 162 163 /** 164 * @brief Start the decoder, this interface must be called after the Prepare is successful. 165 * After being successfully started, the decoder will start reporting NeedInputData events. 166 * @syscap SystemCapability.Multimedia.Media.VideoDecoder 167 * @param codec Pointer to an OH_AVCodec instance 168 * @return Returns AV_ERR_OK if the execution is successful, 169 * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. 170 * {@link AV_ERR_NO_MEMORY}, instance has already released. 171 * {@link AV_ERR_INVALID_VAL}, the decoder is nullptr or invalid. 172 * {@link AV_ERR_UNKNOWN}, unknown error. 173 * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. 174 * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. 175 * {@link AV_ERR_OPERATE_NOT_PERMIT}, video color space conversion is configured but decoder is not prepared. 176 * @since 9 177 * @version 1.0 178 */ 179 OH_AVErrCode OH_VideoDecoder_Start(OH_AVCodec *codec); 180 181 /** 182 * @brief Stop the decoder. After stopping, you can re-enter the Started state through Start, 183 * but it should be noted that if Codec-Specific-Data has been input to the decoder before, it needs to be input again. 184 * @syscap SystemCapability.Multimedia.Media.VideoDecoder 185 * @param codec Pointer to an OH_AVCodec instance 186 * @return Returns AV_ERR_OK if the execution is successful, 187 * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. 188 * {@link AV_ERR_NO_MEMORY}, instance has already released. 189 * {@link AV_ERR_INVALID_VAL}, the decoder is nullptr or invalid. 190 * {@link AV_ERR_UNKNOWN}, unknown error. 191 * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. 192 * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. 193 * @since 9 194 * @version 1.0 195 */ 196 OH_AVErrCode OH_VideoDecoder_Stop(OH_AVCodec *codec); 197 198 /** 199 * @brief Clear the input and output data buffered in the decoder. After this interface is called, all the Buffer 200 * indexes previously reported through the asynchronous callback will be invalidated, make sure not to access 201 * the Buffers corresponding to these indexes. 202 * @syscap SystemCapability.Multimedia.Media.VideoDecoder 203 * @param codec Pointer to an OH_AVCodec instance 204 * @return Returns AV_ERR_OK if the execution is successful, 205 * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. 206 * {@link AV_ERR_NO_MEMORY}, instance has already released. 207 * {@link AV_ERR_INVALID_VAL}, the decoder is nullptr or invalid. 208 * {@link AV_ERR_UNKNOWN}, unknown error. 209 * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. 210 * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. 211 * @since 9 212 * @version 1.0 213 */ 214 OH_AVErrCode OH_VideoDecoder_Flush(OH_AVCodec *codec); 215 216 /** 217 * @brief Reset the decoder. To continue decoding, you need to call the Configure interface again 218 * to configure the decoder instance. 219 * @syscap SystemCapability.Multimedia.Media.VideoDecoder 220 * @param codec Pointer to an OH_AVCodec instance 221 * @return Returns AV_ERR_OK if the execution is successful, 222 * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. 223 * {@link AV_ERR_NO_MEMORY}, instance has already released. 224 * {@link AV_ERR_INVALID_VAL}, the decoder is nullptr or invalid. 225 * {@link AV_ERR_UNKNOWN}, unknown error. 226 * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. 227 * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. 228 * @since 9 229 * @version 1.0 230 */ 231 OH_AVErrCode OH_VideoDecoder_Reset(OH_AVCodec *codec); 232 233 /** 234 * @brief Get the description information of the output data of the decoder, refer to {@link OH_AVFormat} 235 * It should be noted that the life cycle of the OH_AVFormat instance pointed to by the return value * needs 236 * to be manually released by the caller. 237 * @syscap SystemCapability.Multimedia.Media.VideoDecoder 238 * @param codec Pointer to an OH_AVCodec instance 239 * @return Returns a pointer to an OH_AVFormat instance. 240 * Return nullptr if the decoder is nullptr or invaild. 241 * @since 9 242 * @version 1.0 243 */ 244 OH_AVFormat *OH_VideoDecoder_GetOutputDescription(OH_AVCodec *codec); 245 246 /** 247 * @brief Set dynamic parameters to the decoder. Note: This interface can only be called after the decoder is started. 248 * At the same time, incorrect parameter settings may cause decoding failure. 249 * @syscap SystemCapability.Multimedia.Media.VideoDecoder 250 * @param codec Pointer to an OH_AVCodec instance 251 * @param format pointer to an OH_AVFormat instance 252 * @return Returns AV_ERR_OK if the execution is successful, 253 * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. 254 * {@link AV_ERR_NO_MEMORY}, instance has already released. 255 * {@link AV_ERR_INVALID_VAL}, the decoder is nullptr or invalid. Invalid param in format. 256 * {@link AV_ERR_UNKNOWN}, unknown error. 257 * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. 258 * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. 259 * @since 9 260 * @version 1.0 261 */ 262 OH_AVErrCode OH_VideoDecoder_SetParameter(OH_AVCodec *codec, OH_AVFormat *format); 263 264 /** 265 * @brief Submit the input buffer filled with data to the video decoder. The {@link OH_AVCodecOnNeedInputData} callback 266 * will report the available input buffer and the corresponding index value. Once the buffer with the specified index 267 * is submitted to the video decoder, the buffer cannot be accessed again until the {@link OH_AVCodecOnNeedInputData} 268 * callback is received again reporting that the buffer with the same index is available. In addition, for some 269 * decoders, it is required to input Codec-Specific-Data to the decoder at the beginning to initialize the decoding 270 * process of the decoder, such as PPS/SPS data in H264 format. 271 * @syscap SystemCapability.Multimedia.Media.VideoDecoder 272 * @param codec Pointer to an OH_AVCodec instance 273 * @param index Enter the index value corresponding to the Buffer 274 * @param attr Information describing the data contained in the Buffer 275 * @return Returns AV_ERR_OK if the execution is successful, 276 * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. 277 * {@link AV_ERR_NO_MEMORY}, instance has already released. 278 * {@link AV_ERR_INVALID_VAL}, the decoder is nullptr or invalid. 279 * Buffer index should be given by {@link OH_AVCodecOnNeedInputData}. 280 * {@link AV_ERR_UNKNOWN}, unknown error. 281 * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. 282 * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. 283 * @deprecated since 11 284 * @useinstead OH_VideoDecoder_PushInputBuffer 285 * @since 9 286 * @version 1.0 287 */ 288 OH_AVErrCode OH_VideoDecoder_PushInputData(OH_AVCodec *codec, uint32_t index, OH_AVCodecBufferAttr attr); 289 290 /** 291 * @brief Return the processed output Buffer to the decoder, and notify the decoder to finish rendering the 292 * decoded data contained in the Buffer on the output Surface. If the output surface is not configured before, 293 * calling this interface only returns the output buffer corresponding to the specified index to the decoder. 294 * @syscap SystemCapability.Multimedia.Media.VideoDecoder 295 * @param codec Pointer to an OH_AVCodec instance 296 * @param index The index value corresponding to the output 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 nullptr or invalid. 301 * Buffer index should be given by {@link OH_AVCodecOnNewOutputData}. 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_RenderOutputBuffer 307 * @since 9 308 * @version 1.0 309 */ 310 OH_AVErrCode OH_VideoDecoder_RenderOutputData(OH_AVCodec *codec, uint32_t index); 311 312 /** 313 * @brief Return the processed output Buffer to the decoder. 314 * @syscap SystemCapability.Multimedia.Media.VideoDecoder 315 * @param codec Pointer to an OH_AVCodec instance 316 * @param index The index value corresponding to the output Buffer 317 * @return Returns AV_ERR_OK if the execution is successful, 318 * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. 319 * {@link AV_ERR_NO_MEMORY}, instance has already released. 320 * {@link AV_ERR_INVALID_VAL}, the decoder is nullptr or invalid. 321 * Buffer index should be given by {@link OH_AVCodecOnNewOutputData}. 322 * {@link AV_ERR_UNKNOWN}, unknown error. 323 * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. 324 * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. 325 * @deprecated since 11 326 * @useinstead OH_VideoDecoder_FreeOutputBuffer 327 * @since 9 328 * @version 1.0 329 */ 330 OH_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 */ 354 OH_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 */ 373 OH_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 */ 405 OH_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 */ 422 OH_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 */ 439 OH_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 * @version 1.0 456 */ 457 OH_AVErrCode OH_VideoDecoder_SetDecryptionConfig(OH_AVCodec *codec, MediaKeySession *mediaKeySession, 458 bool secureVideoPath); 459 460 #ifdef __cplusplus 461 } 462 #endif 463 464 #endif // NATIVE_AVCODEC_VIDEODECODER_H