diff --git a/multimedia/av_codec/native_avcodec_base.h b/multimedia/av_codec/native_avcodec_base.h index 0042b76b4a2da27c3f8f01b44f2254bfe09f2a95..494517b2c0d54b84ecd116a458297ec79e8f3e63 100644 --- a/multimedia/av_codec/native_avcodec_base.h +++ b/multimedia/av_codec/native_avcodec_base.h @@ -1200,6 +1200,29 @@ extern const char *OH_MD_KEY_ENABLE_SYNC_MODE; */ extern const char *OH_MD_KEY_VIDEO_DECODER_BLANK_FRAME_ON_SHUTDOWN; +/** + * @brief Key for querying native buffer pixel formats for video codec operations, value type is int32_t. + * The value represents pixel formats defined in {@link OH_NativeBuffer_Format}. + * + * This key serves two primary purposes: + * 1. Runtime decoder output: Get current output format via {@link OH_VideoDecoder_GetOutputDescription} + * or {@link OH_AVCodecOnStreamChanged} events. + * 2. Runtime encoder input: Get current input format via {@link OH_VideoEncoder_GetInputDescription}. + * + * @since 22 + */ +extern const char *OH_MD_KEY_VIDEO_NATIVE_BUFFER_FORMAT; + +/** + * @brief Key for querying if the codec is a hardware codec, + * value type is int32_t (0: a software codec, 1: hardware codec). + * + * Get the value from an OH_AVFormat instance, which obtained by calling {@link OH_VideoDecoder_GetCodecInfo}. + * + * @since 22 + */ +extern const char *OH_MD_KEY_IS_HARDWARE; + /** * @brief Media type. * @@ -1750,9 +1773,28 @@ typedef enum OH_BitrateMode { BITRATE_MODE_SQR = 3 } OH_BitrateMode; +/** + * @brief Enumeration of operation codes indicating specific actions recommended for the codec. + * + * @since 22 + */ +typedef enum AVCodec_OperationCode { + /** No specific operation is recommended. */ + AVCODEC_OP_CODE_NONE = 0, + /** An unrecoverable error has occurred, suggesting that the codec should be reset. */ + AVCODEC_OP_CODE_RESET_CODEC = 1, + /** No buffers are available. It is recommended to wait for a short interval and retry the operation. */ + AVCODEC_OP_CODE_TRY_AGAIN = 2, + /** DRM key is required to proceed. */ + AVCODEC_OP_CODE_INPUT_DRM_KEY = 3, + /** Key information is missing. It is recommended to input the parameter sets along with an I-frame. */ + AVCODEC_OP_CODE_INPUT_PARAMETERSETS_WITH_I_FRAME = 4, + /** The current specification is not supported. It is recommended to try using a different codec. */ + AVCODEC_OP_CODE_TRY_OTHER_CODEC = 5 +} AVCodec_OperationCode; #ifdef __cplusplus } #endif #endif // NATIVE_AVCODEC_BASE_H -/** @} */ +/** @} */ \ No newline at end of file diff --git a/multimedia/av_codec/native_avcodec_videodecoder.h b/multimedia/av_codec/native_avcodec_videodecoder.h index 91f9a9095042eb44a0fe17ed020732d37d231056..c6ee1f78d8f8179a108c96281b066eccc2a2d552 100644 --- a/multimedia/av_codec/native_avcodec_videodecoder.h +++ b/multimedia/av_codec/native_avcodec_videodecoder.h @@ -548,6 +548,38 @@ OH_AVErrCode OH_VideoDecoder_IsValid(OH_AVCodec *codec, bool *isValid); OH_AVErrCode OH_VideoDecoder_SetDecryptionConfig(OH_AVCodec *codec, MediaKeySession *mediaKeySession, bool secureVideoPath); +/** + * @brief Get the description information of the decoder. + * + * This function provides detailed information about the decoder, including its configuration and capabilities. + * The returned OH_AVFormat instance must be manually released by the caller to prevent memory leaks. + * + * @param codec A pointer to a valid OH_AVCodec instance. + * @return Returns a pointer to an OH_AVFormat instance containing the decoder's description information. + * Return nullptr if the provided codec pointer is nullptr or invaild. + * @since 22 + */ +OH_AVFormat *OH_VideoDecoder_GetCodecInfo(OH_AVCodec *codec); + +/** + * @brief Provides specific operations to take when an error occurs. + * + * This function offers guidance on the appropriate actions to handle errors encountered during the codec process. + * It returns suggested operations and detailed error messages to help developers manage the situation effectively. + * + * @param codec A pointer to a valid OH_AVCodec instance. + * @param operationCode A pointer to an AVCodec_OperationCode variable that will receive the suggested operation code. + * This code indicates the recommended action, refer to {@link AVCodec_OperationCode}. + * @param msg A pointer to a const char** variable that will hold a detailed error message string. + * The lifecycle of this string is tied to the OH_AVCodec instance. If the caller needs to retain the message + * beyond the instance's lifetime, copy the string to avoid memory issues. + * @return AV_ERR_OK if the function executes successfully and provides the suggested operation and message. + * If an error occurs, a specific error code is returned. For details, refer to {@link OH_AVErrCode}. + * {@link AV_ERR_INVALID_VAL}, the decoder is nullptr or invalid. + * @since 22 + */ +OH_AVErrCode OH_VideoDecoder_SuggestOperation(OH_AVCodec *codec, AVCodec_OperationCode *operationCode, const char **msg); + #ifdef __cplusplus } #endif