diff --git a/multimedia/av_codec/native_avcodec_videoencoder.h b/multimedia/av_codec/native_avcodec_videoencoder.h index a0ccb13b6d782a5ea7520a9bc64f7d5d24a346af..24f16ddd39d8d4db28e4f015fa342166160534c8 100644 --- a/multimedia/av_codec/native_avcodec_videoencoder.h +++ b/multimedia/av_codec/native_avcodec_videoencoder.h @@ -46,68 +46,70 @@ extern "C" { #endif /** - * @brief When OH_AVCodec needs new input parameter during the running process, the function pointer will be called and - * carry an available OH_AVFormat to fill in the new input parameter. This parameter takes effect immediately with the - * frame. - * + * @brief Configure frame parameters. This interface can be used to set the encode parameters + * of the frame corresponding to the index, take effect only in Surface mode. + * It is nedd to call {@link OH_VideoEncoder_RegisterParametercallbacks} interface to register bedfore use. + * In Buffer mode, OH_AVBuffer can directly carry the encoding parameters of frames. + * Currently, frame level QPMin/QPMax parameters are supported, and specify LTR to set the reference frame. * @syscap SystemCapability.Multimedia.Media.VideoEncoder * @param codec OH_AVCodec instance - * @param index The index corresponding to the new OH_AVFormat instance - * @param parameter Parameter containing the new OH_AVFormat instance - * @param userData specified data + * @param index The index corresponding to the encode frame + * @param parameter Encode parameter + * @param userData The data that the user rely on to execute the callback * @since 12 */ typedef void (*OH_VideoEncoder_OnNeedInputParameter)(OH_AVCodec *codec, uint32_t index, OH_AVFormat *parameter, void *userData); /** - * @brief Creates a video encoder instance from the mime type, which is recommended in most cases. + * @brief Creates a video encoder instance from the mime type, it is recommended to use. * @syscap SystemCapability.Multimedia.Media.VideoEncoder * @param mime mime type description string, refer to {@link AVCODEC_MIME_TYPE} * @return Returns a Pointer to an OH_AVCodec instance. - * Return nullptr if memory ran out or the mime type is not supported. + * Return NULL if memory ran out or the mime type is not supported. * @since 9 */ OH_AVCodec *OH_VideoEncoder_CreateByMime(const char *mime); /** - * @brief Create a video encoder instance through the video encoder name. The premise of using this interface is to - * know the exact name of the encoder. + * @brief Create a video encoder instance through the video encoder name. The premise of using this interface is + * to know the exact name of the encoder. The encoder name can be obtained through capability query. * @syscap SystemCapability.Multimedia.Media.VideoEncoder * @param name Video encoder name * @return Returns a Pointer to an OH_AVCodec instance. - * Return nullptr if memory ran out or the encoder name is not supported. + * Return NULL if memory ran out or the encoder name is not supported. * @since 9 */ OH_AVCodec *OH_VideoEncoder_CreateByName(const char *name); /** - * @brief Clear the internal resources of the encoder and destroy the encoder instance + * @brief Clear the internal resources of the encoder and destroy the encoder instance. + * Can not be destoryed repeatedly. * @syscap SystemCapability.Multimedia.Media.VideoEncoder * @param codec Pointer to an OH_AVCodec instance * @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}, inner resource has already released. - * {@link AV_ERR_INVALID_VAL}, the encoder is nullptr or invalid. + * {@link AV_ERR_NO_MEMORY}, internal errors in the input encode instance, such as an abnormal NULL. + * {@link AV_ERR_INVALID_VAL}, the input codec pointer is non encoder instance or NULL. * {@link AV_ERR_UNKNOWN}, unknown error. - * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. + * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error. * @since 9 */ OH_AVErrCode OH_VideoEncoder_Destroy(OH_AVCodec *codec); /** - * @brief Set the asynchronous callback function so that your application can respond to the events generated by the - * video encoder. This interface must be called before Prepare is called. + * @brief Set the OH_AVCodecCallback callback function so that the application can respond to the events + * generated by the video encoder. This interface must be called before Prepare is called. * @syscap SystemCapability.Multimedia.Media.VideoEncoder * @param codec Pointer to an OH_AVCodec instance * @param callback A collection of all callback functions, see {@link OH_AVCodecAsyncCallback} - * @param userData User specific data + * @param userData The data that the user rely on to execute the callback * @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}, inner resource has already released. - * {@link AV_ERR_INVALID_VAL}, the encoder is nullptr or invalid. + * {@link AV_ERR_NO_MEMORY}, internal errors in the input encode instance, such as an abnormal NULL. + * {@link AV_ERR_INVALID_VAL}, the input codec pointer is non encoder instance or NULL. * {@link AV_ERR_UNKNOWN}, unknown error. - * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. + * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state, must be called before Prepare. * @deprecated since 11 * @useinstead OH_VideoEncoder_RegisterCallback @@ -116,38 +118,38 @@ OH_AVErrCode OH_VideoEncoder_Destroy(OH_AVCodec *codec); OH_AVErrCode OH_VideoEncoder_SetCallback(OH_AVCodec *codec, OH_AVCodecAsyncCallback callback, void *userData); /** - * @brief Set the asynchronous callback function so that your application can respond to the events generated by the - * video encoder. This interface must be called before Prepare is called. + * @brief Set the OH_AVCodecCallback callback function so that the application can respond to the events + * generated by the video encoder. This interface must be called before Prepare is called. * @syscap SystemCapability.Multimedia.Media.VideoEncoder * @param codec Pointer to an OH_AVCodec instance * @param callback A collection of all callback functions, see {@link OH_AVCodecCallback} - * @param userData User specific data + * @param userData The data that the user rely on to execute the callback * @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}, inner resource has already released. - * {@link AV_ERR_INVALID_VAL}, the encoder is nullptr or invalid. + * {@link AV_ERR_NO_MEMORY}, internal errors in the input encode instance, such as an abnormal NULL. + * {@link AV_ERR_INVALID_VAL}, the input codec pointer is non encoder instance or NULL. * {@link AV_ERR_UNKNOWN}, unknown error. - * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. + * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state, must be called before Prepare. * @since 11 */ OH_AVErrCode OH_VideoEncoder_RegisterCallback(OH_AVCodec *codec, OH_AVCodecCallback callback, void *userData); /** - * @brief Set the asynchronous callback function so that your application can respond to the events generated by the - * video encoder. This interface is optional only for input surface. If this interface is used, it must be invoked - * before {@link OH_VideoEncoder_Configure}. + * @brief Set the OH_AVCodecCallback callback function so that the application can respond to the events generated + * by the video encoder. In encode Surface mode, this interface is used to set frame-specific parameters. + * If this interface is used, it must be invoked before {@link OH_VideoEncoder_Configure}. * * @syscap SystemCapability.Multimedia.Media.VideoEncoder * @param codec Pointer to an OH_AVCodec instance * @param onInputParameter A callback functions, see {@link OH_VideoEncoder_OnNeedInputParameter} - * @param userData User specific data + * @param userData The data that the user rely on to execute the callback * @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}, inner resource has already released. - * {@link AV_ERR_INVALID_VAL}, the encoder is nullptr or invalid. + * {@link AV_ERR_NO_MEMORY}, internal errors in the input encode instance, such as an abnormal NULL. + * {@link AV_ERR_INVALID_VAL}, the input codec pointer is non encoder instance or NULL. * {@link AV_ERR_UNKNOWN}, unknown error. - * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. + * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state, must be called before Prepare. * @since 12 */ @@ -156,160 +158,164 @@ OH_AVErrCode OH_VideoEncoder_RegisterParameterCallback(OH_AVCodec *codec, void *userData); /** - * @brief To configure the video encoder, typically, you need to configure the description information of the - * encoded video track. This interface must be called before Prepare is called. + * @brief To configure the encode parameters of video encoder, typically, you need to configure + * the description information of the encoded video track, such as the width, height, and pixel format. + * This interface must be called before Prepare is called. * @syscap SystemCapability.Multimedia.Media.VideoEncoder * @param codec Pointer to an OH_AVCodec instance * @param format A pointer to an OH_AVFormat that gives the description of the video track to be encoded * @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}, instance has already released. - * {@link AV_ERR_INVALID_VAL}, the encoder is nullptr or invalid. Invalid param in format. + * {@link AV_ERR_NO_MEMORY}, internal errors in the input encode instance, such as an abnormal NULL. + * {@link AV_ERR_INVALID_VAL} + * 1. the input codec pointer is non encoder instance or NULL; + * 2. unsupported input format parameters. * {@link AV_ERR_UNKNOWN}, unknown error. - * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. + * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state, must be called before Prepare. * @since 9 */ OH_AVErrCode OH_VideoEncoder_Configure(OH_AVCodec *codec, OH_AVFormat *format); /** - * @brief To prepare the internal resources of the encoder, the Configure interface must be called before + * @brief Prepare the internal resources of the encoder.The Configure interface must be called before * calling this interface. * @syscap SystemCapability.Multimedia.Media.VideoEncoder * @param codec Pointer to an OH_AVCodec instance * @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}, instance has already released. - * {@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_INVALID_VAL}, the input codec pointer is non encoder instance or NULL. + * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error. * @since 9 */ OH_AVErrCode OH_VideoEncoder_Prepare(OH_AVCodec *codec); /** * @brief Start the encoder, this interface must be called after the Prepare is successful. After being - * successfully started, the encoder will start reporting NeedInputData events. + * successfully started, the encoder will start reporting NeedInputData events. In Surface mode, OnNewOutputBuffer + * will be triggered for each completed frame encoding after a correct input is received on the surface. + * In Buffer mode, the encoder trigger an input callback immediately. Each time the caller completes an input, + * the encoder performs encoding, OnNewOutputBuffer will be triggered for each completed frame encoding. * @syscap SystemCapability.Multimedia.Media.VideoEncoder * @param codec Pointer to an OH_AVCodec instance * @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}, instance has already released. - * {@link AV_ERR_INVALID_VAL}, the encoder is nullptr or invalid. + * {@link AV_ERR_NO_MEMORY}, internal errors in the input encode instance, such as an abnormal NULL. + * {@link AV_ERR_INVALID_VAL}, the input codec pointer is non encoder instance or NULL. * {@link AV_ERR_UNKNOWN}, unknown error. - * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. + * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. * @since 9 */ OH_AVErrCode OH_VideoEncoder_Start(OH_AVCodec *codec); /** - * @brief Stop the encoder. After stopping, you can re-enter the Started state through Start. + * @brief Stop the encoder and release the input and output buffer. After stopping, + * you can re-enter the Running state through Start. * @syscap SystemCapability.Multimedia.Media.VideoEncoder * @param codec Pointer to an OH_AVCodec instance * @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}, instance has already released. - * {@link AV_ERR_INVALID_VAL}, the encoder is nullptr or invalid. + * {@link AV_ERR_NO_MEMORY}, internal errors in the input encode instance, such as an abnormal NULL. + * {@link AV_ERR_INVALID_VAL}, the input codec pointer is non encoder instance or NULL. * {@link AV_ERR_UNKNOWN}, unknown error. - * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. + * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. * @since 9 */ OH_AVErrCode OH_VideoEncoder_Stop(OH_AVCodec *codec); /** - * @brief Clear the input and output data buffered in the encoder. After this interface is called, all the Buffer - * indexes previously reported through the asynchronous callback will be invalidated, make sure not to access the - * Buffers corresponding to these indexes. + * @brief Clear the input and output data buffered and parameters in the encoder, for example, PPS/SPS in H264 format. + * After this interface is called, all the buffer indexes previously reported through the asynchronous callback + * will be invalidated, make sure not to access the buffers corresponding to these indexes. + * This interface cannot be called continuously. * @syscap SystemCapability.Multimedia.Media.VideoEncoder * @param codec Pointer to an OH_AVCodec instance * @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}, instance has already released. - * {@link AV_ERR_INVALID_VAL}, the encoder is nullptr or invalid. + * {@link AV_ERR_NO_MEMORY}, internal errors in the input encode instance, such as an abnormal NULL. + * {@link AV_ERR_INVALID_VAL}, the input codec pointer is non encoder instance or NULL. * {@link AV_ERR_UNKNOWN}, unknown error. - * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. + * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. * @since 9 */ OH_AVErrCode OH_VideoEncoder_Flush(OH_AVCodec *codec); /** - * @brief Reset the encoder. To continue coding, you need to call the Configure interface again to - * configure the encoder instance. + * @brief Reset the encoder. The encoder returns to the Initialized state. To continue encoding, + * you need to call the Configure interface again to configure the encoder instance. * @syscap SystemCapability.Multimedia.Media.VideoEncoder * @param codec Pointer to an OH_AVCodec instance * @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}, instance has already released. - * {@link AV_ERR_INVALID_VAL}, the encoder is nullptr or invalid. + * {@link AV_ERR_NO_MEMORY}, internal errors in the input encode instance, such as an abnormal NULL. + * {@link AV_ERR_INVALID_VAL}, the input codec pointer is non encoder instance or NULL. * {@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}, internal execution error. * @since 9 */ OH_AVErrCode OH_VideoEncoder_Reset(OH_AVCodec *codec); /** - * @brief Get the description information of the output data of the encoder, refer to {@link OH_AVFormat} for details. + * @brief Get the OH_AVFormat of the output data of the encoder, refer to {@link OH_AVFormat} for details. * It should be noted that the life cycle of the OH_AVFormat instance pointed to by the return value * needs to - * be manually released by the caller. + * be released by {@link OH_AVFormat_Destroy}. * @syscap SystemCapability.Multimedia.Media.VideoEncoder * @param codec Pointer to an OH_AVCodec instance * @return Returns a pointer to an OH_AVFormat instance. - * Return nullptr if the codec is nullptr or invaild. + * Return NULL if the codec is NULL or invaild. * @since 9 */ OH_AVFormat *OH_VideoEncoder_GetOutputDescription(OH_AVCodec *codec); /** - * @brief Set dynamic parameters to the encoder. Note: This interface can only be called after the encoder is started. - * At the same time, incorrect parameter settings may cause the encoding to fail. + * @brief Set encoder parameters when encoder running. Note: This interface can only be called after + * the encoder is started. At the same time, incorrect parameter settings may cause the encoding to fail. * @syscap SystemCapability.Multimedia.Media.VideoEncoder * @param codec Pointer to an OH_AVCodec instance * @param format OH_AVFormat handle pointer * @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}, instance has already released. - * {@link AV_ERR_INVALID_VAL}, the encoder is nullptr or invalid. Invalid param in format. + * {@link AV_ERR_NO_MEMORY}, internal errors in the input encode instance, such as an abnormal NULL. + * {@link AV_ERR_INVALID_VAL} + * 1. the input codec pointer is non encoder instance or NULL; + * 2. unsupported input format parameters. * {@link AV_ERR_UNKNOWN}, unknown error. - * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. + * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. * @since 9 */ OH_AVErrCode OH_VideoEncoder_SetParameter(OH_AVCodec *codec, OH_AVFormat *format); /** - * @brief Get the input Surface from the video encoder, this interface must be called before Prepare is called. + * @brief Get the input surface from the video encoder, this interface must be called before Prepare is called. * @syscap SystemCapability.Multimedia.Media.VideoEncoder * @param codec Pointer to an OH_AVCodec instance * @param window A pointer to a OHNativeWindow instance, see {@link OHNativeWindow}, the application is responsible for * managing the life cycle of the window, call OH_NativeWindow_DestroyNativeWindow() when done. * @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}, inner resource has already released. - * {@link AV_ERR_INVALID_VAL}, the encoder is nullptr or invalid. + * {@link AV_ERR_INVALID_VAL}, the input codec pointer is non encoder instance or NULL. * {@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}, internal execution error. * @since 9 */ OH_AVErrCode OH_VideoEncoder_GetSurface(OH_AVCodec *codec, OHNativeWindow **window); /** - * @brief Return the processed output Buffer to the encoder. + * @brief Return the processed output buffer to the encoder. * @syscap SystemCapability.Multimedia.Media.VideoEncoder * @param codec Pointer to an OH_AVCodec instance - * @param index The index value corresponding to the output Buffer + * @param index The index value corresponding to the output buffer, + * should be given by {@link OH_AVCodecOnNewOutputData} * @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}, instance has already released. - * {@link AV_ERR_INVALID_VAL}, the encoder is nullptr or invalid. - * Buffer index should be given by {@link OH_AVCodecOnNewOutputData}. + * {@link AV_ERR_NO_MEMORY}, internal errors in the input encode instance, such as an abnormal NULL. + * {@link AV_ERR_INVALID_VAL}, the input codec pointer is non encoder instance or NULL. * {@link AV_ERR_UNKNOWN}, unknown error. - * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. + * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. * @deprecated since 11 * @useinstead OH_VideoEncoder_FreeOutputBuffer @@ -318,16 +324,16 @@ OH_AVErrCode OH_VideoEncoder_GetSurface(OH_AVCodec *codec, OHNativeWindow **wind OH_AVErrCode OH_VideoEncoder_FreeOutputData(OH_AVCodec *codec, uint32_t index); /** - * @brief Notifies the video encoder that the input stream has ended. It is recommended to use this interface to notify - * the encoder of the end of the stream in surface mode + * @brief Notifies the video encoder that the input stream has ended. This interface is only used in Surface mode. + * In Buffer mode, the OH_AVBuffer carries the EOS information to notify the end of the stream. * @syscap SystemCapability.Multimedia.Media.VideoEncoder * @param codec Pointer to an OH_AVCodec instance * @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}, instance has already released. - * {@link AV_ERR_INVALID_VAL}, the encoder is nullptr or invalid. + * {@link AV_ERR_NO_MEMORY}, internal errors in the input encode instance, such as an abnormal NULL. + * {@link AV_ERR_INVALID_VAL}, the input codec pointer is non encoder instance or NULL. * {@link AV_ERR_UNKNOWN}, unknown error. - * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. + * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. * @since 9 */ @@ -337,15 +343,17 @@ OH_AVErrCode OH_VideoEncoder_NotifyEndOfStream(OH_AVCodec *codec); * @brief Submit the input buffer filled with data to the video encoder. * @syscap SystemCapability.Multimedia.Media.VideoEncoder * @param codec Pointer to an OH_AVCodec instance - * @param index Enter the index value corresponding to the Buffer - * @param attr Information describing the data contained in the Buffer + * @param index Enter the index value corresponding to the buffer, + * should be given by {@link OH_AVCodecOnNeedInputData}. + * @param attr Information describing the data contained in the buffer * @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}, instance has already released. - * {@link AV_ERR_INVALID_VAL}, the encoder is nullptr or invalid. - * Buffer index should be given by {@link OH_AVCodecOnNeedInputData}. + * {@link AV_ERR_NO_MEMORY}, internal errors in the input encode instance, such as an abnormal NULL. + * {@link AV_ERR_INVALID_VAL} + * 1. the input codec pointer is non encoder instance or NULL; + * 2. unsupported input format parameters. * {@link AV_ERR_UNKNOWN}, unknown error. - * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. + * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. * @deprecated since 11 * @useinstead OH_VideoEncoder_PushInputBuffer @@ -354,17 +362,17 @@ OH_AVErrCode OH_VideoEncoder_NotifyEndOfStream(OH_AVCodec *codec); OH_AVErrCode OH_VideoEncoder_PushInputData(OH_AVCodec *codec, uint32_t index, OH_AVCodecBufferAttr attr); /** - * @brief Submit the input buffer filled with data to the video encoder. + * @brief In Buffer mode, the OH_AVBuffer corresponding to the index is submited to the encoder for encoding. * @syscap SystemCapability.Multimedia.Media.VideoEncoder * @param codec Pointer to an OH_AVCodec instance - * @param index Enter the index value corresponding to the Buffer + * @param index Enter the index value corresponding to the buffer, + * should be given by {@link OH_AVCodecOnNeedInputBuffer}. * @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}, instance has already released. - * {@link AV_ERR_INVALID_VAL}, the encoder is nullptr or invalid. - * Buffer index should be given by {@link OH_AVCodecOnNeedInputBuffer}. + * {@link AV_ERR_NO_MEMORY}, internal errors in the input encode instance, such as an abnormal NULL. + * {@link AV_ERR_INVALID_VAL}, the input codec pointer is non encoder instance or NULL. * {@link AV_ERR_UNKNOWN}, unknown error. - * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. + * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. * @since 11 @@ -372,65 +380,67 @@ OH_AVErrCode OH_VideoEncoder_PushInputData(OH_AVCodec *codec, uint32_t index, OH OH_AVErrCode OH_VideoEncoder_PushInputBuffer(OH_AVCodec *codec, uint32_t index); /** - * @brief Submit the input parameter filled with data to the video encoder. - * + * @brief In Surface mode, the encode parameters of the frame corresponding to the + * index is submited to the encoder for encoding. * @syscap SystemCapability.Multimedia.Media.VideoEncoder * @param codec Pointer to an OH_AVCodec instance - * @param index Enter the index value corresponding to the input parameter + * @param index Enter the index value corresponding to the input parameter, + * should be given by {@link OH_VideoEncoder_OnNeedInputParameter} * @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}, instance has already released. - * {@link AV_ERR_INVALID_VAL}, the encoder is nullptr or invalid. - * Index should be given by {@link OH_VideoEncoder_OnNeedInputParameter}. + * {@link AV_ERR_NO_MEMORY}, internal errors in the input encode instance, such as an abnormal NULL. + * {@link AV_ERR_INVALID_VAL}, the input codec pointer is non encoder instance or NULL. * {@link AV_ERR_UNKNOWN}, unknown error. - * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. + * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. * @since 12 */ OH_AVErrCode OH_VideoEncoder_PushInputParameter(OH_AVCodec *codec, uint32_t index); /** - * @brief Return the processed output Buffer to the encoder. + * @brief Return the OH_AVBuffer corresponding to the processed index to the encoder. + * Need to call this interface to release output buffer immediately after using. + * Otherwise, the encode process will be blocked. * @syscap SystemCapability.Multimedia.Media.VideoEncoder * @param codec Pointer to an OH_AVCodec instance - * @param index The index value corresponding to the output Buffer + * @param index The index value corresponding to the output buffer, + * should be given by {@link OH_AVCodecOnNewOutputBuffer}. * @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}, instance has already released. - * {@link AV_ERR_INVALID_VAL}, the encoder is nullptr or invalid. - * Buffer index should be given by {@link OH_AVCodecOnNewOutputBuffer}. + * {@link AV_ERR_NO_MEMORY}, internal errors in the input encode instance, such as an abnormal NULL. + * {@link AV_ERR_INVALID_VAL} + * 1. the input codec pointer is non encoder instance or NULL; + * 2. unsupported input format parameters; + * 3. the index is vaild or consecutively assigned to the same index, + * the error do not affect the subsequent encode process * {@link AV_ERR_UNKNOWN}, unknown error. - * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. + * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. * @since 11 */ OH_AVErrCode OH_VideoEncoder_FreeOutputBuffer(OH_AVCodec *codec, uint32_t index); /** - * @brief Get the input data description of the encoder after call {@OH_VideoEncoder_Configure}, + * @brief Description information of the image received by 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 - * instance pointed to by the return value needs to be manually released by the caller. + * instance pointed to by the return value needs to be released by {@link OH_AVFormat_Destroy}. * @syscap SystemCapability.Multimedia.Media.VideoEncoder * @param codec Pointer to an OH_AVCodec instance * @return Returns a pointer to an OH_AVFormat instance. - * Return nullptr if the encoder is nullptr or invaild. + * Return NULL if the encoder is NULL or invaild. * @since 10 */ OH_AVFormat *OH_VideoEncoder_GetInputDescription(OH_AVCodec *codec); /** - * @brief Check whether the current codec instance is valid. It can be used fault recovery or app - * switchback from the background + * @brief Check whether the current codec instance is valid. * @syscap SystemCapability.Multimedia.Media.VideoEncoder * @param codec Pointer to an OH_AVCodec instance * @param isValid Output Parameter. A pointer to a boolean instance, it is true if the codec instance is valid, - * false if the codec instance is invalid + * false if the codec instance is invalid. It is recommend that the invoker initialize isValid to false. * @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}, instance has already released. - * {@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_VAL}, the input codec pointer is non encoder instance or NULL. * @since 10 */ OH_AVErrCode OH_VideoEncoder_IsValid(OH_AVCodec *codec, bool *isValid); diff --git a/multimedia/media_foundation/native_audio_channel_layout.h b/multimedia/media_foundation/native_audio_channel_layout.h index 1397d70cda341f32f7a98807fbf59d6d7c2f09fa..2b62da8004dc83b03040a2230c816ac29496a570 100644 --- a/multimedia/media_foundation/native_audio_channel_layout.h +++ b/multimedia/media_foundation/native_audio_channel_layout.h @@ -25,8 +25,7 @@ /** * @file native_audio_channel_layout.h * - * @brief The channel layout indicates the appearance and order of the speakers for recording or playback. - * + * @brief The channel layout during recording and playback. * @kit AVCodecKit * @library NA * @syscap SystemCapability.Multimedia.Media.Core diff --git a/multimedia/media_foundation/native_avbuffer.h b/multimedia/media_foundation/native_avbuffer.h index 29ff41d31536af91b853ac9913aa96a421a5d150..872f3b852f69d555fb822e71970e612483a06c12 100644 --- a/multimedia/media_foundation/native_avbuffer.h +++ b/multimedia/media_foundation/native_avbuffer.h @@ -62,78 +62,88 @@ typedef struct OH_AVBuffer OH_AVBuffer; typedef struct OH_NativeBuffer OH_NativeBuffer; /** - * @brief Create an OH_AVBuffer instance, It should be noted that the life cycle of the OH_AVBuffer instance pointed - * to by the return value * needs to be manually released by {@link OH_AVBuffer_Destroy}. + * @brief Create an OH_AVBuffer instance, It should be noted that the OH_AVBuffer instance pointed + * to by the return value * needs to be released by {@link OH_AVBuffer_Destroy}. * @syscap SystemCapability.Multimedia.Media.Core * @param capacity the buffer's capacity, bytes - * @return Returns a pointer to an OH_AVBuffer instance if the execution is successful, otherwise returns nullptr. - * Possible failure causes: 1. capacity <= 0. 2. create allocator failed. 3. create OH_AVBuffer failed. - * 4. created buffer memory is nullptr. 5. created buffer memory's addr is nullptr. 6. failed to new OH_AVBuffer. + * @return Returns a pointer to an OH_AVBuffer instance if the execution is successful, otherwise returns NULL. + * Possible failure causes: + * 1. capacity <= 0; + * 2. internal error occurred, the system has no resources. * @since 11 */ OH_AVBuffer *OH_AVBuffer_Create(int32_t capacity); /** * @brief Clear the internal resources of the buffer and destroy the buffer instance. + * The same buffer can not be destroyed repeatedly. * @syscap SystemCapability.Multimedia.Media.Core * @param buffer Encapsulate OH_AVBuffer structure instance pointer * @return Function result code. * {@link AV_ERR_OK} if the execution is successful. - * {@link AV_ERR_INVALID_VAL} if input buffer is nullptr or buffer's magic error. + * {@link AV_ERR_INVALID_VAL} if input buffer is NULL or structure verification failed of the buffer. * {@link AV_ERR_OPERATE_NOT_PERMIT} if input buffer is not user created. * @since 11 */ OH_AVErrCode OH_AVBuffer_Destroy(OH_AVBuffer *buffer); /** - * @brief Get the buffer's attribute. + * @brief Get the buffer's attribute, such as pts, size, offset, and flags. * @syscap SystemCapability.Multimedia.Media.Core * @param buffer Encapsulate OH_AVBuffer structure instance pointer * @param attr Encapsulate OH_AVCodecBufferAttr structure instance pointer, please refer to * {@link OH_AVCodecBufferAttr} * @return Function result code. * {@link AV_ERR_OK} if the execution is successful. - * {@link AV_ERR_INVALID_VAL} if input buffer is nullptr, buffer's magic error, - * input buffer's buffer is nulllptr or attr is nullptr. + * {@link AV_ERR_INVALID_VAL} + * 1. input buffer or attr is NULL; + * 2. structure verification failed of the buffer. * @since 11 */ OH_AVErrCode OH_AVBuffer_GetBufferAttr(OH_AVBuffer *buffer, OH_AVCodecBufferAttr *attr); /** - * @brief Set the buffer's attribute. + * @brief Set the buffer's attribute, such as pts, size, offset, and flags. * @syscap SystemCapability.Multimedia.Media.Core * @param buffer Encapsulate OH_AVBuffer structure instance pointer * @param attr Encapsulate OH_AVCodecBufferAttr structure instance pointer, please refer to * {@link OH_AVCodecBufferAttr} * @return Function result code. * {@link AV_ERR_OK} if the execution is successful. - * {@link AV_ERR_INVALID_VAL} if input buffer is nullptr, buffer's magic error, - * input buffer's buffer is nulllptr, attr is nullptr, the size or offset of input buffer's memory is invalid. + * {@link AV_ERR_INVALID_VAL} + * 1. input buffer or attr is NULL; + * 2. structure verification failed of the buffer; + * 3. the size or offset of input buffer's memory is invalid. * @since 11 */ OH_AVErrCode OH_AVBuffer_SetBufferAttr(OH_AVBuffer *buffer, const OH_AVCodecBufferAttr *attr); /** - * @brief Get the buffer's parameter. It should be noted that the life cycle of the OH_AVFormat instance pointed to - * by the return value * needs to be manually released by {@link OH_AVFormat_Destroy}. + * @brief Get parameters except basic attributes, the information is carried in OH_AVFormat. + * It should be noted that the OH_AVFormat instance pointed to + * by the return value * needs to be released by {@link OH_AVFormat_Destroy}. * @syscap SystemCapability.Multimedia.Media.Core * @param buffer Encapsulate OH_AVBuffer structure instance pointer * @return Returns Encapsulate OH_AVFormat structure instance pointer if the execution is successful, - * otherwise returns nullptr. Possible failure causes: 1. input buffer is nullptr. 2. buffer's magic error. - * 3. input buffer's buffer is nulllptr. 4. buffer's meta is nullptr. + * otherwise returns NULL. Possible failure causes: + * 1. input buffer is NULL; + * 2. structure verification failed of the buffer; + * 3. buffer's meta is NULL. * @since 11 */ OH_AVFormat *OH_AVBuffer_GetParameter(OH_AVBuffer *buffer); /** - * @brief Set the buffer's parameter. + * @brief Set parameters except basic attributes, the information is carried in OH_AVFormat. * @syscap SystemCapability.Multimedia.Media.Core * @param buffer Encapsulate OH_AVBuffer structure instance pointer * @param format Encapsulate OH_AVFormat structure instance pointer * @return Function result code. * {@link AV_ERR_OK} if the execution is successful. - * {@link AV_ERR_INVALID_VAL} if input buffer is nullptr, buffer's magic error, - * input buffer's buffer is nulllptr, input format is nullptr, buffer's magic error, or input meta is nullptr. + * {@link AV_ERR_INVALID_VAL} + * 1. input buffer or format is NULL; + * 2. structure verification failed of the buffer; + * 3. input meta is NULL. * @since 11 */ OH_AVErrCode OH_AVBuffer_SetParameter(OH_AVBuffer *buffer, const OH_AVFormat *format); @@ -142,32 +152,38 @@ OH_AVErrCode OH_AVBuffer_SetParameter(OH_AVBuffer *buffer, const OH_AVFormat *fo * @brief Get the buffer's virtual address. * @syscap SystemCapability.Multimedia.Media.Core * @param buffer Encapsulate OH_AVBuffer structure instance pointer - * @return the buffer's virtual address if the buffer is valid, otherwise nullptr - * Possible failure causes: 1. input buffer is nullptr. 2. buffer's magic error. - * 3. input buffer's buffer is nulllptr. 4. buffer's memory is nullptr. + * @return the buffer's virtual address if the buffer is valid, otherwise NULL + * Possible failure causes: + * 1. input buffer is NULL; + * 2. structure verification failed of the OH_AVBuffer; + * 3. internal error has occurred. * @since 11 */ uint8_t *OH_AVBuffer_GetAddr(OH_AVBuffer *buffer); /** - * @brief Get the buffer's capacity + * @brief Get the buffer's capacity(byte). * @syscap SystemCapability.Multimedia.Media.Core * @param buffer Encapsulate OH_AVBuffer structure instance pointer - * @return the buffer's capacity if the buffer is valid, otherwise -1 - * Possible failure causes: 1. input buffer is nullptr. 2. buffer's magic error. - * 3. input buffer's buffer is nulllptr. 4. buffer's memory is nullptr. + * @return The buffer's capacity if the buffer is valid, otherwise -1 + * Possible failure causes: + * 1. input buffer is NULL; + * 2. structure verification failed of the OH_AVBuffer; + * 3. internal error has occurred. * @since 11 */ int32_t OH_AVBuffer_GetCapacity(OH_AVBuffer *buffer); /** - * @brief Get the OH_NativeBuffer instance pointer,It should be noted that the life cycle of the OH_AVBuffer - * instance pointed to by the return value * needs to be manually released by {@link OH_NativeBuffer_Unreference}. + * @brief Get the OH_NativeBuffer instance pointer. It should be noted that the OH_AVBuffer + * instance pointed to by the return value * needs to be released by {@link OH_NativeBuffer_Unreference}. * @syscap SystemCapability.Multimedia.Media.Core * @param buffer Encapsulate OH_AVBuffer structure instance pointer - * @return Returns Encapsulate OH_NativeBuffer structure instance pointer is successful, otherwise returns nullptr - * Possible failure causes: 1. input buffer is nullptr. 2. buffer's magic error. - * 3. input buffer's buffer is nulllptr. 4. buffer's memory is nullptr. 5. surfaceBuffer is nullptr. + * @return Returns Encapsulate OH_NativeBuffer structure instance pointer is successful, otherwise returns NULL + * Possible failure causes: + * 1. input buffer is NULL; + * 2. structure verification failed of the OH_AVBuffer; + * 3. internal error has occurred. * @since 11 */ OH_NativeBuffer *OH_AVBuffer_GetNativeBuffer(OH_AVBuffer *buffer); diff --git a/multimedia/media_foundation/native_avformat.h b/multimedia/media_foundation/native_avformat.h index ac30d2d47e37ffb44167ee56b6eef7c65b8f52b0..11ab1aec80b97e9aaf285e3ac0efc9a6289f4854 100644 --- a/multimedia/media_foundation/native_avformat.h +++ b/multimedia/media_foundation/native_avformat.h @@ -92,13 +92,13 @@ typedef enum OH_AVPixelFormat { struct OH_AVFormat *OH_AVFormat_Create(void); /** - * @briefCreate an audio OH_AVFormat handle pointer to read and write data + * @briefCreate an audio OH_AVFormat handle pointer to read and write data. * @syscap SystemCapability.Multimedia.Media.Core * @param mimeType mime type * @param sampleRate sample rate * @param channelCount channel count - * @return Returns a pointer to an OH_AVFormat instance if the execution is successful, otherwise nullptr - * Possible failure causes: 1. mimeType is nullptr. 2. new format is nullptr. + * @return Returns a pointer to an OH_AVFormat instance if the execution is successful, otherwise NULL + * Possible failure causes: 1. mimeType is NULL; 2. new format is NULL. * @since 10 * @version 1.0 */ @@ -107,13 +107,13 @@ struct OH_AVFormat *OH_AVFormat_CreateAudioFormat(const char *mimeType, int32_t channelCount); /** - * @briefCreate an video OH_AVFormat handle pointer to read and write data + * @brief Create an video OH_AVFormat handle pointer to read and write data. * @syscap SystemCapability.Multimedia.Media.Core * @param mimeType mime type * @param width width * @param height height - * @return Returns a pointer to an OH_AVFormat instance if the execution is successful, otherwise nullptr - * Possible failure causes: 1. mimeType is nullptr. 2. new format is nullptr. + * @return Returns a pointer to an OH_AVFormat instance if the execution is successful, otherwise NULL + * Possible failure causes: 1. mimeType is NULL; 2. new format is NULL. * @since 10 * @version 1.0 */ @@ -122,7 +122,7 @@ struct OH_AVFormat *OH_AVFormat_CreateVideoFormat(const char *mimeType, int32_t height); /** - * @brief Destroy the specified OH_AVFormat handle resource + * @brief Destroy the OH_AVFormat instance, can not be destoryed repeatedly. * @syscap SystemCapability.Multimedia.Media.Core * @param format pointer to an OH_AVFormat instance * @return void @@ -132,164 +132,212 @@ struct OH_AVFormat *OH_AVFormat_CreateVideoFormat(const char *mimeType, void OH_AVFormat_Destroy(struct OH_AVFormat *format); /** - * @brief Copy OH_AVFormat handle resource + * @brief Copy OH_AVFormat handle resource. * @syscap SystemCapability.Multimedia.Media.Core * @param to OH_AVFormat handle pointer to receive data * @param from pointer to the OH_AVFormat handle of the copied 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. + * Possible failure causes: + * 1. input parameter is NULL; + * 2. structure verification failed of the input OH_AVFormat. * @since 9 * @version 1.0 */ bool OH_AVFormat_Copy(struct OH_AVFormat *to, struct OH_AVFormat *from); /** - * @brief Write Int data to OH_AVFormat + * @brief Set a value of Int type to the key of OH_AVFormat. * @syscap SystemCapability.Multimedia.Media.Core * @param format pointer to an OH_AVFormat instance * @param key key to write data * @param value written 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. + * Possible failure causes: + * 1. input format is NULL; + * 2. structure verification failed of the input format; + * 3. input key is NULL; + * 4. value type corresponding to the key is incorrect. * @since 9 * @version 1.0 */ bool OH_AVFormat_SetIntValue(struct OH_AVFormat *format, const char *key, int32_t value); /** - * @brief Write Long data to OH_AVFormat + * @brief Set a value of Long type to the key of OH_AVFormat. * @syscap SystemCapability.Multimedia.Media.Core * @param format pointer to an OH_AVFormat instance * @param key key to write data * @param value written 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. + * Possible failure causes: + * 1. input format is NULL; + * 2. structure verification failed of the input format; + * 3. input key is NULL; + * 4. value type corresponding to the key is incorrect. * @since 9 * @version 1.0 */ bool OH_AVFormat_SetLongValue(struct OH_AVFormat *format, const char *key, int64_t value); /** - * @brief Write Float data to OH_AVFormat + * @brief Set a value of Float type to the key of OH_AVFormat. * @syscap SystemCapability.Multimedia.Media.Core * @param format pointer to an OH_AVFormat instance * @param key key to write data * @param value written 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. + * Possible failure causes: + * 1. input format is NULL; + * 2. structure verification failed of the input format; + * 3. input key is NULL; + * 4. value type corresponding to the key is incorrect. * @since 9 * @version 1.0 */ bool OH_AVFormat_SetFloatValue(struct OH_AVFormat *format, const char *key, float value); /** - * @brief Write Double data to OH_AVFormat + * @brief Set a value of Double type to the key of OH_AVFormat. * @syscap SystemCapability.Multimedia.Media.Core * @param format pointer to an OH_AVFormat instance * @param key key to write data * @param value written 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. + * Possible failure causes: + * 1. input format is NULL; + * 2. structure verification failed of the input format; + * 3. input key is NULL; + * 4. value type corresponding to the key is incorrect. * @since 9 * @version 1.0 */ bool OH_AVFormat_SetDoubleValue(struct OH_AVFormat *format, const char *key, double value); /** - * @brief Write String data to OH_AVFormat + * @brief Set a value of String type to the key of OH_AVFormat. * @syscap SystemCapability.Multimedia.Media.Core * @param format pointer to an OH_AVFormat instance * @param key key to write data * @param value written 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. - * 4. value is nullptr. + * Possible failure causes: + * 1. input format is NULL; + * 2. structure verification failed of the input format; + * 3. input key is NULL; + * 4. input value is NULL; + * 5. value type corresponding to the key is incorrect; * @since 9 * @version 1.0 */ bool OH_AVFormat_SetStringValue(struct OH_AVFormat *format, const char *key, const char *value); /** - * @brief Write a block of data of a specified length to OH_AVFormat + * @brief Write a block of 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 + * @param addr written data addr, the lifecycle is managed by the invoker + * @param size written data length, range is(0, 1)MB * @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 NULL; + * 2. structure verification failed of the input format; + * 3. input key is NULL; + * 4. input addr is NULL; + * 5. size is 0 or exceeds the upper limit, which is 1MB; + * 6. value type corresponding to the key is incorrect. * @since 9 * @version 1.0 */ bool OH_AVFormat_SetBuffer(struct OH_AVFormat *format, const char *key, const uint8_t *addr, size_t size); /** - * @brief Read Int data from OH_AVFormat + * @brief Get the Int value from the key of OH_AVFormat. * @syscap SystemCapability.Multimedia.Media.Core * @param format pointer to an OH_AVFormat instance * @param key read key value * @param out read 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. - * 4. out is nullptr. + * Possible failure causes: + * 1. input format is NULL; + * 2. structure verification failed of the input format; + * 3. input key is NULL; + * 4. input out is NULL; + * 5. the obtained key does not exist or is not set. * @since 9 * @version 1.0 */ bool OH_AVFormat_GetIntValue(struct OH_AVFormat *format, const char *key, int32_t *out); /** - * @brief Read Long data from OH_AVFormat + * @brief Get the Long value from the key of OH_AVFormat. * @syscap SystemCapability.Multimedia.Media.Core * @param format pointer to an OH_AVFormat instance * @param key read key value * @param out read 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. - * 4. out is nullptr. + * Possible failure causes: + * 1. input format is NULL; + * 2. structure verification failed of the input format; + * 3. input key is NULL; + * 4. input out is NULL; + * 5. the obtained key does not exist or is not set. * @since 9 * @version 1.0 */ bool OH_AVFormat_GetLongValue(struct OH_AVFormat *format, const char *key, int64_t *out); /** - * @brief Read Float data from OH_AVFormat + * @brief Get the Float value from the key of OH_AVFormat. * @syscap SystemCapability.Multimedia.Media.Core * @param format pointer to an OH_AVFormat instance * @param key read key value * @param out read 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. - * 4. out is nullptr. + * Possible failure causes: + * 1. input format is NULL; + * 2. structure verification failed of the input format; + * 3. input key is NULL; + * 4. input out is NULL; + * 5. the obtained key does not exist or is not set. * @since 9 * @version 1.0 */ bool OH_AVFormat_GetFloatValue(struct OH_AVFormat *format, const char *key, float *out); /** - * @brief Read Double data from OH_AVFormat + * @brief Get the Double value from the key of OH_AVFormat. * @syscap SystemCapability.Multimedia.Media.Core * @param format pointer to an OH_AVFormat instance * @param key read key value * @param out read 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. - * 4. out is nullptr. + * Possible failure causes: + * 1. input format is NULL; + * 2. structure verification failed of the input format; + * 3. input key is NULL; + * 4. input out is NULL; + * 5. the obtained key does not exist or is not set. * @since 9 * @version 1.0 */ bool OH_AVFormat_GetDoubleValue(struct OH_AVFormat *format, const char *key, double *out); /** - * @brief Read String data from OH_AVFormat + * @brief Get the String value from the key of OH_AVFormat. * @syscap SystemCapability.Multimedia.Media.Core * @param format pointer to an OH_AVFormat instance * @param key read key value * @param out The read string pointer, the data life cycle pointed to is updated with GetString, * and Format is destroyed. If the caller needs to hold it for a long time, it must copy the memory * @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. out is nullptr. 5. malloc out string nullptr. + * Possible failure causes: + * 1. input format is NULL; + * 2. structure verification failed of the input format; + * 3. input key is NULL; + * 4. input out is NULL; + * 5. malloc out string NULL; + * 6. the obtained key does not exist or is not set. * @since 9 * @version 1.0 */ @@ -299,24 +347,31 @@ bool OH_AVFormat_GetStringValue(struct OH_AVFormat *format, const char *key, con * @brief Read a block of 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 key Key value for reading 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 size Length of read 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. - * 4. addr is nullptr. 5. size is nullptr. + * Possible failure causes: + * 1. input format is NULL; + * 2. structure verification failed of the input format; + * 3. input key is NULL; + * 4. input addr is NULL; + * 5. input size is NULL; + * 6. the obtained key does not exist or is not set. * @since 9 * @version 1.0 */ bool OH_AVFormat_GetBuffer(struct OH_AVFormat *format, const char *key, uint8_t **addr, size_t *size); /** - * @brief Output the information contained in OH_AVFormat as a string. + * @brief Return a string consisting of key and values contained in OH_AVFormat. + * the max string that can be returned is 1024 bytes, + * and the string pointer is released when the format is destroyed. * @syscap SystemCapability.Multimedia.Media.Core - * @param format pointer to an OH_AVFormat instance - * @return Returns a string consisting of key and data for success, nullptr for failure - * Possible failure causes: 1. input format is nullptr. 2. malloc dump info nullptr. + * @param format Pointer to an OH_AVFormat instance + * @return Returns a string consisting of key and data for success, NULL for failure + * Possible failure causes: 1. input format is NULL; 2. system resources are insufficient. * @since 9 * @version 1.0 */ diff --git a/multimedia/media_foundation/native_avmemory.h b/multimedia/media_foundation/native_avmemory.h index 224f34004246d6cf48a998f3d405491d47544b06..3f67c28c644dbabc54af06032d3786e0deff9d8a 100644 --- a/multimedia/media_foundation/native_avmemory.h +++ b/multimedia/media_foundation/native_avmemory.h @@ -57,8 +57,7 @@ typedef struct OH_AVMemory OH_AVMemory; * @syscap SystemCapability.Multimedia.Media.Core * @param size the memory's size, bytes. * @return Returns a pointer to an OH_AVMemory instance for success, needs to be freed by OH_AVMemory_Destroy, - * otherwise returns nullptr. Possible failure causes: 1. size <= 0. 2. create OH_AVMemory failed. - * 3.failed to new OH_AVMemory. + * otherwise returns NULL. * @deprecated since 11 * @useinstead OH_AVBuffer_Create * @since 10 @@ -69,8 +68,8 @@ OH_AVMemory *OH_AVMemory_Create(int32_t size); * @brief Get the memory's virtual address * @syscap SystemCapability.Multimedia.Media.Core * @param mem Encapsulate OH_AVMemory structure instance pointer - * @return the memory's virtual address if the memory is valid, otherwise nullptr. - * Possible failure causes: 1. input mem is nullptr. 2. mem's magic error. 3. mem's memory is nullptr. + * @return the memory's virtual address if the memory is valid, otherwise NULL. + * Possible failure causes: 1. input mem is NULL. 2. mem's magic error. 3. mem's memory is NULL. * @deprecated since 11 * @useinstead OH_AVBuffer_GetAddr * @since 9 @@ -83,7 +82,7 @@ uint8_t *OH_AVMemory_GetAddr(struct OH_AVMemory *mem); * @syscap SystemCapability.Multimedia.Media.Core * @param mem Encapsulate OH_AVMemory structure instance pointer * @return the memory's size if the memory is valid, otherwise -1. - * Possible failure causes: 1. input mem is nullptr. 2. mem's magic error. 3. mem's memory is nullptr. + * Possible failure causes: 1. input mem is NULL. 2. mem's magic error. 3. mem's memory is NULL. * @deprecated since 11 * @useinstead OH_AVBuffer_GetCapacity * @since 9 @@ -98,7 +97,7 @@ int32_t OH_AVMemory_GetSize(struct OH_AVMemory *mem); * @param mem Encapsulate OH_AVMemory structure instance pointer * @return Function result code. * {@link AV_ERR_OK} if the execution is successful. - * {@link AV_ERR_INVALID_VAL} if input mem is nullptr, mem's magic error or input mem is not user created. + * {@link AV_ERR_INVALID_VAL} if input mem is NULL, mem's magic error or input mem is not user created. * @deprecated since 11 * @useinstead OH_AVBuffer_Destroy * @since 10