From 2b7cc362f3ff6f5e6ff750def07ca2247d40b89b Mon Sep 17 00:00:00 2001 From: zhanghongran Date: Tue, 29 Apr 2025 15:52:03 +0800 Subject: [PATCH 01/29] =?UTF-8?q?=E6=96=B0=E5=A2=9EAPI20=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhanghongran --- multimedia/av_codec/native_avcodec_base.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/multimedia/av_codec/native_avcodec_base.h b/multimedia/av_codec/native_avcodec_base.h index 609dc238e..3bc499eab 100644 --- a/multimedia/av_codec/native_avcodec_base.h +++ b/multimedia/av_codec/native_avcodec_base.h @@ -1032,6 +1032,8 @@ extern const char *OH_MD_KEY_VIDEO_ENCODER_REPEAT_PREVIOUS_FRAME_AFTER; */ extern const char *OH_MD_KEY_VIDEO_ENCODER_REPEAT_PREVIOUS_MAX_COUNT; +extern const char *OH_MD_KEY_ENABLE_MOOV_FRONT; + /** * @brief Media type. * -- Gitee From 2eed9e376bb2c2ec3e63955c9cd156295761f79e Mon Sep 17 00:00:00 2001 From: zhanghongran Date: Tue, 29 Apr 2025 16:12:45 +0800 Subject: [PATCH 02/29] =?UTF-8?q?avcodec=E6=96=B0=E5=A2=9E=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhanghongran --- multimedia/av_codec/native_avcapability.h | 21 +++++ multimedia/av_codec/native_avcodec_base.h | 79 +++++++++++++++++++ multimedia/media_foundation/native_avformat.h | 35 ++++++++ 3 files changed, 135 insertions(+) diff --git a/multimedia/av_codec/native_avcapability.h b/multimedia/av_codec/native_avcapability.h index dd17584d4..64c99b4e0 100644 --- a/multimedia/av_codec/native_avcapability.h +++ b/multimedia/av_codec/native_avcapability.h @@ -86,6 +86,10 @@ typedef enum OH_AVCapabilityFeature { VIDEO_ENCODER_LONG_TERM_REFERENCE = 1, /** Feature for codec supports low latency. It is used in video encoder and video decoder. */ VIDEO_LOW_LATENCY = 2, + /** Feature for codec supports B-frame encoding. It is only used in video encoder. + * @since 20 + */ + VIDEO_ENCODER_B_FRAME = 7, } OH_AVCapabilityFeature; /** @@ -448,6 +452,23 @@ bool OH_AVCapability_IsFeatureSupported(OH_AVCapability *capability, OH_AVCapabi */ OH_AVFormat *OH_AVCapability_GetFeatureProperties(OH_AVCapability *capability, OH_AVCapabilityFeature feature); +/** + * @brief Get the audio codec's supported sample rate ranges. + * + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @param capability Audio codec capability pointer. Do not give a video codec capability pointer + * @param sampleRateRanges Output parameter. A pointer to the sample rate ranges array + * @param rangesNum Output parameter. The element number of the sample rate ranges array + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * {@link AV_ERR_INVALID_VAL}, the capability is invalid, the sampleRates is nullptr, or sampleRateNum is nullptr. + * {@link AV_ERR_UNKNOWN}, unknown error. + * {@link AV_ERR_NO_MEMORY}, internal use memory malloc failed. + * @since 20 +*/ +OH_AVErrCode OH_AVCapability_GetAudioSupportedSampleRateRanges(OH_AVCapability *capability, + OH_AVRange **sampleRateRanges, uint32_t *rangesNum); + #ifdef __cplusplus } #endif diff --git a/multimedia/av_codec/native_avcodec_base.h b/multimedia/av_codec/native_avcodec_base.h index 3bc499eab..b4375da8a 100644 --- a/multimedia/av_codec/native_avcodec_base.h +++ b/multimedia/av_codec/native_avcodec_base.h @@ -1032,6 +1032,85 @@ extern const char *OH_MD_KEY_VIDEO_ENCODER_REPEAT_PREVIOUS_FRAME_AFTER; */ extern const char *OH_MD_KEY_VIDEO_ENCODER_REPEAT_PREVIOUS_MAX_COUNT; +/** + * @brief Key for describing the reference relationship between tracks, value type is int32_t*. + * + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @since 20 +*/ +extern const char *OH_MD_KEY_REFERENCE_TRACK_IDS; +/** + * @brief Key for describing the track reference type, value type is string. + * + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @since 20 +*/ +extern const char *OH_MD_KEY_TRACK_REFERENCE_TYPE; +/** + * @brief Key for describing the track description, value type is string. + * + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @since 20 +*/ +extern const char *OH_MD_KEY_TRACK_DESCRIPTION; +/** + * @brief Key to enable B-frame encoding, value type is int32_t (0 or 1):1 is enabled, 0 otherwise. + * + * This is an optional key that applies only to video encoder, default is 0. + * If enabled, the video encoder will use B-frames, the decode order will be different from the display order. + * It is used in configure. + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @since 20 +*/ +extern const char *OH_MD_KEY_VIDEO_ENCODER_ENABLE_B_FRAME; +/** + * @brief Key for the desired encoding quality, value type is int32_t, this key is only + * supported for encoders that are configured in Stable Quality RateControl, the higher + * values generally result in more efficient(smaller-sized) encoding. + * + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @since 20 +*/ +extern const char *OH_MD_KEY_SQR_FACTOR; +/** + * @brief Key for maximum bitrate, value type is int64_t. + * + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @since 20 +*/ +extern const char *OH_MD_KEY_MAX_BITRATE; +/** + * @brief Key to enable Bitrate Control Based on Presentation Time Stamp(PTS), + * value type is int32_t (0 or 1):1 is enabled, 0 otherwise. + * + * This is an optional key that applies only to video encoder, default is 0. + * If enabled, the PTS information must be carried in each video frame and sent to the encoder. + * It is used in configure. + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @since 20 +*/ +extern const char *OH_MD_KEY_VIDEO_ENCODER_ENABLE_PTS_BASED_RATECONTROL; +/** + * @brief Key to set the region of interest(ROI) as QpOffset-Rects, value type is string in the format + * "Top1,Left1-Bottom1,Right1=Offset1;Top2,Left2-Bottom2,Right2=Offset2;...". Each "Top,Left-Bottom,Right=Offset" + * represents the coordinate information and quantization parameter of one ROI. Each "=Offset" in the string + * can be omitted, like "Top1,Left1-Bottom1,Right1;Top2,Left2-Bottom2,Right2=Offset2;...", the encoder + * will use the default quantization parameter to perform the ROI encoding on the first ROI and + * use Offset2 on the second ROI. + * + * This is an optional key that applies only to video encoder. + * It is used in running process. + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @since 20 +*/ +extern const char *OH_MD_KEY_VIDEO_ENCODER_ROI_PARAMS; +/** + * @brief Key for front moov of the mp4 and m4a media file, value type is int32_t (0 or 1):1 is enabled, 0 otherwise. + * + * This key may affect the performance of the stop function of the mp4 and m4a muxer. + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @since 20 +*/ extern const char *OH_MD_KEY_ENABLE_MOOV_FRONT; /** diff --git a/multimedia/media_foundation/native_avformat.h b/multimedia/media_foundation/native_avformat.h index ac30d2d47..fbc82fdaf 100644 --- a/multimedia/media_foundation/native_avformat.h +++ b/multimedia/media_foundation/native_avformat.h @@ -80,6 +80,10 @@ typedef enum OH_AVPixelFormat { * RGBA8888 */ AV_PIXEL_FORMAT_RGBA = 5, + /** RGBA1010102 + * since 20 + */ + AV_PIXEL_FORMAT_RGBA1010102 = 6, } OH_AVPixelFormat; /** @@ -322,6 +326,37 @@ bool OH_AVFormat_GetBuffer(struct OH_AVFormat *format, const char *key, uint8_t */ const char *OH_AVFormat_DumpInfo(struct OH_AVFormat *format); +/** + * @brief Write a list of int32_t data of a specified length to OH_AVFormat. + * + * @syscap SystemCapability.Multimedia.Media.Core + * @param format pointer to an OH_AVFormat instance + * @param key key to write data + * @param addr written data addr + * @param size written data length + * @return The return value is TRUE for success, FALSE for failure + * Possible failure causes: 1. input format is nullptr. 2. input format's magic error. 3. key is nullptr. + * addr is nullptr. 5. size is zero. + * @since 20 + */ +bool OH_AVFormat_SetIntBuffer(struct OH_AVFormat *format, const char *key, const int32_t *addr, size_t size); + +/** + * @brief Read a list of int32_t data of specified length from OH_AVFormat. + * + * @syscap SystemCapability.Multimedia.Media.Core + * @param format pointer to an OH_AVFormat instance + * @param key Key value for reading and writing data + * @param addr The life cycle is held by the format, with the destruction of the format, + * if the caller needs to hold it for a long time, it must copy the memory + * @param size Length of read and write data + * @return The return value is TRUE for success, FALSE for failure + * Possible failure causes: 1. input format is nullptr. 2. input format's magic error. 3. key is nullptr. + * addr is nullptr. 5. size is nullptr. + * @since 20 + */ +bool OH_AVFormat_GetIntBuffer(struct OH_AVFormat *format, const char *key, int32_t **addr, size_t *size); + #ifdef __cplusplus } #endif -- Gitee From e279862d4d4d20100f6e6e866cc07021ec984844 Mon Sep 17 00:00:00 2001 From: zhanghongran Date: Thu, 8 May 2025 17:30:13 +0800 Subject: [PATCH 03/29] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhanghongran --- .../av_codec/native_avcodec_videodecoder.h | 87 ++++++++++++ .../av_codec/native_avcodec_videoencoder.h | 129 ++++++++++++++++++ multimedia/media_foundation/native_averrors.h | 13 ++ 3 files changed, 229 insertions(+) diff --git a/multimedia/av_codec/native_avcodec_videodecoder.h b/multimedia/av_codec/native_avcodec_videodecoder.h index 462d5011d..77a5f4cfa 100644 --- a/multimedia/av_codec/native_avcodec_videodecoder.h +++ b/multimedia/av_codec/native_avcodec_videodecoder.h @@ -432,6 +432,93 @@ OH_AVErrCode OH_VideoDecoder_RenderOutputBufferAtTime(OH_AVCodec *codec, uint32_ */ OH_AVErrCode OH_VideoDecoder_FreeOutputBuffer(OH_AVCodec *codec, uint32_t index); +/** + * @brief Get index of next available input buffer. + * + * It's necessary to use {@link OH_VideoDecoder_GetInputBuffer} to get the buffer handle. + * It's only used in synchronous mode. + * @syscap SystemCapability.Multimedia.Media.VideoDecoder + * @param codec Pointer to an OH_AVCodec instance. + * @param index The index value corresponding to the input buffer. + * @param timeoutUs the query timeout time, in microseconds. + * + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. + * {@link AV_ERR_NO_MEMORY}, internal errors in the input decode instance, such as an abnormal NULL. + * {@link AV_ERR_INVALID_VAL}, the decoder is nullptr or invalid. + * {@link AV_ERR_UNKNOWN}, unknown error. + * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. + * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. + * {@link AVCS_ERR_VIDEO_STREAM_CHANGED}, the stream is changed, call {@link OH_VideoDecoder_GetOutputDescription} to + * retrieve steam information. + * {@link AVCS_ERR_VIDEO_TRY_AGAIN_LATER}, query failed,recommended to wait for a while and try the query again. + * @since 20 + */ +OH_AVErrCode OH_VideoDecoder_QueryInputBuffer(struct OH_AVCodec *codec, uint32_t *index, int64_t timeoutUs); + +/** + * @brief Get the available input buffer handle. + * + * It's only used in synchronous mode. + * @syscap SystemCapability.Multimedia.Media.VideoDecoder + * @param codec Pointer to an OH_AVCodec instance + * @param index The index value corresponding to the input buffer, + * should be given by {@link OH_VideoDecoder_QueryInputBuffer}. + * + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. + * {@link AV_ERR_NO_MEMORY}, internal errors in the input decode instance, such as an abnormal NULL. + * {@link AV_ERR_INVALID_VAL}, the decoder is nullptr or invalid. + * {@link AV_ERR_UNKNOWN}, unknown error. + * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. + * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. + * @since 20 + */ +OH_AVBuffer *OH_VideoDecoder_GetInputBuffer(struct OH_AVCodec *codec, uint32_t index); + +/** + * @brief Get index of next available output buffer. + * + * It's necessary to use {@link OH_VideoDecoder_GetOutputBuffer} to get the buffer handle. + * It's only used in synchronous mode. + * @syscap SystemCapability.Multimedia.Media.VideoDecoder + * @param codec Pointer to an OH_AVCodec instance + * @param index The index value corresponding to the output buffer + * @param timeoutUs the query timeout time, in microseconds. + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. + * {@link AV_ERR_NO_MEMORY}, internal errors in the input decode instance, such as an abnormal NULL. + * {@link AV_ERR_INVALID_VAL}, the decoder is nullptr or invalid. + * {@link AV_ERR_UNKNOWN}, unknown error. + * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. + * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. + * {@link AVCS_ERR_VIDEO_STREAM_CHANGED}, the stream is changed, call {@link OH_VideoDecoder_GetOutputDescription} to + * retrieve steam information. + * {@link AVCS_ERR_VIDEO_TRY_AGAIN_LATER}, query failed,recommended to wait for a while and try the query again. + * @since 20 + */ +OH_AVErrCode OH_VideoDecoder_QueryOutputBuffer(struct OH_AVCodec *codec, uint32_t *index, int64_t timeoutUs); + +/** + * @brief Get the available output buffer handle. + * + * It's only used in synchronous mode. + * @syscap SystemCapability.Multimedia.Media.VideoDecoder + * @param codec Pointer to an OH_AVCodec instance + * @param index The index value corresponding to the input buffer, + * should be given by {@link OH_VideoDecoder_QueryOutputBuffer}. + * + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. + * {@link AV_ERR_NO_MEMORY}, internal errors in the input decode instance, such as an abnormal NULL. + * {@link AV_ERR_INVALID_VAL}, the decoder is nullptr or invalid. + * {@link AV_ERR_UNKNOWN}, unknown error. + * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. + * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. + * @since 20 + */ +OH_AVBuffer *OH_VideoDecoder_GetOutputBuffer(struct OH_AVCodec *codec, uint32_t index); + /** * @brief Check whether the current codec instance is valid. It can be used fault recovery or app * switchback from the background. diff --git a/multimedia/av_codec/native_avcodec_videoencoder.h b/multimedia/av_codec/native_avcodec_videoencoder.h index a0ccb13b6..8a7c25424 100644 --- a/multimedia/av_codec/native_avcodec_videoencoder.h +++ b/multimedia/av_codec/native_avcodec_videoencoder.h @@ -406,6 +406,135 @@ OH_AVErrCode OH_VideoEncoder_PushInputParameter(OH_AVCodec *codec, uint32_t inde */ OH_AVErrCode OH_VideoEncoder_FreeOutputBuffer(OH_AVCodec *codec, uint32_t index); +/** + * @brief Get index of next available input parameter. + * + * It's necessary to use {@link OH_VideoEncoder_GetInputParameter} to get the parameter handle. + * It's only used in synchronous mode. + * It's optional only for input surface + * and it's necessary to configure {@link OH_MD_KEY_VIDEO_ENCODER_ENABLE_INPUT_PARAMETER_SYNC_MODE}. + * + * @syscap SystemCapability.Multimedia.Media.VideoEncoder + * @param codec Pointer to an OH_AVCodec instance + * @param index The index value corresponding to the input buffer + * @param timeoutUs the query timeout time, in microseconds. + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. + * {@link AV_ERR_NO_MEMORY}, internal errors in the input encode instance, such as an abnormal NULL. + * {@link AV_ERR_INVALID_VAL}, the encoder is nullptr or invalid. + * {@link AV_ERR_UNKNOWN}, unknown error. + * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. + * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. + * {@link AVCS_ERR_VIDEO_STREAM_CHANGED}, the stream is changed, call {@link OH_VideoEncoder_GetOutputDescription} to + * retrieve steam information. + * {@link AVCS_ERR_VIDEO_TRY_AGAIN_LATER}, query failed,recommended to wait for a while and try the query again. + * @since 20 + */ +OH_AVErrCode OH_VideoEncoder_QueryInputParameter(struct OH_AVCodec *codec, uint32_t *index, int64_t timeoutUs); + +/** + * @brief Get the input parameter handle. + * + * It's only used in synchronous mode. + * @syscap SystemCapability.Multimedia.Media.VideoEncoder + * @param codec Pointer to an OH_AVCodec instance + * @param index The index value corresponding to the input buffer, + * should be given by {@link OH_VideoEncoder_QueryInputParameter}. + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. + * {@link AV_ERR_NO_MEMORY}, internal errors in the input encode instance, such as an abnormal NULL. + * {@link AV_ERR_INVALID_VAL}, the encoder is nullptr or invalid. + * {@link AV_ERR_UNKNOWN}, unknown error. + * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. + * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. + * @since 20 + */ +OH_AVFormat *OH_VideoEncoder_GetInputParameter(struct OH_AVCodec *codec, uint32_t index); + +/** + * @brief Get index of next available input buffer. + * + * It's necessary to use {@link OH_VideoEncoder_GetInputBuffer} to get the parameter handle. + * It's only used in synchronous mode. + * @syscap SystemCapability.Multimedia.Media.VideoEncoder + * @param codec Pointer to an OH_AVCodec instance + * @param index The index value corresponding to the input buffer + * @param timeoutUs the query timeout time, in microseconds. + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. + * {@link AV_ERR_NO_MEMORY}, internal errors in the input encode instance, such as an abnormal NULL. + * {@link AV_ERR_INVALID_VAL}, the encoder is nullptr or invalid. + * {@link AV_ERR_UNKNOWN}, unknown error. + * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. + * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. + * {@link AVCS_ERR_VIDEO_STREAM_CHANGED}, the stream is changed, call {@link OH_VideoEncoder_GetOutputDescription} to + * retrieve steam information. + * {@link AVCS_ERR_VIDEO_TRY_AGAIN_LATER}, query failed,recommended to wait for a while and try the query again. + * @since 20 + */ +OH_AVErrCode OH_VideoEncoder_QueryInputBuffer(struct OH_AVCodec *codec, uint32_t *index, int64_t timeoutUs); + +/** + * @brief Get the available input buffer handle. + * + * It's only used in synchronous mode. + * @syscap SystemCapability.Multimedia.Media.VideoEncoder + * @param codec Pointer to an OH_AVCodec instance + * @param index The index value corresponding to the input buffer, + * should be given by {@link OH_VideoEncoder_QueryInputBuffer}. + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. + * {@link AV_ERR_NO_MEMORY}, internal errors in the input encode instance, such as an abnormal NULL. + * {@link AV_ERR_INVALID_VAL}, the encoder is nullptr or invalid. + * {@link AV_ERR_UNKNOWN}, unknown error. + * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. + * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. + * @since 20 + */ +OH_AVBuffer *OH_VideoEncoder_GetInputBuffer(struct OH_AVCodec *codec, uint32_t index); + +/** + * @brief Get index of next available output buffer. + * + * It's necessary to use {@link OH_VideoEncoder_GetOutputBuffer} to get the parameter handle. + * It's only used in synchronous mode. + * @syscap SystemCapability.Multimedia.Media.VideoEncoder + * @param codec Pointer to an OH_AVCodec instance + * @param index The index value corresponding to the output buffer + * @param timeoutUs the query timeout time, in microseconds. + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. + * {@link AV_ERR_NO_MEMORY}, internal errors in the input encode instance, such as an abnormal NULL. + * {@link AV_ERR_INVALID_VAL}, the encoder is nullptr or invalid. + * {@link AV_ERR_UNKNOWN}, unknown error. + * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. + * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. + * {@link AVCS_ERR_VIDEO_STREAM_CHANGED}, the stream is changed, call {@link OH_VideoEncoder_GetOutputDescription} to + * retrieve steam information. + * {@link AVCS_ERR_VIDEO_TRY_AGAIN_LATER}, query failed,recommended to wait for a while and try the query again. + * @since 20 + */ +OH_AVErrCode OH_VideoEncoder_QueryOutputBuffer(struct OH_AVCodec *codec, uint32_t *index, int64_t timeoutUs); + +/** + * @brief Get the available Output buffer handle. + * + * It's only used in synchronous mode. + * @syscap SystemCapability.Multimedia.Media.VideoEncoder + * @param codec Pointer to an OH_AVCodec instance + * @param index The index value corresponding to the input buffer, + * should be given by {@link OH_VideoEncoder_QueryOutputBuffer}. + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. + * {@link AV_ERR_NO_MEMORY}, internal errors in the input encode instance, such as an abnormal NULL. + * {@link AV_ERR_INVALID_VAL}, the encoder is nullptr or invalid. + * {@link AV_ERR_UNKNOWN}, unknown error. + * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. + * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. + * @since 20 + */ +OH_AVBuffer *OH_VideoEncoder_GetOutputBuffer(struct OH_AVCodec *codec, uint32_t index); + /** * @brief Get the input data description of the encoder after call {@OH_VideoEncoder_Configure}, * refer to {@link OH_AVFormat} for details. It should be noted that the life cycle of the OH_AVFormat diff --git a/multimedia/media_foundation/native_averrors.h b/multimedia/media_foundation/native_averrors.h index 398a16f0f..1a87e7d14 100644 --- a/multimedia/media_foundation/native_averrors.h +++ b/multimedia/media_foundation/native_averrors.h @@ -180,6 +180,19 @@ typedef enum OH_AVErrCode { * @since 14 */ AV_ERR_IO_UNSUPPORTED_REQUEST = 5411011, + /** + * @error Indicates a stream change for synchronous mode. + * It's necessary to call {@link OH_VideoEncoder_GetInputDescription} to retrieve steam information + * for the video encoder instance, call {@link OH_VideoDecoder_GetOutputDescription} for + * the video decoder instance. + * @since 20 + */ + AVCS_ERR_VIDEO_STREAM_CHANGED = 5413001, + /** + * @error Indicates buffer query failed within certain time for synchronous mode, + * it's recommended to wait for a while and try the query again. + */ + AVCS_ERR_VIDEO_TRY_AGAIN_LATER = 5413002, } OH_AVErrCode; #ifdef __cplusplus -- Gitee From 7c9957c603daa4244219171020d4c5371504ac64 Mon Sep 17 00:00:00 2001 From: zhanghongran Date: Thu, 8 May 2025 19:50:28 +0800 Subject: [PATCH 04/29] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhanghongran --- multimedia/av_codec/native_avcodec_base.h | 24 ++++++++++++++++++ .../av_codec/native_avcodec_videodecoder.h | 19 +++++++------- .../av_codec/native_avcodec_videoencoder.h | 25 +++++++++++-------- 3 files changed, 49 insertions(+), 19 deletions(-) diff --git a/multimedia/av_codec/native_avcodec_base.h b/multimedia/av_codec/native_avcodec_base.h index b4375da8a..bf46ab6fe 100644 --- a/multimedia/av_codec/native_avcodec_base.h +++ b/multimedia/av_codec/native_avcodec_base.h @@ -1113,6 +1113,30 @@ extern const char *OH_MD_KEY_VIDEO_ENCODER_ROI_PARAMS; */ extern const char *OH_MD_KEY_ENABLE_MOOV_FRONT; +/** + * @brief Key to enable synchronous mode, value type is (0 or 1):1 is enabled, 0 otherwise. + * + * This is an optional key, default is 0.\n + * If enabled, the caller should not set callbacks for the decoder or encoder but should query buffers instead.\n + * It is used in configure.\n + * + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @since 20 + */ +extern const char *OH_MD_KEY_ENABLE_SYNC_MODE; +/** + * @brief Key to enable to set input parameters per frame for video encoder, + * value type is (0 or 1):1 is enabled, 0 otherwise. + * + * This is an optional key, default is 0. Only use in synchronous mode.\n + * If enabled, the caller will set parameters for input surface of the encoder.\n + * It is used in configure.\n + * + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @since 20 + */ +extern const char *OH_MD_KEY_VIDEO_ENCODER_ENABLE_INPUT_PARAMETER_SYNC_MODE; + /** * @brief Media type. * diff --git a/multimedia/av_codec/native_avcodec_videodecoder.h b/multimedia/av_codec/native_avcodec_videodecoder.h index 77a5f4cfa..79e48ac24 100644 --- a/multimedia/av_codec/native_avcodec_videodecoder.h +++ b/multimedia/av_codec/native_avcodec_videodecoder.h @@ -435,13 +435,13 @@ OH_AVErrCode OH_VideoDecoder_FreeOutputBuffer(OH_AVCodec *codec, uint32_t index) /** * @brief Get index of next available input buffer. * - * It's necessary to use {@link OH_VideoDecoder_GetInputBuffer} to get the buffer handle. - * It's only used in synchronous mode. + * It's necessary to use {@link OH_VideoDecoder_GetInputBuffer} to get the buffer handle.\n + * It's only used in synchronous mode.\n + * * @syscap SystemCapability.Multimedia.Media.VideoDecoder * @param codec Pointer to an OH_AVCodec instance. * @param index The index value corresponding to the input buffer. * @param timeoutUs the query timeout time, in microseconds. - * * @return Returns AV_ERR_OK if the execution is successful, * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. * {@link AV_ERR_NO_MEMORY}, internal errors in the input decode instance, such as an abnormal NULL. @@ -459,12 +459,12 @@ OH_AVErrCode OH_VideoDecoder_QueryInputBuffer(struct OH_AVCodec *codec, uint32_t /** * @brief Get the available input buffer handle. * - * It's only used in synchronous mode. + * It's only used in synchronous mode.\n + * * @syscap SystemCapability.Multimedia.Media.VideoDecoder * @param codec Pointer to an OH_AVCodec instance * @param index The index value corresponding to the input buffer, * should be given by {@link OH_VideoDecoder_QueryInputBuffer}. - * * @return Returns AV_ERR_OK if the execution is successful, * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. * {@link AV_ERR_NO_MEMORY}, internal errors in the input decode instance, such as an abnormal NULL. @@ -479,8 +479,9 @@ OH_AVBuffer *OH_VideoDecoder_GetInputBuffer(struct OH_AVCodec *codec, uint32_t i /** * @brief Get index of next available output buffer. * - * It's necessary to use {@link OH_VideoDecoder_GetOutputBuffer} to get the buffer handle. - * It's only used in synchronous mode. + * It's necessary to use {@link OH_VideoDecoder_GetOutputBuffer} to get the buffer handle.\n + * It's only used in synchronous mode.\n + * * @syscap SystemCapability.Multimedia.Media.VideoDecoder * @param codec Pointer to an OH_AVCodec instance * @param index The index value corresponding to the output buffer @@ -502,12 +503,12 @@ OH_AVErrCode OH_VideoDecoder_QueryOutputBuffer(struct OH_AVCodec *codec, uint32_ /** * @brief Get the available output buffer handle. * - * It's only used in synchronous mode. + * It's only used in synchronous mode.\n + * * @syscap SystemCapability.Multimedia.Media.VideoDecoder * @param codec Pointer to an OH_AVCodec instance * @param index The index value corresponding to the input buffer, * should be given by {@link OH_VideoDecoder_QueryOutputBuffer}. - * * @return Returns AV_ERR_OK if the execution is successful, * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. * {@link AV_ERR_NO_MEMORY}, internal errors in the input decode instance, such as an abnormal NULL. diff --git a/multimedia/av_codec/native_avcodec_videoencoder.h b/multimedia/av_codec/native_avcodec_videoencoder.h index 8a7c25424..3b96468a4 100644 --- a/multimedia/av_codec/native_avcodec_videoencoder.h +++ b/multimedia/av_codec/native_avcodec_videoencoder.h @@ -409,10 +409,10 @@ OH_AVErrCode OH_VideoEncoder_FreeOutputBuffer(OH_AVCodec *codec, uint32_t index) /** * @brief Get index of next available input parameter. * - * It's necessary to use {@link OH_VideoEncoder_GetInputParameter} to get the parameter handle. - * It's only used in synchronous mode. + * It's necessary to use {@link OH_VideoEncoder_GetInputParameter} to get the parameter handle.\n + * It's only used in synchronous mode.\n * It's optional only for input surface - * and it's necessary to configure {@link OH_MD_KEY_VIDEO_ENCODER_ENABLE_INPUT_PARAMETER_SYNC_MODE}. + * and it's necessary to configure {@link OH_MD_KEY_VIDEO_ENCODER_ENABLE_INPUT_PARAMETER_SYNC_MODE}.\n * * @syscap SystemCapability.Multimedia.Media.VideoEncoder * @param codec Pointer to an OH_AVCodec instance @@ -435,7 +435,8 @@ OH_AVErrCode OH_VideoEncoder_QueryInputParameter(struct OH_AVCodec *codec, uint3 /** * @brief Get the input parameter handle. * - * It's only used in synchronous mode. + * It's only used in synchronous mode.\n + * * @syscap SystemCapability.Multimedia.Media.VideoEncoder * @param codec Pointer to an OH_AVCodec instance * @param index The index value corresponding to the input buffer, @@ -454,8 +455,9 @@ OH_AVFormat *OH_VideoEncoder_GetInputParameter(struct OH_AVCodec *codec, uint32_ /** * @brief Get index of next available input buffer. * - * It's necessary to use {@link OH_VideoEncoder_GetInputBuffer} to get the parameter handle. - * It's only used in synchronous mode. + * It's necessary to use {@link OH_VideoEncoder_GetInputBuffer} to get the parameter handle.\n + * It's only used in synchronous mode.\n + * * @syscap SystemCapability.Multimedia.Media.VideoEncoder * @param codec Pointer to an OH_AVCodec instance * @param index The index value corresponding to the input buffer @@ -477,7 +479,8 @@ OH_AVErrCode OH_VideoEncoder_QueryInputBuffer(struct OH_AVCodec *codec, uint32_t /** * @brief Get the available input buffer handle. * - * It's only used in synchronous mode. + * It's only used in synchronous mode.\n + * * @syscap SystemCapability.Multimedia.Media.VideoEncoder * @param codec Pointer to an OH_AVCodec instance * @param index The index value corresponding to the input buffer, @@ -496,8 +499,9 @@ OH_AVBuffer *OH_VideoEncoder_GetInputBuffer(struct OH_AVCodec *codec, uint32_t i /** * @brief Get index of next available output buffer. * - * It's necessary to use {@link OH_VideoEncoder_GetOutputBuffer} to get the parameter handle. - * It's only used in synchronous mode. + * It's necessary to use {@link OH_VideoEncoder_GetOutputBuffer} to get the parameter handle.\n + * It's only used in synchronous mode.\n + * * @syscap SystemCapability.Multimedia.Media.VideoEncoder * @param codec Pointer to an OH_AVCodec instance * @param index The index value corresponding to the output buffer @@ -519,7 +523,8 @@ OH_AVErrCode OH_VideoEncoder_QueryOutputBuffer(struct OH_AVCodec *codec, uint32_ /** * @brief Get the available Output buffer handle. * - * It's only used in synchronous mode. + * It's only used in synchronous mode.\n + * * @syscap SystemCapability.Multimedia.Media.VideoEncoder * @param codec Pointer to an OH_AVCodec instance * @param index The index value corresponding to the input buffer, -- Gitee From c08b68ac48f32c4ede21bee6363cd1a54a84fa51 Mon Sep 17 00:00:00 2001 From: zhanghongran Date: Fri, 9 May 2025 10:35:51 +0800 Subject: [PATCH 05/29] =?UTF-8?q?=E5=AE=8C=E5=96=84avcodec=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhanghongran --- multimedia/av_codec/native_avcodec_base.h | 8 ++++++++ multimedia/av_codec/native_avcodec_videodecoder.h | 4 ++++ multimedia/av_codec/native_avcodec_videoencoder.h | 6 ++++++ multimedia/media_foundation/native_avformat.h | 4 ++-- 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/multimedia/av_codec/native_avcodec_base.h b/multimedia/av_codec/native_avcodec_base.h index bf46ab6fe..7f43fa952 100644 --- a/multimedia/av_codec/native_avcodec_base.h +++ b/multimedia/av_codec/native_avcodec_base.h @@ -1152,6 +1152,14 @@ typedef enum OH_MediaType { * @since 12 */ MEDIA_TYPE_SUBTITLE = 2, + /** track is timed meta. + * @since 20 + */ + MEDIA_TYPE_TIMED_METADATA=5, + /** track is auxiliary. + * @since 20 + */ + MEDIA_TYPE_AUXILIARY=6, } OH_MediaType; /** diff --git a/multimedia/av_codec/native_avcodec_videodecoder.h b/multimedia/av_codec/native_avcodec_videodecoder.h index 79e48ac24..76d2d436e 100644 --- a/multimedia/av_codec/native_avcodec_videodecoder.h +++ b/multimedia/av_codec/native_avcodec_videodecoder.h @@ -449,6 +449,7 @@ OH_AVErrCode OH_VideoDecoder_FreeOutputBuffer(OH_AVCodec *codec, uint32_t index) * {@link AV_ERR_UNKNOWN}, unknown error. * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. + * {@link AV_ERR_OPERATE_NOT_PERMIT}, not permitted in asynchronous mode. * {@link AVCS_ERR_VIDEO_STREAM_CHANGED}, the stream is changed, call {@link OH_VideoDecoder_GetOutputDescription} to * retrieve steam information. * {@link AVCS_ERR_VIDEO_TRY_AGAIN_LATER}, query failed,recommended to wait for a while and try the query again. @@ -472,6 +473,7 @@ OH_AVErrCode OH_VideoDecoder_QueryInputBuffer(struct OH_AVCodec *codec, uint32_t * {@link AV_ERR_UNKNOWN}, unknown error. * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. + * {@link AV_ERR_OPERATE_NOT_PERMIT}, not permitted in asynchronous mode. * @since 20 */ OH_AVBuffer *OH_VideoDecoder_GetInputBuffer(struct OH_AVCodec *codec, uint32_t index); @@ -493,6 +495,7 @@ OH_AVBuffer *OH_VideoDecoder_GetInputBuffer(struct OH_AVCodec *codec, uint32_t i * {@link AV_ERR_UNKNOWN}, unknown error. * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. + * {@link AV_ERR_OPERATE_NOT_PERMIT}, not permitted in asynchronous mode. * {@link AVCS_ERR_VIDEO_STREAM_CHANGED}, the stream is changed, call {@link OH_VideoDecoder_GetOutputDescription} to * retrieve steam information. * {@link AVCS_ERR_VIDEO_TRY_AGAIN_LATER}, query failed,recommended to wait for a while and try the query again. @@ -516,6 +519,7 @@ OH_AVErrCode OH_VideoDecoder_QueryOutputBuffer(struct OH_AVCodec *codec, uint32_ * {@link AV_ERR_UNKNOWN}, unknown error. * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. + * {@link AV_ERR_OPERATE_NOT_PERMIT}, not permitted in asynchronous mode. * @since 20 */ OH_AVBuffer *OH_VideoDecoder_GetOutputBuffer(struct OH_AVCodec *codec, uint32_t index); diff --git a/multimedia/av_codec/native_avcodec_videoencoder.h b/multimedia/av_codec/native_avcodec_videoencoder.h index 3b96468a4..d691d3402 100644 --- a/multimedia/av_codec/native_avcodec_videoencoder.h +++ b/multimedia/av_codec/native_avcodec_videoencoder.h @@ -425,6 +425,7 @@ OH_AVErrCode OH_VideoEncoder_FreeOutputBuffer(OH_AVCodec *codec, uint32_t index) * {@link AV_ERR_UNKNOWN}, unknown error. * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. + * {@link AV_ERR_OPERATE_NOT_PERMIT}, not permitted in asynchronous mode. * {@link AVCS_ERR_VIDEO_STREAM_CHANGED}, the stream is changed, call {@link OH_VideoEncoder_GetOutputDescription} to * retrieve steam information. * {@link AVCS_ERR_VIDEO_TRY_AGAIN_LATER}, query failed,recommended to wait for a while and try the query again. @@ -448,6 +449,7 @@ OH_AVErrCode OH_VideoEncoder_QueryInputParameter(struct OH_AVCodec *codec, uint3 * {@link AV_ERR_UNKNOWN}, unknown error. * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. + * {@link AV_ERR_OPERATE_NOT_PERMIT}, not permitted in asynchronous mode. * @since 20 */ OH_AVFormat *OH_VideoEncoder_GetInputParameter(struct OH_AVCodec *codec, uint32_t index); @@ -469,6 +471,7 @@ OH_AVFormat *OH_VideoEncoder_GetInputParameter(struct OH_AVCodec *codec, uint32_ * {@link AV_ERR_UNKNOWN}, unknown error. * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. + * {@link AV_ERR_OPERATE_NOT_PERMIT}, not permitted in asynchronous mode. * {@link AVCS_ERR_VIDEO_STREAM_CHANGED}, the stream is changed, call {@link OH_VideoEncoder_GetOutputDescription} to * retrieve steam information. * {@link AVCS_ERR_VIDEO_TRY_AGAIN_LATER}, query failed,recommended to wait for a while and try the query again. @@ -492,6 +495,7 @@ OH_AVErrCode OH_VideoEncoder_QueryInputBuffer(struct OH_AVCodec *codec, uint32_t * {@link AV_ERR_UNKNOWN}, unknown error. * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. + * {@link AV_ERR_OPERATE_NOT_PERMIT}, not permitted in asynchronous mode. * @since 20 */ OH_AVBuffer *OH_VideoEncoder_GetInputBuffer(struct OH_AVCodec *codec, uint32_t index); @@ -513,6 +517,7 @@ OH_AVBuffer *OH_VideoEncoder_GetInputBuffer(struct OH_AVCodec *codec, uint32_t i * {@link AV_ERR_UNKNOWN}, unknown error. * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. + * {@link AV_ERR_OPERATE_NOT_PERMIT}, not permitted in asynchronous mode. * {@link AVCS_ERR_VIDEO_STREAM_CHANGED}, the stream is changed, call {@link OH_VideoEncoder_GetOutputDescription} to * retrieve steam information. * {@link AVCS_ERR_VIDEO_TRY_AGAIN_LATER}, query failed,recommended to wait for a while and try the query again. @@ -536,6 +541,7 @@ OH_AVErrCode OH_VideoEncoder_QueryOutputBuffer(struct OH_AVCodec *codec, uint32_ * {@link AV_ERR_UNKNOWN}, unknown error. * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. + * {@link AV_ERR_OPERATE_NOT_PERMIT}, not permitted in asynchronous mode. * @since 20 */ OH_AVBuffer *OH_VideoEncoder_GetOutputBuffer(struct OH_AVCodec *codec, uint32_t index); diff --git a/multimedia/media_foundation/native_avformat.h b/multimedia/media_foundation/native_avformat.h index fbc82fdaf..a1e313320 100644 --- a/multimedia/media_foundation/native_avformat.h +++ b/multimedia/media_foundation/native_avformat.h @@ -336,7 +336,7 @@ const char *OH_AVFormat_DumpInfo(struct OH_AVFormat *format); * @param size written data length * @return The return value is TRUE for success, FALSE for failure * Possible failure causes: 1. input format is nullptr. 2. input format's magic error. 3. key is nullptr. - * addr is nullptr. 5. size is zero. + * 4. addr is nullptr. 5. size is zero. * @since 20 */ bool OH_AVFormat_SetIntBuffer(struct OH_AVFormat *format, const char *key, const int32_t *addr, size_t size); @@ -352,7 +352,7 @@ bool OH_AVFormat_SetIntBuffer(struct OH_AVFormat *format, const char *key, const * @param size Length of read and write data * @return The return value is TRUE for success, FALSE for failure * Possible failure causes: 1. input format is nullptr. 2. input format's magic error. 3. key is nullptr. - * addr is nullptr. 5. size is nullptr. + * 4. addr is nullptr. 5. size is nullptr. * @since 20 */ bool OH_AVFormat_GetIntBuffer(struct OH_AVFormat *format, const char *key, int32_t **addr, size_t *size); -- Gitee From 0058196b74834c1d0cdf5a2530579f3ed80c87d3 Mon Sep 17 00:00:00 2001 From: zhanghongran Date: Fri, 9 May 2025 10:50:39 +0800 Subject: [PATCH 06/29] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhanghongran --- multimedia/av_codec/native_avcodec_videodecoder.h | 7 +++++-- multimedia/av_codec/native_avcodec_videoencoder.h | 9 ++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/multimedia/av_codec/native_avcodec_videodecoder.h b/multimedia/av_codec/native_avcodec_videodecoder.h index 76d2d436e..a61f75906 100644 --- a/multimedia/av_codec/native_avcodec_videodecoder.h +++ b/multimedia/av_codec/native_avcodec_videodecoder.h @@ -435,7 +435,8 @@ OH_AVErrCode OH_VideoDecoder_FreeOutputBuffer(OH_AVCodec *codec, uint32_t index) /** * @brief Get index of next available input buffer. * - * It's necessary to use {@link OH_VideoDecoder_GetInputBuffer} to get the buffer handle.\n + * It's necessary to use {@link OH_VideoDecoder_GetInputBuffer} to get the buffer handle, and then + * use {@link OH_VideoDecoder_PushInputBuffer} to pass to the encoder.\n * It's only used in synchronous mode.\n * * @syscap SystemCapability.Multimedia.Media.VideoDecoder @@ -481,7 +482,9 @@ OH_AVBuffer *OH_VideoDecoder_GetInputBuffer(struct OH_AVCodec *codec, uint32_t i /** * @brief Get index of next available output buffer. * - * It's necessary to use {@link OH_VideoDecoder_GetOutputBuffer} to get the buffer handle.\n + * It's necessary to use {@link OH_VideoDecoder_GetOutputBuffer} to get the buffer handle, and then + * use {@link OH_VideoDecoder_FreeOutputBuffer} or {@link OH_VideoDecoder_RenderOutputBuffer} + * or {@link OH_VideoDecoder_RenderOutputBufferAtTime} to return the buffer to the decoder.\n * It's only used in synchronous mode.\n * * @syscap SystemCapability.Multimedia.Media.VideoDecoder diff --git a/multimedia/av_codec/native_avcodec_videoencoder.h b/multimedia/av_codec/native_avcodec_videoencoder.h index d691d3402..d3c193ff2 100644 --- a/multimedia/av_codec/native_avcodec_videoencoder.h +++ b/multimedia/av_codec/native_avcodec_videoencoder.h @@ -409,7 +409,8 @@ OH_AVErrCode OH_VideoEncoder_FreeOutputBuffer(OH_AVCodec *codec, uint32_t index) /** * @brief Get index of next available input parameter. * - * It's necessary to use {@link OH_VideoEncoder_GetInputParameter} to get the parameter handle.\n + * It's necessary to use {@link OH_VideoEncoder_GetInputParameter} to get the parameter handle, and then + * use {@link OH_VideoEncoder_PushInputParameter} to pass to the encoder.\n * It's only used in synchronous mode.\n * It's optional only for input surface * and it's necessary to configure {@link OH_MD_KEY_VIDEO_ENCODER_ENABLE_INPUT_PARAMETER_SYNC_MODE}.\n @@ -457,7 +458,8 @@ OH_AVFormat *OH_VideoEncoder_GetInputParameter(struct OH_AVCodec *codec, uint32_ /** * @brief Get index of next available input buffer. * - * It's necessary to use {@link OH_VideoEncoder_GetInputBuffer} to get the parameter handle.\n + * It's necessary to use {@link OH_VideoEncoder_GetInputBuffer} to get the buffer handle, and then + * use {@link OH_VideoEncoder_PushInputBuffer} to pass to the encoder.\n * It's only used in synchronous mode.\n * * @syscap SystemCapability.Multimedia.Media.VideoEncoder @@ -503,7 +505,8 @@ OH_AVBuffer *OH_VideoEncoder_GetInputBuffer(struct OH_AVCodec *codec, uint32_t i /** * @brief Get index of next available output buffer. * - * It's necessary to use {@link OH_VideoEncoder_GetOutputBuffer} to get the parameter handle.\n + * It's necessary to use {@link OH_VideoEncoder_GetOutputBuffer} to get the buffer handle, and then + * use {@link OH_VideoEncoder_FreeOutputBuffer} to return the buffer to the encoder.\n * It's only used in synchronous mode.\n * * @syscap SystemCapability.Multimedia.Media.VideoEncoder -- Gitee From ef6cec8cfc8b268d1ab967847455164fdb23febe Mon Sep 17 00:00:00 2001 From: zhanghongran Date: Tue, 20 May 2025 14:41:48 +0800 Subject: [PATCH 07/29] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhanghongran --- .../av_codec/native_avcodec_videodecoder.h | 20 +++---------- .../av_codec/native_avcodec_videoencoder.h | 30 ++++--------------- 2 files changed, 10 insertions(+), 40 deletions(-) diff --git a/multimedia/av_codec/native_avcodec_videodecoder.h b/multimedia/av_codec/native_avcodec_videodecoder.h index a61f75906..1c1cedcf6 100644 --- a/multimedia/av_codec/native_avcodec_videodecoder.h +++ b/multimedia/av_codec/native_avcodec_videodecoder.h @@ -467,14 +467,8 @@ OH_AVErrCode OH_VideoDecoder_QueryInputBuffer(struct OH_AVCodec *codec, uint32_t * @param codec Pointer to an OH_AVCodec instance * @param index The index value corresponding to the input buffer, * should be given by {@link OH_VideoDecoder_QueryInputBuffer}. - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. - * {@link AV_ERR_NO_MEMORY}, internal errors in the input decode instance, such as an abnormal NULL. - * {@link AV_ERR_INVALID_VAL}, the decoder is nullptr or invalid. - * {@link AV_ERR_UNKNOWN}, unknown error. - * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. - * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. - * {@link AV_ERR_OPERATE_NOT_PERMIT}, not permitted in asynchronous mode. + * @return Returns a Pointer to an OH_AVBuffer instance. + * Return nullptr when no input buffer is available. * @since 20 */ OH_AVBuffer *OH_VideoDecoder_GetInputBuffer(struct OH_AVCodec *codec, uint32_t index); @@ -515,14 +509,8 @@ OH_AVErrCode OH_VideoDecoder_QueryOutputBuffer(struct OH_AVCodec *codec, uint32_ * @param codec Pointer to an OH_AVCodec instance * @param index The index value corresponding to the input buffer, * should be given by {@link OH_VideoDecoder_QueryOutputBuffer}. - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. - * {@link AV_ERR_NO_MEMORY}, internal errors in the input decode instance, such as an abnormal NULL. - * {@link AV_ERR_INVALID_VAL}, the decoder is nullptr or invalid. - * {@link AV_ERR_UNKNOWN}, unknown error. - * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. - * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. - * {@link AV_ERR_OPERATE_NOT_PERMIT}, not permitted in asynchronous mode. + * @return Returns a Pointer to an OH_AVBuffer instance. + * Return nullptr when no output buffer is available. * @since 20 */ OH_AVBuffer *OH_VideoDecoder_GetOutputBuffer(struct OH_AVCodec *codec, uint32_t index); diff --git a/multimedia/av_codec/native_avcodec_videoencoder.h b/multimedia/av_codec/native_avcodec_videoencoder.h index d3c193ff2..3994dfd78 100644 --- a/multimedia/av_codec/native_avcodec_videoencoder.h +++ b/multimedia/av_codec/native_avcodec_videoencoder.h @@ -443,14 +443,8 @@ OH_AVErrCode OH_VideoEncoder_QueryInputParameter(struct OH_AVCodec *codec, uint3 * @param codec Pointer to an OH_AVCodec instance * @param index The index value corresponding to the input buffer, * should be given by {@link OH_VideoEncoder_QueryInputParameter}. - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. - * {@link AV_ERR_NO_MEMORY}, internal errors in the input encode instance, such as an abnormal NULL. - * {@link AV_ERR_INVALID_VAL}, the encoder is nullptr or invalid. - * {@link AV_ERR_UNKNOWN}, unknown error. - * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. - * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. - * {@link AV_ERR_OPERATE_NOT_PERMIT}, not permitted in asynchronous mode. + * @return Returns a Pointer to an OH_AVFormat instance. + * Return nullptr when no input parameter is available. * @since 20 */ OH_AVFormat *OH_VideoEncoder_GetInputParameter(struct OH_AVCodec *codec, uint32_t index); @@ -490,14 +484,8 @@ OH_AVErrCode OH_VideoEncoder_QueryInputBuffer(struct OH_AVCodec *codec, uint32_t * @param codec Pointer to an OH_AVCodec instance * @param index The index value corresponding to the input buffer, * should be given by {@link OH_VideoEncoder_QueryInputBuffer}. - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. - * {@link AV_ERR_NO_MEMORY}, internal errors in the input encode instance, such as an abnormal NULL. - * {@link AV_ERR_INVALID_VAL}, the encoder is nullptr or invalid. - * {@link AV_ERR_UNKNOWN}, unknown error. - * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. - * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. - * {@link AV_ERR_OPERATE_NOT_PERMIT}, not permitted in asynchronous mode. + * @return Returns a Pointer to an OH_AVBuffer instance. + * Return nullptr when no input buffer is available. * @since 20 */ OH_AVBuffer *OH_VideoEncoder_GetInputBuffer(struct OH_AVCodec *codec, uint32_t index); @@ -537,14 +525,8 @@ OH_AVErrCode OH_VideoEncoder_QueryOutputBuffer(struct OH_AVCodec *codec, uint32_ * @param codec Pointer to an OH_AVCodec instance * @param index The index value corresponding to the input buffer, * should be given by {@link OH_VideoEncoder_QueryOutputBuffer}. - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. - * {@link AV_ERR_NO_MEMORY}, internal errors in the input encode instance, such as an abnormal NULL. - * {@link AV_ERR_INVALID_VAL}, the encoder is nullptr or invalid. - * {@link AV_ERR_UNKNOWN}, unknown error. - * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. - * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. - * {@link AV_ERR_OPERATE_NOT_PERMIT}, not permitted in asynchronous mode. + * @return Returns a Pointer to an OH_AVBuffer instance. + * Return nullptr when no output buffer is available. * @since 20 */ OH_AVBuffer *OH_VideoEncoder_GetOutputBuffer(struct OH_AVCodec *codec, uint32_t index); -- Gitee From a857ac0f646a43fe4d8f8215cc7f83bd124d3a60 Mon Sep 17 00:00:00 2001 From: Corvo_s Date: Thu, 22 May 2025 15:47:15 +0800 Subject: [PATCH 08/29] =?UTF-8?q?sqr=E7=A0=81=E6=8E=A7=20Signed-off-by:=20?= =?UTF-8?q?Yanghaolong=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- multimedia/av_codec/native_avcodec_base.h | 4 +++- multimedia/av_codec/native_avcodec_videoencoder.h | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/multimedia/av_codec/native_avcodec_base.h b/multimedia/av_codec/native_avcodec_base.h index 7f43fa952..c66dd7cee 100644 --- a/multimedia/av_codec/native_avcodec_base.h +++ b/multimedia/av_codec/native_avcodec_base.h @@ -1675,7 +1675,9 @@ typedef enum OH_BitrateMode { /** Variable Bit rate mode. */ BITRATE_MODE_VBR = 1, /** Constant Quality mode. */ - BITRATE_MODE_CQ = 2 + BITRATE_MODE_CQ = 2, + /* Stable Quality Rate Control Mode. */ + BITRATE_MODE_SQR = 3 } OH_BitrateMode; #ifdef __cplusplus diff --git a/multimedia/av_codec/native_avcodec_videoencoder.h b/multimedia/av_codec/native_avcodec_videoencoder.h index d3c193ff2..2ec6b4c24 100644 --- a/multimedia/av_codec/native_avcodec_videoencoder.h +++ b/multimedia/av_codec/native_avcodec_videoencoder.h @@ -601,6 +601,11 @@ typedef enum OH_VideoEncodeBitrateMode { * @useinstead BITRATE_MODE_CQ */ CQ = 2, + /** stable quality rate control mode. + * @deprecated since 20 + * @useinstead BITRATE_MODE_SQR + */ + SQR = 3, } OH_VideoEncodeBitrateMode; #ifdef __cplusplus -- Gitee From 7254af22350759671c9075871ca18f5374f562df Mon Sep 17 00:00:00 2001 From: Corvo_s Date: Thu, 22 May 2025 20:17:45 +0800 Subject: [PATCH 09/29] =?UTF-8?q?sqr=E7=A0=81=E6=8E=A7=20Signed-off-by:=20?= =?UTF-8?q?Yanghaolong=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- multimedia/av_codec/native_avcodec_base.h | 4 +++- multimedia/av_codec/native_avcodec_videoencoder.h | 5 ----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/multimedia/av_codec/native_avcodec_base.h b/multimedia/av_codec/native_avcodec_base.h index c66dd7cee..f00b64d6c 100644 --- a/multimedia/av_codec/native_avcodec_base.h +++ b/multimedia/av_codec/native_avcodec_base.h @@ -1676,7 +1676,9 @@ typedef enum OH_BitrateMode { BITRATE_MODE_VBR = 1, /** Constant Quality mode. */ BITRATE_MODE_CQ = 2, - /* Stable Quality Rate Control Mode. */ + /** Stable Quality Rate Control mode. + * @since 20 + */ BITRATE_MODE_SQR = 3 } OH_BitrateMode; diff --git a/multimedia/av_codec/native_avcodec_videoencoder.h b/multimedia/av_codec/native_avcodec_videoencoder.h index 2ec6b4c24..d3c193ff2 100644 --- a/multimedia/av_codec/native_avcodec_videoencoder.h +++ b/multimedia/av_codec/native_avcodec_videoencoder.h @@ -601,11 +601,6 @@ typedef enum OH_VideoEncodeBitrateMode { * @useinstead BITRATE_MODE_CQ */ CQ = 2, - /** stable quality rate control mode. - * @deprecated since 20 - * @useinstead BITRATE_MODE_SQR - */ - SQR = 3, } OH_VideoEncodeBitrateMode; #ifdef __cplusplus -- Gitee From d19e01588add6e127db4eff850557647465f5656 Mon Sep 17 00:00:00 2001 From: zhanghongran Date: Mon, 9 Jun 2025 21:40:40 +0800 Subject: [PATCH 10/29] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhanghongran --- .../av_codec/native_avcodec_videodecoder.h | 10 ++++------ .../av_codec/native_avcodec_videoencoder.h | 16 +++++++--------- multimedia/media_foundation/native_averrors.h | 4 ++-- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/multimedia/av_codec/native_avcodec_videodecoder.h b/multimedia/av_codec/native_avcodec_videodecoder.h index 1c1cedcf6..25a433b6e 100644 --- a/multimedia/av_codec/native_avcodec_videodecoder.h +++ b/multimedia/av_codec/native_avcodec_videodecoder.h @@ -451,9 +451,7 @@ OH_AVErrCode OH_VideoDecoder_FreeOutputBuffer(OH_AVCodec *codec, uint32_t index) * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. * {@link AV_ERR_OPERATE_NOT_PERMIT}, not permitted in asynchronous mode. - * {@link AVCS_ERR_VIDEO_STREAM_CHANGED}, the stream is changed, call {@link OH_VideoDecoder_GetOutputDescription} to - * retrieve steam information. - * {@link AVCS_ERR_VIDEO_TRY_AGAIN_LATER}, query failed,recommended to wait for a while and try the query again. + * {@link AV_ERR_VIDEO_TRY_AGAIN_LATER}, query failed,recommended to wait for a while and try the query again. * @since 20 */ OH_AVErrCode OH_VideoDecoder_QueryInputBuffer(struct OH_AVCodec *codec, uint32_t *index, int64_t timeoutUs); @@ -493,9 +491,9 @@ OH_AVBuffer *OH_VideoDecoder_GetInputBuffer(struct OH_AVCodec *codec, uint32_t i * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. * {@link AV_ERR_OPERATE_NOT_PERMIT}, not permitted in asynchronous mode. - * {@link AVCS_ERR_VIDEO_STREAM_CHANGED}, the stream is changed, call {@link OH_VideoDecoder_GetOutputDescription} to + * {@link AV_ERR_VIDEO_STREAM_CHANGED}, the stream is changed, call {@link OH_VideoDecoder_GetOutputDescription} to * retrieve steam information. - * {@link AVCS_ERR_VIDEO_TRY_AGAIN_LATER}, query failed,recommended to wait for a while and try the query again. + * {@link AV_ERR_VIDEO_TRY_AGAIN_LATER}, query failed,recommended to wait for a while and try the query again. * @since 20 */ OH_AVErrCode OH_VideoDecoder_QueryOutputBuffer(struct OH_AVCodec *codec, uint32_t *index, int64_t timeoutUs); @@ -507,7 +505,7 @@ OH_AVErrCode OH_VideoDecoder_QueryOutputBuffer(struct OH_AVCodec *codec, uint32_ * * @syscap SystemCapability.Multimedia.Media.VideoDecoder * @param codec Pointer to an OH_AVCodec instance - * @param index The index value corresponding to the input buffer, + * @param index The index value corresponding to the output buffer, * should be given by {@link OH_VideoDecoder_QueryOutputBuffer}. * @return Returns a Pointer to an OH_AVBuffer instance. * Return nullptr when no output buffer is available. diff --git a/multimedia/av_codec/native_avcodec_videoencoder.h b/multimedia/av_codec/native_avcodec_videoencoder.h index 3994dfd78..69a5aece1 100644 --- a/multimedia/av_codec/native_avcodec_videoencoder.h +++ b/multimedia/av_codec/native_avcodec_videoencoder.h @@ -427,9 +427,9 @@ OH_AVErrCode OH_VideoEncoder_FreeOutputBuffer(OH_AVCodec *codec, uint32_t index) * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. * {@link AV_ERR_OPERATE_NOT_PERMIT}, not permitted in asynchronous mode. - * {@link AVCS_ERR_VIDEO_STREAM_CHANGED}, the stream is changed, call {@link OH_VideoEncoder_GetOutputDescription} to + * {@link AV_ERR_VIDEO_STREAM_CHANGED}, the stream is changed, call {@link OH_VideoEncoder_GetOutputDescription} to * retrieve steam information. - * {@link AVCS_ERR_VIDEO_TRY_AGAIN_LATER}, query failed,recommended to wait for a while and try the query again. + * {@link AV_ERR_VIDEO_TRY_AGAIN_LATER}, query failed,recommended to wait for a while and try the query again. * @since 20 */ OH_AVErrCode OH_VideoEncoder_QueryInputParameter(struct OH_AVCodec *codec, uint32_t *index, int64_t timeoutUs); @@ -441,7 +441,7 @@ OH_AVErrCode OH_VideoEncoder_QueryInputParameter(struct OH_AVCodec *codec, uint3 * * @syscap SystemCapability.Multimedia.Media.VideoEncoder * @param codec Pointer to an OH_AVCodec instance - * @param index The index value corresponding to the input buffer, + * @param index The index value corresponding to the input param buffer, * should be given by {@link OH_VideoEncoder_QueryInputParameter}. * @return Returns a Pointer to an OH_AVFormat instance. * Return nullptr when no input parameter is available. @@ -468,9 +468,7 @@ OH_AVFormat *OH_VideoEncoder_GetInputParameter(struct OH_AVCodec *codec, uint32_ * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. * {@link AV_ERR_OPERATE_NOT_PERMIT}, not permitted in asynchronous mode. - * {@link AVCS_ERR_VIDEO_STREAM_CHANGED}, the stream is changed, call {@link OH_VideoEncoder_GetOutputDescription} to - * retrieve steam information. - * {@link AVCS_ERR_VIDEO_TRY_AGAIN_LATER}, query failed,recommended to wait for a while and try the query again. + * {@link AV_ERR_VIDEO_TRY_AGAIN_LATER}, query failed,recommended to wait for a while and try the query again. * @since 20 */ OH_AVErrCode OH_VideoEncoder_QueryInputBuffer(struct OH_AVCodec *codec, uint32_t *index, int64_t timeoutUs); @@ -509,9 +507,9 @@ OH_AVBuffer *OH_VideoEncoder_GetInputBuffer(struct OH_AVCodec *codec, uint32_t i * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. * {@link AV_ERR_OPERATE_NOT_PERMIT}, not permitted in asynchronous mode. - * {@link AVCS_ERR_VIDEO_STREAM_CHANGED}, the stream is changed, call {@link OH_VideoEncoder_GetOutputDescription} to + * {@link AV_ERR_VIDEO_STREAM_CHANGED}, the stream is changed, call {@link OH_VideoEncoder_GetOutputDescription} to * retrieve steam information. - * {@link AVCS_ERR_VIDEO_TRY_AGAIN_LATER}, query failed,recommended to wait for a while and try the query again. + * {@link AV_ERR_VIDEO_TRY_AGAIN_LATER}, query failed,recommended to wait for a while and try the query again. * @since 20 */ OH_AVErrCode OH_VideoEncoder_QueryOutputBuffer(struct OH_AVCodec *codec, uint32_t *index, int64_t timeoutUs); @@ -523,7 +521,7 @@ OH_AVErrCode OH_VideoEncoder_QueryOutputBuffer(struct OH_AVCodec *codec, uint32_ * * @syscap SystemCapability.Multimedia.Media.VideoEncoder * @param codec Pointer to an OH_AVCodec instance - * @param index The index value corresponding to the input buffer, + * @param index The index value corresponding to the output buffer, * should be given by {@link OH_VideoEncoder_QueryOutputBuffer}. * @return Returns a Pointer to an OH_AVBuffer instance. * Return nullptr when no output buffer is available. diff --git a/multimedia/media_foundation/native_averrors.h b/multimedia/media_foundation/native_averrors.h index 1a87e7d14..7b1c06ba8 100644 --- a/multimedia/media_foundation/native_averrors.h +++ b/multimedia/media_foundation/native_averrors.h @@ -187,12 +187,12 @@ typedef enum OH_AVErrCode { * the video decoder instance. * @since 20 */ - AVCS_ERR_VIDEO_STREAM_CHANGED = 5413001, + AV_ERR_VIDEO_STREAM_CHANGED = 5413001, /** * @error Indicates buffer query failed within certain time for synchronous mode, * it's recommended to wait for a while and try the query again. */ - AVCS_ERR_VIDEO_TRY_AGAIN_LATER = 5413002, + AV_ERR_VIDEO_TRY_AGAIN_LATER = 5413002, } OH_AVErrCode; #ifdef __cplusplus -- Gitee From 3254a1bee5f0b4e49225ef812431cd82a79cf736 Mon Sep 17 00:00:00 2001 From: zhanghongran Date: Mon, 9 Jun 2025 21:55:39 +0800 Subject: [PATCH 11/29] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhanghongran --- multimedia/av_codec/native_avcodec_videodecoder.h | 6 +++--- multimedia/av_codec/native_avcodec_videoencoder.h | 10 +++++----- multimedia/media_foundation/native_averrors.h | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/multimedia/av_codec/native_avcodec_videodecoder.h b/multimedia/av_codec/native_avcodec_videodecoder.h index 25a433b6e..c51aa92be 100644 --- a/multimedia/av_codec/native_avcodec_videodecoder.h +++ b/multimedia/av_codec/native_avcodec_videodecoder.h @@ -451,7 +451,7 @@ OH_AVErrCode OH_VideoDecoder_FreeOutputBuffer(OH_AVCodec *codec, uint32_t index) * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. * {@link AV_ERR_OPERATE_NOT_PERMIT}, not permitted in asynchronous mode. - * {@link AV_ERR_VIDEO_TRY_AGAIN_LATER}, query failed,recommended to wait for a while and try the query again. + * {@link AV_ERR_TRY_AGAIN_LATER}, query failed,recommended to wait for a while and try the query again. * @since 20 */ OH_AVErrCode OH_VideoDecoder_QueryInputBuffer(struct OH_AVCodec *codec, uint32_t *index, int64_t timeoutUs); @@ -491,9 +491,9 @@ OH_AVBuffer *OH_VideoDecoder_GetInputBuffer(struct OH_AVCodec *codec, uint32_t i * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. * {@link AV_ERR_OPERATE_NOT_PERMIT}, not permitted in asynchronous mode. - * {@link AV_ERR_VIDEO_STREAM_CHANGED}, the stream is changed, call {@link OH_VideoDecoder_GetOutputDescription} to + * {@link AV_ERR_STREAM_CHANGED}, the stream is changed, call {@link OH_VideoDecoder_GetOutputDescription} to * retrieve steam information. - * {@link AV_ERR_VIDEO_TRY_AGAIN_LATER}, query failed,recommended to wait for a while and try the query again. + * {@link AV_ERR_TRY_AGAIN_LATER}, query failed,recommended to wait for a while and try the query again. * @since 20 */ OH_AVErrCode OH_VideoDecoder_QueryOutputBuffer(struct OH_AVCodec *codec, uint32_t *index, int64_t timeoutUs); diff --git a/multimedia/av_codec/native_avcodec_videoencoder.h b/multimedia/av_codec/native_avcodec_videoencoder.h index 69a5aece1..a644bc9cf 100644 --- a/multimedia/av_codec/native_avcodec_videoencoder.h +++ b/multimedia/av_codec/native_avcodec_videoencoder.h @@ -427,9 +427,9 @@ OH_AVErrCode OH_VideoEncoder_FreeOutputBuffer(OH_AVCodec *codec, uint32_t index) * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. * {@link AV_ERR_OPERATE_NOT_PERMIT}, not permitted in asynchronous mode. - * {@link AV_ERR_VIDEO_STREAM_CHANGED}, the stream is changed, call {@link OH_VideoEncoder_GetOutputDescription} to + * {@link AV_ERR_STREAM_CHANGED}, the stream is changed, call {@link OH_VideoEncoder_GetOutputDescription} to * retrieve steam information. - * {@link AV_ERR_VIDEO_TRY_AGAIN_LATER}, query failed,recommended to wait for a while and try the query again. + * {@link AV_ERR_TRY_AGAIN_LATER}, query failed,recommended to wait for a while and try the query again. * @since 20 */ OH_AVErrCode OH_VideoEncoder_QueryInputParameter(struct OH_AVCodec *codec, uint32_t *index, int64_t timeoutUs); @@ -468,7 +468,7 @@ OH_AVFormat *OH_VideoEncoder_GetInputParameter(struct OH_AVCodec *codec, uint32_ * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. * {@link AV_ERR_OPERATE_NOT_PERMIT}, not permitted in asynchronous mode. - * {@link AV_ERR_VIDEO_TRY_AGAIN_LATER}, query failed,recommended to wait for a while and try the query again. + * {@link AV_ERR_TRY_AGAIN_LATER}, query failed,recommended to wait for a while and try the query again. * @since 20 */ OH_AVErrCode OH_VideoEncoder_QueryInputBuffer(struct OH_AVCodec *codec, uint32_t *index, int64_t timeoutUs); @@ -507,9 +507,9 @@ OH_AVBuffer *OH_VideoEncoder_GetInputBuffer(struct OH_AVCodec *codec, uint32_t i * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. * {@link AV_ERR_OPERATE_NOT_PERMIT}, not permitted in asynchronous mode. - * {@link AV_ERR_VIDEO_STREAM_CHANGED}, the stream is changed, call {@link OH_VideoEncoder_GetOutputDescription} to + * {@link AV_ERR_STREAM_CHANGED}, the stream is changed, call {@link OH_VideoEncoder_GetOutputDescription} to * retrieve steam information. - * {@link AV_ERR_VIDEO_TRY_AGAIN_LATER}, query failed,recommended to wait for a while and try the query again. + * {@link AV_ERR_TRY_AGAIN_LATER}, query failed,recommended to wait for a while and try the query again. * @since 20 */ OH_AVErrCode OH_VideoEncoder_QueryOutputBuffer(struct OH_AVCodec *codec, uint32_t *index, int64_t timeoutUs); diff --git a/multimedia/media_foundation/native_averrors.h b/multimedia/media_foundation/native_averrors.h index 7b1c06ba8..3d2d7b7c7 100644 --- a/multimedia/media_foundation/native_averrors.h +++ b/multimedia/media_foundation/native_averrors.h @@ -187,12 +187,12 @@ typedef enum OH_AVErrCode { * the video decoder instance. * @since 20 */ - AV_ERR_VIDEO_STREAM_CHANGED = 5413001, + AV_ERR_STREAM_CHANGED = 5410005, /** * @error Indicates buffer query failed within certain time for synchronous mode, * it's recommended to wait for a while and try the query again. */ - AV_ERR_VIDEO_TRY_AGAIN_LATER = 5413002, + AV_ERR_TRY_AGAIN_LATER = 5410006, } OH_AVErrCode; #ifdef __cplusplus -- Gitee From 23de77a97077668a7b55019cb5d390c59ee7ef1a Mon Sep 17 00:00:00 2001 From: SuRuoyan Date: Mon, 9 Jun 2025 22:14:26 +0800 Subject: [PATCH 12/29] add audio sync interface Signed-off-by: SuRuoyan --- .../av_codec/native_avcodec_audiocodec.h | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/multimedia/av_codec/native_avcodec_audiocodec.h b/multimedia/av_codec/native_avcodec_audiocodec.h index 5495a534b..5de950ea8 100644 --- a/multimedia/av_codec/native_avcodec_audiocodec.h +++ b/multimedia/av_codec/native_avcodec_audiocodec.h @@ -295,6 +295,79 @@ OH_AVErrCode OH_AudioCodec_IsValid(OH_AVCodec *codec, bool *isValid); */ OH_AVErrCode OH_AudioCodec_SetDecryptionConfig(OH_AVCodec *codec, MediaKeySession *mediaKeySession, bool secureAudio); + +/** + * @brief Get index of next available input buffer. + * + * It's necessary to use {@link OH_AudioCodec_GetInputBuffer} to get the buffer handle, and then + * use {@link OH_AudioCodec_PushInputBuffer} to pass to the audio codec. + * It's only used in synchronous mode. + * + * @syscap SystemCapability.Multimedia.Media.AudioCodec + * @param codec Pointer to an OH_AVCodec instance. + * @param index The index value corresponding to the input buffer. + * @param timeoutUs the query timeout time, in microseconds. + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. + * {@link AV_ERR_INVALID_VAL}, input parameter is empty or invalid. + * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. + * {@link AV_ERR_OPERATE_NOT_PERMIT}, not permitted in asynchronous mode. + * {@link AV_ERR_TRY_AGAIN_LATER}, query failed,recommended to wait for a while and try the query again. + * @since 20 + */ +OH_AVErrCode OH_AudioCodec_QueryInputBuffer(struct OH_AVCodec *codec, uint32_t *index, int64_t timeoutUs); + +/** + * @brief Get the available input buffer handle. + * + * It's only used in synchronous mode.\n + * + * @syscap SystemCapability.Multimedia.Media.AudioCodec + * @param codec Pointer to an OH_AVCodec instance + * @param index The index value corresponding to the input buffer, + * should be given by {@link OH_AudioCodec_QueryInputBuffer}. + * @return Returns a Pointer to an OH_AVBuffer instance. + * Return nullptr when no input buffer is available. + * @since 20 + */ +OH_AVBuffer *OH_AudioCodec_GetInputBuffer(struct OH_AVCodec *codec, uint32_t index); + +/** + * @brief Get index of next available output buffer. + * + * It's necessary to use {@link OH_AudioCodec_GetOutputBuffer} to get the buffer handle, and then + * use {@link OH_AudioCodec_FreeOutputBuffer} to return the buffer to the audio codec.\n + * It's only used in synchronous mode.\n + * + * @syscap SystemCapability.Multimedia.Media.AudioCodec + * @param codec Pointer to an OH_AVCodec instance + * @param index The index value corresponding to the output buffer + * @param timeoutUs the query timeout time, in microseconds. + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. + * {@link AV_ERR_INVALID_VAL}, input parameter is empty or invalid. + * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. + * {@link AV_ERR_OPERATE_NOT_PERMIT}, not permitted in asynchronous mode. + * {@link AV_ERR_STREAM_CHANGED}, the stream is changed, call {@link OH_AudioCodec_GetOutputDescription} to + * retrieve steam information. + * {@link AV_ERR_TRY_AGAIN_LATER}, query failed,recommended to wait for a while and try the query again. + * @since 20 + */ +OH_AVErrCode OH_AudioCodec_QueryOutputBuffer(struct OH_AVCodec *codec, uint32_t *index, int64_t timeoutUs); + +/** + * @brief Get the available output buffer handle. + * + * It's only used in synchronous mode. + * + * @syscap SystemCapability.Multimedia.Media.AudioCodec + * @param codec Pointer to an OH_AVCodec instance + * @param index The index value corresponding to the output buffer, + * should be given by {@link OH_AudioCodec_QueryOutputBuffer}. + * @return Returns a Pointer to an OH_AVBuffer instance. Return nullptr when no output buffer is available. + * @since 20 + */ +OH_AVBuffer *OH_AudioCodec_GetOutputBuffer(struct OH_AVCodec *codec, uint32_t index); #ifdef __cplusplus } #endif -- Gitee From 1631c74e3608ba089cc1c2b1ea75acd257d25d7a Mon Sep 17 00:00:00 2001 From: zhanghongran Date: Tue, 10 Jun 2025 11:18:43 +0800 Subject: [PATCH 13/29] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhanghongran --- .../av_codec/native_avcodec_videodecoder.h | 51 +++++++++---------- .../av_codec/native_avcodec_videoencoder.h | 46 ++++++++--------- 2 files changed, 47 insertions(+), 50 deletions(-) diff --git a/multimedia/av_codec/native_avcodec_videodecoder.h b/multimedia/av_codec/native_avcodec_videodecoder.h index c51aa92be..ceb39b4a6 100644 --- a/multimedia/av_codec/native_avcodec_videodecoder.h +++ b/multimedia/av_codec/native_avcodec_videodecoder.h @@ -433,16 +433,16 @@ OH_AVErrCode OH_VideoDecoder_RenderOutputBufferAtTime(OH_AVCodec *codec, uint32_ OH_AVErrCode OH_VideoDecoder_FreeOutputBuffer(OH_AVCodec *codec, uint32_t index); /** - * @brief Get index of next available input buffer. + * @brief Queries the index of the next available input buffer. * - * It's necessary to use {@link OH_VideoDecoder_GetInputBuffer} to get the buffer handle, and then - * use {@link OH_VideoDecoder_PushInputBuffer} to pass to the encoder.\n - * It's only used in synchronous mode.\n + * This API must be followed by calling {@link OH_VideoDecoder_GetInputBuffer} to obtain the buffer handle, + * which should then be passed to the decoder via {@link OH_VideoDecoder_PushInputBuffer}.\n + * Note: This operation is only supported in synchronous mode.\n * * @syscap SystemCapability.Multimedia.Media.VideoDecoder * @param codec Pointer to an OH_AVCodec instance. * @param index The index value corresponding to the input buffer. - * @param timeoutUs the query timeout time, in microseconds. + * @param timeoutUs Timeout duration in microseconds, negative value indicates infinite wait. * @return Returns AV_ERR_OK if the execution is successful, * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. * {@link AV_ERR_NO_MEMORY}, internal errors in the input decode instance, such as an abnormal NULL. @@ -451,38 +451,38 @@ OH_AVErrCode OH_VideoDecoder_FreeOutputBuffer(OH_AVCodec *codec, uint32_t index) * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. * {@link AV_ERR_OPERATE_NOT_PERMIT}, not permitted in asynchronous mode. - * {@link AV_ERR_TRY_AGAIN_LATER}, query failed,recommended to wait for a while and try the query again. + * {@link AV_ERR_TRY_AGAIN_LATER}, query failed,recommended retry after delay. * @since 20 */ OH_AVErrCode OH_VideoDecoder_QueryInputBuffer(struct OH_AVCodec *codec, uint32_t *index, int64_t timeoutUs); /** - * @brief Get the available input buffer handle. + * @brief Acquires the handle of an available input buffer. * - * It's only used in synchronous mode.\n + * Note: It's only applicable in synchronous mode.\n * * @syscap SystemCapability.Multimedia.Media.VideoDecoder * @param codec Pointer to an OH_AVCodec instance - * @param index The index value corresponding to the input buffer, - * should be given by {@link OH_VideoDecoder_QueryInputBuffer}. + * @param index Buffer index obtained via {@link OH_VideoDecoder_QueryInputBuffer}. * @return Returns a Pointer to an OH_AVBuffer instance. - * Return nullptr when no input buffer is available. + * Return nullptr if no buffer available. * @since 20 */ OH_AVBuffer *OH_VideoDecoder_GetInputBuffer(struct OH_AVCodec *codec, uint32_t index); /** - * @brief Get index of next available output buffer. + * @brief Queries the index of the next available output buffer. * - * It's necessary to use {@link OH_VideoDecoder_GetOutputBuffer} to get the buffer handle, and then - * use {@link OH_VideoDecoder_FreeOutputBuffer} or {@link OH_VideoDecoder_RenderOutputBuffer} - * or {@link OH_VideoDecoder_RenderOutputBufferAtTime} to return the buffer to the decoder.\n - * It's only used in synchronous mode.\n + * The obtained buffer handle through {@link OH_VideoDecoder_GetOutputBuffer} must be: + * - Released via {@link OH_VideoDecoder_FreeOutputBuffer}, or + * - Rendered using {@link OH_VideoDecoder_RenderOutputBuffer}, or + * - Scheduled for rendering with {@link OH_VideoDecoder_RenderOutputBufferAtTime}\n + * Note: This operation is only supported in synchronous mode.\n * * @syscap SystemCapability.Multimedia.Media.VideoDecoder * @param codec Pointer to an OH_AVCodec instance - * @param index The index value corresponding to the output buffer - * @param timeoutUs the query timeout time, in microseconds. + * @param index The index of the output buffer + * @param timeoutUs Timeout duration in microseconds, negative value indicates infinite wait. * @return Returns AV_ERR_OK if the execution is successful, * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. * {@link AV_ERR_NO_MEMORY}, internal errors in the input decode instance, such as an abnormal NULL. @@ -491,24 +491,23 @@ OH_AVBuffer *OH_VideoDecoder_GetInputBuffer(struct OH_AVCodec *codec, uint32_t i * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. * {@link AV_ERR_OPERATE_NOT_PERMIT}, not permitted in asynchronous mode. - * {@link AV_ERR_STREAM_CHANGED}, the stream is changed, call {@link OH_VideoDecoder_GetOutputDescription} to - * retrieve steam information. - * {@link AV_ERR_TRY_AGAIN_LATER}, query failed,recommended to wait for a while and try the query again. + * {@link AV_ERR_STREAM_CHANGED}, stream format changed, call {@link OH_VideoDecoder_GetOutputDescription} to + * retrieve new steam information. + * {@link AV_ERR_TRY_AGAIN_LATER}, query failed,recommended retry after delay. * @since 20 */ OH_AVErrCode OH_VideoDecoder_QueryOutputBuffer(struct OH_AVCodec *codec, uint32_t *index, int64_t timeoutUs); /** - * @brief Get the available output buffer handle. + * @brief Acquires the handle of an available output buffer. * - * It's only used in synchronous mode.\n + * Note: It's only applicable in synchronous mode.\n * * @syscap SystemCapability.Multimedia.Media.VideoDecoder * @param codec Pointer to an OH_AVCodec instance - * @param index The index value corresponding to the output buffer, - * should be given by {@link OH_VideoDecoder_QueryOutputBuffer}. + * @param index Buffer index obtained via {@link OH_VideoDecoder_QueryOutputBuffer}. * @return Returns a Pointer to an OH_AVBuffer instance. - * Return nullptr when no output buffer is available. + * Return nullptr if no buffer available. * @since 20 */ OH_AVBuffer *OH_VideoDecoder_GetOutputBuffer(struct OH_AVCodec *codec, uint32_t index); diff --git a/multimedia/av_codec/native_avcodec_videoencoder.h b/multimedia/av_codec/native_avcodec_videoencoder.h index a644bc9cf..15ed5e938 100644 --- a/multimedia/av_codec/native_avcodec_videoencoder.h +++ b/multimedia/av_codec/native_avcodec_videoencoder.h @@ -450,16 +450,16 @@ OH_AVErrCode OH_VideoEncoder_QueryInputParameter(struct OH_AVCodec *codec, uint3 OH_AVFormat *OH_VideoEncoder_GetInputParameter(struct OH_AVCodec *codec, uint32_t index); /** - * @brief Get index of next available input buffer. + * @brief Queries the index of the next available input buffer. * - * It's necessary to use {@link OH_VideoEncoder_GetInputBuffer} to get the buffer handle, and then - * use {@link OH_VideoEncoder_PushInputBuffer} to pass to the encoder.\n - * It's only used in synchronous mode.\n + * This API must be followed by calling {@link OH_VideoEncoder_GetInputBuffer} to obtain the buffer handle, + * which should then be passed to the encoder via {@link OH_VideoEncoder_PushInputBuffer}.\n + * Note: This operation is only supported in synchronous mode.\n * * @syscap SystemCapability.Multimedia.Media.VideoEncoder * @param codec Pointer to an OH_AVCodec instance - * @param index The index value corresponding to the input buffer - * @param timeoutUs the query timeout time, in microseconds. + * @param index The index of the input buffer + * @param timeoutUs Timeout duration in microseconds, negative value indicates infinite wait. * @return Returns AV_ERR_OK if the execution is successful, * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. * {@link AV_ERR_NO_MEMORY}, internal errors in the input encode instance, such as an abnormal NULL. @@ -468,32 +468,31 @@ OH_AVFormat *OH_VideoEncoder_GetInputParameter(struct OH_AVCodec *codec, uint32_ * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. * {@link AV_ERR_OPERATE_NOT_PERMIT}, not permitted in asynchronous mode. - * {@link AV_ERR_TRY_AGAIN_LATER}, query failed,recommended to wait for a while and try the query again. + * {@link AV_ERR_TRY_AGAIN_LATER}, query failed,recommended retry after delay.. * @since 20 */ OH_AVErrCode OH_VideoEncoder_QueryInputBuffer(struct OH_AVCodec *codec, uint32_t *index, int64_t timeoutUs); /** - * @brief Get the available input buffer handle. + * @brief Acquires the handle of an available input buffer. * - * It's only used in synchronous mode.\n + * Note: It's only applicable in synchronous mode.\n * * @syscap SystemCapability.Multimedia.Media.VideoEncoder * @param codec Pointer to an OH_AVCodec instance - * @param index The index value corresponding to the input buffer, - * should be given by {@link OH_VideoEncoder_QueryInputBuffer}. + * @param index Buffer index obtained via {@link OH_VideoEncoder_QueryInputBuffer}. * @return Returns a Pointer to an OH_AVBuffer instance. - * Return nullptr when no input buffer is available. + * Return nullptr if no buffer available. * @since 20 */ OH_AVBuffer *OH_VideoEncoder_GetInputBuffer(struct OH_AVCodec *codec, uint32_t index); /** - * @brief Get index of next available output buffer. + * @brief Queries the index of the next available output buffer. * - * It's necessary to use {@link OH_VideoEncoder_GetOutputBuffer} to get the buffer handle, and then - * use {@link OH_VideoEncoder_FreeOutputBuffer} to return the buffer to the encoder.\n - * It's only used in synchronous mode.\n + * The obtained buffer handle through {@link OH_VideoEncoder_GetOutputBuffer} must be + * released via {@link OH_VideoEncoder_FreeOutputBuffer}.\n + * Note: This operation is only supported in synchronous mode.\n * * @syscap SystemCapability.Multimedia.Media.VideoEncoder * @param codec Pointer to an OH_AVCodec instance @@ -507,24 +506,23 @@ OH_AVBuffer *OH_VideoEncoder_GetInputBuffer(struct OH_AVCodec *codec, uint32_t i * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. * {@link AV_ERR_OPERATE_NOT_PERMIT}, not permitted in asynchronous mode. - * {@link AV_ERR_STREAM_CHANGED}, the stream is changed, call {@link OH_VideoEncoder_GetOutputDescription} to - * retrieve steam information. - * {@link AV_ERR_TRY_AGAIN_LATER}, query failed,recommended to wait for a while and try the query again. + * {@link AV_ERR_STREAM_CHANGED}, stream format changed, call {@link OH_VideoEncoder_GetOutputDescription} to + * retrieve new steam information. + * {@link AV_ERR_TRY_AGAIN_LATER}, query failed,recommended retry after delay. * @since 20 */ OH_AVErrCode OH_VideoEncoder_QueryOutputBuffer(struct OH_AVCodec *codec, uint32_t *index, int64_t timeoutUs); /** - * @brief Get the available Output buffer handle. + * @brief Acquires the handle of an available output buffer. * - * It's only used in synchronous mode.\n + * Note: It's only applicable in synchronous mode.\n * * @syscap SystemCapability.Multimedia.Media.VideoEncoder * @param codec Pointer to an OH_AVCodec instance - * @param index The index value corresponding to the output buffer, - * should be given by {@link OH_VideoEncoder_QueryOutputBuffer}. + * @param index Buffer index obtained via {@link OH_VideoEncoder_QueryOutputBuffer}. * @return Returns a Pointer to an OH_AVBuffer instance. - * Return nullptr when no output buffer is available. + * Return nullptr if no buffer available. * @since 20 */ OH_AVBuffer *OH_VideoEncoder_GetOutputBuffer(struct OH_AVCodec *codec, uint32_t index); -- Gitee From 8da2ec180a7ffe718f1e6fcefbe40eab7048771e Mon Sep 17 00:00:00 2001 From: zhanghongran Date: Tue, 10 Jun 2025 11:26:30 +0800 Subject: [PATCH 14/29] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhanghongran --- multimedia/media_foundation/native_averrors.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/multimedia/media_foundation/native_averrors.h b/multimedia/media_foundation/native_averrors.h index 3d2d7b7c7..a09adbb99 100644 --- a/multimedia/media_foundation/native_averrors.h +++ b/multimedia/media_foundation/native_averrors.h @@ -181,16 +181,19 @@ typedef enum OH_AVErrCode { */ AV_ERR_IO_UNSUPPORTED_REQUEST = 5411011, /** - * @error Indicates a stream change for synchronous mode. - * It's necessary to call {@link OH_VideoEncoder_GetInputDescription} to retrieve steam information - * for the video encoder instance, call {@link OH_VideoDecoder_GetOutputDescription} for - * the video decoder instance. + * Required follow-up actions: + * - For video encoders: Call {@link OH_VideoEncoder_GetInputDescription} + * - For video decoders: Call {@link OH_VideoDecoder_GetOutputDescription} + * - For audio encoders: Call {@link OH_AudioEncoder_GetInputDescription} + * - For audio decoders: Call {@link OH_AudioDecoder_GetOutputDescription} + * to retrieve updated stream configuration. * @since 20 */ AV_ERR_STREAM_CHANGED = 5410005, /** - * @error Indicates buffer query failed within certain time for synchronous mode, - * it's recommended to wait for a while and try the query again. + * @error Indicates temporary buffer query failure in synchronous mode, + * it's recommended to wait and retry the operation after a short interval. + * @since 20 */ AV_ERR_TRY_AGAIN_LATER = 5410006, } OH_AVErrCode; -- Gitee From e407fc29d1a81361b663fa8dc93297067ce6caee Mon Sep 17 00:00:00 2001 From: zhanghongran Date: Tue, 10 Jun 2025 11:33:23 +0800 Subject: [PATCH 15/29] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhanghongran --- multimedia/media_foundation/native_averrors.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/multimedia/media_foundation/native_averrors.h b/multimedia/media_foundation/native_averrors.h index a09adbb99..e22609842 100644 --- a/multimedia/media_foundation/native_averrors.h +++ b/multimedia/media_foundation/native_averrors.h @@ -181,12 +181,13 @@ typedef enum OH_AVErrCode { */ AV_ERR_IO_UNSUPPORTED_REQUEST = 5411011, /** + * @error Signals a stream format change in synchronous mode. * Required follow-up actions: - * - For video encoders: Call {@link OH_VideoEncoder_GetInputDescription} - * - For video decoders: Call {@link OH_VideoDecoder_GetOutputDescription} - * - For audio encoders: Call {@link OH_AudioEncoder_GetInputDescription} - * - For audio decoders: Call {@link OH_AudioDecoder_GetOutputDescription} - * to retrieve updated stream configuration. + * - For video encoders: Call {@link OH_VideoEncoder_GetOutputDescription} + * - For video decoders: Call {@link OH_VideoDecoder_GetOutputDescription} + * - For audio encoders : Call {@link OH_AudioCodec_GetOutputDescription} + * - For audio decoders : Call {@link OH_AudioCodec_GetOutputDescription} + * to retrieve updated stream configuration. * @since 20 */ AV_ERR_STREAM_CHANGED = 5410005, -- Gitee From 10c3fa4a3a7e3b858520196d1e47dca99f976a04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=8F=E5=8D=8E=E5=86=9B?= <13735532946@163.com> Date: Tue, 10 Jun 2025 03:40:58 +0000 Subject: [PATCH 16/29] =?UTF-8?q?!1=20roi=E5=A2=9E=E5=8A=A0=E6=B3=A8?= =?UTF-8?q?=E9=87=8A=20*=20=E4=BF=AE=E6=94=B9=E6=B3=A8=E9=87=8A=20*=20roi?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- multimedia/av_codec/native_avcodec_base.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/multimedia/av_codec/native_avcodec_base.h b/multimedia/av_codec/native_avcodec_base.h index f00b64d6c..762b63980 100644 --- a/multimedia/av_codec/native_avcodec_base.h +++ b/multimedia/av_codec/native_avcodec_base.h @@ -1092,14 +1092,16 @@ extern const char *OH_MD_KEY_MAX_BITRATE; extern const char *OH_MD_KEY_VIDEO_ENCODER_ENABLE_PTS_BASED_RATECONTROL; /** * @brief Key to set the region of interest(ROI) as QpOffset-Rects, value type is string in the format - * "Top1,Left1-Bottom1,Right1=Offset1;Top2,Left2-Bottom2,Right2=Offset2;...". Each "Top,Left-Bottom,Right=Offset" + * "Top1,Left1-Bottom1,Right1=Offset1;Top2,Left2-Bottom2,Right2=Offset2;". Each "Top,Left-Bottom,Right=Offset" * represents the coordinate information and quantization parameter of one ROI. Each "=Offset" in the string - * can be omitted, like "Top1,Left1-Bottom1,Right1;Top2,Left2-Bottom2,Right2=Offset2;...", the encoder + * can be omitted, like "Top1,Left1-Bottom1,Right1;Top2,Left2-Bottom2,Right2=Offset2;", the encoder * will use the default quantization parameter to perform the ROI encoding on the first ROI and * use Offset2 on the second ROI. * * This is an optional key that applies only to video encoder. - * It is used in running process. + * It is used in running process and is set with each frame. + * In surface mode, it is used in {@link OH_VideoEncoder_OnNeedInputParameter}. + * In buffer mode, it is configured via {@link OH_AVBuffer_SetParameter}. * @syscap SystemCapability.Multimedia.Media.CodecBase * @since 20 */ -- Gitee From 58a393d5e30dbbb1c60a195f044d7866c05ce39f Mon Sep 17 00:00:00 2001 From: zhanghongran Date: Tue, 10 Jun 2025 11:55:26 +0800 Subject: [PATCH 17/29] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhanghongran --- .../av_codec/native_avcodec_audiocodec.h | 43 +++++++++---------- .../av_codec/native_avcodec_videodecoder.h | 2 +- .../av_codec/native_avcodec_videoencoder.h | 2 +- 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/multimedia/av_codec/native_avcodec_audiocodec.h b/multimedia/av_codec/native_avcodec_audiocodec.h index 5de950ea8..86fde9470 100644 --- a/multimedia/av_codec/native_avcodec_audiocodec.h +++ b/multimedia/av_codec/native_avcodec_audiocodec.h @@ -297,60 +297,58 @@ OH_AVErrCode OH_AudioCodec_SetDecryptionConfig(OH_AVCodec *codec, MediaKeySessio bool secureAudio); /** - * @brief Get index of next available input buffer. + * @brief Queries the index of the next available input buffer. * - * It's necessary to use {@link OH_AudioCodec_GetInputBuffer} to get the buffer handle, and then - * use {@link OH_AudioCodec_PushInputBuffer} to pass to the audio codec. - * It's only used in synchronous mode. + * This API must be followed by calling {@link OH_AudioCodec_GetInputBuffer} to obtain the buffer handle, + * which should then be passed to the codec via {@link OH_AudioCodec_PushInputBuffer}.\n + * Note: This operation is only supported in synchronous mode.\n * * @syscap SystemCapability.Multimedia.Media.AudioCodec * @param codec Pointer to an OH_AVCodec instance. - * @param index The index value corresponding to the input buffer. - * @param timeoutUs the query timeout time, in microseconds. + * @param index The index of the input buffer. + * @param timeoutUs Timeout duration in microseconds, negative value indicates infinite wait. * @return Returns AV_ERR_OK if the execution is successful, * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. * {@link AV_ERR_INVALID_VAL}, input parameter is empty or invalid. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. * {@link AV_ERR_OPERATE_NOT_PERMIT}, not permitted in asynchronous mode. - * {@link AV_ERR_TRY_AGAIN_LATER}, query failed,recommended to wait for a while and try the query again. + * {@link AV_ERR_TRY_AGAIN_LATER}, query failed,recommended retry after delay. * @since 20 */ OH_AVErrCode OH_AudioCodec_QueryInputBuffer(struct OH_AVCodec *codec, uint32_t *index, int64_t timeoutUs); /** - * @brief Get the available input buffer handle. + * @brief Acquires the handle of an available input buffer. * - * It's only used in synchronous mode.\n + * Note: It's only applicable in synchronous mode.\n * * @syscap SystemCapability.Multimedia.Media.AudioCodec * @param codec Pointer to an OH_AVCodec instance - * @param index The index value corresponding to the input buffer, - * should be given by {@link OH_AudioCodec_QueryInputBuffer}. + * @param index Buffer index obtained via {@link OH_AudioCodec_QueryInputBuffer}. * @return Returns a Pointer to an OH_AVBuffer instance. - * Return nullptr when no input buffer is available. + * Return nullptr if no buffer available. * @since 20 */ OH_AVBuffer *OH_AudioCodec_GetInputBuffer(struct OH_AVCodec *codec, uint32_t index); /** - * @brief Get index of next available output buffer. + * @brief Queries the index of the next available output buffer. * - * It's necessary to use {@link OH_AudioCodec_GetOutputBuffer} to get the buffer handle, and then - * use {@link OH_AudioCodec_FreeOutputBuffer} to return the buffer to the audio codec.\n - * It's only used in synchronous mode.\n + * The obtained buffer handle through {@link OH_AudioCodec_GetOutputBuffer} must be + * return to the audio codec via {@link OH_AudioCodec_FreeOutputBuffer}.\n * * @syscap SystemCapability.Multimedia.Media.AudioCodec * @param codec Pointer to an OH_AVCodec instance - * @param index The index value corresponding to the output buffer - * @param timeoutUs the query timeout time, in microseconds. + * @param index The index of the output buffer + * @param timeoutUs Timeout duration in microseconds, negative value indicates infinite wait. * @return Returns AV_ERR_OK if the execution is successful, * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. * {@link AV_ERR_INVALID_VAL}, input parameter is empty or invalid. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. * {@link AV_ERR_OPERATE_NOT_PERMIT}, not permitted in asynchronous mode. - * {@link AV_ERR_STREAM_CHANGED}, the stream is changed, call {@link OH_AudioCodec_GetOutputDescription} to - * retrieve steam information. - * {@link AV_ERR_TRY_AGAIN_LATER}, query failed,recommended to wait for a while and try the query again. + * {@link AV_ERR_STREAM_CHANGED}, stream format changed, call {@link OH_AudioCodec_GetOutputDescription} to + * retrieve new steam information. + * {@link AV_ERR_TRY_AGAIN_LATER}, query failed,recommended retry after delay. * @since 20 */ OH_AVErrCode OH_AudioCodec_QueryOutputBuffer(struct OH_AVCodec *codec, uint32_t *index, int64_t timeoutUs); @@ -364,7 +362,8 @@ OH_AVErrCode OH_AudioCodec_QueryOutputBuffer(struct OH_AVCodec *codec, uint32_t * @param codec Pointer to an OH_AVCodec instance * @param index The index value corresponding to the output buffer, * should be given by {@link OH_AudioCodec_QueryOutputBuffer}. - * @return Returns a Pointer to an OH_AVBuffer instance. Return nullptr when no output buffer is available. + * @return Returns a Pointer to an OH_AVBuffer instance. + * Return nullptr if no buffer available. * @since 20 */ OH_AVBuffer *OH_AudioCodec_GetOutputBuffer(struct OH_AVCodec *codec, uint32_t index); diff --git a/multimedia/av_codec/native_avcodec_videodecoder.h b/multimedia/av_codec/native_avcodec_videodecoder.h index ceb39b4a6..e6cc9b166 100644 --- a/multimedia/av_codec/native_avcodec_videodecoder.h +++ b/multimedia/av_codec/native_avcodec_videodecoder.h @@ -474,7 +474,7 @@ OH_AVBuffer *OH_VideoDecoder_GetInputBuffer(struct OH_AVCodec *codec, uint32_t i * @brief Queries the index of the next available output buffer. * * The obtained buffer handle through {@link OH_VideoDecoder_GetOutputBuffer} must be: - * - Released via {@link OH_VideoDecoder_FreeOutputBuffer}, or + * - Return to the decoder via {@link OH_VideoDecoder_FreeOutputBuffer}, or * - Rendered using {@link OH_VideoDecoder_RenderOutputBuffer}, or * - Scheduled for rendering with {@link OH_VideoDecoder_RenderOutputBufferAtTime}\n * Note: This operation is only supported in synchronous mode.\n diff --git a/multimedia/av_codec/native_avcodec_videoencoder.h b/multimedia/av_codec/native_avcodec_videoencoder.h index 15ed5e938..977899eed 100644 --- a/multimedia/av_codec/native_avcodec_videoencoder.h +++ b/multimedia/av_codec/native_avcodec_videoencoder.h @@ -491,7 +491,7 @@ OH_AVBuffer *OH_VideoEncoder_GetInputBuffer(struct OH_AVCodec *codec, uint32_t i * @brief Queries the index of the next available output buffer. * * The obtained buffer handle through {@link OH_VideoEncoder_GetOutputBuffer} must be - * released via {@link OH_VideoEncoder_FreeOutputBuffer}.\n + * return to the encoder via {@link OH_VideoEncoder_FreeOutputBuffer}.\n * Note: This operation is only supported in synchronous mode.\n * * @syscap SystemCapability.Multimedia.Media.VideoEncoder -- Gitee From f1ba9e2cb0cd5d21000db6f9192c0942f7bfd661 Mon Sep 17 00:00:00 2001 From: zhanghongran Date: Tue, 10 Jun 2025 11:59:12 +0800 Subject: [PATCH 18/29] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhanghongran --- multimedia/av_codec/native_avcodec_audiocodec.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/multimedia/av_codec/native_avcodec_audiocodec.h b/multimedia/av_codec/native_avcodec_audiocodec.h index 86fde9470..35be37a7d 100644 --- a/multimedia/av_codec/native_avcodec_audiocodec.h +++ b/multimedia/av_codec/native_avcodec_audiocodec.h @@ -336,6 +336,7 @@ OH_AVBuffer *OH_AudioCodec_GetInputBuffer(struct OH_AVCodec *codec, uint32_t ind * * The obtained buffer handle through {@link OH_AudioCodec_GetOutputBuffer} must be * return to the audio codec via {@link OH_AudioCodec_FreeOutputBuffer}.\n + * Note: This operation is only supported in synchronous mode.\n * * @syscap SystemCapability.Multimedia.Media.AudioCodec * @param codec Pointer to an OH_AVCodec instance @@ -356,7 +357,7 @@ OH_AVErrCode OH_AudioCodec_QueryOutputBuffer(struct OH_AVCodec *codec, uint32_t /** * @brief Get the available output buffer handle. * - * It's only used in synchronous mode. + * Note: This operation is only supported in synchronous mode.\n * * @syscap SystemCapability.Multimedia.Media.AudioCodec * @param codec Pointer to an OH_AVCodec instance -- Gitee From 48e76c15bdb1ca1be69c14f7628fca1301f3c081 Mon Sep 17 00:00:00 2001 From: zhanghongran Date: Tue, 10 Jun 2025 12:20:04 +0800 Subject: [PATCH 19/29] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhanghongran --- multimedia/av_codec/native_avcodec_base.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/multimedia/av_codec/native_avcodec_base.h b/multimedia/av_codec/native_avcodec_base.h index 762b63980..a503ec1f3 100644 --- a/multimedia/av_codec/native_avcodec_base.h +++ b/multimedia/av_codec/native_avcodec_base.h @@ -1116,11 +1116,13 @@ extern const char *OH_MD_KEY_VIDEO_ENCODER_ROI_PARAMS; extern const char *OH_MD_KEY_ENABLE_MOOV_FRONT; /** - * @brief Key to enable synchronous mode, value type is (0 or 1):1 is enabled, 0 otherwise. + * @brief Key to enable synchronous mode, value type is (0 or 1): 1 is enabled, 0 otherwise. * * This is an optional key, default is 0.\n - * If enabled, the caller should not set callbacks for the decoder or encoder but should query buffers instead.\n - * It is used in configure.\n + * When enabled: + * - Callbacks should NOT be set for codecs + * - Buffer query APIs must be used instead + * - Must be set during configuration phase * * @syscap SystemCapability.Multimedia.Media.CodecBase * @since 20 -- Gitee From 13e5239872666d8f90db6c8b1b723791a86ff1d8 Mon Sep 17 00:00:00 2001 From: zhanghongran Date: Tue, 10 Jun 2025 12:34:07 +0800 Subject: [PATCH 20/29] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhanghongran --- multimedia/media_foundation/native_avformat.h | 38 ++++++++++++------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/multimedia/media_foundation/native_avformat.h b/multimedia/media_foundation/native_avformat.h index a1e313320..652be149c 100644 --- a/multimedia/media_foundation/native_avformat.h +++ b/multimedia/media_foundation/native_avformat.h @@ -327,32 +327,44 @@ bool OH_AVFormat_GetBuffer(struct OH_AVFormat *format, const char *key, uint8_t const char *OH_AVFormat_DumpInfo(struct OH_AVFormat *format); /** - * @brief Write a list of int32_t data of a specified length to OH_AVFormat. + * @brief Write an array of int32_t values to an OH_AVFormat object. * * @syscap SystemCapability.Multimedia.Media.Core * @param format pointer to an OH_AVFormat instance - * @param key key to write data - * @param addr written data addr - * @param size written data length + * @param key Data identifier key + * @param addr Pointer to the source data buffer + * @param size Number of elements to write (in elements, not bytes) * @return The return value is TRUE for success, FALSE for failure - * Possible failure causes: 1. input format is nullptr. 2. input format's magic error. 3. key is nullptr. - * 4. addr is nullptr. 5. size is zero. + * Possible failure causes: + * 1. input format is nullptr. + * 2. input format's magic error. + * 3. key is nullptr. + * 4. addr is nullptr. + * 5. size is zero. * @since 20 */ bool OH_AVFormat_SetIntBuffer(struct OH_AVFormat *format, const char *key, const int32_t *addr, size_t size); /** - * @brief Read a list of int32_t data of specified length from OH_AVFormat. + * @brief Read an array of int32_t values from an OH_AVFormat object. + * + * Note that the obtained buffer's lifetime bound to the OH_AVFormat object, + * it's automatically invalidated when the format object is destroyed.\n + * Applications must explicitly copy the data to newly allocated memory if + * the data needs to outlive the OH_AVFormat instance.\n * * @syscap SystemCapability.Multimedia.Media.Core * @param format pointer to an OH_AVFormat instance - * @param key Key value for reading and writing data - * @param addr The life cycle is held by the format, with the destruction of the format, - * if the caller needs to hold it for a long time, it must copy the memory - * @param size Length of read and write data + * @param key Data identifier key + * @param addr Pointer to receive the data buffer reference + * @param size Pointer to receive the element count * @return The return value is TRUE for success, FALSE for failure - * Possible failure causes: 1. input format is nullptr. 2. input format's magic error. 3. key is nullptr. - * 4. addr is nullptr. 5. size is nullptr. + * Possible failure causes: + * 1. input format is nullptr. + * 2. input format's magic error. + * 3. key is nullptr. + * 4. addr is nullptr. + * 5. size is nullptr. * @since 20 */ bool OH_AVFormat_GetIntBuffer(struct OH_AVFormat *format, const char *key, int32_t **addr, size_t *size); -- Gitee From b6fd71b34ba6eb5cb782f37be71aa4ee1f73541e Mon Sep 17 00:00:00 2001 From: zhanghongran Date: Tue, 10 Jun 2025 14:54:50 +0800 Subject: [PATCH 21/29] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=B9=B6=E5=AE=8C=E5=96=84=E6=B3=A8=E9=87=8A:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhanghongran --- multimedia/av_codec/native_avcodec_base.h | 26 ++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/multimedia/av_codec/native_avcodec_base.h b/multimedia/av_codec/native_avcodec_base.h index a503ec1f3..d558f9342 100644 --- a/multimedia/av_codec/native_avcodec_base.h +++ b/multimedia/av_codec/native_avcodec_base.h @@ -1056,13 +1056,33 @@ extern const char *OH_MD_KEY_TRACK_DESCRIPTION; /** * @brief Key to enable B-frame encoding, value type is int32_t (0 or 1):1 is enabled, 0 otherwise. * - * This is an optional key that applies only to video encoder, default is 0. - * If enabled, the video encoder will use B-frames, the decode order will be different from the display order. - * It is used in configure. + * This is an optional key that applies only to video encoder, default is 0.\n + * If enabled, the video encoder will use B-frame, the decode order will be different from the display order.\n + * For unsupported platforms, Configuring this key will have no effect.\n + * Platform capability can be checked via {@link OH_AVCapability_IsFeatureSupported} with + * {@link OH_AVCapabilityFeature::VIDEO_ENCODER_B_FRAME}.\n + * + * Must be set during configuration phase.\n + * * @syscap SystemCapability.Multimedia.Media.CodecBase * @since 20 */ extern const char *OH_MD_KEY_VIDEO_ENCODER_ENABLE_B_FRAME; + +/** + * @brief Key for describing the maximum B-frame count of video encoder, value type is int32_t. + * + * Note: This key is only for querying the capability of the codec currently. + * Usage specifications: + * Check feature support via {@link OH_AVCapability_GetFeatureProperties} with + * {@link OH_AVCapabilityFeature::VIDEO_ENCODER_B_FRAME}. + * If supported, query max B-frame count through AVFormat handle + * + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @since 20 +*/ +extern const char *OH_MD_KEY_VIDEO_ENCODER_MAX_B_FRAMES; + /** * @brief Key for the desired encoding quality, value type is int32_t, this key is only * supported for encoders that are configured in Stable Quality RateControl, the higher -- Gitee From a0b9973013bd7863906d885a4d96beb64be96b52 Mon Sep 17 00:00:00 2001 From: zhanghongran Date: Tue, 10 Jun 2025 14:56:40 +0800 Subject: [PATCH 22/29] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhanghongran --- multimedia/av_codec/native_avcodec_base.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/multimedia/av_codec/native_avcodec_base.h b/multimedia/av_codec/native_avcodec_base.h index d558f9342..ebb17993b 100644 --- a/multimedia/av_codec/native_avcodec_base.h +++ b/multimedia/av_codec/native_avcodec_base.h @@ -1054,7 +1054,7 @@ extern const char *OH_MD_KEY_TRACK_REFERENCE_TYPE; */ extern const char *OH_MD_KEY_TRACK_DESCRIPTION; /** - * @brief Key to enable B-frame encoding, value type is int32_t (0 or 1):1 is enabled, 0 otherwise. + * @brief Key to enable B-frame encoding, value type is int32_t (0 or 1): 1 is enabled, 0 otherwise. * * This is an optional key that applies only to video encoder, default is 0.\n * If enabled, the video encoder will use B-frame, the decode order will be different from the display order.\n -- Gitee From cc2f6e451e78f79ef47d60fd4bd4c0d7139ebcf2 Mon Sep 17 00:00:00 2001 From: zhanghongran Date: Tue, 10 Jun 2025 14:58:01 +0800 Subject: [PATCH 23/29] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhanghongran --- multimedia/media_foundation/native_averrors.h | 1 - 1 file changed, 1 deletion(-) diff --git a/multimedia/media_foundation/native_averrors.h b/multimedia/media_foundation/native_averrors.h index e22609842..93b6704f7 100644 --- a/multimedia/media_foundation/native_averrors.h +++ b/multimedia/media_foundation/native_averrors.h @@ -185,7 +185,6 @@ typedef enum OH_AVErrCode { * Required follow-up actions: * - For video encoders: Call {@link OH_VideoEncoder_GetOutputDescription} * - For video decoders: Call {@link OH_VideoDecoder_GetOutputDescription} - * - For audio encoders : Call {@link OH_AudioCodec_GetOutputDescription} * - For audio decoders : Call {@link OH_AudioCodec_GetOutputDescription} * to retrieve updated stream configuration. * @since 20 -- Gitee From c49a36e0e53ee05596f5352bb10453b262b0dad8 Mon Sep 17 00:00:00 2001 From: zhanghongran Date: Tue, 10 Jun 2025 15:03:39 +0800 Subject: [PATCH 24/29] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhanghongran --- multimedia/av_codec/native_avcodec_base.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/multimedia/av_codec/native_avcodec_base.h b/multimedia/av_codec/native_avcodec_base.h index ebb17993b..bcc4fad57 100644 --- a/multimedia/av_codec/native_avcodec_base.h +++ b/multimedia/av_codec/native_avcodec_base.h @@ -1061,7 +1061,6 @@ extern const char *OH_MD_KEY_TRACK_DESCRIPTION; * For unsupported platforms, Configuring this key will have no effect.\n * Platform capability can be checked via {@link OH_AVCapability_IsFeatureSupported} with * {@link OH_AVCapabilityFeature::VIDEO_ENCODER_B_FRAME}.\n - * * Must be set during configuration phase.\n * * @syscap SystemCapability.Multimedia.Media.CodecBase @@ -1074,9 +1073,11 @@ extern const char *OH_MD_KEY_VIDEO_ENCODER_ENABLE_B_FRAME; * * Note: This key is only for querying the capability of the codec currently. * Usage specifications: - * Check feature support via {@link OH_AVCapability_GetFeatureProperties} with - * {@link OH_AVCapabilityFeature::VIDEO_ENCODER_B_FRAME}. - * If supported, query max B-frame count through AVFormat handle + * 1. Check feature support via {@link OH_AVCapability_IsFeatureSupported} with + * {@link OH_AVCapabilityFeature::VIDEO_ENCODER_B_FRAME}.\n + * 2. Obtain AVFormat handle via {@link OH_AVCapability_GetFeatureProperties} with + * {@link OH_AVCapabilityFeature::VIDEO_ENCODER_B_FRAME}.\n + * 3. Get maximum B-frame count via {@link OH_AVFormat_GetIntValue} with this key.\n * * @syscap SystemCapability.Multimedia.Media.CodecBase * @since 20 -- Gitee From fefc094bb3238ce4d8b7b6cb99a4b29ae34a7e6b Mon Sep 17 00:00:00 2001 From: zhanghongran Date: Tue, 10 Jun 2025 15:05:09 +0800 Subject: [PATCH 25/29] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhanghongran --- multimedia/av_codec/native_avcodec_base.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/multimedia/av_codec/native_avcodec_base.h b/multimedia/av_codec/native_avcodec_base.h index bcc4fad57..0c47e8e78 100644 --- a/multimedia/av_codec/native_avcodec_base.h +++ b/multimedia/av_codec/native_avcodec_base.h @@ -1075,7 +1075,7 @@ extern const char *OH_MD_KEY_VIDEO_ENCODER_ENABLE_B_FRAME; * Usage specifications: * 1. Check feature support via {@link OH_AVCapability_IsFeatureSupported} with * {@link OH_AVCapabilityFeature::VIDEO_ENCODER_B_FRAME}.\n - * 2. Obtain AVFormat handle via {@link OH_AVCapability_GetFeatureProperties} with + * 2. Obtain OH_AVFormat handle via {@link OH_AVCapability_GetFeatureProperties} with * {@link OH_AVCapabilityFeature::VIDEO_ENCODER_B_FRAME}.\n * 3. Get maximum B-frame count via {@link OH_AVFormat_GetIntValue} with this key.\n * -- Gitee From 6634d89e269eb3f296747048841d3fee81adb742 Mon Sep 17 00:00:00 2001 From: zhanghongran Date: Tue, 10 Jun 2025 15:08:27 +0800 Subject: [PATCH 26/29] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhanghongran --- multimedia/av_codec/native_avcodec_base.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/multimedia/av_codec/native_avcodec_base.h b/multimedia/av_codec/native_avcodec_base.h index 0c47e8e78..53d04c9f9 100644 --- a/multimedia/av_codec/native_avcodec_base.h +++ b/multimedia/av_codec/native_avcodec_base.h @@ -1061,7 +1061,7 @@ extern const char *OH_MD_KEY_TRACK_DESCRIPTION; * For unsupported platforms, Configuring this key will have no effect.\n * Platform capability can be checked via {@link OH_AVCapability_IsFeatureSupported} with * {@link OH_AVCapabilityFeature::VIDEO_ENCODER_B_FRAME}.\n - * Must be set during configuration phase.\n + * It's only used in configuration phase.\n * * @syscap SystemCapability.Multimedia.Media.CodecBase * @since 20 @@ -1143,7 +1143,7 @@ extern const char *OH_MD_KEY_ENABLE_MOOV_FRONT; * When enabled: * - Callbacks should NOT be set for codecs * - Buffer query APIs must be used instead - * - Must be set during configuration phase + * - Only used in configuration phase * * @syscap SystemCapability.Multimedia.Media.CodecBase * @since 20 -- Gitee From dacf65ae0ac0865165fec258ce24260d5d276297 Mon Sep 17 00:00:00 2001 From: zhanghongran Date: Tue, 10 Jun 2025 15:52:01 +0800 Subject: [PATCH 27/29] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhanghongran --- multimedia/av_codec/native_avcodec_audiocodec.h | 4 ++-- multimedia/av_codec/native_avcodec_videodecoder.h | 8 ++++---- multimedia/av_codec/native_avcodec_videoencoder.h | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/multimedia/av_codec/native_avcodec_audiocodec.h b/multimedia/av_codec/native_avcodec_audiocodec.h index 35be37a7d..edf5861d5 100644 --- a/multimedia/av_codec/native_avcodec_audiocodec.h +++ b/multimedia/av_codec/native_avcodec_audiocodec.h @@ -312,7 +312,7 @@ OH_AVErrCode OH_AudioCodec_SetDecryptionConfig(OH_AVCodec *codec, MediaKeySessio * {@link AV_ERR_INVALID_VAL}, input parameter is empty or invalid. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. * {@link AV_ERR_OPERATE_NOT_PERMIT}, not permitted in asynchronous mode. - * {@link AV_ERR_TRY_AGAIN_LATER}, query failed,recommended retry after delay. + * {@link AV_ERR_TRY_AGAIN_LATER}, query failed, recommended retry after delay. * @since 20 */ OH_AVErrCode OH_AudioCodec_QueryInputBuffer(struct OH_AVCodec *codec, uint32_t *index, int64_t timeoutUs); @@ -349,7 +349,7 @@ OH_AVBuffer *OH_AudioCodec_GetInputBuffer(struct OH_AVCodec *codec, uint32_t ind * {@link AV_ERR_OPERATE_NOT_PERMIT}, not permitted in asynchronous mode. * {@link AV_ERR_STREAM_CHANGED}, stream format changed, call {@link OH_AudioCodec_GetOutputDescription} to * retrieve new steam information. - * {@link AV_ERR_TRY_AGAIN_LATER}, query failed,recommended retry after delay. + * {@link AV_ERR_TRY_AGAIN_LATER}, query failed, recommended retry after delay. * @since 20 */ OH_AVErrCode OH_AudioCodec_QueryOutputBuffer(struct OH_AVCodec *codec, uint32_t *index, int64_t timeoutUs); diff --git a/multimedia/av_codec/native_avcodec_videodecoder.h b/multimedia/av_codec/native_avcodec_videodecoder.h index e6cc9b166..7169203ea 100644 --- a/multimedia/av_codec/native_avcodec_videodecoder.h +++ b/multimedia/av_codec/native_avcodec_videodecoder.h @@ -435,13 +435,13 @@ OH_AVErrCode OH_VideoDecoder_FreeOutputBuffer(OH_AVCodec *codec, uint32_t index) /** * @brief Queries the index of the next available input buffer. * - * This API must be followed by calling {@link OH_VideoDecoder_GetInputBuffer} to obtain the buffer handle, + * This API must be followed by calling {@link OH_VideoDecoder_GetInputBuffer} to obtain the buffer handle, * which should then be passed to the decoder via {@link OH_VideoDecoder_PushInputBuffer}.\n * Note: This operation is only supported in synchronous mode.\n * * @syscap SystemCapability.Multimedia.Media.VideoDecoder * @param codec Pointer to an OH_AVCodec instance. - * @param index The index value corresponding to the input buffer. + * @param index The index of the input buffer. * @param timeoutUs Timeout duration in microseconds, negative value indicates infinite wait. * @return Returns AV_ERR_OK if the execution is successful, * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. @@ -451,7 +451,7 @@ OH_AVErrCode OH_VideoDecoder_FreeOutputBuffer(OH_AVCodec *codec, uint32_t index) * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. * {@link AV_ERR_OPERATE_NOT_PERMIT}, not permitted in asynchronous mode. - * {@link AV_ERR_TRY_AGAIN_LATER}, query failed,recommended retry after delay. + * {@link AV_ERR_TRY_AGAIN_LATER}, query failed, recommended retry after delay. * @since 20 */ OH_AVErrCode OH_VideoDecoder_QueryInputBuffer(struct OH_AVCodec *codec, uint32_t *index, int64_t timeoutUs); @@ -493,7 +493,7 @@ OH_AVBuffer *OH_VideoDecoder_GetInputBuffer(struct OH_AVCodec *codec, uint32_t i * {@link AV_ERR_OPERATE_NOT_PERMIT}, not permitted in asynchronous mode. * {@link AV_ERR_STREAM_CHANGED}, stream format changed, call {@link OH_VideoDecoder_GetOutputDescription} to * retrieve new steam information. - * {@link AV_ERR_TRY_AGAIN_LATER}, query failed,recommended retry after delay. + * {@link AV_ERR_TRY_AGAIN_LATER}, query failed, recommended retry after delay. * @since 20 */ OH_AVErrCode OH_VideoDecoder_QueryOutputBuffer(struct OH_AVCodec *codec, uint32_t *index, int64_t timeoutUs); diff --git a/multimedia/av_codec/native_avcodec_videoencoder.h b/multimedia/av_codec/native_avcodec_videoencoder.h index 977899eed..fcc35b41d 100644 --- a/multimedia/av_codec/native_avcodec_videoencoder.h +++ b/multimedia/av_codec/native_avcodec_videoencoder.h @@ -429,7 +429,7 @@ OH_AVErrCode OH_VideoEncoder_FreeOutputBuffer(OH_AVCodec *codec, uint32_t index) * {@link AV_ERR_OPERATE_NOT_PERMIT}, not permitted in asynchronous mode. * {@link AV_ERR_STREAM_CHANGED}, the stream is changed, call {@link OH_VideoEncoder_GetOutputDescription} to * retrieve steam information. - * {@link AV_ERR_TRY_AGAIN_LATER}, query failed,recommended to wait for a while and try the query again. + * {@link AV_ERR_TRY_AGAIN_LATER}, query failed, recommended to wait for a while and try the query again. * @since 20 */ OH_AVErrCode OH_VideoEncoder_QueryInputParameter(struct OH_AVCodec *codec, uint32_t *index, int64_t timeoutUs); @@ -468,7 +468,7 @@ OH_AVFormat *OH_VideoEncoder_GetInputParameter(struct OH_AVCodec *codec, uint32_ * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. * {@link AV_ERR_OPERATE_NOT_PERMIT}, not permitted in asynchronous mode. - * {@link AV_ERR_TRY_AGAIN_LATER}, query failed,recommended retry after delay.. + * {@link AV_ERR_TRY_AGAIN_LATER}, query failed, recommended retry after delay.. * @since 20 */ OH_AVErrCode OH_VideoEncoder_QueryInputBuffer(struct OH_AVCodec *codec, uint32_t *index, int64_t timeoutUs); @@ -508,7 +508,7 @@ OH_AVBuffer *OH_VideoEncoder_GetInputBuffer(struct OH_AVCodec *codec, uint32_t i * {@link AV_ERR_OPERATE_NOT_PERMIT}, not permitted in asynchronous mode. * {@link AV_ERR_STREAM_CHANGED}, stream format changed, call {@link OH_VideoEncoder_GetOutputDescription} to * retrieve new steam information. - * {@link AV_ERR_TRY_AGAIN_LATER}, query failed,recommended retry after delay. + * {@link AV_ERR_TRY_AGAIN_LATER}, query failed, recommended retry after delay. * @since 20 */ OH_AVErrCode OH_VideoEncoder_QueryOutputBuffer(struct OH_AVCodec *codec, uint32_t *index, int64_t timeoutUs); -- Gitee From 87e660cfa6d360022bc7f1e2dd1dc278e33a2afd Mon Sep 17 00:00:00 2001 From: zhanghongran Date: Tue, 10 Jun 2025 16:01:50 +0800 Subject: [PATCH 28/29] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhanghongran --- multimedia/av_codec/native_avcodec_videoencoder.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/multimedia/av_codec/native_avcodec_videoencoder.h b/multimedia/av_codec/native_avcodec_videoencoder.h index fcc35b41d..50ff9785b 100644 --- a/multimedia/av_codec/native_avcodec_videoencoder.h +++ b/multimedia/av_codec/native_avcodec_videoencoder.h @@ -497,7 +497,7 @@ OH_AVBuffer *OH_VideoEncoder_GetInputBuffer(struct OH_AVCodec *codec, uint32_t i * @syscap SystemCapability.Multimedia.Media.VideoEncoder * @param codec Pointer to an OH_AVCodec instance * @param index The index value corresponding to the output buffer - * @param timeoutUs the query timeout time, in microseconds. + * @param timeoutUs Timeout duration in microseconds, negative value indicates infinite wait. * @return Returns AV_ERR_OK if the execution is successful, * otherwise returns a specific error code, refer to {@link OH_AVErrCode}. * {@link AV_ERR_NO_MEMORY}, internal errors in the input encode instance, such as an abnormal NULL. -- Gitee From e4d47fa8670fe49a8f2c5689224a26c9559b5a69 Mon Sep 17 00:00:00 2001 From: zhanghongran Date: Tue, 10 Jun 2025 16:21:45 +0800 Subject: [PATCH 29/29] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhanghongran --- multimedia/av_codec/native_avcodec_audiocodec.h | 2 +- multimedia/av_codec/native_avcodec_videoencoder.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/multimedia/av_codec/native_avcodec_audiocodec.h b/multimedia/av_codec/native_avcodec_audiocodec.h index edf5861d5..bbd90ec7d 100644 --- a/multimedia/av_codec/native_avcodec_audiocodec.h +++ b/multimedia/av_codec/native_avcodec_audiocodec.h @@ -299,7 +299,7 @@ OH_AVErrCode OH_AudioCodec_SetDecryptionConfig(OH_AVCodec *codec, MediaKeySessio /** * @brief Queries the index of the next available input buffer. * - * This API must be followed by calling {@link OH_AudioCodec_GetInputBuffer} to obtain the buffer handle, + * This API must be followed by calling {@link OH_AudioCodec_GetInputBuffer} to obtain the buffer handle, * which should then be passed to the codec via {@link OH_AudioCodec_PushInputBuffer}.\n * Note: This operation is only supported in synchronous mode.\n * diff --git a/multimedia/av_codec/native_avcodec_videoencoder.h b/multimedia/av_codec/native_avcodec_videoencoder.h index 50ff9785b..a2c092f37 100644 --- a/multimedia/av_codec/native_avcodec_videoencoder.h +++ b/multimedia/av_codec/native_avcodec_videoencoder.h @@ -452,7 +452,7 @@ OH_AVFormat *OH_VideoEncoder_GetInputParameter(struct OH_AVCodec *codec, uint32_ /** * @brief Queries the index of the next available input buffer. * - * This API must be followed by calling {@link OH_VideoEncoder_GetInputBuffer} to obtain the buffer handle, + * This API must be followed by calling {@link OH_VideoEncoder_GetInputBuffer} to obtain the buffer handle, * which should then be passed to the encoder via {@link OH_VideoEncoder_PushInputBuffer}.\n * Note: This operation is only supported in synchronous mode.\n * -- Gitee