From a18d564a2269e05cf5654054cc09a6b0ff13e784 Mon Sep 17 00:00:00 2001 From: Gloria Date: Mon, 10 Jul 2023 11:43:46 +0800 Subject: [PATCH] Update docs against 19905+19949 Signed-off-by: wusongqing --- .../reference/native-apis/Readme-EN.md | 28 +- .../reference/native-apis/_a_v_capability.md | 931 ++++++++++ .../reference/native-apis/_a_v_demuxer.md | 224 +++ .../reference/native-apis/_a_v_muxer.md | 251 +++ .../reference/native-apis/_a_v_source.md | 187 +++ .../reference/native-apis/_audio_decoder.md | 442 +++-- .../reference/native-apis/_audio_encoder.md | 366 ++-- .../reference/native-apis/_codec_base.md | 1066 +++++++++--- .../reference/native-apis/_core.md | 601 ++++--- .../reference/native-apis/_native_vsync.md | 149 ++ .../_o_h___a_v_codec_async_callback.md | 84 +- .../_o_h___a_v_codec_buffer_attr.md | 84 +- .../reference/native-apis/_o_h___a_v_range.md | 62 + ...h___audio_capturer___callbacks___struct.md | 26 + ...h___audio_renderer___callbacks___struct.md | 26 + .../native-apis/_o_h___native_buffer.md | 233 +++ .../_o_h___native_buffer___config.md | 29 + .../native-apis/_o_h___native_image.md | 267 +++ .../reference/native-apis/_o_h_audio.md | 1493 +++++++++++++++++ .../reference/native-apis/_video_decoder.md | 391 +++-- .../reference/native-apis/_video_encoder.md | 496 ++++-- .../avcodec__audio__channel__layout_8h.md | 25 + .../native-apis/native__audiocapturer_8h.md | 38 + .../native-apis/native__audiorenderer_8h.md | 38 + .../native__audiostream__base_8h.md | 52 + .../native__audiostreambuilder_8h.md | 40 + .../native-apis/native__avcapability_8h.md | 72 + .../native__avcodec__audiodecoder_8h.md | 38 +- .../native__avcodec__audioencoder_8h.md | 38 +- .../native-apis/native__avcodec__base_8h.md | 143 +- .../native__avcodec__videodecoder_8h.md | 42 +- .../native__avcodec__videoencoder_8h.md | 50 +- .../native-apis/native__avdemuxer_8h.md | 29 + .../native-apis/native__averrors_8h.md | 15 +- .../native-apis/native__avformat_8h.md | 51 +- .../native-apis/native__avmemory_8h.md | 16 +- .../native-apis/native__avmuxer_8h.md | 30 + .../native-apis/native__avsource_8h.md | 28 + .../native-apis/native__buffer_8h.md | 44 + .../reference/native-apis/native__image_8h.md | 39 + .../reference/native-apis/native__vsync_8h.md | 34 + 41 files changed, 7186 insertions(+), 1112 deletions(-) create mode 100644 en/application-dev/reference/native-apis/_a_v_capability.md create mode 100644 en/application-dev/reference/native-apis/_a_v_demuxer.md create mode 100644 en/application-dev/reference/native-apis/_a_v_muxer.md create mode 100644 en/application-dev/reference/native-apis/_a_v_source.md create mode 100644 en/application-dev/reference/native-apis/_native_vsync.md create mode 100644 en/application-dev/reference/native-apis/_o_h___a_v_range.md create mode 100644 en/application-dev/reference/native-apis/_o_h___audio_capturer___callbacks___struct.md create mode 100644 en/application-dev/reference/native-apis/_o_h___audio_renderer___callbacks___struct.md create mode 100644 en/application-dev/reference/native-apis/_o_h___native_buffer.md create mode 100644 en/application-dev/reference/native-apis/_o_h___native_buffer___config.md create mode 100644 en/application-dev/reference/native-apis/_o_h___native_image.md create mode 100644 en/application-dev/reference/native-apis/_o_h_audio.md create mode 100644 en/application-dev/reference/native-apis/avcodec__audio__channel__layout_8h.md create mode 100644 en/application-dev/reference/native-apis/native__audiocapturer_8h.md create mode 100644 en/application-dev/reference/native-apis/native__audiorenderer_8h.md create mode 100644 en/application-dev/reference/native-apis/native__audiostream__base_8h.md create mode 100644 en/application-dev/reference/native-apis/native__audiostreambuilder_8h.md create mode 100644 en/application-dev/reference/native-apis/native__avcapability_8h.md create mode 100644 en/application-dev/reference/native-apis/native__avdemuxer_8h.md create mode 100644 en/application-dev/reference/native-apis/native__avmuxer_8h.md create mode 100644 en/application-dev/reference/native-apis/native__avsource_8h.md create mode 100644 en/application-dev/reference/native-apis/native__buffer_8h.md create mode 100644 en/application-dev/reference/native-apis/native__image_8h.md create mode 100644 en/application-dev/reference/native-apis/native__vsync_8h.md diff --git a/en/application-dev/reference/native-apis/Readme-EN.md b/en/application-dev/reference/native-apis/Readme-EN.md index 7b6840f639..87aeec065c 100644 --- a/en/application-dev/reference/native-apis/Readme-EN.md +++ b/en/application-dev/reference/native-apis/Readme-EN.md @@ -1,21 +1,29 @@ -# Native API +# Native APIs - Modules - [Native XComponent](_o_h___native_x_component.md) - [HiLog](_hi_log.md) - [NativeWindow](_native_window.md) + - [OH_NativeBuffer](_o_h___native_buffer.md) - [Drawing](_drawing.md) + - [OH_NativeImage](_o_h___native_image.md) + - [NativeVsync](_native_vsync.md) - [Image](image.md) - [Rawfile](rawfile.md) - [RDB](_r_d_b.md) - [MindSpore](_mind_spore.md) - [NeuralNeworkRuntime](_neural_nework_runtime.md) + - [AVCapability](_a_v_capability.md) + - [AVMuxer](_a_v_muxer.md) - [AudioDecoder](_audio_decoder.md) - [AudioEncoder](_audio_encoder.md) - [CodecBase](_codec_base.md) + - [Core](_core.md) - [VideoDecoder](_video_decoder.md) - [VideoEncoder](_video_encoder.md) - - [Core](_core.md) + - [AVDemuxer](_a_v_demuxer.md) + - [AVSource](_a_v_source.md) + - [OHAudio](_o_h_audio.md) - [HuksKeyApi](_huks_key_api.md) - [HuksParamSetApi](_huks_param_set_api.md) - [HuksTypeApi](_huks_type_api.md) @@ -35,7 +43,10 @@ - [external_window.h](external__window_8h.md) - [image_pixel_map_napi.h](image__pixel__map__napi_8h.md) - [log.h](log_8h.md) + - [native_buffer.h](native__buffer_8h.md) + - [native_image.h](native__image_8h.md) - [native_interface_xcomponent.h](native__interface__xcomponent_8h.md) + - [native_vsync.h](native__vsync_8h.md) - [raw_dir.h](raw__dir_8h.md) - [raw_file_manager.h](raw__file__manager_8h.md) - [raw_file.h](raw__file_8h.md) @@ -48,14 +59,23 @@ - [types.h](types_8h.md) - [neural_network_runtime_type.h](neural__network__runtime__type_8h.md) - [neural_network_runtime.h](neural__network__runtime_8h.md) + - [avcodec_audio_channel_layout.h](avcodec__audio__channel__layout_8h.md) + - [native_avcapability.h](native__avcapability_8h.md) - [native_avcodec_audiodecoder.h](native__avcodec__audiodecoder_8h.md) - [native_avcodec_audioencoder.h](native__avcodec__audioencoder_8h.md) - [native_avcodec_base.h](native__avcodec__base_8h.md) - [native_avcodec_videodecoder.h](native__avcodec__videodecoder_8h.md) - [native_avcodec_videoencoder.h](native__avcodec__videoencoder_8h.md) + - [native_avdemuxer.h](native__avdemuxer_8h.md) - [native_averrors.h](native__averrors_8h.md) - [native_avformat.h](native__avformat_8h.md) - [native_avmemory.h](native__avmemory_8h.md) + - [native_avmuxer.h](native__avmuxer_8h.md) + - [native_avsource.h](native__avsource_8h.md) + - [native_audiocapturer.h](native__audiocapturer_8h.md) + - [native_audiorenderer.h](native__audiorenderer_8h.md) + - [native_audiostream_base.h](native__audiostream__base_8h.md) + - [native_audiostreambuilder.h](native__audiostreambuilder_8h.md) - [native_huks_api.h](native__huks__api_8h.md) - [native_huks_param.h](native__huks__param_8h.md) - [native_huks_type.h](native__huks__type_8h.md) @@ -69,6 +89,7 @@ - [purgeable_memory.h](purgeable__memory_8h.md) - Structs - [OH_Drawing_BitmapFormat](_o_h___drawing___bitmap_format.md) + - [OH_NativeBuffer_Config](_o_h___native_buffer___config.md) - [OH_NativeXComponent_Callback](_o_h___native_x_component___callback.md) - [OH_NativeXComponent_MouseEvent](_o_h___native_x_component___mouse_event.md) - [OH_NativeXComponent_MouseEvent_Callback](_o_h___native_x_component___mouse_event___callback.md) @@ -90,6 +111,9 @@ - [OH_NN_UInt32Array](_o_h___n_n___u_int32_array.md) - [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) - [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) + - [OH_AVRange](_o_h___a_v_range.md) + - [OH_AudioCapturer_Callbacks_Struct](_o_h___audio_capturer___callbacks___struct.md) + - [OH_AudioRenderer_Callbacks_Struct](_o_h___audio_renderer___callbacks___struct.md) - [OH_Huks_Blob](_o_h___huks___blob.md) - [OH_Huks_CertChain](_o_h___huks___cert_chain.md) - [OH_Huks_KeyInfo](_o_h___huks___key_info.md) diff --git a/en/application-dev/reference/native-apis/_a_v_capability.md b/en/application-dev/reference/native-apis/_a_v_capability.md new file mode 100644 index 0000000000..be81e92b4f --- /dev/null +++ b/en/application-dev/reference/native-apis/_a_v_capability.md @@ -0,0 +1,931 @@ +# AVCapability + + +## Overview + +The **AVCapability** module provides functions for querying the codec capability. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + +**Since** + +10 + + +## Summary + + +### Files + +| Name| Description| +| -------- | -------- | +| [native_avcapability.h](native__avcapability_8h.md) | Declares the native APIs used to query the codec capability.
File to include: \| + + +### Structs + +| Name| Description| +| -------- | -------- | +| [OH_AVRange](_o_h___a_v_range.md) | Defines the value range, which contains the minimum value and maximum value.| + + +### Types + +| Name| Description| +| -------- | -------- | +| [OH_BitrateMode](#oh_bitratemode) | Defines an enum that enumerates the bit rate modes of an encoder. | +| [OH_AVRange](#oh_avrange) | Defines a struct for the value range, which contains the minimum value and maximum value.| +| [OH_AVCodecCategory](#oh_avcodeccategory) | Defines an enum that enumerates the codec categories.| + + +### Enums + +| Name| Description| +| -------- | -------- | +| [OH_BitrateMode](#oh_bitratemode) { **BITRATE_MODE_CBR** = 0, **BITRATE_MODE_VBR** = 1, **BITRATE_MODE_CQ** = 2 } | Enumerates the bit rate modes of an encoder. | +| [OH_AVCodecCategory](#oh_avcodeccategory) { **HARDWARE** = 0, **SOFTWARE** } | Enumerates the codec categories.| + + +### Functions + +| Name| Description| +| -------- | -------- | +| \*[OH_AVCodec_GetCapability](#oh_avcodec_getcapability) (const char \*mime, bool isEncoder) | Obtains the codec capability recommended by the system.| +| \*[OH_AVCodec_GetCapabilityByCategory](#oh_avcodec_getcapabilitybycategory) (const char \*mime, bool isEncoder, [OH_AVCodecCategory](#oh_avcodeccategory) category) | Obtains the codec capability by category, which can be a hardware codec or software codec.| +| [OH_AVCapability_IsHardware](#oh_avcapability_ishardware) (OH_AVCapability \*capability) | Checks whether a codec capability instance describes a hardware codec.| +| \*[OH_AVCapability_GetName](#oh_avcapability_getname) (OH_AVCapability \*capability) | Obtains the codec name.| +| [OH_AVCapability_GetMaxSupportedInstances](#oh_avcapability_getmaxsupportedinstances) (OH_AVCapability \*capability) | Obtains the maximum number of codec instances supported by a codec.| +| [OH_AVCapability_GetEncoderBitrateRange](#oh_avcapability_getencoderbitraterange) (OH_AVCapability \*capability, [OH_AVRange](_o_h___a_v_range.md) \*bitrateRange) | Obtains the bit rate range supported by an encoder.| +| [OH_AVCapability_IsEncoderBitrateModeSupported](#oh_avcapability_isencoderbitratemodesupported) (OH_AVCapability \*capability, [OH_BitrateMode](#oh_bitratemode) bitrateMode) | Checks whether an encoder supports a specific bit rate mode.| +| [OH_AVCapability_GetEncoderQualityRange](#oh_avcapability_getencoderqualityrange) (OH_AVCapability \*capability, [OH_AVRange](_o_h___a_v_range.md) \*qualityRange) | Obtains the quality range supported by an encoder.| +| [OH_AVCapability_GetEncoderComplexityRange](#oh_avcapability_getencodercomplexityrange) (OH_AVCapability \*capability, [OH_AVRange](_o_h___a_v_range.md) \*complexityRange) | Obtains the complexity range supported by an encoder.| +| [OH_AVCapability_GetAudioSupportedSampleRates](#oh_avcapability_getaudiosupportedsamplerates) (OH_AVCapability \*capability, const int32_t \*\*sampleRates, uint32_t \*sampleRateNum) | Obtains the sampling rates supported by an audio codec.| +| [OH_AVCapability_GetAudioChannelCountRange](#oh_avcapability_getaudiochannelcountrange) (OH_AVCapability \*capability, [OH_AVRange](_o_h___a_v_range.md) \*channelCountRange) | Obtains the count range of audio channels supported by an audio codec.| +| [OH_AVCapability_GetVideoWidthAlignment](#oh_avcapability_getvideowidthalignment) (OH_AVCapability \*capability, int32_t \*widthAlignment) | Obtains the video width alignment supported by a video codec.| +| [OH_AVCapability_GetVideoHeightAlignment](#oh_avcapability_getvideoheightalignment) (OH_AVCapability \*capability, int32_t \*heightAlignment) | Obtains the video height alignment supported by a video codec.| +| [OH_AVCapability_GetVideoWidthRangeForHeight](#oh_avcapability_getvideowidthrangeforheight) (OH_AVCapability \*capability, int32_t height, [OH_AVRange](_o_h___a_v_range.md) \*widthRange) | Obtains the video width range supported by a video codec based on a given height.| +| [OH_AVCapability_GetVideoHeightRangeForWidth](#oh_avcapability_getvideoheightrangeforwidth) (OH_AVCapability \*capability, int32_t width, [OH_AVRange](_o_h___a_v_range.md) \*heightRange) | Obtains the video height range supported by a video codec based on a given width.| +| [OH_AVCapability_GetVideoWidthRange](#oh_avcapability_getvideowidthrange) (OH_AVCapability \*capability, [OH_AVRange](_o_h___a_v_range.md) \*widthRange) | Obtains the video width range supported by a video codec.| +| [OH_AVCapability_GetVideoHeightRange](#oh_avcapability_getvideoheightrange) (OH_AVCapability \*capability, [OH_AVRange](_o_h___a_v_range.md) \*heightRange) | Obtains the video height range supported by a video codec.| +| [OH_AVCapability_IsVideoSizeSupported](#oh_avcapability_isvideosizesupported) (OH_AVCapability \*capability, int32_t width, int32_t height) | Checks whether a video codec supports a specific video size.| +| [OH_AVCapability_GetVideoFrameRateRange](#oh_avcapability_getvideoframeraterange) (OH_AVCapability \*capability, [OH_AVRange](_o_h___a_v_range.md) \*frameRateRange) | Obtains the video frame rate range supported by a video codec.| +| [OH_AVCapability_GetVideoFrameRateRangeForSize](#oh_avcapability_getvideoframeraterangeforsize) (OH_AVCapability \*capability, int32_t width, int32_t height, [OH_AVRange](_o_h___a_v_range.md) \*frameRateRange) | Obtains the video frame rate range supported by a video codec based on a given video size.| +| [OH_AVCapability_AreVideoSizeAndFrameRateSupported](#oh_avcapability_arevideosizeandframeratesupported) (OH_AVCapability \*capability, int32_t width, int32_t height, int32_t frameRate) | Checks whether a video codec supports the combination of a video size and frame rate.| +| [OH_AVCapability_GetVideoSupportedPixelFormats](#oh_avcapability_getvideosupportedpixelformats) (OH_AVCapability \*capability, const int32_t \*\*pixelFormats, uint32_t \*pixelFormatNum) | Obtains the video pixel formats supported by a video codec.| +| [OH_AVCapability_GetSupportedProfiles](#oh_avcapability_getsupportedprofiles) (OH_AVCapability \*capability, const int32_t \*\*profiles, uint32_t \*profileNum) | Obtains the profiles supported by a codec.| +| [OH_AVCapability_GetSupportedLevelsForProfile](#oh_avcapability_getsupportedlevelsforprofile) (OH_AVCapability \*capability, int32_t profile, const int32_t \*\*levels, uint32_t \*levelNum) | Obtains the codec levels supported by a profile.| +| [OH_AVCapability_AreProfileAndLevelSupported](#oh_avcapability_areprofileandlevelsupported) (OH_AVCapability \*capability, int32_t profile, int32_t level) | Checks whether a codec supports the combination of a profile and level.| + + +### Variables + +| Name| Description| +| -------- | -------- | +| **OH_AVRange::minVal** | Defines the minimum value.| +| **OH_AVRange::maxVal** | Defines the maximum value.| + + +## Type Description + + +### OH_AVCodecCategory + + +``` +typedef enum OH_AVCodecCategoryOH_AVCodecCategory +``` + +**Description** + +Defines an enum that enumerates the codec categories. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + +**Since** + +10 + + +### OH_AVRange + + +``` +typedef struct OH_AVRangeOH_AVRange +``` + +**Description** + +Defines a struct for the value range, which contains the minimum value and maximum value. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + +**Since** + +10 + + +### OH_BitrateMode + + +``` +typedef enum OH_BitrateModeOH_BitrateMode +``` + +**Description** + +Defines an enum that enumerates the bit rate modes of an encoder. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + +**Since** + +10 + + +## Enum Description + + +### OH_AVCodecCategory + + +``` +enum OH_AVCodecCategory +``` + +**Description** + +Enumerates the codec categories. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + +**Since** + +10 + +| Value| Description| +| -------- | -------- | +| HARDWARE | Hardware codec.| +| SOFTWARE | Software codec.| + + +### OH_BitrateMode + + +``` +enum OH_BitrateMode +``` + +**Description** + +Enumerates the bit rate modes of an encoder. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + +**Since** + +10 + +| Value| Description| +| -------- | -------- | +| BITRATE_MODE_CBR | Constant bit rate.| +| BITRATE_MODE_VBR | Variable bit rate.| +| BITRATE_MODE_CQ | Constant quality.| + + +## Function Description + + +### OH_AVCapability_AreProfileAndLevelSupported() + + +``` +bool OH_AVCapability_AreProfileAndLevelSupported (OH_AVCapability *capability, int32_t profile, int32_t level ) +``` + +**Description** + +Checks whether a codec supports the combination of a profile and level. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + +**Parameters** + +| Name| Description| +| -------- | -------- | +| capability | Pointer to the codec capability.| +| profile | Profile of the codec.| +| level | Level of the codec.| + +**Returns** + +Returns **true** if the combination of the profile and level is supported; returns **false** otherwise. + +**Since** + +10 + + +### OH_AVCapability_AreVideoSizeAndFrameRateSupported() + + +``` +bool OH_AVCapability_AreVideoSizeAndFrameRateSupported (OH_AVCapability *capability, int32_t width, int32_t height, int32_t frameRate ) +``` + +**Description** + +Checks whether a video codec supports the combination of a video size and frame rate. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + +**Parameters** + +| Name| Description| +| -------- | -------- | +| capability | Pointer to the video codec capability. A pointer to the audio codec capability cannot be filled in.| +| width | Number of horizontal video pixels.| +| height | Number of vertical video pixels.| +| frameRate | Number of frames per second.| + +**Returns** + +Returns **true** if the combination of the video size and frame rate is supported; returns **false** otherwise. + +**Since** + +10 + + +### OH_AVCapability_GetAudioChannelCountRange() + + +``` +OH_AVErrCode OH_AVCapability_GetAudioChannelCountRange (OH_AVCapability * capability, OH_AVRange * channelCountRange ) +``` + +**Description** + +Obtains the count range of audio channels supported by an audio codec. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + +**Parameters** + +| Name| Description| +| -------- | -------- | +| capability | Pointer to the audio codec capability. A pointer to the video codec capability cannot be filled in.| +| channelCountRange | Output parameter. Pointer to the count range of audio channels supported.| + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** + +10 + + +### OH_AVCapability_GetAudioSupportedSampleRates() + + +``` +OH_AVErrCode OH_AVCapability_GetAudioSupportedSampleRates (OH_AVCapability * capability, const int32_t ** sampleRates, uint32_t * sampleRateNum ) +``` + +**Description** + +Obtains the sampling rates supported by an audio codec. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + +**Parameters** + +| Name| Description| +| -------- | -------- | +| capability | Pointer to the audio codec capability. A pointer to the video codec capability cannot be filled in.| +| sampleRates | Output parameter. Double pointer to the sampling rate array.| +| sampleRateNum | Output parameter. Pointer to the number of elements in the array.| + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** + +10 + + +### OH_AVCapability_GetEncoderBitrateRange() + + +``` +OH_AVErrCode OH_AVCapability_GetEncoderBitrateRange (OH_AVCapability * capability, OH_AVRange * bitrateRange ) +``` + +**Description** + +Obtains the bit rate range supported by an encoder. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + +**Parameters** + +| Name| Description| +| -------- | -------- | +| capability | Pointer to the encoder capability. A pointer to the decoder capability cannot be filled in.| +| bitrateRange | Output parameter. Pointer to the bit rate range supported.| + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** + +10 + + +### OH_AVCapability_GetEncoderComplexityRange() + + +``` +OH_AVErrCode OH_AVCapability_GetEncoderComplexityRange (OH_AVCapability * capability, OH_AVRange * complexityRange ) +``` + +**Description** + +Obtains the complexity range supported by an encoder. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + +**Parameters** + +| Name| Description| +| -------- | -------- | +| capability | Pointer to the encoder capability. A pointer to the decoder capability cannot be filled in.| +| complexityRange | Output parameter. Pointer to the complexity range supported.| + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** + +10 + + +### OH_AVCapability_GetEncoderQualityRange() + + +``` +OH_AVErrCode OH_AVCapability_GetEncoderQualityRange (OH_AVCapability * capability, OH_AVRange * qualityRange ) +``` + +**Description** + +Obtains the quality range supported by an encoder. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + +**Parameters** + +| Name| Description| +| -------- | -------- | +| capability | Pointer to the encoder capability. A pointer to the decoder capability cannot be filled in.| +| qualityRange | Output parameter. Pointer to the quality range supported.| + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** + +10 + + +### OH_AVCapability_GetMaxSupportedInstances() + + +``` +int32_t OH_AVCapability_GetMaxSupportedInstances (OH_AVCapability * capability) +``` + +**Description** + +Obtains the maximum number of codec instances supported by a codec. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + +**Parameters** + +| Name| Description| +| -------- | -------- | +| capability | Pointer to the codec capability.| + +**Returns** + +Returns the maximum number of codec instances supported. + +**Since** + +10 + + +### OH_AVCapability_GetName() + + +``` +const char* OH_AVCapability_GetName (OH_AVCapability * capability) +``` + +**Description** + +Obtains the codec name. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + +**Parameters** + +| Name| Description| +| -------- | -------- | +| capability | Pointer to the codec capability.| + +**Returns** + +Returns the codec name string. + +**Since** + +10 + + +### OH_AVCapability_GetSupportedLevelsForProfile() + + +``` +OH_AVErrCode OH_AVCapability_GetSupportedLevelsForProfile (OH_AVCapability * capability, int32_t profile, const int32_t ** levels, uint32_t * levelNum ) +``` + +**Description** + +Obtains the codec levels supported by a profile. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + +**Parameters** + +| Name| Description| +| -------- | -------- | +| capability | Pointer to the codec capability.| +| profile | Profile of the codec.| +| levels | Output parameter. Double pointer to the codec level array.| +| levelNum | Output parameter. Pointer to the number of elements in the array.| + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** + +10 + + +### OH_AVCapability_GetSupportedProfiles() + + +``` +OH_AVErrCode OH_AVCapability_GetSupportedProfiles (OH_AVCapability * capability, const int32_t ** profiles, uint32_t * profileNum ) +``` + +**Description** + +Obtains the profiles supported by a codec. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + +**Parameters** + +| Name| Description| +| -------- | -------- | +| capability | Pointer to the codec capability.| +| profiles | Output parameter. Double pointer to the profile array.| +| profileNum | Output parameter. Pointer to the number of elements in the array.| + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** + +10 + + +### OH_AVCapability_GetVideoFrameRateRange() + + +``` +OH_AVErrCode OH_AVCapability_GetVideoFrameRateRange (OH_AVCapability * capability, OH_AVRange * frameRateRange ) +``` + +**Description** + +Obtains the video frame rate range supported by a video codec. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + +**Parameters** + +| Name| Description| +| -------- | -------- | +| capability | Pointer to the video codec capability. A pointer to the audio codec capability cannot be filled in.| +| frameRateRange | Output parameter. Pointer to the video frame rate range supported.| + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** + +10 + + +### OH_AVCapability_GetVideoFrameRateRangeForSize() + + +``` +OH_AVErrCode OH_AVCapability_GetVideoFrameRateRangeForSize (OH_AVCapability * capability, int32_t width, int32_t height, OH_AVRange * frameRateRange ) +``` + +**Description** + +Obtains the video frame rate range supported by a video codec based on a given video size. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + +**Parameters** + +| Name| Description| +| -------- | -------- | +| capability | Pointer to the video codec capability. A pointer to the audio codec capability cannot be filled in.| +| width | Number of horizontal video pixels.| +| height | Number of vertical video pixels.| +| frameRateRange | Output parameter. Pointer to the video frame rate range supported.| + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** + +10 + + +### OH_AVCapability_GetVideoHeightAlignment() + + +``` +OH_AVErrCode OH_AVCapability_GetVideoHeightAlignment (OH_AVCapability * capability, int32_t * heightAlignment ) +``` + +**Description** + +Obtains the video height alignment supported by a video codec. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + +**Parameters** + +| Name| Description| +| -------- | -------- | +| capability | Pointer to the video codec capability. A pointer to the audio codec capability cannot be filled in.| +| heightAlignment | Output parameter. Pointer to the video height alignment supported.| + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** + +10 + + +### OH_AVCapability_GetVideoHeightRange() + + +``` +OH_AVErrCode OH_AVCapability_GetVideoHeightRange (OH_AVCapability * capability, OH_AVRange * heightRange ) +``` + +**Description** + +Obtains the video height range supported by a video codec. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + +**Parameters** + +| Name| Description| +| -------- | -------- | +| capability | Pointer to the video codec capability. A pointer to the audio codec capability cannot be filled in.| +| heightRange | Output parameter. Pointer to the video height range supported.| + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** + +10 + + +### OH_AVCapability_GetVideoHeightRangeForWidth() + + +``` +OH_AVErrCode OH_AVCapability_GetVideoHeightRangeForWidth (OH_AVCapability * capability, int32_t width, OH_AVRange * heightRange ) +``` + +**Description** + +Obtains the video height range supported by a video codec based on a given width. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + +**Parameters** + +| Name| Description| +| -------- | -------- | +| capability | Pointer to the video codec capability. A pointer to the audio codec capability cannot be filled in.| +| width | Number of horizontal video pixels.| +| heightRange | Output parameter. Pointer to the video height range supported.| + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** + +10 + + +### OH_AVCapability_GetVideoSupportedPixelFormats() + + +``` +OH_AVErrCode OH_AVCapability_GetVideoSupportedPixelFormats (OH_AVCapability * capability, const int32_t ** pixelFormats, uint32_t * pixelFormatNum ) +``` + +**Description** + +Obtains the video pixel formats supported by a video codec. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + +**Parameters** + +| Name| Description| +| -------- | -------- | +| capability | Pointer to the video codec capability. A pointer to the audio codec capability cannot be filled in.| +| pixelFormats | Output parameter. Double pointer to the video pixel format array.| +| pixelFormatNum | Output parameter. Pointer to the number of elements in the array.| + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** + +10 + + +### OH_AVCapability_GetVideoWidthAlignment() + + +``` +OH_AVErrCode OH_AVCapability_GetVideoWidthAlignment (OH_AVCapability * capability, int32_t * widthAlignment ) +``` + +**Description** + +Obtains the video width alignment supported by a video codec. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + +**Parameters** + +| Name| Description| +| -------- | -------- | +| capability | Pointer to the video codec capability. A pointer to the audio codec capability cannot be filled in.| +| widthAlignment | Output parameter. Pointer to the video width alignment supported.| + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** + +10 + + +### OH_AVCapability_GetVideoWidthRange() + + +``` +OH_AVErrCode OH_AVCapability_GetVideoWidthRange (OH_AVCapability * capability, OH_AVRange * widthRange ) +``` + +**Description** + +Obtains the video width range supported by a video codec. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + +**Parameters** + +| Name| Description| +| -------- | -------- | +| capability | Pointer to the video codec capability. A pointer to the audio codec capability cannot be filled in.| +| widthRange | Output parameter. Pointer to the video width range supported.| + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** + +10 + + +### OH_AVCapability_GetVideoWidthRangeForHeight() + + +``` +OH_AVErrCode OH_AVCapability_GetVideoWidthRangeForHeight (OH_AVCapability * capability, int32_t height, OH_AVRange * widthRange ) +``` + +**Description** + +Obtains the video width range supported by a video codec based on a given height. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + +**Parameters** + +| Name| Description| +| -------- | -------- | +| capability | Pointer to the video codec capability. A pointer to the audio codec capability cannot be filled in.| +| height | Number of vertical video pixels.| +| widthRange | Output parameter. Pointer to the video width range supported.| + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** + +10 + + +### OH_AVCapability_IsEncoderBitrateModeSupported() + + +``` +bool OH_AVCapability_IsEncoderBitrateModeSupported (OH_AVCapability * capability, OH_BitrateMode bitrateMode ) +``` + +**Description** + +Checks whether an encoder supports a specific bit rate mode. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + +**Parameters** + +| Name| Description| +| -------- | -------- | +| capability | Pointer to the encoder capability. A pointer to the decoder capability cannot be filled in.| +| bitrateMode | Bit rate mode.| + +**Returns** + +Returns **true** if the bit rate mode is supported; returns **false** otherwise. + +**Since** + +10 + + +### OH_AVCapability_IsHardware() + + +``` +bool OH_AVCapability_IsHardware (OH_AVCapability * capability) +``` + +**Description** + +Checks whether a codec capability instance describes a hardware codec. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + +**Parameters** + +| Name| Description| +| -------- | -------- | +| capability | Pointer to the codec capability.| + +**Returns** + +Returns **true** if the codec capability instance describes a hardware codec; returns **false**. + +**Since** + +10 + + +### OH_AVCapability_IsVideoSizeSupported() + + +``` +bool OH_AVCapability_IsVideoSizeSupported (OH_AVCapability * capability, int32_t width, int32_t height ) +``` + +**Description** + +Checks whether a video codec supports a specific video size. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + +**Parameters** + +| Name| Description| +| -------- | -------- | +| capability | Pointer to the video codec capability. A pointer to the audio codec capability cannot be filled in.| +| width | Number of horizontal video pixels.| +| height | Number of vertical video pixels.| + +**Returns** + +Returns **true** if the video size is supported; returns **false** otherwise. + +**Since** + +10 + + +### OH_AVCodec_GetCapability() + + +``` +OH_AVCapability* OH_AVCodec_GetCapability (const char * mime, bool isEncoder ) +``` + +**Description** + +Obtains the codec capability recommended by the system. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + +**Parameters** + +| Name| Description| +| -------- | -------- | +| mime | Pointer to the MIME type.| +| isEncoder | Whether the instance is an encoder. The value **true** means an encoder and **false** means a decoder.| + +**Returns** + +Returns a pointer to the codec capability instance if an existing codec matches; returns NULL otherwise. + +**Since** + +10 + + +### OH_AVCodec_GetCapabilityByCategory() + + +``` +OH_AVCapability* OH_AVCodec_GetCapabilityByCategory (const char * mime, bool isEncoder, OH_AVCodecCategory category ) +``` + +**Description** + +Obtains the codec capability by category, which can be a hardware codec or software codec. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + +**Parameters** + +| Name| Description| +| -------- | -------- | +| mime | Pointer to the MIME type.| +| isEncoder | Whether the instance is an encoder. The value **true** means an encoder and **false** means a decoder.| +| category | Codec category.| + +**Returns** + +Returns a pointer to the codec capability instance if an existing codec matches; returns NULL otherwise. + +**Since** + +10 diff --git a/en/application-dev/reference/native-apis/_a_v_demuxer.md b/en/application-dev/reference/native-apis/_a_v_demuxer.md new file mode 100644 index 0000000000..fb51de7abb --- /dev/null +++ b/en/application-dev/reference/native-apis/_a_v_demuxer.md @@ -0,0 +1,224 @@ +# AVDemuxer + + +## Overview + +The AVDemuxer module provides functions for audio and video decapsulation. + +\@syscap SystemCapability.Multimedia.Media.Spliter + +**Since** + +10 + + +## Summary + + +### File + +| Name| Description| +| -------- | -------- | +| [native_avdemuxer.h](native__avdemuxer_8h.md) | Declares the native APIs used for audio and video decapsulation.
File to include: \ | + + +### Functions + +| Name| Description| +| -------- | -------- | +| \*[OH_AVDemuxer_CreateWithSource](#oh_avdemuxer_createwithsource) (OH_AVSource \*source) | Creates an **OH_AVDemuxer** instance based on an **OH_AVSource** instance.| +| [OH_AVDemuxer_Destroy](#oh_avdemuxer_destroy) (OH_AVDemuxer \*demuxer) | Destroys an **OH_AVDemuxer** instance and clears internal resources.| +| [OH_AVDemuxer_SelectTrackByID](#oh_avdemuxer_selecttrackbyid) (OH_AVDemuxer \*demuxer, uint32_t trackIndex) | Selects a track, from which the demuxer reads data.| +| [OH_AVDemuxer_UnselectTrackByID](#oh_avdemuxer_unselecttrackbyid) (OH_AVDemuxer \*demuxer, uint32_t trackIndex) | Deselects a track. The demuxer no longer reads data from a track after it is deselected.| +| [OH_AVDemuxer_ReadSample](#oh_avdemuxer_readsample) (OH_AVDemuxer \*demuxer, uint32_t trackIndex, OH_AVMemory \*sample, OH_AVCodecBufferAttr \*info) | Obtains the compressed frame and related information at the current position from the selected track.| +| [OH_AVDemuxer_SeekToTime](#oh_avdemuxer_seektotime) (OH_AVDemuxer \*demuxer, int64_t millisecond, OH_AVSeekMode mode) | Seeks to the specified time for all the selected tracks based on a seek mode.| + + +## Function Description + + +### OH_AVDemuxer_CreateWithSource() + + +``` +OH_AVDemuxer* OH_AVDemuxer_CreateWithSource (OH_AVSource * source) +``` + +**Description** + +Creates an **OH_AVDemuxer** instance based on an **OH_AVSource** instance. You can release the instance by calling **OH_AVDemuxer_Destroy**. + +\@syscap SystemCapability.Multimedia.Media.Spliter + +**Parameters** + +| Name| Description| +| -------- | -------- | +| source | Pointer to an **OH_AVSource** instance.| + +**Returns** + +Returns the pointer to an **OH_AVDemuxer** instance. + +**Since** + +10 + + +### OH_AVDemuxer_Destroy() + + +``` +OH_AVErrCode OH_AVDemuxer_Destroy (OH_AVDemuxer * demuxer) +``` + +**Description** + +Destroys an **OH_AVDemuxer** instance and clears internal resources. An instance can be destroyed only once. + +The destroyed instance cannot be used until it is re-created. You are advised to set the pointer to **NULL** after the instance is destroyed. + +\@syscap SystemCapability.Multimedia.Media.Spliter + +**Parameters** + +| Name| Description| +| -------- | -------- | +| demuxer | Pointer to an **OH_AVDemuxer** instance.| + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** + +10 + + +### OH_AVDemuxer_ReadSample() + + +``` +OH_AVErrCode OH_AVDemuxer_ReadSample (OH_AVDemuxer * demuxer, uint32_t trackIndex, OH_AVMemory * sample, OH_AVCodecBufferAttr * info ) +``` + +**Description** + +Obtains the compressed frame and related information at the current position from the selected track. + +You must select a track before reading data. After this API is called, the demuxer automatically proceeds to the next frame. + +\@syscap SystemCapability.Multimedia.Media.Spliter + +**Parameters** + +| Name| Description| +| -------- | -------- | +| demuxer | Pointer to an **OH_AVDemuxer** instance.| +| trackIndex | Index of the track from which the compressed frame is to be read.| +| sample | Pointer to the **OH_AVMemory** instance for storing the compressed frame data.| +| info | Pointer to the **OH_AVCodecBufferAttr** instance for storing the compressed frame information.| + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** + +10 + + +### OH_AVDemuxer_SeekToTime() + + +``` +OH_AVErrCode OH_AVDemuxer_SeekToTime (OH_AVDemuxer * demuxer, int64_t millisecond, OH_AVSeekMode mode ) +``` + +**Description** + +Seeks to the specified time for all the selected tracks based on a seek mode. + +\@syscap SystemCapability.Multimedia.Media.Spliter + +**Parameters** + +| Name| Description| +| -------- | -------- | +| demuxer | Pointer to an **OH_AVDemuxer** instance.| +| millisecond | Time to seek to, in milliseconds. The timestamp is relative to the start position of the file.| +| mode | Seek mode. For details, see **OH_AVSeekMode**.| + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** + +10 + + +### OH_AVDemuxer_SelectTrackByID() + + +``` +OH_AVErrCode OH_AVDemuxer_SelectTrackByID (OH_AVDemuxer * demuxer, uint32_t trackIndex ) +``` + +**Description** + +Selects a track, from which the demuxer reads data. + +You can select multiple tracks by calling this API multiple times, with a different track index passed in each time. + +When **OH_AVDemuxer_ReadSample** is called, only the data in the selected track is read. If the same track is selected multiple times, **AV_ERR_OK** is returned and the API call takes effect only once. + +\@syscap SystemCapability.Multimedia.Media.Spliter + +**Parameters** + +| Name| Description| +| -------- | -------- | +| demuxer | Pointer to an **OH_AVDemuxer** instance.| +| trackIndex | Index of the track.| + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** + +10 + + +### OH_AVDemuxer_UnselectTrackByID() + + +``` +OH_AVErrCode OH_AVDemuxer_UnselectTrackByID (OH_AVDemuxer * demuxer, uint32_t trackIndex ) +``` + +**Description** + +Deselects a track. The demuxer no longer reads data from a track after it is deselected. + +You can deselect multiple tracks by calling this API multiple times, with a different track index passed in each time. + +If the same track is deselected multiple times, **AV_ERR_OK** is returned and the API call takes effect only once. + +\@syscap SystemCapability.Multimedia.Media.Spliter + +**Parameters** + +| Name| Description| +| -------- | -------- | +| demuxer | Pointer to an **OH_AVDemuxer** instance.| +| trackIndex | Index of the track.| + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** + +10 diff --git a/en/application-dev/reference/native-apis/_a_v_muxer.md b/en/application-dev/reference/native-apis/_a_v_muxer.md new file mode 100644 index 0000000000..2f5e17e9d9 --- /dev/null +++ b/en/application-dev/reference/native-apis/_a_v_muxer.md @@ -0,0 +1,251 @@ +# AVMuxer + + +## Overview + +The **AVMuxer** module provides functions for audio and video encapsulation. + +\@syscap SystemCapability.Multimedia.Media.Muxer + +**Since** + +10 + + +## Summary + + +### Files + +| Name| Description| +| -------- | -------- | +| [native_avmuxer.h](native__avmuxer_8h.md) | Declares native APIs used for audio and video encapsulation.
File to include: <multimedia/native_avmuxer.h>| + + +### Functions + +| Name| Description| +| -------- | -------- | +| \*[OH_AVMuxer_Create](#oh_avmuxer_create) (int32_t fd, OH_AVOutputFormat format) | Creates an **OH_AVMuxer** instance by using the file descriptor and encapsulation format.| +| [OH_AVMuxer_SetRotation](#oh_avmuxer_setrotation) (OH_AVMuxer \*muxer, int32_t rotation) | Sets the rotation angle (clockwise) of an output video.| +| [OH_AVMuxer_AddTrack](#oh_avmuxer_addtrack) (OH_AVMuxer \*muxer, int32_t \*trackIndex, OH_AVFormat \*trackFormat) | Adds a media track to the muxer.| +| [OH_AVMuxer_Start](#oh_avmuxer_start) (OH_AVMuxer \*muxer) | Starts encapsulation.| +| [OH_AVMuxer_WriteSample](#oh_avmuxer_writesample) (OH_AVMuxer \*muxer, uint32_t trackIndex, OH_AVMemory \*sample, OH_AVCodecBufferAttr info) | Writes data to the muxer.| +| [OH_AVMuxer_Stop](#oh_avmuxer_stop) (OH_AVMuxer \*muxer) | Stops encapsulation.| +| [OH_AVMuxer_Destroy](#oh_avmuxer_destroy) (OH_AVMuxer \*muxer) | Clears internal resources and destroys an **OH_AVMuxer** instance.| + + +## Function Description + + +### OH_AVMuxer_AddTrack() + + +``` +OH_AVErrCode OH_AVMuxer_AddTrack (OH_AVMuxer * muxer, int32_t * trackIndex, OH_AVFormat * trackFormat ) +``` + +**Description** + +Adds a media track to the muxer. + +This function must be called before **OH_AVMuxer_Start**. + +\@syscap SystemCapability.Multimedia.Media.Muxer + +**Parameters** + + | Name| Description| +| -------- | -------- | +| muxer | Pointer to an **OH_AVMuxer** instance.| +| trackIndex | Pointer to the index of the media track. The index will be used in the **OH_AVMuxer_WriteSample** function. If the media track is added, the index value is greater than or equal to 0; otherwise, the value is less than 0.| +| trackFormat | Pointer to an **OH_AVFormat** instance.| + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode-1) otherwise. + +**Since** + +10 + + +### OH_AVMuxer_Create() + + +``` +OH_AVMuxer* OH_AVMuxer_Create (int32_t fd, OH_AVOutputFormat format ) +``` + +**Description** + +Creates an **OH_AVMuxer** instance by using the file descriptor and encapsulation format. + +\@syscap SystemCapability.Multimedia.Media.Muxer + +**Parameters** + + | Name| Description| +| -------- | -------- | +| fd | File descriptor (FD). You must open the file in read/write mode (O_RDWR) and close the file after using it.| +| format | Format of the encapsulated output file. For details, see [OH_AVOutputFormat](_codec_base.md#oh_avoutputformat).| + +**Returns** + +Returns the pointer to the **OH_AVMuxer** instance created. You must call **OH_AVMuxer_Destroy** to destroy the instance when it is no longer needed. + +**Since** + +10 + + +### OH_AVMuxer_Destroy() + + +``` +OH_AVErrCode OH_AVMuxer_Destroy (OH_AVMuxer * muxer) +``` + +**Description** + +Clears internal resources and destroys an **OH_AVMuxer** instance. + +\@syscap SystemCapability.Multimedia.Media.Muxer + +**Parameters** + + | Name| Description| +| -------- | -------- | +| muxer | Pointer to an **OH_AVMuxer** instance.| + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode-1) otherwise. You must set the muxer to null. + +**Since** + +10 + + +### OH_AVMuxer_SetRotation() + + +``` +OH_AVErrCode OH_AVMuxer_SetRotation (OH_AVMuxer * muxer, int32_t rotation ) +``` + +**Description** + +Sets the rotation angle (clockwise) of an output video. + +This function must be called before **OH_AVMuxer_Start**. + +\@syscap SystemCapability.Multimedia.Media.Muxer + +**Parameters** + + | Name| Description| +| -------- | -------- | +| muxer | Pointer to an **OH_AVMuxer** instance.| +| rotation | Angle to set. The value must be 0, 90, 180, or 270.| + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode-1) otherwise. + +**Since** + +10 + + +### OH_AVMuxer_Start() + + +``` +OH_AVErrCode OH_AVMuxer_Start (OH_AVMuxer * muxer) +``` + +**Description** + +Starts encapsulation. + +This function must be called after **OH_AVMuxer_AddTrack** and before **OH_AVMuxer_WriteSample**. + +\@syscap SystemCapability.Multimedia.Media.Muxer + +**Parameters** + + | Name| Description| +| -------- | -------- | +| muxer | Pointer to an **OH_AVMuxer** instance.| + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode-1) otherwise. + +**Since** + +10 + + +### OH_AVMuxer_Stop() + + +``` +OH_AVErrCode OH_AVMuxer_Stop (OH_AVMuxer * muxer) +``` + +**Description** + +Stops encapsulation. + +Once encapsulation is stopped, it cannot be restarted. + +\@syscap SystemCapability.Multimedia.Media.Muxer + +**Parameters** + + | Name| Description| +| -------- | -------- | +| muxer | Pointer to an **OH_AVMuxer** instance.| + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode-1) otherwise. + +**Since** + +10 + + +### OH_AVMuxer_WriteSample() + + +``` +OH_AVErrCode OH_AVMuxer_WriteSample (OH_AVMuxer * muxer, uint32_t trackIndex, OH_AVMemory * sample, OH_AVCodecBufferAttr info ) +``` + +**Description** + +Writes data to the muxer. + +This function must be called after **OH_AVMuxer_Start** and before **OH_AVMuxer_Stop**. You must ensure that the data is written to the correct media track in ascending order by time. + +\@syscap SystemCapability.Multimedia.Media.Muxer + +**Parameters** + + | Name| Description| +| -------- | -------- | +| muxer | Pointer to an **OH_AVMuxer** instance.| +| trackIndex | Index of the media track corresponding to the data.| +| sample | Pointer to the buffer that stores the data written (data obtained after encoding or decapsulation).| +| info | Information about the data written. For details, see [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md).| + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode-1) otherwise. + +**Since** + +10 diff --git a/en/application-dev/reference/native-apis/_a_v_source.md b/en/application-dev/reference/native-apis/_a_v_source.md new file mode 100644 index 0000000000..5c07b9a923 --- /dev/null +++ b/en/application-dev/reference/native-apis/_a_v_source.md @@ -0,0 +1,187 @@ +# AVSource + + +## Overview + +The AVSource module provides functions for constructing audio and video resource objects. + +\@syscap SystemCapability.Multimedia.Media.Spliter + +**Since** + +10 + + +## Summary + + +### File + +| Name| Description| +| -------- | -------- | +| [native_avsource.h](native__avsource_8h.md) | Declares the native APIs used to construct audio and video resource objects.
File to include: \| + + +### Functions + +| Name| Description| +| -------- | -------- | +| \*[OH_AVSource_CreateWithURI](#oh_avsource_createwithuri) (char \*uri) | Creates an **OH_AVSource** instance based on a URI.| +| \*[OH_AVSource_CreateWithFD](#oh_avsource_createwithfd) (int32_t fd, int64_t offset, int64_t size) | Creates an **OH_AVSource** instance based on a file descriptor (FD).| +| [OH_AVSource_Destroy](#oh_avsource_destroy) (OH_AVSource \*source) | Destroys an **OH_AVSource** instance and clears internal resources. An instance can be destroyed only once.| +| \*[OH_AVSource_GetSourceFormat](#oh_avsource_getsourceformat) (OH_AVSource \*source) | Obtains the basic information about a media resource.| +| \*[OH_AVSource_GetTrackFormat](#oh_avsource_gettrackformat) (OH_AVSource \*source, uint32_t trackIndex) | Obtains the basic information about a track.| + + +## Function Description + + +### OH_AVSource_CreateWithFD() + + +``` +OH_AVSource* OH_AVSource_CreateWithFD (int32_t fd, int64_t offset, int64_t size ) +``` + +**Description** + +Creates an **OH_AVSource** instance based on an FD. + +You can release the instance by calling **OH_AVSource_Destroy**. + +If **offset** is not the start position of the file or **size** is not the file size, undefined errors such as creation failure and decapsulation failure may occur due to incomplete data obtained. + +\@syscap SystemCapability.Multimedia.Media.Spliter + +**Parameters** + +| Name| Description| +| -------- | -------- | +| fd | FD of a media resource file.| +| offset | Position from which data is to read.| +| size | File size, in bytes.| + +**Returns** + +Returns the pointer to an **OH_AVSource** instance. + +**Since** + +10 + + +### OH_AVSource_CreateWithURI() + + +``` +OH_AVSource* OH_AVSource_CreateWithURI (char * uri) +``` + +**Description** + +Create an **OH_AVSource** instance object based on a URI. You can release the instance by calling **OH_AVSource_Destroy**. + +\@syscap SystemCapability.Multimedia.Media.Spliter + +**Parameters** + +| Name| Description| +| -------- | -------- | +| uri | URI of the media resource.| + +**Returns** + +Returns the pointer to an **OH_AVSource** instance. + +**Since** + +10 + + +### OH_AVSource_Destroy() + + +``` +OH_AVErrCode OH_AVSource_Destroy (OH_AVSource * source) +``` + +**Description** + +Destroys an **OH_AVSource** instance and clears internal resources. + +An instance can be destroyed only once. + +The destroyed instance cannot be used until it is re-created. You are advised to set the pointer to **NULL** after the instance is destroyed. + +\@syscap SystemCapability.Multimedia.Media.Spliter + +**Parameters** + +| Name| Description| +| -------- | -------- | +| source | Pointer to an **OH_AVSource** instance.| + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** + +10 + + +### OH_AVSource_GetSourceFormat() + + +``` +OH_AVFormat* OH_AVSource_GetSourceFormat (OH_AVSource * source) +``` + +**Description** + +Obtains the basic information about a media resource. + +\@syscap SystemCapability.Multimedia.Media.Spliter + +**Parameters** + +| Name| Description| +| -------- | -------- | +| source | Pointer to an **OH_AVSource** instance.| + +**Returns** + +Returns the basic information obtained. + +**Since** + +10 + + +### OH_AVSource_GetTrackFormat() + + +``` +OH_AVFormat* OH_AVSource_GetTrackFormat (OH_AVSource * source, uint32_t trackIndex ) +``` + +**Description** + +Obtains the basic information about a track. + +\@syscap SystemCapability.Multimedia.Media.Spliter + +**Parameters** + +| Name| Description| +| -------- | -------- | +| source | Pointer to an **OH_AVSource** instance.| +| trackIndex | Index of the track whose information is to be obtained.| + +**Returns** + +Returns the basic information obtained. + +**Since** + +10 diff --git a/en/application-dev/reference/native-apis/_audio_decoder.md b/en/application-dev/reference/native-apis/_audio_decoder.md index 73487fa40d..05b527261f 100644 --- a/en/application-dev/reference/native-apis/_audio_decoder.md +++ b/en/application-dev/reference/native-apis/_audio_decoder.md @@ -3,41 +3,114 @@ ## Overview -Provides the functions for audio decoding. This module may not be supported on some devices. You can call [CanIUse](../syscap.md) to check whether this module is supported on your device. +The **AudioDecoder** module provides the functions for audio decoding. This module may not be supported on some devices. You can call [CanIUse](../syscap.md) to check whether your device supports this module. -@syscap SystemCapability.Multimedia.Media.AudioDecoder +\@syscap SystemCapability.Multimedia.Media.AudioDecoder **Since** + 9 + ## Summary ### Files - | Name| Description| +| Name| Description| | -------- | -------- | -| [native_avcodec_audiodecoder.h](native__avcodec__audiodecoder_8h.md) | Declares the native APIs used for audio decoding.
File to include: | +| [native_avcodec_audiodecoder.h](native__avcodec__audiodecoder_8h.md) | Declares the native APIs used for audio decoding.
File to include: | +| [avcodec_audio_channel_layout.h](avcodec__audio__channel__layout_8h.md) | Declares the enums used for audio codec.
File to include: \| + + +### Enums + +| Name| Description| +| -------- | -------- | +| [OHOS::Media::AudioChannelSet](#audiochannelset) : uint64_t {
**FRONT_LEFT** = 1ULL << 0U, **FRONT_RIGHT** = 1ULL << 1U, **FRONT_CENTER** = 1ULL << 2U, **LOW_FREQUENCY** = 1ULL << 3U,
**BACK_LEFT** = 1ULL << 4U, **BACK_RIGHT** = 1ULL << 5U, **FRONT_LEFT_OF_CENTER** = 1ULL << 6U, **FRONT_RIGHT_OF_CENTER** = 1ULL << 7U,
**BACK_CENTER** = 1ULL << 8U, **SIDE_LEFT** = 1ULL << 9U, **SIDE_RIGHT** = 1ULL << 10U, **TOP_CENTER** = 1ULL << 11U,
**TOP_FRONT_LEFT** = 1ULL << 12U, **TOP_FRONT_CENTER** = 1ULL << 13U, **TOP_FRONT_RIGHT** = 1ULL << 14U, **TOP_BACK_LEFT** = 1ULL << 15U,
**TOP_BACK_CENTER** = 1ULL << 16U, **TOP_BACK_RIGHT** = 1ULL << 17U, **STEREO_LEFT** = 1ULL << 29U, **STEREO_RIGHT** = 1ULL << 30U,
**WIDE_LEFT** = 1ULL << 31U, **WIDE_RIGHT** = 1ULL << 32U, **SURROUND_DIRECT_LEFT** = 1ULL << 33U, **SURROUND_DIRECT_RIGHT** = 1ULL << 34U,
**LOW_FREQUENCY_2** = 1ULL << 35U, **TOP_SIDE_LEFT** = 1ULL << 36U, **TOP_SIDE_RIGHT** = 1ULL << 37U, **BOTTOM_FRONT_CENTER** = 1ULL << 38U,
**BOTTOM_FRONT_LEFT** = 1ULL << 39U, **BOTTOM_FRONT_RIGHT** = 1ULL << 40U, **AMBISONICS_ACN0** = 1ULL << 41U, OHOS::Media::AMBISONICS_ACN1 = 1ULL << 42U,
OHOS::Media::AMBISONICS_ACN2 = 1ULL << 43U, OHOS::Media::AMBISONICS_ACN3 = 1ULL << 44U, OHOS::Media::AMBISONICS_W = AMBISONICS_ACN0, OHOS::Media::AMBISONICS_Y = AMBISONICS_ACN1,
OHOS::Media::AMBISONICS_Z = AMBISONICS_ACN2, OHOS::Media::AMBISONICS_X = AMBISONICS_ACN3, OHOS::Media::AMBISONICS_ACN4 = 1ULL << 45U, OHOS::Media::AMBISONICS_ACN5 = 1ULL << 46U,
OHOS::Media::AMBISONICS_ACN6 = 1ULL << 47U, OHOS::Media::AMBISONICS_ACN7 = 1ULL << 48U, OHOS::Media::AMBISONICS_ACN8 = 1ULL << 49U, OHOS::Media::AMBISONICS_ACN9 = 1ULL << 50U,
OHOS::Media::AMBISONICS_ACN10 = 1ULL << 51U, OHOS::Media::AMBISONICS_ACN11 = 1ULL << 52U, OHOS::Media::AMBISONICS_ACN12 = 1ULL << 53U, OHOS::Media::AMBISONICS_ACN13 = 1ULL << 54U,
OHOS::Media::AMBISONICS_ACN14 = 1ULL << 55U, OHOS::Media::AMBISONICS_ACN15 = 1ULL << 56U
} | Enumerates the audio channel numbers. Each channel number is mapped to a variable of int64.| +| [OHOS::Media::AudioChannelLayout](#audiochannellayout) : uint64_t {
**UNKNOWN_CHANNEL_LAYOUT** = 0, **MONO** = (AudioChannelSet::FRONT_CENTER), **STEREO** = (AudioChannelSet::FRONT_LEFT \| AudioChannelSet::FRONT_RIGHT), **CH_2POINT1** = (STEREO \| AudioChannelSet::LOW_FREQUENCY),
**CH_2_1** = (STEREO \| AudioChannelSet::BACK_CENTER), **SURROUND** = (STEREO \| AudioChannelSet::FRONT_CENTER), **CH_3POINT1** = (SURROUND \| AudioChannelSet::LOW_FREQUENCY), **CH_4POINT0** = (SURROUND \| AudioChannelSet::BACK_CENTER),
**CH_4POINT1** = (CH_4POINT0 \| AudioChannelSet::LOW_FREQUENCY), **CH_2_2** = (STEREO \| AudioChannelSet::SIDE_LEFT \| AudioChannelSet::SIDE_RIGHT), **QUAD** = (STEREO \| AudioChannelSet::BACK_LEFT \| AudioChannelSet::BACK_RIGHT), **CH_5POINT0** = (SURROUND \| AudioChannelSet::SIDE_LEFT \| AudioChannelSet::SIDE_RIGHT),
**CH_5POINT1** = (CH_5POINT0 \| AudioChannelSet::LOW_FREQUENCY), **CH_5POINT0_BACK** = (SURROUND \| AudioChannelSet::BACK_LEFT \| AudioChannelSet::BACK_RIGHT), **CH_5POINT1_BACK** = (CH_5POINT0_BACK \| AudioChannelSet::LOW_FREQUENCY), **CH_6POINT0** = (CH_5POINT0 \| AudioChannelSet::BACK_CENTER),
**CH_6POINT0_FRONT** = (CH_2_2 \| AudioChannelSet::FRONT_LEFT_OF_CENTER \| AudioChannelSet::FRONT_RIGHT_OF_CENTER), **HEXAGONAL** = (CH_5POINT0_BACK \| AudioChannelSet::BACK_CENTER), **CH_6POINT1** = (CH_5POINT1 \| AudioChannelSet::BACK_CENTER), **CH_6POINT1_BACK** = (CH_5POINT1_BACK \| AudioChannelSet::BACK_CENTER),
**CH_6POINT1_FRONT** = (CH_6POINT0_FRONT \| AudioChannelSet::LOW_FREQUENCY), **CH_7POINT0** = (CH_5POINT0 \| AudioChannelSet::BACK_LEFT \| AudioChannelSet::BACK_RIGHT), **CH_7POINT0_FRONT** = (CH_5POINT0 \| AudioChannelSet::FRONT_LEFT_OF_CENTER \| AudioChannelSet::FRONT_RIGHT_OF_CENTER), **CH_7POINT1** = (CH_5POINT1 \| AudioChannelSet::BACK_LEFT \| AudioChannelSet::BACK_RIGHT),
**CH_7POINT1_WIDE** = (CH_5POINT1 \| AudioChannelSet::FRONT_LEFT_OF_CENTER \| AudioChannelSet::FRONT_RIGHT_OF_CENTER), **CH_7POINT1_WIDE_BACK**, **CH_3POINT1POINT2** = (CH_3POINT1 \| AudioChannelSet::TOP_FRONT_LEFT \| AudioChannelSet::TOP_FRONT_RIGHT), **CH_5POINT1POINT2** = (CH_5POINT1 \| AudioChannelSet::TOP_SIDE_LEFT \| AudioChannelSet::TOP_SIDE_RIGHT),
**CH_5POINT1POINT4**, **CH_7POINT1POINT2** = (CH_7POINT1 \| AudioChannelSet::TOP_SIDE_LEFT \| AudioChannelSet::TOP_SIDE_RIGHT), **CH_7POINT1POINT4**, **CH_9POINT1POINT4** = (CH_7POINT1POINT4 \| AudioChannelSet::WIDE_LEFT \| AudioChannelSet::WIDE_RIGHT),
**CH_9POINT1POINT6** = (CH_9POINT1POINT4 \| AudioChannelSet::TOP_SIDE_LEFT \| AudioChannelSet::TOP_SIDE_RIGHT), **CH_10POINT2**, **CH_22POINT2**, **OCTAGONAL** = (CH_5POINT0 \| AudioChannelSet::BACK_LEFT \| AudioChannelSet::BACK_CENTER \| AudioChannelSet::BACK_RIGHT),
**HEXADECAGONAL**, **STEREO_DOWNMIX** = (AudioChannelSet::STEREO_LEFT \| AudioChannelSet::STEREO_RIGHT), **HOA_FIRST**, **HOA_SECOND**,
**HOA_THIRD**
} | Enumerates the types of the audio channel numbers. The output format of the decoder is represented as the channel type of the codec.| ### Functions - | Name| Description| +| Name| Description| +| -------- | -------- | +| \*[OHOS::Media::OH_AudioDecoder_CreateByMime](#oh_audiodecoder_createbymime) (const char \*mime) | Creates an audio decoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This function is recommended in most cases.| +| \*[OHOS::Media::OH_AudioDecoder_CreateByName](#oh_audiodecoder_createbyname) (const char \*name) | Creates an audio decoder instance based on a decoder name. To use this function, you must know the exact name of the decoder.| +| [OHOS::Media::OH_AudioDecoder_Destroy](#oh_audiodecoder_destroy) (OH_AVCodec \*codec) | Clears the internal resources of an audio decoder and destroys the decoder instance.| +| [OHOS::Media::OH_AudioDecoder_SetCallback](#oh_audiodecoder_setcallback) (OH_AVCodec \*codec, OH_AVCodecAsyncCallback callback, void \*userData) | Sets an asynchronous callback so that your application can respond to events generated by an audio decoder.| +| [OHOS::Media::OH_AudioDecoder_Configure](#oh_audiodecoder_configure) (OH_AVCodec \*codec, OH_AVFormat \*format) | Configures an audio decoder. Typically, you need to configure the audio description information that can be extracted from the container.| +| [OHOS::Media::OH_AudioDecoder_Prepare](#oh_audiodecoder_prepare) (OH_AVCodec \*codec) | Prepares internal resources for an audio decoder. This function must be called after **Configure**.| +| [OHOS::Media::OH_AudioDecoder_Start](#oh_audiodecoder_start) (OH_AVCodec \*codec) | Starts an audio decoder. This function can be called only after the decoder is prepared successfully.| +| [OHOS::Media::OH_AudioDecoder_Stop](#oh_audiodecoder_stop) (OH_AVCodec \*codec) | Stops an audio decoder.| +| [OHOS::Media::OH_AudioDecoder_Flush](#oh_audiodecoder_flush) (OH_AVCodec \*codec) | Clears the input and output data in the internal buffer of an audio decoder.| +| [OHOS::Media::OH_AudioDecoder_Reset](#oh_audiodecoder_reset) (OH_AVCodec \*codec) | Resets an audio decoder. To continue decoding, you must call **Configure** to configure the decoder again.| +| \*[OHOS::Media::OH_AudioDecoder_GetOutputDescription](#oh_audiodecoder_getoutputdescription) (OH_AVCodec \*codec) | Obtains the description information about the output data of an audio decoder. For details, see **OH_AVFormat**.| +| [OHOS::Media::OH_AudioDecoder_SetParameter](#oh_audiodecoder_setparameter) (OH_AVCodec \*codec, OH_AVFormat \*format) | Sets dynamic parameters for an audio decoder. This function can be called only after the decoder is started. Incorrect parameter settings may cause decoding failure.| +| [OHOS::Media::OH_AudioDecoder_PushInputData](#oh_audiodecoder_pushinputdata) (OH_AVCodec \*codec, uint32_t index, OH_AVCodecBufferAttr attr) | Pushes the input buffer filled with data to an audio decoder.| +| [OHOS::Media::OH_AudioDecoder_FreeOutputData](#oh_audiodecoder_freeoutputdata) (OH_AVCodec \*codec, uint32_t index) | Frees an output buffer of an audio decoder.| +| [OHOS::Media::OH_AudioDecoder_IsValid](#oh_audiodecoder_isvalid) (OH_AVCodec \*codec, bool \*isValid) | Checks whether an audio decoder instance is valid.| + + +## Enum Description + + +### AudioChannelLayout + + +``` +enum OHOS::Media::AudioChannelLayout : uint64_t +``` + +**Description** + +Enumerates the types of the audio channel numbers. The output format of the decoder is represented as the channel type of the codec. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + +**Since** + +10 + + +### AudioChannelSet + + +``` +enum OHOS::Media::AudioChannelSet : uint64_t +``` + +**Description** + +Enumerates the audio channel numbers. Each channel number is mapped to a variable of int64. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + +**Since** + +10 + +| Value| Description| | -------- | -------- | -| [OH_AudioDecoder_CreateByMime](#oh_audiodecoder_createbymime) (const char \*mime) | Creates an audio decoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases. | -| [OH_AudioDecoder_CreateByName](#oh_audiodecoder_createbyname) (const char \*name) | Creates an audio decoder instance based on an audio decoder name. To use this API, you must know the exact name of the audio decoder. | -| [OH_AudioDecoder_Destroy](#oh_audiodecoder_destroy) (OH_AVCodec \*codec) | Clears the internal resources of an audio decoder and destroys the audio decoder instance. | -| [OH_AudioDecoder_SetCallback](#oh_audiodecoder_setcallback) (OH_AVCodec \*codec, [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) callback, void \*userData) | Sets an asynchronous callback so that your application can respond to events generated by an audio decoder. This API must be called prior to **Prepare**. | -| [OH_AudioDecoder_Configure](#oh_audiodecoder_configure) (OH_AVCodec \*codec, OH_AVFormat \*format) | Configures an audio decoder. Typically, you need to configure the attributes, which can be extracted from the container, of the audio track that can be decoded. This API must be called prior to **Prepare**. | -| [OH_AudioDecoder_Prepare](#oh_audiodecoder_prepare) (OH_AVCodec \*codec) | Prepares internal resources for an audio decoder. This API must be called after **Configure**. | -| [OH_AudioDecoder_Start](#oh_audiodecoder_start) (OH_AVCodec \*codec) | Starts an audio decoder. This API can be called only after the decoder is prepared successfully. After being started, the decoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. | -| [OH_AudioDecoder_Stop](#oh_audiodecoder_stop) (OH_AVCodec \*codec) | Stops an audio decoder. After the decoder is stopped, you can call **Start** to start it again. If you have passed codec-specific data in the previous **Start** for the decoder, you must pass it again. | -| [OH_AudioDecoder_Flush](#oh_audiodecoder_flush) (OH_AVCodec \*codec) | Clears the input and output data in the internal buffer of an audio decoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. | -| [OH_AudioDecoder_Reset](#oh_audiodecoder_reset) (OH_AVCodec \*codec) | Resets an audio decoder. To continue decoding, you must call **Configure** and **Start** to configure and start the decoder again. | -| [OH_AudioDecoder_GetOutputDescription](#oh_audiodecoder_getoutputdescription) (OH_AVCodec \*codec) | Obtains the attributes of the output data of an audio decoder. The caller must manually release the **OH_AVFormat** instance in the return value. | -| [OH_AudioDecoder_SetParameter](#oh_audiodecoder_setparameter) (OH_AVCodec \*codec, OH_AVFormat \*format) | Sets dynamic parameters for an audio decoder. This API can be called only after the decoder is started. Incorrect parameter settings may cause decoding failure. | -| [OH_AudioDecoder_PushInputData](#oh_audiodecoder_pushinputdata) (OH_AVCodec \*codec, uint32_t index, [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) attr) | Pushes the input buffer filled with data to an audio decoder. The [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback reports available input buffers and their indexes. After being pushed to the decoder, a buffer is not accessible until the buffer with the same index is reported again through the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback. In addition, some decoders require the input of codec-specific data to initialize the decoding process. | -| [OH_AudioDecoder_FreeOutputData](#oh_audiodecoder_freeoutputdata) (OH_AVCodec \*codec, uint32_t index) | Frees an output buffer of an audio decoder. | +| AMBISONICS_ACN1 | Channel 0 for the zero-order stereo.| +| AMBISONICS_ACN2 | Channel 1 for the first-order stereo.| +| AMBISONICS_ACN3 | Channel 2 for the first-order stereo.| +| AMBISONICS_W | Channel 3 for the first-order stereo.| +| AMBISONICS_Y | Equivalent to channel 0 for the zero-order stereo.| +| AMBISONICS_Z | Equivalent to channel 1 for the first-order stereo.| +| AMBISONICS_X | Equivalent to channel 2 for the first-order stereo.| +| AMBISONICS_ACN4 | Equivalent to channel 3 for the first-order stereo.| +| AMBISONICS_ACN5 | Channel 4 for the second-order stereo.| +| AMBISONICS_ACN6 | Channel 5 for the second-order stereo.| +| AMBISONICS_ACN7 | Channel 6 for the second-order stereo.| +| AMBISONICS_ACN8 | Channel 7 for the second-order stereo.| +| AMBISONICS_ACN9 | Channel 8 for the second-order stereo.| +| AMBISONICS_ACN10 | Channel 9 for the third-order stereo.| +| AMBISONICS_ACN11 | Channel 10 for the third-order stereo.| +| AMBISONICS_ACN12 | Channel 11 for the third-order stereo.| +| AMBISONICS_ACN13 | Channel 12 for the third-order stereo.| +| AMBISONICS_ACN14 | Channel 13 for the third-order stereo.| +| AMBISONICS_ACN15 | Channel 14 for the third-order stereo.| ## Function Description @@ -47,334 +120,439 @@ Provides the functions for audio decoding. This module may not be supported on s ``` -OH_AVErrCode OH_AudioDecoder_Configure (OH_AVCodec * codec, OH_AVFormat * format ) +OH_AVErrCode OHOS::Media::OH_AudioDecoder_Configure (OH_AVCodec * codec, OH_AVFormat * format ) ``` -**Description**
-Configures an audio decoder. Typically, you need to configure the attributes, which can be extracted from the container, of the audio track that can be decoded. This API must be called prior to **Prepare**. -@syscap SystemCapability.Multimedia.Media.AudioDecoder +**Description** + +Configures an audio decoder. Typically, you need to configure the audio description information that can be extracted from the container. + +This function must be called prior to **Prepare**. + +\@syscap SystemCapability.Multimedia.Media.AudioDecoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| format | Indicates the handle to an **OH_AVFormat** instance, which provides the attributes of the audio track to be decoded. | +| codec | Pointer to an **OH_AVCodec** instance.| +| format | Pointer to the **OH_AVFormat** instance, which provides the description information about the audio track to be decoded.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +**Since** + +9 ### OH_AudioDecoder_CreateByMime() ``` -OH_AVCodec* OH_AudioDecoder_CreateByMime (const char * mime) +OH_AVCodec* OHOS::Media::OH_AudioDecoder_CreateByMime (const char * mime) ``` -**Description**
-Creates an audio decoder instance based on a MIME type. This API is recommended in most cases. -@syscap SystemCapability.Multimedia.Media.AudioDecoder +**Description** + +Creates an audio decoder instance based on a MIME type. This function is recommended in most cases. + +\@syscap SystemCapability.Multimedia.Media.AudioDecoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| mime | Indicates the pointer to a MIME type. For details, see [OH_AVCODEC_MIMETYPE_AUDIO_AAC](_codec_base.md#oh_avcodec_mimetype_audio_aac).| +| mime | Pointer to a string that describes the MIME type. For details, see **AVCODEC_MIME_TYPE**.| **Returns** Returns the pointer to an **OH_AVCodec** instance. +**Since** + +9 + ### OH_AudioDecoder_CreateByName() ``` -OH_AVCodec* OH_AudioDecoder_CreateByName (const char * name) +OH_AVCodec* OHOS::Media::OH_AudioDecoder_CreateByName (const char * name) ``` -**Description**
-Creates an audio decoder instance based on an audio decoder name. To use this API, you must know the exact name of the audio decoder. -@syscap SystemCapability.Multimedia.Media.AudioDecoder +**Description** + +Creates an audio decoder instance based on a decoder name. To use this function, you must know the exact name of the decoder. + +\@syscap SystemCapability.Multimedia.Media.AudioDecoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| name | Indicates the pointer to an audio decoder name. | +| name | Pointer to an audio decoder name.| **Returns** Returns the pointer to an **OH_AVCodec** instance. +**Since** + +9 + ### OH_AudioDecoder_Destroy() ``` -OH_AVErrCode OH_AudioDecoder_Destroy (OH_AVCodec * codec) +OH_AVErrCode OHOS::Media::OH_AudioDecoder_Destroy (OH_AVCodec * codec) ``` -**Description**
-Clears the internal resources of an audio decoder and destroys the audio decoder instance. -@syscap SystemCapability.Multimedia.Media.AudioDecoder +**Description** + +Clears the internal resources of an audio decoder and destroys the decoder instance. + +\@syscap SystemCapability.Multimedia.Media.AudioDecoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Pointer to an **OH_AVCodec** instance.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +9 ### OH_AudioDecoder_Flush() ``` -OH_AVErrCode OH_AudioDecoder_Flush (OH_AVCodec * codec) +OH_AVErrCode OHOS::Media::OH_AudioDecoder_Flush (OH_AVCodec * codec) ``` -**Description**
-Clears the input and output data in the internal buffer of an audio decoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. -@syscap SystemCapability.Multimedia.Media.AudioDecoder +**Description** + +Clears the input and output data in the internal buffer of an audio decoder. + +This function invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this function, ensure that the buffers with the specified indexes are no longer required. + +\@syscap SystemCapability.Multimedia.Media.AudioDecoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Pointer to an **OH_AVCodec** instance.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +9 ### OH_AudioDecoder_FreeOutputData() ``` -OH_AVErrCode OH_AudioDecoder_FreeOutputData (OH_AVCodec * codec, uint32_t index ) +OH_AVErrCode OHOS::Media::OH_AudioDecoder_FreeOutputData (OH_AVCodec * codec, uint32_t index ) ``` -**Description**
+ +**Description** + Frees an output buffer of an audio decoder. -@syscap SystemCapability.Multimedia.Media.AudioDecoder +\@syscap SystemCapability.Multimedia.Media.AudioDecoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| index | Indicates the index of an output buffer. | +| codec | Pointer to an **OH_AVCodec** instance.| +| index | Index of the output buffer.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +**Since** + +9 ### OH_AudioDecoder_GetOutputDescription() ``` -OH_AVFormat* OH_AudioDecoder_GetOutputDescription (OH_AVCodec * codec) +OH_AVFormat* OHOS::Media::OH_AudioDecoder_GetOutputDescription (OH_AVCodec * codec) ``` -**Description**
-Obtains the attributes of the output data of an audio decoder. The caller must manually release the **OH_AVFormat** instance in the return value. -@syscap SystemCapability.Multimedia.Media.AudioDecoder +**Description** + +Obtains the description information about the output data of an audio decoder. For details, see **OH_AVFormat**. The caller must manually release the **OH_AVFormat** instance in the return value. + +\@syscap SystemCapability.Multimedia.Media.AudioDecoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Pointer to an **OH_AVCodec** instance.| **Returns** -Returns the handle to an **OH_AVFormat** instance, which must be manually released. +Returns the handle to an **OH_AVFormat** instance. The lifecycle of this instance is refreshed when **GetOutputDescription** is called again and destroyed when the **OH_AVCodec** instance is destroyed. + +**Since** + +9 + + +### OH_AudioDecoder_IsValid() + + +``` +OH_AVErrCode OHOS::Media::OH_AudioDecoder_IsValid (OH_AVCodec * codec, bool * isValid ) +``` + +**Description** + +Checks whether an audio decoder instance is valid. + +\@syscap SystemCapability.Multimedia.Media.AudioDecoder + +**Parameters** + +| Name| Description| +| -------- | -------- | +| codec | Pointer to an **OH_AVCodec** instance.| +| isValid | Pointer to an instance of the Boolean type. The value **true** means that the decoder instance is valid and **false** means the opposite.| + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** + +10 ### OH_AudioDecoder_Prepare() ``` -OH_AVErrCode OH_AudioDecoder_Prepare (OH_AVCodec * codec) +OH_AVErrCode OHOS::Media::OH_AudioDecoder_Prepare (OH_AVCodec * codec) ``` -**Description**
-Prepares internal resources for an audio decoder. This API must be called after **Configure**. -@syscap SystemCapability.Multimedia.Media.AudioDecoder +**Description** + +Prepares internal resources for an audio decoder. This function must be called after **Configure**. + +\@syscap SystemCapability.Multimedia.Media.AudioDecoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Pointer to an **OH_AVCodec** instance.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +9 ### OH_AudioDecoder_PushInputData() ``` -OH_AVErrCode OH_AudioDecoder_PushInputData (OH_AVCodec * codec, uint32_t index, OH_AVCodecBufferAttr attr ) +OH_AVErrCode OHOS::Media::OH_AudioDecoder_PushInputData (OH_AVCodec * codec, uint32_t index, OH_AVCodecBufferAttr attr ) ``` -**Description**
-Pushes the input buffer filled with data to an audio decoder. The [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback reports available input buffers and their indexes. After being pushed to the decoder, a buffer is not accessible until the buffer with the same index is reported again through the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback. In addition, some decoders require the input of codec-specific data to initialize the decoding process. -@syscap SystemCapability.Multimedia.Media.AudioDecoder +**Description** + +Pushes the input buffer filled with data to an audio decoder. + +The **OH_AVCodecOnNeedInputData** callback reports the available input buffer and the index. After being pushed to the decoder, a buffer is not accessible until the buffer with the same index is reported again through the **OH_AVCodecOnNeedInputData** callback. In addition, some decoders require the input of specific data to initialize the decoding process. + +\@syscap SystemCapability.Multimedia.Media.AudioDecoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| index | Indicates the index of an input buffer. | -| attr | Indicates the attributes of the data contained in the buffer. | +| codec | Pointer to an **OH_AVCodec** instance.| +| index | Index of the input buffer.| +| attr | Description information about the data in the buffer.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +**Since** + +9 ### OH_AudioDecoder_Reset() ``` -OH_AVErrCode OH_AudioDecoder_Reset (OH_AVCodec * codec) +OH_AVErrCode OHOS::Media::OH_AudioDecoder_Reset (OH_AVCodec * codec) ``` -**Description**
-Resets an audio decoder. To continue decoding, you must call **Configure** and **Start** to configure and start the decoder again. -@syscap SystemCapability.Multimedia.Media.AudioDecoder +**Description** + +Resets an audio decoder. To continue decoding, you must call **Configure** to configure the decoder again. + +\@syscap SystemCapability.Multimedia.Media.AudioDecoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Pointer to an **OH_AVCodec** instance.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +9 ### OH_AudioDecoder_SetCallback() ``` -OH_AVErrCode OH_AudioDecoder_SetCallback (OH_AVCodec * codec, OH_AVCodecAsyncCallback callback, void * userData ) +OH_AVErrCode OHOS::Media::OH_AudioDecoder_SetCallback (OH_AVCodec * codec, OH_AVCodecAsyncCallback callback, void * userData ) ``` -**Description**
-Sets an asynchronous callback so that your application can respond to events generated by an audio decoder. This API must be called prior to **Prepare**. -@syscap SystemCapability.Multimedia.Media.AudioDecoder +**Description** + +Sets an asynchronous callback so that your application can respond to events generated by an audio decoder. + +This function must be called prior to **Prepare**. + +\@syscap SystemCapability.Multimedia.Media.AudioDecoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| callback | Indicates a collection of all callback functions. For details, see [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md).| -| userData | Indicates the pointer to user-specific data. | +| codec | Pointer to an **OH_AVCodec** instance.| +| callback | Callback function to set. For details, see **OH_AVCodecAsyncCallback**.| +| userData | User-specific data.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +9 ### OH_AudioDecoder_SetParameter() ``` -OH_AVErrCode OH_AudioDecoder_SetParameter (OH_AVCodec * codec, OH_AVFormat * format ) +OH_AVErrCode OHOS::Media::OH_AudioDecoder_SetParameter (OH_AVCodec * codec, OH_AVFormat * format ) ``` -**Description**
-Sets dynamic parameters for an audio decoder. This API can be called only after the decoder is started. Incorrect parameter settings may cause decoding failure. -@syscap SystemCapability.Multimedia.Media.AudioDecoder +**Description** + +Sets dynamic parameters for an audio decoder. + +This function can be called only after the decoder is started. Incorrect parameter settings may cause decoding failure. + +\@syscap SystemCapability.Multimedia.Media.AudioDecoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| format | Indicates the handle to an **OH_AVFormat** instance. | +| codec | Pointer to an **OH_AVCodec** instance.| +| format | Handle to an **OH_AVFormat** instance.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +9 ### OH_AudioDecoder_Start() ``` -OH_AVErrCode OH_AudioDecoder_Start (OH_AVCodec * codec) +OH_AVErrCode OHOS::Media::OH_AudioDecoder_Start (OH_AVCodec * codec) ``` -**Description**
-Starts an audio decoder. This API can be called only after the decoder is prepared successfully. After being started, the decoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. -@syscap SystemCapability.Multimedia.Media.AudioDecoder +**Description** + +Starts an audio decoder. This function can be called only after the decoder is prepared successfully. + +After being started, the decoder starts to report the **OH_AVCodecOnNeedInputData** event. + +\@syscap SystemCapability.Multimedia.Media.AudioDecoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Pointer to an **OH_AVCodec** instance.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +9 ### OH_AudioDecoder_Stop() ``` -OH_AVErrCode OH_AudioDecoder_Stop (OH_AVCodec * codec) +OH_AVErrCode OHOS::Media::OH_AudioDecoder_Stop (OH_AVCodec * codec) ``` -**Description**
-Stops an audio decoder. After the decoder is stopped, you can call **Start** to start it again. If you have passed codec-specific data in the previous **Start** for the decoder, you must pass it again. -@syscap SystemCapability.Multimedia.Media.AudioDecoder +**Description** + +Stops an audio decoder. + +After the decoder is stopped, you can call **Start** to start it again. If you have passed specific data in the previous **Start** for the decoder, you must pass it again. + +\@syscap SystemCapability.Multimedia.Media.AudioDecoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Pointer to an **OH_AVCodec** instance.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +9 diff --git a/en/application-dev/reference/native-apis/_audio_encoder.md b/en/application-dev/reference/native-apis/_audio_encoder.md index cf621c755c..2fe3afb0f7 100644 --- a/en/application-dev/reference/native-apis/_audio_encoder.md +++ b/en/application-dev/reference/native-apis/_audio_encoder.md @@ -3,41 +3,44 @@ ## Overview -Provides the functions for audio encoding. This module may not be supported on some devices. You can call [CanIUse](../syscap.md) to check whether this module is supported on your device. +The **AudioEncoder** module provides the functions for audio encoding. This module may not be supported on some devices. You can call [CanIUse](../syscap.md) to check whether your device supports this module. -@syscap SystemCapability.Multimedia.Media.AudioEncoder +\@syscap SystemCapability.Multimedia.Media.AudioEncoder **Since** + 9 + ## Summary ### Files - | Name| Description| +| Name| Description| | -------- | -------- | | [native_avcodec_audioencoder.h](native__avcodec__audioencoder_8h.md) | Declares the native APIs used for audio encoding.
File to include: | ### Functions - | Name| Description| +| Name| Description| | -------- | -------- | -| [OH_AudioEncoder_CreateByMime](#oh_audioencoder_createbymime) (const char \*mime) | Creates an audio encoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases. | -| [OH_AudioEncoder_CreateByName](#oh_audioencoder_createbyname) (const char \*name) | Creates an audio encoder instance based on an audio encoder name. To use this API, you must know the exact name of the audio encoder. | -| [OH_AudioEncoder_Destroy](#oh_audioencoder_destroy) (OH_AVCodec \*codec) | Clears the internal resources of an audio encoder and destroys the audio encoder instance. | -| [OH_AudioEncoder_SetCallback](#oh_audioencoder_setcallback) (OH_AVCodec \*codec, [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) callback, void \*userData) | Sets an asynchronous callback so that your application can respond to events generated by an audio encoder. This API must be called prior to **Prepare**. | -| [OH_AudioEncoder_Configure](#oh_audioencoder_configure) (OH_AVCodec \*codec, OH_AVFormat \*format) | Configures an audio encoder. Typically, you need to configure the attributes of the audio track that can be encoded. This API must be called prior to **Prepare**. | -| [OH_AudioEncoder_Prepare](#oh_audioencoder_prepare) (OH_AVCodec \*codec) | Prepares internal resources for an audio encoder. This API must be called after **Configure**. | -| [OH_AudioEncoder_Start](#oh_audioencoder_start) (OH_AVCodec \*codec) | Starts an audio encoder. This API can be called only after the encoder is prepared successfully. After being started, the encoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. | -| [OH_AudioEncoder_Stop](#oh_audioencoder_stop) (OH_AVCodec \*codec) | Stops an audio encoder. After the encoder is stopped, you can call **Start** to start it again. | -| [OH_AudioEncoder_Flush](#oh_audioencoder_flush) (OH_AVCodec \*codec) | Clears the input and output data in the internal buffer of an audio encoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. | -| [OH_AudioEncoder_Reset](#oh_audioencoder_reset) (OH_AVCodec \*codec) | Resets an audio encoder. To continue encoding, you must call **Configure** and **Start** to configure and start the encoder again. | -| [OH_AudioEncoder_GetOutputDescription](#oh_audioencoder_getoutputdescription) (OH_AVCodec \*codec) | Obtains the attributes of the output data of an audio encoder. The caller must manually release the **OH_AVFormat** instance in the return value. | -| [OH_AudioEncoder_SetParameter](#oh_audioencoder_setparameter) (OH_AVCodec \*codec, OH_AVFormat \*format) | Sets dynamic parameters for an audio encoder. This API can be called only after the encoder is started. Incorrect parameter settings may cause encoding failure. | -| [OH_AudioEncoder_PushInputData](#oh_audioencoder_pushinputdata) (OH_AVCodec \*codec, uint32_t index, [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) attr) | Pushes the input buffer filled with data to an audio encoder. The [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback reports available input buffers and their indexes. After being pushed to the encoder, a buffer is not accessible until the buffer with the same index is reported again through the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback. | -| [OH_AudioEncoder_FreeOutputData](#oh_audioencoder_freeoutputdata) (OH_AVCodec \*codec, uint32_t index) | Frees an output buffer of an audio encoder. | +| \*[OHOS::Media::OH_AudioEncoder_CreateByMime](#oh_audioencoder_createbymime) (const char \*mime) | Creates an audio encoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This function is recommended in most cases.| +| \*[OHOS::Media::OH_AudioEncoder_CreateByName](#oh_audioencoder_createbyname) (const char \*name) | Creates an audio encoder instance based on an encoder name. To use this function, you must know the exact name of the encoder.| +| [OHOS::Media::OH_AudioEncoder_Destroy](#oh_audioencoder_destroy) (OH_AVCodec \*codec) | Clears the internal resources of an audio encoder and destroys the encoder instance.| +| [OHOS::Media::OH_AudioEncoder_SetCallback](#oh_audioencoder_setcallback) (OH_AVCodec \*codec, OH_AVCodecAsyncCallback callback, void \*userData) | Sets an asynchronous callback so that your application can respond to events generated by an audio encoder.| +| [OHOS::Media::OH_AudioEncoder_Configure](#oh_audioencoder_configure) (OH_AVCodec \*codec, OH_AVFormat \*format) | Configures an audio encoder. Typically, you need to configure the description information about the audio track to be encoded.| +| [OHOS::Media::OH_AudioEncoder_Prepare](#oh_audioencoder_prepare) (OH_AVCodec \*codec) | Prepares internal resources for an audio encoder. This function must be called after **Configure**.| +| [OHOS::Media::OH_AudioEncoder_Start](#oh_audioencoder_start) (OH_AVCodec \*codec) | Starts an audio encoder. This function can be called only after the encoder is prepared successfully.| +| [OHOS::Media::OH_AudioEncoder_Stop](#oh_audioencoder_stop) (OH_AVCodec \*codec) | Stops an audio encoder.| +| [OHOS::Media::OH_AudioEncoder_Flush](#oh_audioencoder_flush) (OH_AVCodec \*codec) | Clears the input and output data in the internal buffer of an audio encoder.| +| [OHOS::Media::OH_AudioEncoder_Reset](#oh_audioencoder_reset) (OH_AVCodec \*codec) | Resets an audio encoder.| +| \*[OHOS::Media::OH_AudioEncoder_GetOutputDescription](#oh_audioencoder_getoutputdescription) (OH_AVCodec \*codec) | Obtains the description information about the output data of an audio encoder. For details, see **OH_AVFormat**.| +| [OHOS::Media::OH_AudioEncoder_SetParameter](#oh_audioencoder_setparameter) (OH_AVCodec \*codec, OH_AVFormat \*format) | Sets dynamic parameters for an audio encoder.| +| [OHOS::Media::OH_AudioEncoder_PushInputData](#oh_audioencoder_pushinputdata) (OH_AVCodec \*codec, uint32_t index, OH_AVCodecBufferAttr attr) | Pushes the input buffer filled with data to an audio encoder.| +| [OHOS::Media::OH_AudioEncoder_FreeOutputData](#oh_audioencoder_freeoutputdata) (OH_AVCodec \*codec, uint32_t index) | Frees an output buffer of an audio encoder.| +| [OHOS::Media::OH_AudioEncoder_IsValid](#oh_audioencoder_isvalid) (OH_AVCodec \*codec, bool \*isValid) | Checks whether an audio encoder instance is valid.| ## Function Description @@ -47,334 +50,435 @@ Provides the functions for audio encoding. This module may not be supported on s ``` -OH_AVErrCode OH_AudioEncoder_Configure (OH_AVCodec * codec, OH_AVFormat * format ) +OH_AVErrCode OHOS::Media::OH_AudioEncoder_Configure (OH_AVCodec * codec, OH_AVFormat * format ) ``` -**Description**
-Configures an audio encoder. Typically, you need to configure the attributes of the audio track that can be encoded. This API must be called prior to **Prepare**. -@syscap SystemCapability.Multimedia.Media.AudioEncoder +**Description** + +Configures an audio encoder. Typically, you need to configure the description information about the audio track to be encoded. + +This function must be called prior to **Prepare**. + +\@syscap SystemCapability.Multimedia.Media.AudioEncoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| format | Indicates the handle to an **OH_AVFormat** instance. | +| codec | Pointer to an **OH_AVCodec** instance.| +| format | Pointer to an **OH_AVFormat** instance, which provides the description information about the audio track to be encoded.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +**Since** + +9 ### OH_AudioEncoder_CreateByMime() ``` -OH_AVCodec* OH_AudioEncoder_CreateByMime (const char * mime) +OH_AVCodec* OHOS::Media::OH_AudioEncoder_CreateByMime (const char * mime) ``` -**Description**
-Creates an audio encoder instance based on a MIME type. This API is recommended in most cases. -@syscap SystemCapability.Multimedia.Media.AudioEncoder +**Description** + +Creates an audio encoder instance based on a MIME type. This function is recommended in most cases. + +\@syscap SystemCapability.Multimedia.Media.AudioEncoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| mime | Indicates the pointer to a MIME type. For details, see [OH_AVCODEC_MIMETYPE_AUDIO_AAC](_codec_base.md#oh_avcodec_mimetype_audio_aac).| +| mime | Pointer to a string that describes the MIME type. For details, see **AVCODEC_MIME_TYPE**.| **Returns** Returns the pointer to an **OH_AVCodec** instance. +**Since** + +9 + ### OH_AudioEncoder_CreateByName() ``` -OH_AVCodec* OH_AudioEncoder_CreateByName (const char * name) +OH_AVCodec* OHOS::Media::OH_AudioEncoder_CreateByName (const char * name) ``` -**Description**
-Creates an audio encoder instance based on an audio encoder name. To use this API, you must know the exact name of the audio encoder. -@syscap SystemCapability.Multimedia.Media.AudioEncoder +**Description** + +Creates an audio encoder instance based on an encoder name. To use this function, you must know the exact name of the encoder. + +\@syscap SystemCapability.Multimedia.Media.AudioEncoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| name | Indicates the pointer to an audio encoder name. | +| name | Pointer to an audio encoder name.| **Returns** Returns the pointer to an **OH_AVCodec** instance. +**Since** + +9 + ### OH_AudioEncoder_Destroy() ``` -OH_AVErrCode OH_AudioEncoder_Destroy (OH_AVCodec * codec) +OH_AVErrCode OHOS::Media::OH_AudioEncoder_Destroy (OH_AVCodec * codec) ``` -**Description**
-Clears the internal resources of an audio encoder and destroys the audio encoder instance. -@syscap SystemCapability.Multimedia.Media.AudioEncoder +**Description** + +Clears the internal resources of an audio encoder and destroys the encoder instance. + +\@syscap SystemCapability.Multimedia.Media.AudioEncoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Pointer to an **OH_AVCodec** instance.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +**Since** + +9 ### OH_AudioEncoder_Flush() ``` -OH_AVErrCode OH_AudioEncoder_Flush (OH_AVCodec * codec) +OH_AVErrCode OHOS::Media::OH_AudioEncoder_Flush (OH_AVCodec * codec) ``` -**Description**
-Clears the input and output data in the internal buffer of an audio encoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. -@syscap SystemCapability.Multimedia.Media.AudioEncoder +**Description** + +Clears the input and output data in the internal buffer of an audio encoder. + +This function invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this function, ensure that the buffers with the specified indexes are no longer required. + +\@syscap SystemCapability.Multimedia.Media.AudioEncoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Pointer to an **OH_AVCodec** instance.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +**Since** + +9 ### OH_AudioEncoder_FreeOutputData() ``` -OH_AVErrCode OH_AudioEncoder_FreeOutputData (OH_AVCodec * codec, uint32_t index ) +OH_AVErrCode OHOS::Media::OH_AudioEncoder_FreeOutputData (OH_AVCodec * codec, uint32_t index ) ``` -**Description**
+ +**Description** + Frees an output buffer of an audio encoder. -@syscap SystemCapability.Multimedia.Media.AudioEncoder +\@syscap SystemCapability.Multimedia.Media.AudioEncoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| index | Indicates the index of an output buffer. | +| codec | Pointer to an **OH_AVCodec** instance.| +| index | Index of the output buffer.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +9 ### OH_AudioEncoder_GetOutputDescription() ``` -OH_AVFormat* OH_AudioEncoder_GetOutputDescription (OH_AVCodec * codec) +OH_AVFormat* OHOS::Media::OH_AudioEncoder_GetOutputDescription (OH_AVCodec * codec) ``` -**Description**
-Obtains the attributes of the output data of an audio encoder. The caller must manually release the **OH_AVFormat** instance in the return value. -@syscap SystemCapability.Multimedia.Media.AudioEncoder +**Description** + +Obtains the description information about the output data of an audio encoder. For details, see **OH_AVFormat**. + +The caller must manually release the **OH_AVFormat** instance in the return value. + +\@syscap SystemCapability.Multimedia.Media.AudioEncoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Pointer to an **OH_AVCodec** instance.| **Returns** -Returns the handle to an **OH_AVFormat** instance, which must be manually released. +Returns the handle to an **OH_AVFormat** instance. The lifecycle of this instance is refreshed when **GetOutputDescription** is called again and destroyed when the **OH_AVCodec** instance is destroyed. + +**Since** + +9 + + +### OH_AudioEncoder_IsValid() + + +``` +OH_AVErrCode OHOS::Media::OH_AudioEncoder_IsValid (OH_AVCodec * codec, bool * isValid ) +``` + +**Description** + +Checks whether an audio encoder instance is valid. + +\@syscap SystemCapability.Multimedia.Media.AudioEncoder + +**Parameters** + +| Name| Description| +| -------- | -------- | +| codec | Pointer to an **OH_AVCodec** instance.| +| isValid | Pointer to an instance of the Boolean type. The value **true** means that the encoder instance is valid and **false** means the opposite.| + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** + +10 ### OH_AudioEncoder_Prepare() ``` -OH_AVErrCode OH_AudioEncoder_Prepare (OH_AVCodec * codec) +OH_AVErrCode OHOS::Media::OH_AudioEncoder_Prepare (OH_AVCodec * codec) ``` -**Description**
-Prepares internal resources for an audio encoder. This API must be called after **Configure**. -@syscap SystemCapability.Multimedia.Media.AudioEncoder +**Description** + +Prepares internal resources for an audio encoder. This function must be called after **Configure**. + +\@syscap SystemCapability.Multimedia.Media.AudioEncoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Pointer to an **OH_AVCodec** instance.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +9 ### OH_AudioEncoder_PushInputData() ``` -OH_AVErrCode OH_AudioEncoder_PushInputData (OH_AVCodec * codec, uint32_t index, OH_AVCodecBufferAttr attr ) +OH_AVErrCode OHOS::Media::OH_AudioEncoder_PushInputData (OH_AVCodec * codec, uint32_t index, OH_AVCodecBufferAttr attr ) ``` -**Description**
-Pushes the input buffer filled with data to an audio encoder. The [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback reports available input buffers and their indexes. After being pushed to the encoder, a buffer is not accessible until the buffer with the same index is reported again through the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback. -@syscap SystemCapability.Multimedia.Media.AudioEncoder +**Description** + +Pushes the input buffer filled with data to an audio encoder. + +The **OH_AVCodecOnNeedInputData** callback reports the available input buffer and the index. After being pushed to the encoder, a buffer is not accessible until the buffer with the same index is reported again through the **OH_AVCodecOnNeedInputData** callback. In addition, some encoders require the input of specific data to initialize the encoding process. + +\@syscap SystemCapability.Multimedia.Media.AudioEncoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| index | Indicates the index of an input buffer. | -| attr | Indicates the attributes of the data contained in the buffer. | +| codec | Pointer to an **OH_AVCodec** instance.| +| index | Index of the input buffer.| +| attr | Description information about the data in the buffer.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +9 ### OH_AudioEncoder_Reset() ``` -OH_AVErrCode OH_AudioEncoder_Reset (OH_AVCodec * codec) +OH_AVErrCode OHOS::Media::OH_AudioEncoder_Reset (OH_AVCodec * codec) ``` -**Description**
-Resets an audio encoder. To continue encoding, you must call **Configure** and **Start** to configure and start the encoder again. -@syscap SystemCapability.Multimedia.Media.AudioEncoder +**Description** + +Resets an audio encoder. To continue encoding, you must call **Configure** to configure the encoder again. + +\@syscap SystemCapability.Multimedia.Media.AudioEncoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Pointer to an **OH_AVCodec** instance.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. - -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. ### OH_AudioEncoder_SetCallback() ``` -OH_AVErrCode OH_AudioEncoder_SetCallback (OH_AVCodec * codec, OH_AVCodecAsyncCallback callback, void * userData ) +OH_AVErrCode OHOS::Media::OH_AudioEncoder_SetCallback (OH_AVCodec * codec, OH_AVCodecAsyncCallback callback, void * userData ) ``` -**Description**
-Sets an asynchronous callback so that your application can respond to events generated by an audio encoder. This API must be called prior to **Prepare**. -@syscap SystemCapability.Multimedia.Media.AudioEncoder +**Description** + +Sets an asynchronous callback so that your application can respond to events generated by an audio encoder. + +This function must be called prior to **Prepare**. + +\@syscap SystemCapability.Multimedia.Media.AudioEncoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| callback | Indicates a collection of all callback functions. For details, see [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md).| -| userData | Indicates the pointer to user-specific data. | +| codec | Pointer to an **OH_AVCodec** instance.| +| callback | Callback function to set. For details, see **OH_AVCodecAsyncCallback**.| +| userData | User-specific data.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +9 ### OH_AudioEncoder_SetParameter() ``` -OH_AVErrCode OH_AudioEncoder_SetParameter (OH_AVCodec * codec, OH_AVFormat * format ) +OH_AVErrCode OHOS::Media::OH_AudioEncoder_SetParameter (OH_AVCodec * codec, OH_AVFormat * format ) ``` -**Description**
-Sets dynamic parameters for an audio encoder. This API can be called only after the encoder is started. Incorrect parameter settings may cause encoding failure. -@syscap SystemCapability.Multimedia.Media.AudioEncoder +**Description** + +Sets dynamic parameters for an audio encoder. + +This function can be called only after the encoder is started. Incorrect parameter settings may cause encoding failure. + +\@syscap SystemCapability.Multimedia.Media.AudioEncoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| format | Indicates the handle to an **OH_AVFormat** instance. | +| codec | Pointer to an **OH_AVCodec** instance.| +| format | Handle to an **OH_AVFormat** instance.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +9 ### OH_AudioEncoder_Start() ``` -OH_AVErrCode OH_AudioEncoder_Start (OH_AVCodec * codec) +OH_AVErrCode OHOS::Media::OH_AudioEncoder_Start (OH_AVCodec * codec) ``` -**Description**
-Starts an audio encoder. This API can be called only after the encoder is prepared successfully. After being started, the encoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. -@syscap SystemCapability.Multimedia.Media.AudioEncoder +**Description** + +Starts an audio encoder. This function can be called only after the encoder is prepared successfully. + +After being started, the encoder starts to report the **OH_AVCodecOnNeedInputData** event. + +\@syscap SystemCapability.Multimedia.Media.AudioEncoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Pointer to an **OH_AVCodec** instance.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +9 ### OH_AudioEncoder_Stop() ``` -OH_AVErrCode OH_AudioEncoder_Stop (OH_AVCodec * codec) +OH_AVErrCode OHOS::Media::OH_AudioEncoder_Stop (OH_AVCodec * codec) ``` -**Description**
+ +**Description** + Stops an audio encoder. After the encoder is stopped, you can call **Start** to start it again. -@syscap SystemCapability.Multimedia.Media.AudioEncoder +\@syscap SystemCapability.Multimedia.Media.AudioEncoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Pointer to an **OH_AVCodec** instance.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +**Since** + +9 diff --git a/en/application-dev/reference/native-apis/_codec_base.md b/en/application-dev/reference/native-apis/_codec_base.md index a1f4f21a70..613927e330 100644 --- a/en/application-dev/reference/native-apis/_codec_base.md +++ b/en/application-dev/reference/native-apis/_codec_base.md @@ -3,85 +3,139 @@ ## Overview -Provides the common structs, character constants, and enums for running **OH_AVCodec** instances. This module may not be supported on some devices. You can call [CanIUse](../syscap.md) to check whether this module is supported on your device. +The **CodecBase** module provides the common structs, character constants, and enums for running **OH_AVCodec** instances. This module may not be supported on some devices. You can call [CanIUse](../syscap.md) to check whether your device supports this module. -@syscap SystemCapability.Multimedia.Media.CodecBase +\@syscap SystemCapability.Multimedia.Media.CodecBase **Since** + 9 + ## Summary ### Files - | Name| Description| +| Name| Description| | -------- | -------- | -| [native_avcodec_base.h](native__avcodec__base_8h.md) | Declares the common structs, character constants, and enums for running OH_AVCodec instances.
File to include: | +| [native_avcodec_base.h](native__avcodec__base_8h.md) | Declares the common structs, character constants, and enums for running **OH_AVCodec** instances.
File to include: \| ### Structs - | Name| Description| +| Name| Description| | -------- | -------- | -| [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) | Defines the buffer attributes of an **OH_AVCodec** instance. | -| [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) | Defines a collection of asynchronous callback functions for an **OH_AVCodec** instance. You must register this struct instance for an **OH_AVCodec** instance and process the information reported through these callbacks to ensure the normal running of the instance. | +| [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) | Defines the description information about the buffer of an **OH_AVCodec** instance.| +| [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) | Defines all the asynchronous callback function pointers of an **OH_AVCodec** instance.| ### Types - | Name| Description| +| Name| Description| | -------- | -------- | -| [OH_AVCodecBufferFlags](#oh_avcodecbufferflags) | Enumerates the buffer flags of an **OH_AVCodec** instance. | -| [OH_AVCodecBufferAttr](#oh_avcodecbufferattr) | Defines the buffer attributes of an **OH_AVCodec** instance. | -| (\*[OH_AVCodecOnError](#oh_avcodeconerror)) (OH_AVCodec \*codec, int32_t errorCode, void \*userData) | Defines the function pointer that is called to report error information when an error occurs during the running of an **OH_AVCodec** instance. | -| (\*[OH_AVCodecOnStreamChanged](#oh_avcodeconstreamchanged)) (OH_AVCodec \*codec, OH_AVFormat \*format, void \*userData) | Defines the function pointer that is called to report the attributes of the new stream when the output stream changes. Note that the lifecycle of the pointer to the **OH_AVFormat** instance is valid only when the function pointer is being called. Do not access the pointer to the instance after the function pointer is called. | -| (\*[OH_AVCodecOnNeedInputData](#oh_avcodeconneedinputdata)) (OH_AVCodec \*codec, uint32_t index, OH_AVMemory \*data, void \*userData) | Defines the function pointer that is called, with a new buffer to fill in new input data, when new input data is required during the running of an **OH_AVCodec** instance. | -| (\*[OH_AVCodecOnNewOutputData](#oh_avcodeconnewoutputdata)) (OH_AVCodec \*codec, uint32_t index, OH_AVMemory \*data, [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) \*attr, void \*userData) | Defines the function pointer that is called, with a buffer containing new output data, when the new output data is generated during the running of an **OH_AVCodec** instance. Note that the lifecycle of the pointer to the **OH_AVCodecBufferAttr** instance is valid only when the function pointer is being called. Do not access the pointer to the instance after the function pointer is called. | -| [OH_AVCodecAsyncCallback](#oh_avcodecasynccallback) | Defines a collection of asynchronous callback functions for an **OH_AVCodec** instance. You must register this struct instance for an **OH_AVCodec** instance and process the information reported through these callbacks to ensure the normal running of the instance. | -| [OH_MediaType](#oh_mediatype) | Enumerates the media types. | -| [OH_AVCProfile](#oh_avcprofile) | Enumerates the AVC profiles. | -| [OH_AACProfile](#oh_aacprofile) | Enumerates the AAC profiles. | +| [OH_AVCodecBufferFlags](#oh_avcodecbufferflags) | Defines an enum that enumerates the flags for the buffer of an **OH_AVCodec** instance.| +| [OH_AVOutputFormat](#oh_avoutputformat) | Defines an enum that enumerates the output file formats of a muxer.| +| [OH_AVCodecBufferAttr](#oh_avcodecbufferattr) | Defines a struct for the description information about the buffer of an **OH_AVCodec** instance.| +| (\*[OH_AVCodecOnError](#oh_avcodeconerror)) (OH_AVCodec \*codec, int32_t errorCode, void \*userData) | Defines the pointer to the function that is called to report error information when an error occurs during the running of an **OH_AVCodec** instance.| +| (\*[OH_AVCodecOnStreamChanged](#oh_avcodeconstreamchanged)) (OH_AVCodec \*codec, OH_AVFormat \*format, void \*userData) | Defines the pointer to the function that is called to report the new stream description when the output stream changes.| +| (\*[OH_AVCodecOnNeedInputData](#oh_avcodeconneedinputdata)) (OH_AVCodec \*codec, uint32_t index, OH_AVMemory \*data, void \*userData) | Defines the pointer to the function that is called when new input data is required during the running of an **OH_AVCodec** instance. The function carries a buffer to fill in new input data.| +| (\*[OH_AVCodecOnNewOutputData](#oh_avcodeconnewoutputdata)) (OH_AVCodec \*codec, uint32_t index, OH_AVMemory \*data, [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) \*attr, void \*userData) | Defines the pointer to the function that is called when new output data is generated during the running of an **OH_AVCodec** instance. The function carries a buffer filled with new output data.| +| [OH_AVCodecAsyncCallback](#oh_avcodecasynccallback) | Defines a struct for all the asynchronous callback function pointers of an **OH_AVCodec** instance.| +| [OH_MediaType](#oh_mediatype) | Defines an enum that enumerates the media types.| +| [OH_AVCProfile](#oh_avcprofile) | Defines an enum that enumerates the Advanced Video Coding (AVC) profiles.| +| [OH_HEVCProfile](#oh_hevcprofile) | Defines an enum that enumerates the High Efficiency Video Coding (HEVC) profiles.| +| [OH_AACProfile](#oh_aacprofile) | Defines an enum that enumerates the Advanced Audio Coding (AAC) profiles.| +| [OH_AVSeekMode](#oh_avseekmode) | Defines an enum that enumerates the seek modes.| +| [OH_ColorPrimary](#oh_colorprimary) | Defines an enum that enumerates the primary colors.| +| [OH_TransferCharacteristic](#oh_transfercharacteristic) | Defines an enum that enumerates the transfer characteristics.| +| [OH_MatrixCoefficient](#oh_matrixcoefficient) | Defines an enum that enumerates the matrix coefficients.| +| [OH_BitsPerSample](#oh_bitspersample) | Defines an enum that enumerates the number of audio bits for each coded sample.| ### Enums - | Name| Description| +| Name| Description| | -------- | -------- | -| [OH_AVCodecBufferFlags](#oh_avcodecbufferflags) {
**AVCODEC_BUFFER_FLAGS_NONE** = 0, **AVCODEC_BUFFER_FLAGS_EOS** = 1 << 0, **AVCODEC_BUFFER_FLAGS_SYNC_FRAME** = 1 << 1, **AVCODEC_BUFFER_FLAGS_INCOMPLETE_FRAME** = 1 << 2, **AVCODEC_BUFFER_FLAGS_CODEC_DATA**= 1 << 3
} | Enumerates the buffer flags of an **OH_AVCodec** instance. | -| [OH_MediaType](#oh_mediatype) { **MEDIA_TYPE_AUD** = 0, **MEDIA_TYPE_VID** = 1 } | Enumerates the media types. | -| [OH_AVCProfile](#oh_avcprofile) { **AVC_PROFILE_BASELINE** = 0, **AVC_PROFILE_HIGH** = 4, **AVC_PROFILE_MAIN** = 8 } | Enumerates the Advanced Video Coding (AVC) profiles. | -| [OH_AACProfile](#oh_aacprofile) { **AAC_PROFILE_LC** = 0 } | Enumerates the Advanced Audio Coding (AAC) profiles. | +| [OH_AVCodecBufferFlags](#oh_avcodecbufferflags) {
**AVCODEC_BUFFER_FLAGS_NONE** = 0, **AVCODEC_BUFFER_FLAGS_EOS** = 1 << 0, **AVCODEC_BUFFER_FLAGS_SYNC_FRAME** = 1 << 1, **AVCODEC_BUFFER_FLAGS_INCOMPLETE_FRAME** = 1 << 2,
**AVCODEC_BUFFER_FLAGS_CODEC_DATA** = 1 << 3
} | Enumerates the flags for the buffer of an **OH_AVCodec** instance.| +| [OH_AVOutputFormat](#oh_avoutputformat) { **AV_OUTPUT_FORMAT_DEFAULT** = 0, **AV_OUTPUT_FORMAT_MPEG_4** = 2, **AV_OUTPUT_FORMAT_M4A** = 6 } | Enumerates the output file formats of a muxer.| +| [OH_MediaType](#oh_mediatype) { **MEDIA_TYPE_AUD** = 0, **MEDIA_TYPE_VID** = 1 } | Enumerates the media types.| +| [OH_AVCProfile](#oh_avcprofile) { **AVC_PROFILE_BASELINE** = 0, **AVC_PROFILE_HIGH** = 4, **AVC_PROFILE_MAIN** = 8 } | Enumerates the AVC profiles.| +| [OH_HEVCProfile](#oh_hevcprofile) {
**HEVC_PROFILE_MAIN** = 0, **HEVC_PROFILE_MAIN_10** = 1, **HEVC_PROFILE_MAIN_STILL** = 2, **HEVC_PROFILE_MAIN_10_HDR10** = 3,
**HEVC_PROFILE_MAIN_10_HDR10_PLUS** = 4
} | Enumerates the HEVC profiles.| +| [OH_AACProfile](#oh_aacprofile) { **AAC_PROFILE_LC** = 0 } | Enumerates the AAC profiles.| +| [OH_AVSeekMode](#oh_avseekmode) { **SEEK_MODE_NEXT_SYNC** = 0, **SEEK_MODE_PREVIOUS_SYNC**, **SEEK_MODE_CLOSEST_SYNC** } | Enumerates the seek modes.| +| [OH_ColorPrimary](#oh_colorprimary) {
**COLOR_PRIMARY_BT709** = 1, **COLOR_PRIMARY_UNSPECIFIED** = 2, **COLOR_PRIMARY_BT470_M** = 4, **COLOR_PRIMARY_BT601_625** = 5,
**COLOR_PRIMARY_BT601_525** = 6, **COLOR_PRIMARY_SMPTE_ST240** = 7, **COLOR_PRIMARY_GENERIC_FILM** = 8, **COLOR_PRIMARY_BT2020** = 9,
**COLOR_PRIMARY_SMPTE_ST428** = 10, **COLOR_PRIMARY_P3DCI** = 11, **COLOR_PRIMARY_P3D65** = 12
} | Enumerates the primary colors.| +| [OH_TransferCharacteristic](#oh_transfercharacteristic) {
**TRANSFER_CHARACTERISTIC_BT709** = 1, **TRANSFER_CHARACTERISTIC_UNSPECIFIED** = 2, **TRANSFER_CHARACTERISTIC_GAMMA_2_2** = 4, **TRANSFER_CHARACTERISTIC_GAMMA_2_8** = 5,
**TRANSFER_CHARACTERISTIC_BT601** = 6, **TRANSFER_CHARACTERISTIC_SMPTE_ST240** = 7, **TRANSFER_CHARACTERISTIC_LINEAR** = 8, **TRANSFER_CHARACTERISTIC_LOG** = 9,
**TRANSFER_CHARACTERISTIC_LOG_SQRT** = 10, **TRANSFER_CHARACTERISTIC_IEC_61966_2_4** = 11, **TRANSFER_CHARACTERISTIC_BT1361** = 12, **TRANSFER_CHARACTERISTIC_IEC_61966_2_1** = 13,
**TRANSFER_CHARACTERISTIC_BT2020_10BIT** = 14, **TRANSFER_CHARACTERISTIC_BT2020_12BIT** = 15, **TRANSFER_CHARACTERISTIC_PQ** = 16, **TRANSFER_CHARACTERISTIC_SMPTE_ST428** = 17,
**TRANSFER_CHARACTERISTIC_HLG** = 18
} | Enumerates the transfer characteristics.| +| [OH_MatrixCoefficient](#oh_matrixcoefficient) {
**MATRIX_COEFFICIENT_IDENTITY** = 0, **MATRIX_COEFFICIENT_BT709** = 1, **MATRIX_COEFFICIENT_UNSPECIFIED** = 2, **MATRIX_COEFFICIENT_FCC** = 4,
**MATRIX_COEFFICIENT_BT601_625** = 5, **MATRIX_COEFFICIENT_BT601_525** = 6, **MATRIX_COEFFICIENT_SMPTE_ST240** = 7, **MATRIX_COEFFICIENT_YCGCO** = 8,
**MATRIX_COEFFICIENT_BT2020_NCL** = 9, **MATRIX_COEFFICIENT_BT2020_CL** = 10, **MATRIX_COEFFICIENT_SMPTE_ST2085** = 11, **MATRIX_COEFFICIENT_CHROMATICITY_NCL** = 12,
**MATRIX_COEFFICIENT_CHROMATICITY_CL** = 13, **MATRIX_COEFFICIENT_ICTCP** = 14
} | Enumerates the matrix coefficients.| +| [OH_BitsPerSample](#oh_bitspersample) {
**SAMPLE_U8** = 0, **SAMPLE_S16LE** = 1, **SAMPLE_S24LE** = 2, **SAMPLE_S32LE** = 3,
**SAMPLE_F32LE** = 4, **SAMPLE_U8P** = 5, **SAMPLE_S16P** = 6, **SAMPLE_S24P** = 7,
**SAMPLE_S32P** = 8, **SAMPLE_F32P** = 9, **INVALID_WIDTH** = -1
} | Enumerates the number of audio bits for each coded sample.| ### Variables - | Name| Description| +| Name| Description| | -------- | -------- | -| [OH_AVCodecBufferAttr::pts](#pts) | Defines the presentation timestamp of the buffer, in microseconds. | -| [OH_AVCodecBufferAttr::size](#size) | Defines the size of the data contained in the buffer, in bytes. | -| [OH_AVCodecBufferAttr::offset](#offset) | Defines the start offset of valid data in the buffer. | -| [OH_AVCodecBufferAttr::flags](#flags) | Defines a buffer flag, which is a combination of multiple [OH_AVCodecBufferFlags](#oh_avcodecbufferflags). | -| [OH_AVCODEC_MIMETYPE_VIDEO_AVC](#oh_avcodec_mimetype_video_avc) | Defines the Multipurpose Internet Mail Extension (MIME) type for AVC. | -| [OH_AVCODEC_MIMETYPE_AUDIO_AAC](#oh_avcodec_mimetype_audio_aac) | Defines the MIME type for AAC. | -| [OH_ED_KEY_TIME_STAMP](#oh_ed_key_time_stamp) | Defines the unified character descriptors for the auxiliary data of the surface buffer. | -| [OH_ED_KEY_EOS](#oh_ed_key_eos) | Defines the character descriptor of the end-of-stream in the surface auxiliary data. The value type is bool. | -| [OH_MD_KEY_TRACK_TYPE](#oh_md_key_track_type) | Defines the unified character descriptors for the media playback framework. | -| [OH_MD_KEY_CODEC_MIME](#oh_md_key_codec_mime) | Defines the character descriptor of the MIME type. The value type is string. | -| [OH_MD_KEY_DURATION](#oh_md_key_duration) | Defines the character descriptor of duration. The value type is int64_t. | -| [OH_MD_KEY_BITRATE](#oh_md_key_bitrate) | Defines the character descriptor of the bit rate. The value type is uint32_t. | -| [OH_MD_KEY_MAX_INPUT_SIZE](#oh_md_key_max_input_size) | Defines the character descriptor of the maximum input size. The value type is uint32_t. | -| [OH_MD_KEY_WIDTH](#oh_md_key_width) | Defines the character descriptor of the video width. The value type is uint32_t. | -| [OH_MD_KEY_HEIGHT](#oh_md_key_height) | Defines the character descriptor of the video height. The value type is uint32_t. | -| [OH_MD_KEY_PIXEL_FORMAT](#oh_md_key_pixel_format) | Defines the character descriptor of the video pixel format. The value type is int32_t. For details, see [OH_AVPixelFormat](_core.md#oh_avpixelformat).| -| [OH_MD_KEY_AUDIO_SAMPLE_FORMAT](#oh_md_key_audio_sample_format) | Defines the character descriptor of the audio sample format. The value type is uint32_t. | -| [OH_MD_KEY_FRAME_RATE](#oh_md_key_frame_rate) | Defines the character descriptor of the video frame rate. The value type is double. | -| [OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE](#oh_md_key_video_encode_bitrate_mode) | Defines the character descriptor of the video encoding bit rate mode. The value type is int32_t. For details, see [OH_VideoEncodeBitrateMode](_video_encoder.md#oh_videoencodebitratemode).| -| [OH_MD_KEY_PROFILE](#oh_md_key_profile) | Defines the character descriptor of the audio/video encoding capability. The value type is int32_t. For details, see [OH_AVCProfile](#oh_avcprofile) or [OH_AACProfile](#oh_aacprofile).| -| [OH_MD_KEY_AUD_CHANNEL_COUNT](#oh_md_key_aud_channel_count) | Defines the character descriptor of the number of audio channels. The value type is uint32_t. | -| [OH_MD_KEY_AUD_SAMPLE_RATE](#oh_md_key_aud_sample_rate) | Defines the character descriptor of the audio sampling rate. The value type is uint32_t. | -| [OH_MD_KEY_I_FRAME_INTERVAL](#oh_md_key_i_frame_interval) | Defines the character descriptor of the I-frame interval. The value type is int32_t, and the unit is ms. | -| [OH_MD_KEY_ROTATION](#oh_md_key_rotation) | Defines the character descriptor of the surface rotation angle. The value type is int32_t. The value range is {0, 90, 180, 270}. The default value is 0. | +| [OH_AVCodecBufferAttr::pts](_o_h___a_v_codec_buffer_attr.md#pts) | Defines the display timestamp of the buffer, in microseconds.| +| [OH_AVCodecBufferAttr::size](_o_h___a_v_codec_buffer_attr.md#size) | Defines the size of data contained in the buffer, in bytes.| +| [OH_AVCodecBufferAttr::offset](_o_h___a_v_codec_buffer_attr.md#offset) | Defines the offset of valid data in the buffer.| +| [OH_AVCodecBufferAttr::flags](_o_h___a_v_codec_buffer_attr.md#flags) | Defines the flags of the buffer. It is a combination of multiple [OH_AVCodecBufferFlags](#oh_avcodecbufferflags).| +| [OH_AVCodecAsyncCallback::onError](_o_h___a_v_codec_async_callback.md#onerror) | Defines the callback used to report a codec operation error. For details, see [OH_AVCodecOnError](#oh_avcodeconerror).| +| [OH_AVCodecAsyncCallback::onStreamChanged](_o_h___a_v_codec_async_callback.md#onstreamchanged) | Defines the callback used to report a codec stream change. For details, see [OH_AVCodecOnStreamChanged](#oh_avcodeconstreamchanged).| +| [OH_AVCodecAsyncCallback::onNeedInputData](_o_h___a_v_codec_async_callback.md#onneedinputdata) | Defines the callback used to report input data required. For details, see [OH_AVCodecOnNeedInputData](#oh_avcodeconneedinputdata).| +| [OH_AVCodecAsyncCallback::onNeedOutputData](_o_h___a_v_codec_async_callback.md#onneedinputdata) | Defines the callback used to report output data generated. For details, see [OH_AVCodecOnNewOutputData](#oh_avcodeconnewoutputdata).| +| \*[OH_AVCODEC_MIMETYPE_VIDEO_AVC](#oh_avcodec_mimetype_video_avc) | Defines the pointer to the Multipurpose Internet Mail Extension (MIME) type for AVC video codec.| +| \*[OH_AVCODEC_MIMETYPE_AUDIO_AAC](#oh_avcodec_mimetype_audio_aac) | Defines the pointer to the MIME type for AAC audio codec.| +| \*[OH_AVCODEC_MIMETYPE_VIDEO_MPEG4](#oh_avcodec_mimetype_video_mpeg4) | Defines the pointer to the MIME type for MPEG4 video codec.| +| \*[OH_AVCODEC_MIMETYPE_VIDEO_HEVC](#oh_avcodec_mimetype_video_hevc) | Defines the pointer to the MIME type for HEVC video codec.| +| \*[OH_AVCODEC_MIMETYPE_AUDIO_MPEG](#oh_avcodec_mimetype_audio_mpeg) | Defines the pointer to the MIME type for MPEG audio codec.| +| \*[OH_AVCODEC_MIMETYPE_IMAGE_JPG](#oh_avcodec_mimetype_image_jpg) | Defines the pointer to the MIME type for JPG image codec.| +| \*[OH_AVCODEC_MIMETYPE_IMAGE_PNG](#oh_avcodec_mimetype_image_png) | Defines the pointer to the MIME type for PNG image codec.| +| \*[OH_AVCODEC_MIMETYPE_IMAGE_BMP](#oh_avcodec_mimetype_image_bmp) | Defines the pointer to the MIME type for BMP image codec.| +| \*[OH_AVCODEC_MIMETYPE_AUDIO_FLAC](#oh_avcodec_mimetype_audio_flac) | Defines the pointer to the MIME type for FLAC audio codec.| +| \*[OH_AVCODEC_MIMETYPE_AUDIO_VORBIS](#oh_avcodec_mimetype_audio_vorbis) | Defines the pointer to the MIME type for VORBIS audio codec.| +| \*[OH_ED_KEY_TIME_STAMP](#oh_ed_key_time_stamp) | Defines the pointer to the timestamp in the extra data of the surface. The value type is int64.| +| \*[OH_ED_KEY_EOS](#oh_ed_key_eos) | Defines the pointer to the end of stream (EOS) in the extra data of the surface. The value type is Boolean.| +| \*[OH_MD_KEY_TRACK_TYPE](#oh_md_key_track_type) | Defines the pointer to a container for storing media descriptions.| +| \*[OH_MD_KEY_CODEC_MIME](#oh_md_key_codec_mime) | Define the pointer to the MIME type of codec. The value is a string.| +| \*[OH_MD_KEY_DURATION](#oh_md_key_duration) | Defines the pointer to the duration. The value type is int64_t.| +| \*[OH_MD_KEY_BITRATE](#oh_md_key_bitrate) | Defines the pointer to the bit rate. The value type is uint32_t.| +| \*[OH_MD_KEY_MAX_INPUT_SIZE](#oh_md_key_max_input_size) | Defines the pointer to the maximum input size. The value type is uint32_t.| +| \*[OH_MD_KEY_WIDTH](#oh_md_key_width) | Defines the pointer to the video width. The value type is uint32_t.| +| \*[OH_MD_KEY_HEIGHT](#oh_md_key_height) | Defines the pointer to the video height. The value type is uint32_t.| +| \*[OH_MD_KEY_PIXEL_FORMAT](#oh_md_key_pixel_format) | Defines the pointer to the video pixel format. The value type is int32_t. For details, see [OH_AVPixelFormat](_core.md#oh_avpixelformat).| +| \*[OH_MD_KEY_RANGE_FLAG](#oh_md_key_range_flag) | Defines the pointer to the video YUV value range flag. The value type is Boolean.| +| \*[OH_MD_KEY_COLOR_PRIMARIES](#oh_md_key_color_primaries) | Defines the pointer to the primary color of the video. The value type is int32_t.| +| \*[OH_MD_KEY_TRANSFER_CHARACTERISTICS](#oh_md_key_transfer_characteristics) | Defines the pointer to the video transfer characteristics. The value type is int32_t.| +| \*[OH_MD_KEY_MATRIX_COEFFICIENTS](#oh_md_key_matrix_coefficients) | Defines the pointer to the video matrix coefficient. The value type is int32_t.| +| \*[OH_MD_KEY_AUDIO_SAMPLE_FORMAT](#oh_md_key_audio_sample_format) | Defines the pointer to the original audio format. The value type is uint32_t.| +| \*[OH_MD_KEY_FRAME_RATE](#oh_md_key_frame_rate) | Defines the pointer to the video frame rate. The value is a double-precision floating point number.| +| \*[OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE](#oh_md_key_video_encode_bitrate_mode) | Defines the pointer to the video encoding bit rate mode. The value type is int32_t. For details, see [OH_VideoEncodeBitrateMode](_video_encoder.md#oh_videoencodebitratemode).| +| \*[OH_MD_KEY_PROFILE](#oh_md_key_profile) | Defines the pointer to the encoding template. The value is a number. For details, see [OH_AVCProfile](#oh_avcprofile), [OH_AACProfile](#oh_aacprofile), or [OH_HEVCProfile](#oh_hevcprofile).| +| \*[OH_MD_KEY_AUD_CHANNEL_COUNT](#oh_md_key_aud_channel_count) | Defines the pointer to the number of audio channels. The value type is uint32_t.| +| \*[OH_MD_KEY_AUD_SAMPLE_RATE](#oh_md_key_aud_sample_rate) | Defines the pointer to the audio sampling rate. The value type is uint32_t.| +| \*[OH_MD_KEY_I_FRAME_INTERVAL](#oh_md_key_i_frame_interval) | Defines the pointer to the key frame interval, in milliseconds. The value type is int32_t.| +| \*[OH_MD_KEY_ROTATION](#oh_md_key_rotation) | Defines the pointer to the rotation angle of the surface. The value type is int32_t, and the value range is {0, 90, 180, 270}. The default value is 0.| +| \*[OH_MD_KEY_CODEC_CONFIG](#oh_md_key_codec_config) | Defines the pointer to the codec-specific data. The value type is uint8_t\*.| +| \*[OH_MD_KEY_REQUEST_I_FRAME](#oh_md_key_request_i_frame) | Defines the pointer to the request for immediate encoding of I-frames. The value type is Boolean.| +| \*[OH_MD_KEY_QUALITY](#oh_md_key_quality) | Defines the pointer to the required encoding quality. The value type is uint32_t. This key applies only to encoders configured in constant quality mode.| +| \*[OH_MD_KEY_CHANNEL_LAYOUT](#oh_md_key_channel_layout) | Defines the pointer to the required encoding channel layout. The value type is int64_t. This key applies only to encoders.| +| \*[OH_MD_KEY_BITS_PER_CODED_SAMPLE](#oh_md_key_bits_per_coded_sample) | Defines the pointer to the number of bits for each coded sample. The value type is uint32_t. This key applies to FLAC encoders. For details, see **\@OH_BitsPerSample**.| +| \*[OH_MD_KEY_AAC_IS_ADTS](#oh_md_key_aac_is_adts) | Defines the pointer to the AAC format. The value type is uint32_t. This key applies to AAC decoders.| +| \*[OH_MD_KEY_SBR](#oh_md_key_sbr) | Defines the pointer to the AAC SBR format. The value type is uint32_t. This key applies to AAC encoders.| +| \*[OH_MD_KEY_COMPLIANCE_LEVEL](#oh_md_key_compliance_level) | Defines the pointer to the FLAC compliance level. The value type is int32_t.| +| \*[OH_MD_KEY_IDENTIFICATION_HEADER](#oh_md_key_identification_header) | Defines the pointer to the VORBIS identification header. The value type is uint8_t\*. This key applies only to VORBIS decoders.| +| \*[OH_MD_KEY_SETUP_HEADER](#oh_md_key_setup_header) | Defines the pointer to the VORBIS setup header. The value type is uint8_t\*. This key applies only to VORBIS decoders.| +| \*[OH_MD_KEY_TITLE](#oh_md_key_title) | Defines the pointer to the title of the input media. The value is a string.| +| \*[OH_MD_KEY_ARTIST](#oh_md_key_artist) | Defines the pointer to the artist of the input media. The value is a string.| +| \*[OH_MD_KEY_ALBUM](#oh_md_key_album) | Defines the pointer to the album of the input media. The value is a string.| +| \*[OH_MD_KEY_ALBUM_ARTIST](#oh_md_key_album_artist) | Defines the pointer to the album_artist of the input media. The value is a string.| +| \*[OH_MD_KEY_DATE](#oh_md_key_date) | Defines the pointer to the date of the input media. The value is a string.| +| \*[OH_MD_KEY_COMMENT](#oh_md_key_comment) | Defines the pointer to the comment of the input media. The value is a string.| +| \*[OH_MD_KEY_GENRE](#oh_md_key_genre) | Defines the pointer to the genre of the input media. The value is a string.| +| \*[OH_MD_KEY_COPYRIGHT](#oh_md_key_copyright) | Defines the pointer to the copyright of the input media. The value is a string.| +| \*[OH_MD_KEY_LANGUAGE](#oh_md_key_language) | Defines the pointer to the language of the input media. The value is a string.| +| \*[OH_MD_KEY_DESCRIPTION](#oh_md_key_description) | Defines the pointer to the description of the input media. The value is a string.| +| \*[OH_MD_KEY_LYRICS](#oh_md_key_lyrics) | Defines the pointer to the lyrics of the input media. The value is a string.| +| \*[OH_MD_KEY_TRACK_COUNT](#oh_md_key_track_count) | Defines the pointer to the track count of the input media. The value type is uint32_t.| ## Type Description @@ -93,10 +147,12 @@ Provides the common structs, character constants, and enums for running **OH_AVC ``` typedef enum OH_AACProfileOH_AACProfile ``` -**Description**
-Enumerates the AAC profiles. -@syscap SystemCapability.Multimedia.Media.CodecBase +**Description** + +Defines an enum that enumerates the AAC profiles. + +\@syscap SystemCapability.Multimedia.Media.CodecBase ### OH_AVCodecAsyncCallback @@ -105,19 +161,21 @@ Enumerates the AAC profiles. ``` typedef struct OH_AVCodecAsyncCallbackOH_AVCodecAsyncCallback ``` -**Description**
-Defines a collection of asynchronous callback functions for an **OH_AVCodec** instance. You must register this struct instance for an **OH_AVCodec** instance and process the information reported through these callbacks to ensure the normal running of the instance. -@syscap SystemCapability.Multimedia.Media.CodecBase +**Description** + +Defines a struct for all the asynchronous callback function pointers of an **OH_AVCodec** instance. To ensure the normal running of **OH_AVCodec**, you must register the instance of this struct with the **OH_AVCodec** instance and process the information reported by the callback function. + +\@syscap SystemCapability.Multimedia.Media.CodecBase **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| onError | Indicates the callback used to report errors occurred during the running of the instance. For details, see [OH_AVCodecOnError](#oh_avcodeconerror).| -| onStreamChanged | Indicates the callback used to report stream information. For details, see [OH_AVCodecOnStreamChanged](#oh_avcodeconstreamchanged).| -| onNeedInputData | Indicates the callback used to report input data needed. For details, see [OH_AVCodecOnNeedInputData](#oh_avcodeconneedinputdata).| -| onNeedInputData | Indicates the callback used to report output data needed. For details, see [OH_AVCodecOnNewOutputData](#oh_avcodeconnewoutputdata).| +| [onError](_o_h___a_v_codec_async_callback.md#onerror) | Callback used to report a codec operation error. For details, see [OH_AVCodecOnError](#oh_avcodeconerror).| +| [onStreamChanged](_o_h___a_v_codec_async_callback.md#onstreamchanged) | Callback used to report a codec stream change. For details, see [OH_AVCodecOnStreamChanged](#oh_avcodeconstreamchanged).| +| [onNeedInputData](_o_h___a_v_codec_async_callback.md#onneedinputdata) | Callback used to report input data required. For details, see [OH_AVCodecOnNeedInputData](#oh_avcodeconneedinputdata).| +| [onNeedOutputData](_o_h___a_v_codec_async_callback.md#onneedoutputdata) | Callback used to report output data generated. For details, see [OH_AVCodecOnNewOutputData](#oh_avcodeconnewoutputdata).| ### OH_AVCodecBufferAttr @@ -126,10 +184,12 @@ Defines a collection of asynchronous callback functions for an **OH_AVCodec** in ``` typedef struct OH_AVCodecBufferAttrOH_AVCodecBufferAttr ``` -**Description**
-Defines the buffer attributes of an **OH_AVCodec** instance. -@syscap SystemCapability.Multimedia.Media.CodecBase +**Description** + +Defines a struct for the description information about the buffer of an **OH_AVCodec** instance. + +\@syscap SystemCapability.Multimedia.Media.CodecBase ### OH_AVCodecBufferFlags @@ -138,10 +198,12 @@ Defines the buffer attributes of an **OH_AVCodec** instance. ``` typedef enum OH_AVCodecBufferFlagsOH_AVCodecBufferFlags ``` -**Description**
-Enumerates the buffer flags of an **OH_AVCodec** instance. -@syscap SystemCapability.Multimedia.Media.CodecBase +**Description** + +Defines an enum that enumerates the flags for the buffer of an **OH_AVCodec** instance. + +\@syscap SystemCapability.Multimedia.Media.CodecBase ### OH_AVCodecOnError @@ -150,18 +212,20 @@ Enumerates the buffer flags of an **OH_AVCodec** instance. ``` typedef void(* OH_AVCodecOnError) (OH_AVCodec *codec, int32_t errorCode, void *userData) ``` -**Description**
-Defines the function pointer that is called to report error information when an error occurs during the running of an **OH_AVCodec** instance. -@syscap SystemCapability.Multimedia.Media.CodecBase +**Description** + +Defines the pointer to the function that is called to report error information when an error occurs during the running of an **OH_AVCodec** instance. + +\@syscap SystemCapability.Multimedia.Media.CodecBase **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| errorCode | Indicates an error code. | -| userData | Indicates the pointer to user-specific data. | +| codec | Pointer to an **OH_AVCodec** instance.| +| errorCode | Error code.| +| userData | Pointer to user-specific data.| ### OH_AVCodecOnNeedInputData @@ -170,19 +234,21 @@ Defines the function pointer that is called to report error information when an ``` typedef void(* OH_AVCodecOnNeedInputData) (OH_AVCodec *codec, uint32_t index, OH_AVMemory *data, void *userData) ``` -**Description**
-Defines the function pointer that is called, with a new buffer to fill in new input data, when new input data is required during the running of an **OH_AVCodec** instance. -@syscap SystemCapability.Multimedia.Media.CodecBase +**Description** + +Defines the pointer to the function that is called when new input data is required during the running of an **OH_AVCodec** instance. The function carries a buffer to fill in new input data. + +\@syscap SystemCapability.Multimedia.Media.CodecBase **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| index | Indicates the index of an input buffer. | -| data | Indicates the pointer to the new input data. | -| userData | Indicates the pointer to user-specific data. | +| codec | Pointer to an **OH_AVCodec** instance.| +| index | Index of the new input buffer.| +| data | Pointer to the data to fill in the new input buffer.| +| userData | Pointer to user-specific data.| ### OH_AVCodecOnNewOutputData @@ -191,20 +257,22 @@ Defines the function pointer that is called, with a new buffer to fill in new in ``` typedef void(* OH_AVCodecOnNewOutputData) (OH_AVCodec *codec, uint32_t index, OH_AVMemory *data, OH_AVCodecBufferAttr *attr, void *userData) ``` -**Description**
-Defines the function pointer that is called, with a buffer containing new output data, when the new output data is generated during the running of an **OH_AVCodec** instance. Note that the lifecycle of the pointer to the **OH_AVCodecBufferAttr** instance is valid only when the function pointer is being called. Do not access the pointer to the instance after the function pointer is called. -@syscap SystemCapability.Multimedia.Media.CodecBase +**Description** + +Defines the pointer to the function that is called when new output data is generated during the running of an **OH_AVCodec** instance. The function carries a buffer filled with new output data. Note that the lifecycle of the pointer to the **OH_AVCodecBufferAttr** instance is valid only when the function pointer is being called. Do not access the pointer to the instance after the function pointer is called. + +\@syscap SystemCapability.Multimedia.Media.CodecBase **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| index | Indicates the index of a new output buffer. | -| data | Indicates the pointer to the new output data. | -| attr | Indicates the pointer to the attributes of the new output buffer. For details, see [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md).| -| userData | Indicates the pointer to user-specific data. | +| codec | Pointer to an **OH_AVCodec** instance.| +| index | Index of the new output buffer.| +| data | Pointer to the data filled in the new output buffer.| +| attr | Pointer to the description information about the new output buffer. For details, see [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md).| +| userData | Pointer to user-specific data.| ### OH_AVCodecOnStreamChanged @@ -213,18 +281,20 @@ Defines the function pointer that is called, with a buffer containing new output ``` typedef void(* OH_AVCodecOnStreamChanged) (OH_AVCodec *codec, OH_AVFormat *format, void *userData) ``` -**Description**
-Defines the function pointer that is called to report the attributes of the new stream when the output stream changes. Note that the lifecycle of the pointer to the **OH_AVFormat** instance is valid only when the function pointer is being called. Do not access the pointer to the instance after the function pointer is called. -@syscap SystemCapability.Multimedia.Media.CodecBase +**Description** + +Defines the pointer to the function that is called to report the new stream description when the output stream changes. Note that the lifecycle of the pointer to the **OH_AVFormat** instance is valid only when the function pointer is being called. Do not access the pointer to the instance after the function pointer is called. + +\@syscap SystemCapability.Multimedia.Media.CodecBase **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| format | Indicates the handle to the attributes of the new output stream. | -| userData | Indicates the pointer to user-specific data. | +| codec | Pointer to an **OH_AVCodec** instance.| +| format | Pointer to the description information about the new output stream.| +| userData | Pointer to user-specific data.| ### OH_AVCProfile @@ -233,10 +303,94 @@ Defines the function pointer that is called to report the attributes of the new ``` typedef enum OH_AVCProfileOH_AVCProfile ``` -**Description**
-Enumerates the AVC profiles. -@syscap SystemCapability.Multimedia.Media.CodecBase +**Description** + +Defines an enum that enumerates the AVC profiles. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + + +### OH_AVOutputFormat + + +``` +typedef enum OH_AVOutputFormatOH_AVOutputFormat +``` + +**Description** + +Defines an enum that enumerates the output file formats of a muxer. + + +### OH_AVSeekMode + + +``` +typedef enum OH_AVSeekModeOH_AVSeekMode +``` + +**Description** + +Defines an enum that enumerates the seek modes. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + + +### OH_BitsPerSample + + +``` +typedef enum OH_BitsPerSampleOH_BitsPerSample +``` + +**Description** + +Defines an enum that enumerates the number of audio bits for each coded sample. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + + +### OH_ColorPrimary + + +``` +typedef enum OH_ColorPrimaryOH_ColorPrimary +``` + +**Description** + +Defines an enum that enumerates the primary colors. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + + +### OH_HEVCProfile + + +``` +typedef enum OH_HEVCProfileOH_HEVCProfile +``` + +**Description** + +Defines an enum that enumerates the HEVC profiles. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + + +### OH_MatrixCoefficient + + +``` +typedef enum OH_MatrixCoefficientOH_MatrixCoefficient +``` + +**Description** + +Defines an enum that enumerates the matrix coefficients. + +\@syscap SystemCapability.Multimedia.Media.CodecBase ### OH_MediaType @@ -245,10 +399,26 @@ Enumerates the AVC profiles. ``` typedef enum OH_MediaTypeOH_MediaType ``` -**Description**
-Enumerates the media types. -@syscap SystemCapability.Multimedia.Media.CodecBase +**Description** + +Defines an enum that enumerates the media types. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + + +### OH_TransferCharacteristic + + +``` +typedef enum OH_TransferCharacteristicOH_TransferCharacteristic +``` + +**Description** + +Defines an enum that enumerates the transfer characteristics. + +\@syscap SystemCapability.Multimedia.Media.CodecBase ## Enum Description @@ -260,10 +430,12 @@ Enumerates the media types. ``` enum OH_AACProfile ``` -**Description**
+ +**Description** + Enumerates the AAC profiles. -@syscap SystemCapability.Multimedia.Media.CodecBase +\@syscap SystemCapability.Multimedia.Media.CodecBase ### OH_AVCodecBufferFlags @@ -272,17 +444,12 @@ Enumerates the AAC profiles. ``` enum OH_AVCodecBufferFlags ``` -**Description**
-Enumerates the buffer flags of an **OH_AVCodec** instance. -@syscap SystemCapability.Multimedia.Media.CodecBase +**Description** - | Value| Description| -| -------- | -------- | -| AVCODEC_BUFFER_FLAGS_EOS | The buffer contains an end-of-stream frame.| -| AVCODEC_BUFFER_FLAGS_SYNC_FRAME | The buffer contains a sync frame.| -| AVCODEC_BUFFER_FLAGS_INCOMPLETE_FRAME | The buffer contains part of a frame.| -| AVCODEC_BUFFER_FLAGS_CODEC_DATA | The buffer contains codec-specific data.| +Enumerates the flags for the buffer of an **OH_AVCodec** instance. + +\@syscap SystemCapability.Multimedia.Media.CodecBase ### OH_AVCProfile @@ -291,10 +458,94 @@ Enumerates the buffer flags of an **OH_AVCodec** instance. ``` enum OH_AVCProfile ``` -**Description**
+ +**Description** + Enumerates the AVC profiles. -@syscap SystemCapability.Multimedia.Media.CodecBase +\@syscap SystemCapability.Multimedia.Media.CodecBase + + +### OH_AVOutputFormat + + +``` +enum OH_AVOutputFormat +``` + +**Description** + +Enumerates the output file formats of a muxer. + + +### OH_AVSeekMode + + +``` +enum OH_AVSeekMode +``` + +**Description** + +Enumerates the seek modes. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + + +### OH_BitsPerSample + + +``` +enum OH_BitsPerSample +``` + +**Description** + +Enumerates the number of audio bits for each coded sample. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + + +### OH_ColorPrimary + + +``` +enum OH_ColorPrimary +``` + +**Description** + +Enumerates the primary colors. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + + +### OH_HEVCProfile + + +``` +enum OH_HEVCProfile +``` + +**Description** + +Enumerates the HEVC profiles. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + + +### OH_MatrixCoefficient + + +``` +enum OH_MatrixCoefficient +``` + +**Description** + +Enumerates the matrix coefficients. + +\@syscap SystemCapability.Multimedia.Media.CodecBase ### OH_MediaType @@ -303,50 +554,127 @@ Enumerates the AVC profiles. ``` enum OH_MediaType ``` -**Description**
+ +**Description** + Enumerates the media types. -@syscap SystemCapability.Multimedia.Media.CodecBase +\@syscap SystemCapability.Multimedia.Media.CodecBase - | Value| Description| -| -------- | -------- | -| MEDIA_TYPE_AUD | Audio track.| -| MEDIA_TYPE_VID | Video track.| + +### OH_TransferCharacteristic + + +``` +enum OH_TransferCharacteristic +``` + +**Description** + +Enumerates the transfer characteristics. + +\@syscap SystemCapability.Multimedia.Media.CodecBase ## Variable Description -### flags +### OH_AVCODEC_MIMETYPE_AUDIO_AAC ``` -uint32_t OH_AVCodecBufferAttr::flags +const char* OH_AVCODEC_MIMETYPE_AUDIO_AAC ``` -**Description**
-Defines a buffer flag, which is a combination of multiple [OH_AVCodecBufferFlags](#oh_avcodecbufferflags). +**Description** + +Defines the pointer to the MIME type for AAC audio codec. -### offset +\@syscap SystemCapability.Multimedia.Media.CodecBase + + +### OH_AVCODEC_MIMETYPE_AUDIO_FLAC ``` -int32_t OH_AVCodecBufferAttr::offset +const char* OH_AVCODEC_MIMETYPE_AUDIO_FLAC ``` -**Description**
-Start offset of valid data in the buffer. +**Description** -### OH_AVCODEC_MIMETYPE_AUDIO_AAC +Defines the pointer to the MIME type for FLAC audio codec. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + + +### OH_AVCODEC_MIMETYPE_AUDIO_MPEG ``` -const char* OH_AVCODEC_MIMETYPE_AUDIO_AAC +const char* OH_AVCODEC_MIMETYPE_AUDIO_MPEG +``` + +**Description** + +Defines the pointer to the MIME type for MPEG audio codec. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + + +### OH_AVCODEC_MIMETYPE_AUDIO_VORBIS + + +``` +const char* OH_AVCODEC_MIMETYPE_AUDIO_VORBIS ``` -**Description**
-Defines the MIME type for AAC. -@syscap SystemCapability.Multimedia.Media.CodecBase +**Description** + +Defines the pointer to the MIME type for VORBIS audio codec. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + + +### OH_AVCODEC_MIMETYPE_IMAGE_BMP + + +``` +const char* OH_AVCODEC_MIMETYPE_IMAGE_BMP +``` + +**Description** + +Defines the pointer to the MIME type for BMP image codec. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + + +### OH_AVCODEC_MIMETYPE_IMAGE_JPG + + +``` +const char* OH_AVCODEC_MIMETYPE_IMAGE_JPG +``` + +**Description** + +Defines the pointer to the MIME type for JPG image codec. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + + +### OH_AVCODEC_MIMETYPE_IMAGE_PNG + + +``` +const char* OH_AVCODEC_MIMETYPE_IMAGE_PNG +``` + +**Description** + +Defines the pointer to the MIME type for PNG image codec. + +\@syscap SystemCapability.Multimedia.Media.CodecBase ### OH_AVCODEC_MIMETYPE_VIDEO_AVC @@ -355,10 +683,40 @@ Defines the MIME type for AAC. ``` const char* OH_AVCODEC_MIMETYPE_VIDEO_AVC ``` -**Description**
-Defines the MIME type for AVC. -@syscap SystemCapability.Multimedia.Media.CodecBase +**Description** + +Defines the pointer to the MIME type for AVC video codec. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + + +### OH_AVCODEC_MIMETYPE_VIDEO_HEVC + + +``` +const char* OH_AVCODEC_MIMETYPE_VIDEO_HEVC +``` + +**Description** + +Defines the pointer to the MIME type for HEVC video codec. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + + +### OH_AVCODEC_MIMETYPE_VIDEO_MPEG4 + + +``` +const char* OH_AVCODEC_MIMETYPE_VIDEO_MPEG4 +``` + +**Description** + +Defines the pointer to the MIME type for MPEG4 video codec. + +\@syscap SystemCapability.Multimedia.Media.CodecBase ### OH_ED_KEY_EOS @@ -367,8 +725,12 @@ Defines the MIME type for AVC. ``` const char* OH_ED_KEY_EOS ``` -**Description**
-Defines the character descriptor of the end-of-stream in the surface auxiliary data. The value type is bool. + +**Description** + +Defines the pointer to the EOS in the extra data of the surface. The value type is Boolean. + +\@syscap SystemCapability.Multimedia.Media.CodecBase ### OH_ED_KEY_TIME_STAMP @@ -377,10 +739,60 @@ Defines the character descriptor of the end-of-stream in the surface auxiliary d ``` const char* OH_ED_KEY_TIME_STAMP ``` -**Description**
-Defines the unified character descriptors for the auxiliary data of the surface buffer. -@syscap SystemCapability.Multimedia.Media.CodecBase +**Description** + +Defines the pointer to the timestamp in the extra data of the surface. The value type is int64. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + + +### OH_MD_KEY_AAC_IS_ADTS + + +``` +const char* OH_MD_KEY_AAC_IS_ADTS +``` + +**Description** + +Defines the pointer to the AAC format. The value type is uint32_t. This key applies to AAC decoders. + + +### OH_MD_KEY_ALBUM + + +``` +const char* OH_MD_KEY_ALBUM +``` + +**Description** + +Defines the pointer to the album of the input media. The value is a string. + + +### OH_MD_KEY_ALBUM_ARTIST + + +``` +const char* OH_MD_KEY_ALBUM_ARTIST +``` + +**Description** + +Defines the pointer to the album_artist of the input media. The value is a string. + + +### OH_MD_KEY_ARTIST + + +``` +const char* OH_MD_KEY_ARTIST +``` + +**Description** + +Defines the pointer to the artist of the input media. The value is a string. ### OH_MD_KEY_AUD_CHANNEL_COUNT @@ -389,8 +801,10 @@ Defines the unified character descriptors for the auxiliary data of the surface ``` const char* OH_MD_KEY_AUD_CHANNEL_COUNT ``` -**Description**
-Defines the character descriptor of the number of audio channels. The value type is uint32_t. + +**Description** + +Defines the pointer to the number of audio channels. The value type is uint32_t. ### OH_MD_KEY_AUD_SAMPLE_RATE @@ -399,8 +813,10 @@ Defines the character descriptor of the number of audio channels. The value type ``` const char* OH_MD_KEY_AUD_SAMPLE_RATE ``` -**Description**
-Defines the character descriptor of the audio sampling rate. The value type is uint32_t. + +**Description** + +Defines the pointer to the audio sampling rate. The value type is uint32_t. ### OH_MD_KEY_AUDIO_SAMPLE_FORMAT @@ -409,8 +825,10 @@ Defines the character descriptor of the audio sampling rate. The value type is u ``` const char* OH_MD_KEY_AUDIO_SAMPLE_FORMAT ``` -**Description**
-Defines the character descriptor of the audio sample format. The value type is uint32_t. + +**Description** + +Defines the pointer to the original audio format. The value type is uint32_t. ### OH_MD_KEY_BITRATE @@ -419,8 +837,46 @@ Defines the character descriptor of the audio sample format. The value type is u ``` const char* OH_MD_KEY_BITRATE ``` -**Description**
-Defines the character descriptor of the bit rate. The value type is uint32_t. + +**Description** + +Defines the pointer to the bit rate. The value type is uint32_t. + + +### OH_MD_KEY_BITS_PER_CODED_SAMPLE + + +``` +const char* OH_MD_KEY_BITS_PER_CODED_SAMPLE +``` + +**Description** + +Defines the pointer to the number of bits for each coded sample. The value type is uint32_t. This key applies to FLAC encoders. + + +### OH_MD_KEY_CHANNEL_LAYOUT + + +``` +const char* OH_MD_KEY_CHANNEL_LAYOUT +``` + +**Description** + +Defines the pointer to the required encoding channel layout. The value type is int64_t. This key applies only to encoders. + + +### OH_MD_KEY_CODEC_CONFIG + + +``` +const char* OH_MD_KEY_CODEC_CONFIG +``` + +**Description** + +Defines the pointer to the codec-specific data. The value type is uint8_t\*. ### OH_MD_KEY_CODEC_MIME @@ -429,8 +885,82 @@ Defines the character descriptor of the bit rate. The value type is uint32_t. ``` const char* OH_MD_KEY_CODEC_MIME ``` -**Description**
-Defines the character descriptor of the MIME type. The value type is string. + +**Description** + +Define the pointer to the MIME type of codec. The value is a string. + + +### OH_MD_KEY_COLOR_PRIMARIES + + +``` +const char* OH_MD_KEY_COLOR_PRIMARIES +``` + +**Description** + +Defines the pointer to the primary color of the video. The value type is int32_t. + + +### OH_MD_KEY_COMMENT + + +``` +const char* OH_MD_KEY_COMMENT +``` + +**Description** + +Defines the pointer to the comment of the input media. The value is a string. + + +### OH_MD_KEY_COMPLIANCE_LEVEL + + +``` +const char* OH_MD_KEY_COMPLIANCE_LEVEL +``` + +**Description** + +Defines the pointer to the FLAC compliance level. The value type is int32_t. + + +### OH_MD_KEY_COPYRIGHT + + +``` +const char* OH_MD_KEY_COPYRIGHT +``` + +**Description** + +Defines the pointer to the copyright of the input media. The value is a string. + + +### OH_MD_KEY_DATE + + +``` +const char* OH_MD_KEY_DATE +``` + +**Description** + +Defines the pointer to the date of the input media. The value is a string. + + +### OH_MD_KEY_DESCRIPTION + + +``` +const char* OH_MD_KEY_DESCRIPTION +``` + +**Description** + +Defines the pointer to the description of the input media. The value is a string. ### OH_MD_KEY_DURATION @@ -439,8 +969,10 @@ Defines the character descriptor of the MIME type. The value type is string. ``` const char* OH_MD_KEY_DURATION ``` -**Description**
-Defines the character descriptor of duration. The value type is int64_t. + +**Description** + +Defines the pointer to the duration. The value type is int64_t. ### OH_MD_KEY_FRAME_RATE @@ -449,8 +981,22 @@ Defines the character descriptor of duration. The value type is int64_t. ``` const char* OH_MD_KEY_FRAME_RATE ``` -**Description**
-Defines the character descriptor of the video frame rate. The value type is double. + +**Description** + +Defines the pointer to the video frame rate. The value is a double-precision floating point number. + + +### OH_MD_KEY_GENRE + + +``` +const char* OH_MD_KEY_GENRE +``` + +**Description** + +Defines the pointer to the genre of the input media. The value is a string. ### OH_MD_KEY_HEIGHT @@ -459,8 +1005,10 @@ Defines the character descriptor of the video frame rate. The value type is doub ``` const char* OH_MD_KEY_HEIGHT ``` -**Description**
-Defines the character descriptor of the video height. The value type is uint32_t. + +**Description** + +Defines the pointer to the video height. The value type is uint32_t. ### OH_MD_KEY_I_FRAME_INTERVAL @@ -469,8 +1017,58 @@ Defines the character descriptor of the video height. The value type is uint32_t ``` const char* OH_MD_KEY_I_FRAME_INTERVAL ``` -**Description**
-Defines the character descriptor of the I-frame interval. The value type is int32_t, and the unit is ms. + +**Description** + +Defines the pointer to the key frame interval, in milliseconds. The value type is int32_t. + + +### OH_MD_KEY_IDENTIFICATION_HEADER + + +``` +const char* OH_MD_KEY_IDENTIFICATION_HEADER +``` + +**Description** + +Defines the pointer to the VORBIS identification header. The value type is uint8_t\*. This key applies only to VORBIS decoders. + + +### OH_MD_KEY_LANGUAGE + + +``` +const char* OH_MD_KEY_LANGUAGE +``` + +**Description** + +Defines the pointer to the language of the input media. The value is a string. + + +### OH_MD_KEY_LYRICS + + +``` +const char* OH_MD_KEY_LYRICS +``` + +**Description** + +Defines the pointer to the lyrics of the input media. The value is a string. + + +### OH_MD_KEY_MATRIX_COEFFICIENTS + + +``` +const char* OH_MD_KEY_MATRIX_COEFFICIENTS +``` + +**Description** + +Defines the pointer to the video matrix coefficient. The value type is int32_t. ### OH_MD_KEY_MAX_INPUT_SIZE @@ -479,8 +1077,10 @@ Defines the character descriptor of the I-frame interval. The value type is int3 ``` const char* OH_MD_KEY_MAX_INPUT_SIZE ``` -**Description**
-Defines the character descriptor of the maximum input size. The value type is uint32_t. + +**Description** + +Defines the pointer to the maximum input size. The value type is uint32_t. ### OH_MD_KEY_PIXEL_FORMAT @@ -489,8 +1089,10 @@ Defines the character descriptor of the maximum input size. The value type is ui ``` const char* OH_MD_KEY_PIXEL_FORMAT ``` -**Description**
-Defines the character descriptor of the video pixel format. The value type is int32_t. For details, see [OH_AVPixelFormat](_core.md#oh_avpixelformat). + +**Description** + +Defines the pointer to the video pixel format. The value type is int32_t. For details, see [OH_AVPixelFormat](_core.md#oh_avpixelformat). ### OH_MD_KEY_PROFILE @@ -499,8 +1101,46 @@ Defines the character descriptor of the video pixel format. The value type is in ``` const char* OH_MD_KEY_PROFILE ``` -**Description**
-Defines the character descriptor of the audio/video encoding capability. The value type is int32_t. For details, see [OH_AVCProfile](#oh_avcprofile) or [OH_AACProfile](#oh_aacprofile). + +**Description** + +Defines the pointer to the encoding template. The value is a number. For details, see [OH_AVCProfile](#oh_avcprofile), [OH_AACProfile](#oh_aacprofile), or [OH_HEVCProfile](#oh_hevcprofile). + + +### OH_MD_KEY_QUALITY + + +``` +const char* OH_MD_KEY_QUALITY +``` + +**Description** + +Defines the pointer to the required encoding quality. The value type is uint32_t. This key applies only to encoders configured in constant quality mode. + + +### OH_MD_KEY_RANGE_FLAG + + +``` +const char* OH_MD_KEY_RANGE_FLAG +``` + +**Description** + +Defines the pointer to the video YUV value range flag. The value type is Boolean. + + +### OH_MD_KEY_REQUEST_I_FRAME + + +``` +const char* OH_MD_KEY_REQUEST_I_FRAME +``` + +**Description** + +Defines the pointer to the request for immediate encoding of I-frames. The value type is Boolean. ### OH_MD_KEY_ROTATION @@ -509,57 +1149,105 @@ Defines the character descriptor of the audio/video encoding capability. The val ``` const char* OH_MD_KEY_ROTATION ``` -**Description**
-Defines the character descriptor of the surface rotation angle. The value type is int32_t. The value range is {0, 90, 180, 270}. The default value is 0. +**Description** + +Defines the pointer to the rotation angle of the surface. The value type is int32_t, and the value range is {0, 90, 180, 270}. The default value is 0. -### OH_MD_KEY_TRACK_TYPE + +### OH_MD_KEY_SBR ``` -const char* OH_MD_KEY_TRACK_TYPE +const char* OH_MD_KEY_SBR ``` -**Description**
-Defines the unified character descriptors for the media playback framework. -@syscap SystemCapability.Multimedia.Media.CodecBase +**Description** +Defines the pointer to the AAC SBR format. The value type is uint32_t. This key applies to AAC encoders. -### OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE + +### OH_MD_KEY_SETUP_HEADER ``` -const char* OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE +const char* OH_MD_KEY_SETUP_HEADER ``` -**Description**
-Defines the character descriptor of the video encoding bit rate mode. The value type is int32_t. For details, see [OH_VideoEncodeBitrateMode](_video_encoder.md#oh_videoencodebitratemode). +**Description** + +Defines the pointer to the VORBIS setup header. The value type is uint8_t\*. This key applies only to VORBIS decoders. -### OH_MD_KEY_WIDTH + +### OH_MD_KEY_TITLE ``` -const char* OH_MD_KEY_WIDTH +const char* OH_MD_KEY_TITLE +``` + +**Description** + +Defines the pointer to the title of the input media. The value is a string. + + +### OH_MD_KEY_TRACK_COUNT + + +``` +const char* OH_MD_KEY_TRACK_COUNT ``` -**Description**
-Defines the character descriptor of the video width. The value type is uint32_t. +**Description** -### pts +Defines the pointer to the track count of the input media. The value type is uint32_t. + + +### OH_MD_KEY_TRACK_TYPE ``` -int64_t OH_AVCodecBufferAttr::pts +const char* OH_MD_KEY_TRACK_TYPE ``` -**Description**
-Defines the presentation timestamp of the buffer, in microseconds. +**Description** -### size +Defines the pointer to a container for storing media descriptions. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + + +### OH_MD_KEY_TRANSFER_CHARACTERISTICS ``` -int32_t OH_AVCodecBufferAttr::size +const char* OH_MD_KEY_TRANSFER_CHARACTERISTICS +``` + +**Description** + +Defines the pointer to the video transfer characteristics. The value type is int32_t. + + +### OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE + + ``` -**Description**
-Defines the size of the data contained in the buffer, in bytes. +const char* OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE +``` + +**Description** + +Defines the pointer to the video encoding bit rate mode. The value type is int32_t. For details, see [OH_VideoEncodeBitrateMode](_video_encoder.md#oh_videoencodebitratemode). + + +### OH_MD_KEY_WIDTH + + +``` +const char* OH_MD_KEY_WIDTH +``` + +**Description** + +Defines the pointer to the video width. The value type is uint32_t. diff --git a/en/application-dev/reference/native-apis/_core.md b/en/application-dev/reference/native-apis/_core.md index 711afe0875..f4fbb00279 100644 --- a/en/application-dev/reference/native-apis/_core.md +++ b/en/application-dev/reference/native-apis/_core.md @@ -3,11 +3,12 @@ ## Overview -Provides the basic backbone capabilities for the media playback framework, including functions related to the memory, error code, and format carrier. +The **Core** module provides the basic backbone capabilities for the media playback framework, including functions related to the memory, error code, and format carrier. \@syscap SystemCapability.Multimedia.Media.Core -**Since:** +**Since** + 9 @@ -16,51 +17,55 @@ Provides the basic backbone capabilities for the media playback framework, inclu ### Files -| Name | Description | +| Name| Description| | -------- | -------- | -| [native_averrors.h](native__averrors_8h.md) | Declares the error codes used by the media playback framework.
File to Include: | -| [native_avformat.h](native__avformat_8h.md) | Declares the format-related functions and enums.
File to Include: | -| [native_avmemory.h](native__avmemory_8h.md) | Declares the memory-related functions.
File to Include: | +| [native_averrors.h](native__averrors_8h.md) | Declares the error codes used by the media playback framework.
File to include: \ | +| [native_avformat.h](native__avformat_8h.md) | Declares the format-related functions and enums.
File to include: \ | +| [native_avmemory.h](native__avmemory_8h.md) | Declares the memory-related functions.
File to include: \ | ### Types -| Name | Description | +| Name| Description| | -------- | -------- | -| [OH_AVErrCode](#oh_averrcode) | Enumerates the audio and video error codes. | -| [OH_AVPixelFormat](#oh_avpixelformat) | Enumerates the audio and video pixel formats. | +| [OH_AVErrCode](#oh_averrcode) | Defines an enum that enumerates the audio and video error codes.| +| [OH_AVPixelFormat](#oh_avpixelformat) | Defines an enum that enumerates the video pixel formats.| ### Enums -| Name | Description | +| Name| Description| | -------- | -------- | -| [OH_AVErrCode](#oh_averrcode) {
AV_ERR_OK = 0, AV_ERR_NO_MEMORY = 1, AV_ERR_OPERATE_NOT_PERMIT = 2, AV_ERR_INVALID_VAL = 3,
AV_ERR_IO = 4, AV_ERR_TIMEOUT = 5, AV_ERR_UNKNOWN = 6, AV_ERR_SERVICE_DIED = 7,
AV_ERR_INVALID_STATE = 8, AV_ERR_UNSUPPORT = 9, AV_ERR_EXTEND_START = 100
} | Enumerates the audio and video error codes. | -| [OH_AVPixelFormat](#oh_avpixelformat) {
AV_PIXEL_FORMAT_YUVI420 = 1, AV_PIXEL_FORMAT_NV12 = 2, AV_PIXEL_FORMAT_NV21 = 3, AV_PIXEL_FORMAT_SURFACE_FORMAT = 4,
AV_PIXEL_FORMAT_RGBA = 5
} | Enumerates the audio and video pixel formats. | +| [OH_AVErrCode](#oh_averrcode) {
AV_ERR_OK = 0, AV_ERR_NO_MEMORY = 1, AV_ERR_OPERATE_NOT_PERMIT = 2, AV_ERR_INVALID_VAL = 3,
AV_ERR_IO = 4, AV_ERR_TIMEOUT = 5, AV_ERR_UNKNOWN = 6, AV_ERR_SERVICE_DIED = 7,
AV_ERR_INVALID_STATE = 8, AV_ERR_UNSUPPORT = 9, AV_ERR_EXTEND_START = 100
} | Enumerates the audio and video error codes.| +| [OH_AVPixelFormat](#oh_avpixelformat) {
AV_PIXEL_FORMAT_YUVI420 = 1, AV_PIXEL_FORMAT_NV12 = 2, AV_PIXEL_FORMAT_NV21 = 3, AV_PIXEL_FORMAT_SURFACE_FORMAT = 4,
AV_PIXEL_FORMAT_RGBA = 5
} | Enumerates the video pixel formats.| ### Functions -| Name | Description | +| Name| Description| | -------- | -------- | -| [OH_AVFormat_Create](#oh_avformat_create) (void) | Creates an **OH_AVFormat** instance for reading and writing data. | -| [OH_AVFormat_Destroy](#oh_avformat_destroy) (struct OH_AVFormat \*format) | Destroys an **OH_AVFormat** instance. | -| [OH_AVFormat_Copy](#oh_avformat_copy) (struct OH_AVFormat \*to, struct OH_AVFormat \*from) | Copies the resources from an **OH_AVFormat** instance to another. | -| [OH_AVFormat_SetIntValue](#oh_avformat_setintvalue) (struct OH_AVFormat \*format, const char \*key, int32_t value) | Writes data of the int type to an **OH_AVFormat** instance. | -| [OH_AVFormat_SetLongValue](#oh_avformat_setlongvalue) (struct OH_AVFormat \*format, const char \*key, int64_t value) | Writes data of the long type to an **OH_AVFormat** instance. | -| [OH_AVFormat_SetFloatValue](#oh_avformat_setfloatvalue) (struct OH_AVFormat \*format, const char \*key, float value) | Writes data of the float type to an **OH_AVFormat** instance. | -| [OH_AVFormat_SetDoubleValue](#oh_avformat_setdoublevalue) (struct OH_AVFormat \*format, const char \*key, double value) | Writes data of the double type to an **OH_AVFormat** instance. | -| [OH_AVFormat_SetStringValue](#oh_avformat_setstringvalue) (struct OH_AVFormat \*format, const char \*key, const char \*value) | Writes data of the string type to an **OH_AVFormat** instance. | -| [OH_AVFormat_SetBuffer](#oh_avformat_setbuffer) (struct OH_AVFormat \*format, const char \*key, const uint8_t \*addr, size_t size) | Writes data with a specified size to an **OH_AVFormat** instance. | -| [OH_AVFormat_GetIntValue](#oh_avformat_getintvalue) (struct OH_AVFormat \*format, const char \*key, int32_t \*out) | Reads data of the int type from an **OH_AVFormat** instance. | -| [OH_AVFormat_GetLongValue](#oh_avformat_getlongvalue) (struct OH_AVFormat \*format, const char \*key, int64_t \*out) | Reads data of the long type from an **OH_AVFormat** instance. | -| [OH_AVFormat_GetFloatValue](#oh_avformat_getfloatvalue) (struct OH_AVFormat \*format, const char \*key, float \*out) | Reads data of the float type from an **OH_AVFormat** instance. | -| [OH_AVFormat_GetDoubleValue](#oh_avformat_getdoublevalue) (struct OH_AVFormat \*format, const char \*key, double \*out) | Reads data of the double type from an **OH_AVFormat** instance. | -| [OH_AVFormat_GetStringValue](#oh_avformat_getstringvalue) (struct OH_AVFormat \*format, const char \*key, const char \*\*out) | Reads data of the double type from an **OH_AVFormat** instance. | -| [OH_AVFormat_GetBuffer](#oh_avformat_getbuffer) (struct OH_AVFormat \*format, const char \*key, uint8_t \*\*addr, size_t \*size) | Reads data with a specified size from an **OH_AVFormat** instance. | -| [OH_AVFormat_DumpInfo](#oh_avformat_dumpinfo) (struct OH_AVFormat \*format) | Dumps the information contained in an**OH_AVFormat** instance as a string. | -| [OH_AVMemory_GetAddr](#oh_avmemory_getaddr) (struct OH_AVMemory \*mem) | Obtains the virtual memory address of an **OH_AVMemory** instance. | -| [OH_AVMemory_GetSize](#oh_avmemory_getsize) (struct OH_AVMemory \*mem) | Obtains the memory size of an **OH_AVMemory** instance. | +| \*[OH_AVFormat_Create](#oh_avformat_create) (void) | Creates an **OH_AVFormat** instance for reading data.| +| \*[OH_AVFormat_CreateAudioFormat](#oh_avformat_createaudioformat) (const char \*mimeType, int32_t sampleRate, int32_t channelCount) | Creates an audio **OH_AVFormat** instance for reading and writing data.| +| \*[OH_AVFormat_CreateVideoFormat](#oh_avformat_createvideoformat) (const char \*mimeType, int32_t width, int32_t height) | Creates a video **OH_AVFormat** instance for reading and writing data.| +| [OH_AVFormat_Destroy](#oh_avformat_destroy) (struct OH_AVFormat \*format) | Destroys an **OH_AVFormat** instance.| +| [OH_AVFormat_Copy](#oh_avformat_copy) (struct OH_AVFormat \*to, struct OH_AVFormat \*from) | Copies an **OH_AVFormat** instance.| +| [OH_AVFormat_SetIntValue](#oh_avformat_setintvalue) (struct OH_AVFormat \*format, const char \*key, int32_t value) | Writes data of the int type to an **OH_AVFormat** instance.| +| [OH_AVFormat_SetLongValue](#oh_avformat_setlongvalue) (struct OH_AVFormat \*format, const char \*key, int64_t value) | Writes data of the long type to an **OH_AVFormat** instance.| +| [OH_AVFormat_SetFloatValue](#oh_avformat_setfloatvalue) (struct OH_AVFormat \*format, const char \*key, float value) | Writes data of the float type to an **OH_AVFormat** instance.| +| [OH_AVFormat_SetDoubleValue](#oh_avformat_setdoublevalue) (struct OH_AVFormat \*format, const char \*key, double value) | Writes data of the double type to an **OH_AVFormat** instance.| +| [OH_AVFormat_SetStringValue](#oh_avformat_setstringvalue) (struct OH_AVFormat \*format, const char \*key, const char \*value) | Writes data of the string type to an **OH_AVFormat** instance.| +| [OH_AVFormat_SetBuffer](#oh_avformat_setbuffer) (struct OH_AVFormat \*format, const char \*key, const uint8_t \*addr, size_t size) | Writes data blocks of a specified length to an **OH_AVFormat** instance.| +| [OH_AVFormat_GetIntValue](#oh_avformat_getintvalue) (struct OH_AVFormat \*format, const char \*key, int32_t \*out) | Reads data of the int type from an **OH_AVFormat** instance.| +| [OH_AVFormat_GetLongValue](#oh_avformat_getlongvalue) (struct OH_AVFormat \*format, const char \*key, int64_t \*out) | Reads data of the long type from an **OH_AVFormat** instance.| +| [OH_AVFormat_GetFloatValue](#oh_avformat_getfloatvalue) (struct OH_AVFormat \*format, const char \*key, float \*out) | Reads data of the float type from an **OH_AVFormat** instance.| +| [OH_AVFormat_GetDoubleValue](#oh_avformat_getdoublevalue) (struct OH_AVFormat \*format, const char \*key, double \*out) | Reads data of the double type from an **OH_AVFormat** instance.| +| [OH_AVFormat_GetStringValue](#oh_avformat_getstringvalue) (struct OH_AVFormat \*format, const char \*key, const char \*\*out) | Reads data of the string type from an **OH_AVFormat** instance.| +| [OH_AVFormat_GetBuffer](#oh_avformat_getbuffer) (struct OH_AVFormat \*format, const char \*key, uint8_t \*\*addr, size_t \*size) | Reads data blocks of a specified length from an **OH_AVFormat** instance.| +| \*[OH_AVFormat_DumpInfo](#oh_avformat_dumpinfo) (struct OH_AVFormat \*format) | Dumps the information contained in an **OH_AVFormat** instance as a string.| +| \*[OH_AVMemory_Create](#oh_avmemory_create) (int32_t size) | Creates an **OH_AVMemory** instance.| +| \*[OH_AVMemory_GetAddr](#oh_avmemory_getaddr) (struct OH_AVMemory \*mem) | Obtains the virtual memory address of an **OH_AVMemory** instance.| +| [OH_AVMemory_GetSize](#oh_avmemory_getsize) (struct OH_AVMemory \*mem) | Obtains the memory size of an **OH_AVMemory** instance.| +| [OH_AVMemory_Destroy](#oh_avmemory_destroy) (struct OH_AVMemory \*mem) | Releases an **OH_AVMemory** instance.| ## Type Description @@ -72,11 +77,17 @@ Provides the basic backbone capabilities for the media playback framework, inclu ``` typedef enum OH_AVErrCodeOH_AVErrCode ``` -**Description**
-Enumerates the audio and video error codes. + +**Description** + +Defines an enum that enumerates the audio and video error codes. \@syscap SystemCapability.Multimedia.Media.Core +**Since** + +9 + ### OH_AVPixelFormat @@ -84,11 +95,17 @@ Enumerates the audio and video error codes. ``` typedef enum OH_AVPixelFormatOH_AVPixelFormat ``` -**Description**
-Enumerates the audio and video pixel formats. + +**Description** + +Defines an enum that enumerates the video pixel formats. \@syscap SystemCapability.Multimedia.Media.Core +**Since** + +9 + ## Enum Description @@ -99,24 +116,30 @@ Enumerates the audio and video pixel formats. ``` enum OH_AVErrCode ``` -**Description**
+ +**Description** + Enumerates the audio and video error codes. \@syscap SystemCapability.Multimedia.Media.Core -| Name | Description | +**Since** + +9 + +| Value| Description| | -------- | -------- | -| AV_ERR_OK | Operation successful. | -| AV_ERR_NO_MEMORY | No memory. | -| AV_ERR_OPERATE_NOT_PERMIT | Invalid parameter. | -| AV_ERR_INVALID_VAL | Invalid value. | -| AV_ERR_IO | I/O error. | -| AV_ERR_TIMEOUT | Timeout. | -| AV_ERR_UNKNOWN | Unknown error. | -| AV_ERR_SERVICE_DIED | Unavailable media service. | -| AV_ERR_INVALID_STATE | Unsupported operation in this state. | -| AV_ERR_UNSUPPORT | Unsupported API. | -| AV_ERR_EXTEND_START | Initial value for extended error codes. | +| AV_ERR_OK | Operation successful.| +| AV_ERR_NO_MEMORY | No memory.| +| AV_ERR_OPERATE_NOT_PERMIT | Operation not allowed.| +| AV_ERR_INVALID_VAL | Invalid value.| +| AV_ERR_IO | I/O error.| +| AV_ERR_TIMEOUT | Timeout.| +| AV_ERR_UNKNOWN | Unknown error.| +| AV_ERR_SERVICE_DIED | Unavailable service.| +| AV_ERR_INVALID_STATE | Unsupported operation in this state.| +| AV_ERR_UNSUPPORT | Unsupported API.| +| AV_ERR_EXTEND_START | Initial value for extended error codes.| ### OH_AVPixelFormat @@ -125,18 +148,24 @@ Enumerates the audio and video error codes. ``` enum OH_AVPixelFormat ``` -**Description**
-Enumerates the audio and video pixel formats. + +**Description** + +Enumerates the video pixel formats. \@syscap SystemCapability.Multimedia.Media.Core -| Name | Description | +**Since** + +9 + +| Value| Description| | -------- | -------- | -| AV_PIXEL_FORMAT_YUVI420 | YUV 420 Planar. | -| AV_PIXEL_FORMAT_NV12 | NV12. YUV 420 Semi-planar. | -| AV_PIXEL_FORMAT_NV21 | NV21. YVU 420 Semi-planar. | -| AV_PIXEL_FORMAT_SURFACE_FORMAT | Surface. | -| AV_PIXEL_FORMAT_RGBA | RGBA8888. | +| AV_PIXEL_FORMAT_YUVI420 | YUV 420 Planar.| +| AV_PIXEL_FORMAT_NV12 | NV12. YUV 420 semi-planar.| +| AV_PIXEL_FORMAT_NV21 | NV21. YVU 420 semi-planar.| +| AV_PIXEL_FORMAT_SURFACE_FORMAT | Surface.| +| AV_PIXEL_FORMAT_RGBA | RGBA8888.| ## Function Description @@ -148,23 +177,27 @@ Enumerates the audio and video pixel formats. ``` bool OH_AVFormat_Copy (struct OH_AVFormat * to, struct OH_AVFormat * from ) ``` -**Description**
-Copies the resources from an **OH_AVFormat** instance to another. + +**Description** + +Copies an **OH_AVFormat** instance. \@syscap SystemCapability.Multimedia.Media.Core - **Parameters** +**Parameters** -| Name | Description | +| Name| Description| | -------- | -------- | -| to | Indicates the handle to the **OH_AVFormat** instance to which the data will be copied. | -| from | Indicates the handle to the **OH_AVFormat** instance from which the data will be copied. | +| to | Handle to the **OH_AVFormat** instance to which the data will be copied.| +| from | Handle to the **OH_AVFormat** instance from which the data will be copied.| **Returns** -Returns **TRUE** if the operation is successful. +Returns **true** if the operation is successful; returns **false** otherwise. -Returns **FALSE** if the operation fails. +**Since** + +9 ### OH_AVFormat_Create() @@ -173,14 +206,80 @@ Returns **FALSE** if the operation fails. ``` struct OH_AVFormat* OH_AVFormat_Create (void ) ``` -**Description**
-Creates an **OH_AVFormat** instance for reading and writing data. + +**Description** + +Creates an **OH_AVFormat** instance for reading data. + +\@syscap SystemCapability.Multimedia.Media.Core + +**Returns** + +Returns the pointer to an **OH_AVFormat** instance. + +**Since** + +9 + + +### OH_AVFormat_CreateAudioFormat() + + +``` +struct OH_AVFormat* OH_AVFormat_CreateAudioFormat (const char * mimeType, int32_t sampleRate, int32_t channelCount ) +``` + +**Description** + +Creates an audio **OH_AVFormat** instance for reading and writing data. \@syscap SystemCapability.Multimedia.Media.Core +**Parameters** + +| Name| Description| +| -------- | -------- | +| mimeType | Pointer to the MIME type.| +| sampleRate | Sampling rate, in Hz.| +| channelCount | Number of audio channels. For example, 1 indicates mono and 2 indicates stereo.| + +**Returns** + +Returns the pointer to an **OH_AVFormat** instance. + +**Since** + +10 + + +### OH_AVFormat_CreateVideoFormat() + + +``` +struct OH_AVFormat* OH_AVFormat_CreateVideoFormat (const char * mimeType, int32_t width, int32_t height ) +``` + +**Description** + +Creates a video **OH_AVFormat** instance for reading and writing data. + +\@syscap SystemCapability.Multimedia.Media.Core + +**Parameters** + +| Name| Description| +| -------- | -------- | +| mimeType | Pointer to the MIME type.| +| width | Video width, in pixels.| +| height | Video height, in pixels.| + **Returns** -Returns the handle to an **OH_AVFormat** instance. +Returns the pointer to an **OH_AVFormat** instance. + +**Since** + +10 ### OH_AVFormat_Destroy() @@ -189,20 +288,22 @@ Returns the handle to an **OH_AVFormat** instance. ``` void OH_AVFormat_Destroy (struct OH_AVFormat * format) ``` -**Description**
+ +**Description** + Destroys an **OH_AVFormat** instance. \@syscap SystemCapability.Multimedia.Media.Core - **Parameters** +**Parameters** -| Name | Description | +| Name| Description| | -------- | -------- | -| format | Indicates the handle to an **OH_AVFormat** instance. | +| format | Pointer to an **OH_AVFormat** instance.| -**Returns** +**Since** -void +9 ### OH_AVFormat_DumpInfo() @@ -211,20 +312,26 @@ void ``` const char* OH_AVFormat_DumpInfo (struct OH_AVFormat * format) ``` -**Description**
-Dumps the information contained in an**OH_AVFormat** instance as a string. + +**Description** + +Dumps the information contained in an **OH_AVFormat** instance as a string. \@syscap SystemCapability.Multimedia.Media.Core - **Parameters** +**Parameters** -| Name | Description | +| Name| Description| | -------- | -------- | -| format | Indicates the handle to an **OH_AVFormat** instance. | +| format | Pointer to an **OH_AVFormat** instance.| **Returns** -Returns the pointer to a collect of strings, each of which consists of a key and value. +Returns the pointer to a collection of strings, each of which consists of a key and value. + +**Since** + +9 ### OH_AVFormat_GetBuffer() @@ -233,25 +340,29 @@ Returns the pointer to a collect of strings, each of which consists of a key and ``` bool OH_AVFormat_GetBuffer (struct OH_AVFormat * format, const char * key, uint8_t ** addr, size_t * size ) ``` -**Description**
-Reads data with a specified size from an **OH_AVFormat** instance. + +**Description** + +Reads data blocks of a specified length from an **OH_AVFormat** instance. \@syscap SystemCapability.Multimedia.Media.Core - **Parameters** +**Parameters** -| Name | Description | +| Name| Description| | -------- | -------- | -| format | Indicates the handle to an **OH_AVFormat** instance. | -| key | Indicates the pointer to the key of the data to read. | -| addr | Indicates the double pointer to the address where the data read is stored. The data read is destroyed when the **OH_AVFormat** instance is destroyed. To hold the data for an extended period of time, copy it to the memory. | -| size | Indicates the pointer to the size of the data read. | +| format | Pointer to an **OH_AVFormat** instance.| +| key | Pointer to the key of the data to read.| +| addr | Double pointer to the address where the data read is stored. The data read is destroyed when the **OH_AVFormat** instance is destroyed. To hold the data for an extended period of time, copy it to the memory.| +| size | Pointer to the size of the data read.| **Returns** -Returns **TRUE** if the operation is successful. +Returns **true** if the operation is successful; returns **false** otherwise. + +**Since** -Returns **FALSE** if the operation fails. +9 ### OH_AVFormat_GetDoubleValue() @@ -260,24 +371,28 @@ Returns **FALSE** if the operation fails. ``` bool OH_AVFormat_GetDoubleValue (struct OH_AVFormat * format, const char * key, double * out ) ``` -**Description**
+ +**Description** + Reads data of the double type from an **OH_AVFormat** instance. \@syscap SystemCapability.Multimedia.Media.Core - **Parameters** +**Parameters** -| Name | Description | +| Name| Description| | -------- | -------- | -| format | Indicates the handle to an **OH_AVFormat** instance. | -| key | Indicates the pointer to the key of the data to read. | -| out | Indicates the pointer to the data read. | +| format | Pointer to an **OH_AVFormat** instance.| +| key | Pointer to the key of the data to read.| +| out | Pointer to the value of the data read.| **Returns** -Returns **TRUE** if the operation is successful. +Returns **true** if the operation is successful; returns **false** otherwise. -Returns **FALSE** if the operation fails. +**Since** + +9 ### OH_AVFormat_GetFloatValue() @@ -286,24 +401,28 @@ Returns **FALSE** if the operation fails. ``` bool OH_AVFormat_GetFloatValue (struct OH_AVFormat * format, const char * key, float * out ) ``` -**Description**
+ +**Description** + Reads data of the float type from an **OH_AVFormat** instance. \@syscap SystemCapability.Multimedia.Media.Core - **Parameters** +**Parameters** -| Name | Description | +| Name| Description| | -------- | -------- | -| format | Indicates the handle to an **OH_AVFormat** instance. | -| key | Indicates the pointer to the key of the data to read. | -| out | Indicates the pointer to the data read. | +| format | Pointer to an **OH_AVFormat** instance.| +| key | Pointer to the key of the data to read.| +| out | Pointer to the value of the data read.| **Returns** -Returns **TRUE** if the operation is successful. +Returns **true** if the operation is successful; returns **false** otherwise. + +**Since** -Returns **FALSE** if the operation fails. +9 ### OH_AVFormat_GetIntValue() @@ -312,24 +431,24 @@ Returns **FALSE** if the operation fails. ``` bool OH_AVFormat_GetIntValue (struct OH_AVFormat * format, const char * key, int32_t * out ) ``` -**Description**
+ +**Description** + Reads data of the int type from an **OH_AVFormat** instance. \@syscap SystemCapability.Multimedia.Media.Core - **Parameters** +**Parameters** -| Name | Description | +| Name| Description| | -------- | -------- | -| format | Indicates the handle to an **OH_AVFormat** instance. | -| key | Indicates the pointer to the key of the data to read. | -| out | Indicates the pointer to the data read. | +| format | Pointer to an **OH_AVFormat** instance.| +| key | Pointer to the key of the data to read.| +| out | Pointer to the value of the data read.| **Returns** -Returns **TRUE** if the operation is successful. - -Returns **FALSE** if the operation fails. +Returns **true** if the operation is successful; returns **false** otherwise. ### OH_AVFormat_GetLongValue() @@ -338,24 +457,28 @@ Returns **FALSE** if the operation fails. ``` bool OH_AVFormat_GetLongValue (struct OH_AVFormat * format, const char * key, int64_t * out ) ``` -**Description**
+ +**Description** + Reads data of the long type from an **OH_AVFormat** instance. \@syscap SystemCapability.Multimedia.Media.Core - **Parameters** +**Parameters** -| Name | Description | +| Name| Description| | -------- | -------- | -| format | Indicates the handle to an **OH_AVFormat** instance. | -| key | Indicates the pointer to the key of the data to read. | -| out | Indicates the pointer to the data read. | +| format | Pointer to an **OH_AVFormat** instance.| +| key | Pointer to the key of the data to read.| +| out | Pointer to the value of the data read.| **Returns** -Returns **TRUE** if the operation is successful. +Returns **true** if the operation is successful; returns **false** otherwise. -Returns **FALSE** if the operation fails. +**Since** + +9 ### OH_AVFormat_GetStringValue() @@ -364,24 +487,28 @@ Returns **FALSE** if the operation fails. ``` bool OH_AVFormat_GetStringValue (struct OH_AVFormat * format, const char * key, const char ** out ) ``` -**Description**
-Reads data of the double type from an **OH_AVFormat** instance. + +**Description** + +Reads data of the string type from an **OH_AVFormat** instance. \@syscap SystemCapability.Multimedia.Media.Core - **Parameters** +**Parameters** -| Name | Description | +| Name| Description| | -------- | -------- | -| format | Indicates the handle to an **OH_AVFormat** instance. | -| key | Indicates the pointer to the key of the data to read. | -| out | Indicates the double pointer to the data read. The data read is updated when **GetString** is called and destroyed when the **OH_AVFormat** instance is destroyed. To hold the data for an extended period of time, copy it to the memory. | +| format | Pointer to an **OH_AVFormat** instance.| +| key | Pointer to the key of the data to read.| +| out | Double pointer to the data read. The data read is destroyed when the **OH_AVFormat** instance is destroyed. To hold the data for an extended period of time, copy it to the memory.| **Returns** -Returns **TRUE** if the operation is successful. +Returns **true** if the operation is successful; returns **false** otherwise. -Returns **FALSE** if the operation fails. +**Since** + +9 ### OH_AVFormat_SetBuffer() @@ -390,25 +517,29 @@ Returns **FALSE** if the operation fails. ``` bool OH_AVFormat_SetBuffer (struct OH_AVFormat * format, const char * key, const uint8_t * addr, size_t size ) ``` -**Description**
-Writes data with a specified size to an **OH_AVFormat** instance. + +**Description** + +Writes data blocks of a specified length to an **OH_AVFormat** instance. \@syscap SystemCapability.Multimedia.Media.Core - **Parameters** +**Parameters** -| Name | Description | +| Name| Description| | -------- | -------- | -| format | Indicates the handle to an **OH_AVFormat** instance. | -| key | Indicates the pointer to the key of the data to write. | -| addr | Indicates the pointer to the address where the data is written. | -| size | Indicates the size of the data written. | +| format | Pointer to an **OH_AVFormat** instance.| +| key | Pointer to the key of the data to write.| +| addr | Pointer to the address where the data is written.| +| size | Size of the data written.| **Returns** -Returns **TRUE** if the operation is successful. +Returns **true** if the operation is successful; returns **false** otherwise. -Returns **FALSE** if the operation fails. +**Since** + +9 ### OH_AVFormat_SetDoubleValue() @@ -417,24 +548,28 @@ Returns **FALSE** if the operation fails. ``` bool OH_AVFormat_SetDoubleValue (struct OH_AVFormat * format, const char * key, double value ) ``` -**Description**
+ +**Description** + Writes data of the double type to an **OH_AVFormat** instance. \@syscap SystemCapability.Multimedia.Media.Core - **Parameters** +**Parameters** -| Name | Description | +| Name| Description| | -------- | -------- | -| format | Indicates the handle to an **OH_AVFormat** instance. | -| key | Indicates the pointer to the key of the data to write. | -| value | Indicates the value of the data to write. | +| format | Pointer to an **OH_AVFormat** instance.| +| key | Pointer to the key of the data to write.| +| value | Value of the data to write.| **Returns** -Returns **TRUE** if the operation is successful. +Returns **true** if the operation is successful; returns **false** otherwise. + +**Since** -Returns **FALSE** if the operation fails. +9 ### OH_AVFormat_SetFloatValue() @@ -443,24 +578,28 @@ Returns **FALSE** if the operation fails. ``` bool OH_AVFormat_SetFloatValue (struct OH_AVFormat * format, const char * key, float value ) ``` -**Description**
+ +**Description** + Writes data of the float type to an **OH_AVFormat** instance. \@syscap SystemCapability.Multimedia.Media.Core - **Parameters** +**Parameters** -| Name | Description | +| Name| Description| | -------- | -------- | -| format | Indicates the handle to an **OH_AVFormat** instance. | -| key | Indicates the pointer to the key of the data to write. | -| value | Indicates the value of the data to write. | +| format | Pointer to an **OH_AVFormat** instance.| +| key | Pointer to the key of the data to write.| +| value | Value of the data to write.| **Returns** -Returns **TRUE** if the operation is successful. +Returns **true** if the operation is successful; returns **false** otherwise. -Returns **FALSE** if the operation fails. +**Since** + +9 ### OH_AVFormat_SetIntValue() @@ -469,24 +608,28 @@ Returns **FALSE** if the operation fails. ``` bool OH_AVFormat_SetIntValue (struct OH_AVFormat * format, const char * key, int32_t value ) ``` -**Description**
+ +**Description** + Writes data of the int type to an **OH_AVFormat** instance. \@syscap SystemCapability.Multimedia.Media.Core - **Parameters** +**Parameters** -| Name | Description | +| Name| Description| | -------- | -------- | -| format | Indicates the handle to an **OH_AVFormat** instance. | -| key | Indicates the pointer to the key of the data to write. | -| value | Indicates the value of the data to write. | +| format | Pointer to an **OH_AVFormat** instance.| +| key | Pointer to the key of the data to write.| +| value | Value of the data to write.| **Returns** -Returns **TRUE** if the operation is successful. +Returns **true** if the operation is successful; returns **false** otherwise. -Returns **FALSE** if the operation fails. +**Since** + +9 ### OH_AVFormat_SetLongValue() @@ -495,24 +638,28 @@ Returns **FALSE** if the operation fails. ``` bool OH_AVFormat_SetLongValue (struct OH_AVFormat * format, const char * key, int64_t value ) ``` -**Description**
+ +**Description** + Writes data of the long type to an **OH_AVFormat** instance. \@syscap SystemCapability.Multimedia.Media.Core - **Parameters** +**Parameters** -| Name | Description | +| Name| Description| | -------- | -------- | -| format | Indicates the handle to an **OH_AVFormat** instance. | -| key | Indicates the pointer to the key of the data to write. | -| value | Indicates the value of the data to write. | +| format | Pointer to an **OH_AVFormat** instance.| +| key | Pointer to the key of the data to write.| +| value | Value of the data to write.| **Returns** -Returns **TRUE** if the operation is successful. +Returns **true** if the operation is successful; returns **false** otherwise. -Returns **FALSE** if the operation fails. +**Since** + +9 ### OH_AVFormat_SetStringValue() @@ -521,24 +668,84 @@ Returns **FALSE** if the operation fails. ``` bool OH_AVFormat_SetStringValue (struct OH_AVFormat * format, const char * key, const char * value ) ``` -**Description**
+ +**Description** + Writes data of the string type to an **OH_AVFormat** instance. \@syscap SystemCapability.Multimedia.Media.Core - **Parameters** +**Parameters** + +| Name| Description| +| -------- | -------- | +| format | Pointer to an **OH_AVFormat** instance.| +| key | Pointer to the key of the data to write.| +| value | Value of the data to write.| + +**Returns** + +Returns **true** if the operation is successful; returns **false** otherwise. + +**Since** + +9 + + +### OH_AVMemory_Create() + + +``` +OH_AVMemory* OH_AVMemory_Create (int32_t size) +``` + +**Description** + +Creates an **OH_AVMemory** instance. + +\@syscap SystemCapability.Multimedia.Media.Core + +**Parameters** + +| Name| Description| +| -------- | -------- | +| size | Size of the created memory, in bytes.| + +**Returns** + +Returns the pointer to the **OH_AVMemory** instance created if the operation is successful; returns a null pointer otherwise. The instance must be released by calling **OH_AVMemory_Destroy** when it is no longer required. + +**Since** + +10 + + +### OH_AVMemory_Destroy() + + +``` +OH_AVErrCode OH_AVMemory_Destroy (struct OH_AVMemory * mem) +``` + +**Description** + +Releases an **OH_AVMemory** instance. + +\@syscap SystemCapability.Multimedia.Media.Core + +**Parameters** -| Name | Description | +| Name| Description| | -------- | -------- | -| format | Indicates the handle to an **OH_AVFormat** instance. | -| key | Indicates the pointer to the key of the data to write. | -| value | Indicates the pointer to the value of the data to write. | +| mem | Pointer to an **OH_AVMemory** instance.| **Returns** -Returns **TRUE** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](#oh_averrcode) otherwise. + +**Since** -Returns **FALSE** if the operation fails. +10 ### OH_AVMemory_GetAddr() @@ -547,22 +754,26 @@ Returns **FALSE** if the operation fails. ``` uint8_t* OH_AVMemory_GetAddr (struct OH_AVMemory * mem) ``` -**Description**
+ +**Description** + Obtains the virtual memory address of an **OH_AVMemory** instance. \@syscap SystemCapability.Multimedia.Media.Core - **Parameters** +**Parameters** -| Name | Description | +| Name| Description| | -------- | -------- | -| mem | Indicates the pointer to an **OH_AVMemory** instance. | +| mem | Pointer to an **OH_AVMemory** instance.| **Returns** -Returns the virtual address if the memory is valid. +Returns the pointer to the virtual memory address if the memory is valid; returns a null pointer otherwise. + +**Since** -Returns a null pointer if the memory is invalid. +9 ### OH_AVMemory_GetSize() @@ -571,19 +782,23 @@ Returns a null pointer if the memory is invalid. ``` int32_t OH_AVMemory_GetSize (struct OH_AVMemory * mem) ``` -**Description**
+ +**Description** + Obtains the memory size of an **OH_AVMemory** instance. \@syscap SystemCapability.Multimedia.Media.Core - **Parameters** +**Parameters** -| Name | Description | +| Name| Description| | -------- | -------- | -| mem | Indicates the pointer to an **OH_AVMemory** instance. | +| mem | Pointer to an **OH_AVMemory** instance.| **Returns** -Returns the size if the memory is valid. +Returns the memory size if the memory is valid; returns **-1** otherwise. -Returns **-1** if the memory is invalid. +**Since** + +9 diff --git a/en/application-dev/reference/native-apis/_native_vsync.md b/en/application-dev/reference/native-apis/_native_vsync.md new file mode 100644 index 0000000000..531ef2634e --- /dev/null +++ b/en/application-dev/reference/native-apis/_native_vsync.md @@ -0,0 +1,149 @@ +# NativeVsync + + +## Overview + +The **NativeVsync** module provides the capabilities of native virtual synchronization (VSync). + +\@syscap SystemCapability.Graphic.Graphic2D.NativeVsync + +**Since** + +9 + + +## Summary + + +### Files + +| Name| Description| +| -------- | -------- | +| [native_vsync.h](native__vsync_8h.md) | Declares the functions for obtaining and using native VSync.
File to include: <native_vsync/native_vsync.h>| + + +### Types + +| Name| Description| +| -------- | -------- | +| [OH_NativeVSync](#oh_nativevsync) | Provides the declaration of an **OH_NativeVSync** struct. | +| (\*[OH_NativeVSync_FrameCallback](#oh_nativevsync_framecallback)) (long long timestamp, void \*data) | Defines the pointer to a VSync callback function.| + + +### Functions + +| Name| Description| +| -------- | -------- | +| [OH_NativeVSync_Create](#oh_nativevsync_create) (const char \*name, unsigned int length) | Creates an **OH_NativeVSync** instance. A new **OH_NativeVSync** instance is created each time this function is called.| +| [OH_NativeVSync_Destroy](#oh_nativevsync_destroy) ([OH_NativeVSync](#oh_nativevsync) \*nativeVsync) | Destroys an **OH_NativeVSync** instance.| +| [OH_NativeVSync_RequestFrame](#oh_nativevsync_requestframe) ([OH_NativeVSync](#oh_nativevsync) \*nativeVsync, [OH_NativeVSync_FrameCallback](#oh_nativevsync_framecallback) callback, void \*data) | Requests the next VSync signal. When the signal arrives, a callback function is invoked.| + + +## Type Description + + +### OH_NativeVSync + + +``` +typedef struct OH_NativeVSync OH_NativeVSync +``` + +**Description** + +Provides the declaration of a **OH_NativeVSync** struct. + + +### OH_NativeVSync_FrameCallback + + +``` +typedef void(* OH_NativeVSync_FrameCallback) (long long timestamp, void *data) +``` + +**Description** + +Defines the pointer to a VSync callback function. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeVsync + +**Parameters** + +| Name| Description| +| -------- | -------- | +| timestamp | VSync timestamp.| +| data | User-defined data.| + + +## Function Description + + +### OH_NativeVSync_Create() + + +``` +OH_NativeVSync* OH_NativeVSync_Create (const char * name, unsigned int length ) +``` + +**Description** + +Creates an **OH_NativeVSync** instance. A new **OH_NativeVSync** instance is created each time this function is called. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeVsync + +**Parameters** + +| Name| Description| +| -------- | -------- | +| name | Pointer to the name that associates with an **OH_NativeVSync** instance.| +| length | Length of the name.| + +**Returns** + +Returns the pointer to an **OH_NativeVSync** instance. + + +### OH_NativeVSync_Destroy() + + +``` +void OH_NativeVSync_Destroy (OH_NativeVSync * nativeVsync) +``` + +**Description** + +Destroys an **OH_NativeVSync** instance. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeVsync + +**Parameters** + +| Name| Description| +| -------- | -------- | +| nativeVsync | Pointer to an **OH_NativeVSync** instance.| + + +### OH_NativeVSync_RequestFrame() + + +``` +int OH_NativeVSync_RequestFrame (OH_NativeVSync * nativeVsync, OH_NativeVSync_FrameCallback callback, void * data ) +``` + +**Description** + +Requests the next VSync signal. When the signal arrives, a callback function is invoked. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeVsync + +**Parameters** + +| Name| Description| +| -------- | -------- | +| nativeVsync | Pointer to an **OH_NativeVSync** instance.| +| callback | Function pointer of the **OH_NativeVSync_FrameCallback** type. This function pointer will be called when the next VSync signal arrives.| +| data | Pointer to the user-defined data struct. The type is void\*.| + +**Returns** + +Returns **0** if the operation is successful. diff --git a/en/application-dev/reference/native-apis/_o_h___a_v_codec_async_callback.md b/en/application-dev/reference/native-apis/_o_h___a_v_codec_async_callback.md index adb8cb60db..ba164c3449 100644 --- a/en/application-dev/reference/native-apis/_o_h___a_v_codec_async_callback.md +++ b/en/application-dev/reference/native-apis/_o_h___a_v_codec_async_callback.md @@ -3,14 +3,15 @@ ## Overview -Defines a collection of asynchronous callback functions for an **OH_AVCodec** instance. You must register this struct instance for an **OH_AVCodec** instance and process the information reported through these callbacks to ensure the normal running of the instance. +The **OH_AVCodecAsyncCallback** struct defines all the asynchronous callback function pointers of an **OH_AVCodec** instance. To ensure the normal running of **OH_AVCodec**, you must register the instance of this struct with the **OH_AVCodec** instance and process the information reported by the callback function. \@syscap SystemCapability.Multimedia.Media.CodecBase -**Since:** +**Since** + 9 -**Related Modules:** +**Related Modules** [CodecBase](_codec_base.md) @@ -20,9 +21,76 @@ Defines a collection of asynchronous callback functions for an **OH_AVCodec** in ### Member Variables -| Name | Description | +| Name| Description| | -------- | -------- | -| **onError** | Indicates the callback used to report errors occurred during the running of the instance. For details, see [OH_AVCodecOnError](_codec_base.md#oh_avcodeconerror) | -| **onStreamChanged** | Indicates the callback used to report stream information. For details, see [OH_AVCodecOnStreamChanged](_codec_base.md#oh_avcodeconstreamchanged) | -| **onNeedInputData** | Indicates the callback used to report input data needed. For details, see [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) | -| **onNeedOutputData** | Indicates the callback used to report output data needed. For details, see [OH_AVCodecOnNewOutputData](_codec_base.md#oh_avcodeconnewoutputdata) | +| [onError](#onerror) | Defines the callback used to report a codec operation error. For details, see [OH_AVCodecOnError](_codec_base.md#oh_avcodeconerror).| +| [onStreamChanged](#onstreamchanged) | Defines the callback used to report a codec stream change. For details, see [OH_AVCodecOnStreamChanged](_codec_base.md#oh_avcodeconstreamchanged).| +| [onNeedInputData](#onneedinputdata) | Defines the callback used to report input data required. For details, see [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata).| +| [onNeedOutputData](#onneedoutputdata) | Defines the callback used to report output data generated. For details, see [OH_AVCodecOnNewOutputData](_codec_base.md#oh_avcodeconnewoutputdata).| + + +## Member Variable Description + + +### onError + + +``` +OH_AVCodecOnError onError +``` + +**Description** + +Defines the callback used to report a codec operation error. For details, see [OH_AVCodecOnError](_codec_base.md#oh_avcodeconerror). + +**Since** + +9 + + +### onNeedInputData + + +``` +OH_AVCodecOnNeedInputData onNeedInputData +``` + +**Description** + +Defines the callback used to report input data required. For details, see [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata). + +**Since** + +9 + + +### onNeedOutputData + + +``` +OH_AVCodecOnNewOutputData onNeedOutputData +``` + +**Description** + +Defines the callback used to report output data generated. For details, see [OH_AVCodecOnNewOutputData](_codec_base.md#oh_avcodeconnewoutputdata). + +**Since** + +9 + + +### onStreamChanged + + +``` +OH_AVCodecOnStreamChanged onStreamChanged +``` + +**Description** + +Defines the callback used to report a codec stream change. For details, see [OH_AVCodecOnStreamChanged](_codec_base.md#oh_avcodeconstreamchanged). + +**Since** + +9 diff --git a/en/application-dev/reference/native-apis/_o_h___a_v_codec_buffer_attr.md b/en/application-dev/reference/native-apis/_o_h___a_v_codec_buffer_attr.md index dc711939d9..8aed911225 100644 --- a/en/application-dev/reference/native-apis/_o_h___a_v_codec_buffer_attr.md +++ b/en/application-dev/reference/native-apis/_o_h___a_v_codec_buffer_attr.md @@ -3,14 +3,15 @@ ## Overview -Defines the buffer attributes of an **OH_AVCodec** instance. +The **OH_AVCodecBufferAttr** struct defines the description information about the buffer of an **OH_AVCodec** instance. \@syscap SystemCapability.Multimedia.Media.CodecBase -**Since:** +**Since** + 9 -**Related Modules:** +**Related Modules** [CodecBase](_codec_base.md) @@ -20,9 +21,76 @@ Defines the buffer attributes of an **OH_AVCodec** instance. ### Member Variables -| Name | Description | +| Name| Description| | -------- | -------- | -| [pts](_codec_base.md#pts) | Presentation timestamp of the buffer, in microseconds.| -| [size](_codec_base.md#size) | Size of the data contained in the buffer, in bytes. | -| [offset](_codec_base.md#offset) | Start offset of valid data in the buffer. | -| [flags](_codec_base.md#flags) | Buffer flag, which is a combination of multiple **OH_AVCodecBufferFlags**. | +| [pts](#pts) | Defines the display timestamp of the buffer, in microseconds.| +| [size](#size) | Defines the size of data contained in the buffer, in bytes.| +| [offset](#offset) | Defines the offset of valid data in the buffer.| +| [flags](#flags) | Defines the flags of the buffer. It is a combination of multiple [OH_AVCodecBufferFlags](_codec_base.md#oh_avcodecbufferflags).| + + +## Member Variable Description + + +### pts + + +``` +int64_t pts +``` + +**Description** + +Defines the display timestamp of the buffer, in microseconds. + +**Since** + +9 + + +### size + + +``` +int32_t size +``` + +**Description** + +Defines the size of data contained in the buffer, in bytes. + +**Since** + +9 + + +### offset + + +``` +int32_t offset +``` + +**Description** + +Defines the offset of valid data in the buffer. + +**Since** + +9 + + +### flags + + +``` +uint32_t flags +``` + +**Description** + +Defines the flags of the buffer. It is a combination of multiple [OH_AVCodecBufferFlags](_codec_base.md#oh_avcodecbufferflags). + +**Since** + +9 diff --git a/en/application-dev/reference/native-apis/_o_h___a_v_range.md b/en/application-dev/reference/native-apis/_o_h___a_v_range.md new file mode 100644 index 0000000000..94eb6d7f41 --- /dev/null +++ b/en/application-dev/reference/native-apis/_o_h___a_v_range.md @@ -0,0 +1,62 @@ +# OH_AVRange + + +## Overview + +The **OH_AVRange** struct defines the value range, which contains the minimum value and maximum value. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + +**Since** + +10 + +**Related Modules** + +[AVCapability](_a_v_capability.md) + + +## Summary + + +### Member Variables + +| Name| Description| +| -------- | -------- | +| [minVal](#minval) | Defines the minimum value.| +| [maxVal](#maxval) | Defines the maximum value.| + + +## Member Variable Description + + +### minVal + + +``` +int32_t minVal +``` + +**Description** + +Defines the minimum value. + +**Since** + +10 + + +### maxVal + + +``` +int32_t maxVal +``` + +**Description** + +Defines the maximum value. + +**Since** + +10 diff --git a/en/application-dev/reference/native-apis/_o_h___audio_capturer___callbacks___struct.md b/en/application-dev/reference/native-apis/_o_h___audio_capturer___callbacks___struct.md new file mode 100644 index 0000000000..e3da1272a5 --- /dev/null +++ b/en/application-dev/reference/native-apis/_o_h___audio_capturer___callbacks___struct.md @@ -0,0 +1,26 @@ +# OH_AudioCapturer_Callbacks_Struct + + +## Overview + +The **OH_AudioCapturer_Callbacks_Struct** struct defines a pointer to the callback functions related to an audio capturer. + +\@syscap SystemCapability.Multimedia.Audio.Core + +**Since** + +10 + +**Related Modules** + +[OHAudio](_o_h_audio.md) + + +## Summary + + +### Member Variables + +| Name| Description| +| -------- | -------- | +| (\*[OH_AudioCapturer_OnReadData](_o_h_audio.md#oh_audiocapturer_onreaddata) )([OH_AudioCapturer](_o_h_audio.md#oh_audiocapturer) \*capturer, void \*userData, void \*buffer, int32_t lenth) | Defines a function pointer to the callback function used to read audio data.| diff --git a/en/application-dev/reference/native-apis/_o_h___audio_renderer___callbacks___struct.md b/en/application-dev/reference/native-apis/_o_h___audio_renderer___callbacks___struct.md new file mode 100644 index 0000000000..264b39a389 --- /dev/null +++ b/en/application-dev/reference/native-apis/_o_h___audio_renderer___callbacks___struct.md @@ -0,0 +1,26 @@ +# OH_AudioRenderer_Callbacks_Struct + + +## Overview + +The **OH_AudioRenderer_Callbacks_Struct** struct defines a pointer to the callback functions related to an audio renderer. + +\@syscap SystemCapability.Multimedia.Audio.Core + +**Since** + +10 + +**Related Modules** + +[OHAudio](_o_h_audio.md) + + +## Summary + + +### Member Variables + +| Name| Description | +| -------- | -------- | +| (\*[OH_AudioRenderer_OnWriteData](_o_h_audio.md#oh_audiorenderer_onwritedata) )([OH_AudioRenderer](_o_h_audio.md#oh_audiorenderer) \*renderer, void \*userData, void \*buffer, int32_t lenth) | Defines a function pointer to the callback function used to write audio data.| diff --git a/en/application-dev/reference/native-apis/_o_h___native_buffer.md b/en/application-dev/reference/native-apis/_o_h___native_buffer.md new file mode 100644 index 0000000000..3bd77436cb --- /dev/null +++ b/en/application-dev/reference/native-apis/_o_h___native_buffer.md @@ -0,0 +1,233 @@ +# OH_NativeBuffer + + +## Overview + +The **OH_NativeBuffer** module provides the capabilities of **NativeBuffer**. Using the functions provided by this module, you can apply for, use, and release the shared memory, and query its attributes. + +\@syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer + +**Since** + +9 + + +## Summary + + +### Files + +| Name| Description| +| -------- | -------- | +| [native_buffer.h](native__buffer_8h.md) | Declares the functions for obtaining and using **NativeBuffer**.
File to include: <native_buffer/native_buffer.h> | + + +### Structs + +| Name| Description| +| -------- | -------- | +| [OH_NativeBuffer_Config](_o_h___native_buffer___config.md) | Defines the **OH_NativeBuffer** attribute configuration, which is used when you apply for a new **OH_NativeBuffer** instance or query the attributes of an existing instance.| + + +### Types + +| Name| Description| +| -------- | -------- | +| [OH_NativeBuffer](#oh_nativebuffer) | Provides the declaration of an **OH_NativeBuffer** struct.| + + +### Functions + +| Name| Description| +| -------- | -------- | +| [OH_NativeBuffer_Alloc](#oh_nativebuffer_alloc) (const [OH_NativeBuffer_Config](_o_h___native_buffer___config.md) \*config) | Creates an **OH_NativeBuffer** instance based on an **OH_NativeBuffer_Config** struct. A new **OH_NativeBuffer** instance is created each time this function is called.| +| [OH_NativeBuffer_Reference](#oh_nativebuffer_reference) ([OH_NativeBuffer](#oh_nativebuffer) \*buffer) | Increases the reference count of an **OH_NativeBuffer** instance by 1.| +| [OH_NativeBuffer_Unreference](#oh_nativebuffer_unreference) ([OH_NativeBuffer](#oh_nativebuffer) \*buffer) | Decreases the reference count of an **OH_NativeBuffer** instance by 1 and, when the reference count reaches 0, destroys the instance.| +| [OH_NativeBuffer_GetConfig](#oh_nativebuffer_getconfig) ([OH_NativeBuffer](#oh_nativebuffer) \*buffer, [OH_NativeBuffer_Config](_o_h___native_buffer___config.md) \*config) | Obtains the attributes of an **OH_NativeBuffer** instance.| +| [OH_NativeBuffer_Map](#oh_nativebuffer_map) ([OH_NativeBuffer](#oh_nativebuffer) \*buffer, void \*\*virAddr) | Maps the ION memory corresponding to an **OH_NativeBuffer** instance to the process address space.| +| [OH_NativeBuffer_Unmap](#oh_nativebuffer_unmap) ([OH_NativeBuffer](#oh_nativebuffer) \*buffer) | Unmaps the ION memory corresponding to an **OH_NativeBuffer** instance from the process address space.| +| [OH_NativeBuffer_GetSeqNum](#oh_nativebuffer_getseqnum) ([OH_NativeBuffer](#oh_nativebuffer) \*buffer) | Obtains the sequence number of an **OH_NativeBuffer** instance.| + + +## Type Description + + +### OH_NativeBuffer + + +``` +typedef struct OH_NativeBuffer OH_NativeBuffer +``` + +**Description** + +Provides the declaration of an **OH_NativeBuffer** struct. + + +## Function Description + + +### OH_NativeBuffer_Alloc() + + +``` +OH_NativeBuffer* OH_NativeBuffer_Alloc (const OH_NativeBuffer_Config * config) +``` + +**Description** + +Creates an **OH_NativeBuffer** instance based on an **OH_NativeBuffer_Config** struct. A new **OH_NativeBuffer** instance is created each time this function is called. + +\@syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer + +**Parameters** + +| Name| Description| +| -------- | -------- | +| config | Pointer to an **OH_NativeBuffer_Config** instance.| + +**Returns** + +Returns the pointer to the **OH_NativeBuffer** instance created if the operation is successful; returns **NULL** otherwise. + + +### OH_NativeBuffer_GetConfig() + + +``` +void OH_NativeBuffer_GetConfig (OH_NativeBuffer * buffer, OH_NativeBuffer_Config * config ) +``` + +**Description** + +Obtains the attributes of an **OH_NativeBuffer** instance. + +\@syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer + +**Parameters** + +| Name| Description| +| -------- | -------- | +| buffer | Pointer to an **OH_NativeBuffer** instance.| +| config | Pointer to an **OH_NativeBuffer_Config** instance, which is used to receive the attributes of **OH_NativeBuffer**.| + + +### OH_NativeBuffer_GetSeqNum() + + +``` +uint32_t OH_NativeBuffer_GetSeqNum (OH_NativeBuffer * buffer) +``` + +**Description** + +Obtains the sequence number of an **OH_NativeBuffer** instance. + +\@syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer + +**Parameters** + +| Name| Description| +| -------- | -------- | +| buffer | Pointer to an **OH_NativeBuffer** instance.| + +**Returns** + +Returns the unique sequence number of the **OH_NativeBuffer** instance. + + +### OH_NativeBuffer_Map() + + +``` +int32_t OH_NativeBuffer_Map (OH_NativeBuffer * buffer, void ** virAddr ) +``` + +**Description** + +Maps the ION memory corresponding to an **OH_NativeBuffer** instance to the process address space. + +\@syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer + +**Parameters** + +| Name| Description| +| -------- | -------- | +| buffer | Pointer to an **OH_NativeBuffer** instance.| +| virAddr | Double pointer to the address of the virtual memory.| + +**Returns** + +Returns **0** if the operation is successful. + + +### OH_NativeBuffer_Reference() + + +``` +int32_t OH_NativeBuffer_Reference (OH_NativeBuffer * buffer) +``` + +**Description** + +Increases the reference count of an **OH_NativeBuffer** instance by 1. + +\@syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer + +**Parameters** + +| Name| Description| +| -------- | -------- | +| buffer | Pointer to an **OH_NativeBuffer** instance.| + +**Returns** + +Returns **0** if the operation is successful. + + +### OH_NativeBuffer_Unmap() + + +``` +int32_t OH_NativeBuffer_Unmap (OH_NativeBuffer * buffer) +``` + +**Description** + +Unmaps the ION memory corresponding to an **OH_NativeBuffer** instance from the process address space. + +\@syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer + +**Parameters** + +| Name| Description| +| -------- | -------- | +| buffer | Pointer to an **OH_NativeBuffer** instance.| + +**Returns** + +Returns **0** if the operation is successful. + + +### OH_NativeBuffer_Unreference() + + +``` +int32_t OH_NativeBuffer_Unreference (OH_NativeBuffer * buffer) +``` + +**Description** + +Decreases the reference count of an **OH_NativeBuffer** instance by 1 and, when the reference count reaches 0, destroys the instance. + +\@syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer + +**Parameters** + +| Name| Description| +| -------- | -------- | +| buffer | Pointer to an **OH_NativeBuffer** instance.| + +**Returns** + +Returns **0** if the operation is successful. diff --git a/en/application-dev/reference/native-apis/_o_h___native_buffer___config.md b/en/application-dev/reference/native-apis/_o_h___native_buffer___config.md new file mode 100644 index 0000000000..b08c50eaf3 --- /dev/null +++ b/en/application-dev/reference/native-apis/_o_h___native_buffer___config.md @@ -0,0 +1,29 @@ +# OH_NativeBuffer_Config + + +## Overview + +The **OH_NativeBuffer_Config** struct defines the **OH_NativeBuffer** attribute configuration, which is used when you apply for a new **OH_NativeBuffer** instance or query the attributes of an existing instance. + +\@syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer + +**Since** + +9 + +**Related Modules** + +[OH_NativeBuffer](_o_h___native_buffer.md) + + +## Summary + + +### Member Variables + +| Name| Description| +| -------- | -------- | +| width | Width, in pixels.| +| height | Height, in pixels.| +| format | Pixel map format.| +| usage | Description of the buffer usage.| diff --git a/en/application-dev/reference/native-apis/_o_h___native_image.md b/en/application-dev/reference/native-apis/_o_h___native_image.md new file mode 100644 index 0000000000..f9968d4343 --- /dev/null +++ b/en/application-dev/reference/native-apis/_o_h___native_image.md @@ -0,0 +1,267 @@ +# OH_NativeImage + + +## Overview + +The **OH_NativeImage** module provides the capabilities of **NativeImage**. Functioning as a data consumer, it is used to associate data with the OpenGL texture. It is used in the OpenGL environment. + +\@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage + +**Since** + +9 + + +## Summary + + +### Files + +| Name| Description| +| -------- | -------- | +| [native_image.h](native__image_8h.md) | Defines the functions for obtaining and using **NativeImage**.
File to include: <native_image/native_image.h> | + + +### Types + +| Name| Description| +| -------- | -------- | +| [OH_NativeImage](#oh_nativeimage) | Provides the declaration of an **OH_NativeImage** struct.| +| [OHNativeWindow](#ohnativewindow) | Provides the capability of accessing the **NativeWindow**.| + + +### Functions + +| Name| Description| +| -------- | -------- | +| [OH_NativeImage_Create](#oh_nativeimage_create) (uint32_t textureId, uint32_t textureTarget) | Creates an **OH_NativeImage** instance to be associated with the OpenGL ES texture ID and target.| +| [OH_NativeImage_AcquireNativeWindow](#oh_nativeimage_acquirenativewindow) (OH_NativeImage \*image) | Obtains an **OHNativeWindow** instance associated with an **OH_NativeImage** instance. You need to call **OH_NativeWindow_DestroyNativeWindow** to release the **OHNativeWindow** instance when it is no longer required. | +| [OH_NativeImage_AttachContext](#oh_nativeimage_attachcontext) (OH_NativeImage \*image, uint32_t textureId) | Attaches an **OH_NativeImage** instance to the current OpenGL ES context.
The OpenGL ES texture will be bound to an **GL_TEXTURE_EXTERNAL_OES** instance and updated through the **OH_NativeImage** instance.| +| [OH_NativeImage_DetachContext](#oh_nativeimage_detachcontext) (OH_NativeImage \*image) | Detaches an **OH_NativeImage** instance from the current OpenGL ES context.| +| [OH_NativeImage_UpdateSurfaceImage](#oh_nativeimage_updatesurfaceimage) (OH_NativeImage \*image) | Updates the OpenGL ES texture associated with the latest frame through an **OH_NativeImage** instance.| +| [OH_NativeImage_GetTimestamp](#oh_nativeimage_gettimestamp) (OH_NativeImage*image) | Obtains the timestamp of the texture image that recently called the **OH_NativeImage_UpdateSurfaceImage** function.| +| [OH_NativeImage_GetTransformMatrix](#oh_nativeimage_gettransformmatrix) (OH_NativeImage \*image, float matrix[16]) | Obtains the transform matrix of the texture image that recently called the **OH_NativeImage_UpdateSurfaceImage** function.| +| [OH_NativeImage_Destroy](#oh_nativeimage_destroy) (OH_NativeImage \*\*image) | Destroys an **OH_NativeImage** instance created by calling **OH_NativeImage_Create**. After the instance is destroyed, the pointer to the **OH_NativeImage** instance is assigned **NULL**. | + + +## Type Description + + +### OH_NativeImage + + +``` +typedef struct OH_NativeImage OH_NativeImage +``` + +**Description** + +Provides the declaration of an **OH_NativeImage** struct. + + +### OHNativeWindow + + +``` +typedef struct NativeWindow OHNativeWindow +``` + +**Description** + +Provides the capability of accessing the **NativeWindow**. + + +## Function Description + + +### OH_NativeImage_AcquireNativeWindow() + + +``` +OHNativeWindow* OH_NativeImage_AcquireNativeWindow (OH_NativeImage * image) +``` + +**Description** + +Obtains an **OHNativeWindow** instance associated with an **OH_NativeImage** instance. You need to call **OH_NativeWindow_DestroyNativeWindow** to release the **OHNativeWindow** instance when it is no longer required. + +\@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage + +**Parameters** + +| Name| Description| +| -------- | -------- | +| image | Pointer to an **OH_NativeImage** instance.| + +**Returns** + +Returns a pointer to the **OHNativeWindow** instance if the operation is successful; returns **NULL** otherwise. + + +### OH_NativeImage_AttachContext() + + +``` +int32_t OH_NativeImage_AttachContext (OH_NativeImage * image, uint32_t textureId ) +``` + +**Description** + +Attaches an **OH_NativeImage** instance to the current OpenGL ES context. + +The OpenGL ES texture will be bound to an **GL_TEXTURE_EXTERNAL_OES** instance and updated through the **OH_NativeImage** instance. + +\@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage + +**Parameters** + +| Name| Description| +| -------- | -------- | +| image | Pointer to an **OH_NativeImage** instance.| +| textureId | ID of the OpenGL ES texture to which the **OH_NativeImage** instance is to be attached.| + +**Returns** + +Returns **0** if the operation is successful. + + +### OH_NativeImage_Create() + + +``` +OH_NativeImage* OH_NativeImage_Create (uint32_t textureId, uint32_t textureTarget ) +``` + +**Description** + +Creates an **OH_NativeImage** instance to be associated with the OpenGL ES texture ID and target. + +\@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage + +**Parameters** + +| Name| Description| +| -------- | -------- | +| textureId | OpenGL ES texture ID.| +| textureTarget | OpenGL ES texture target.| + +**Returns** + +Returns a pointer to the **OH_NativeImage** instance if the operation is successful; returns **NULL** otherwise. + + +### OH_NativeImage_Destroy() + + +``` +void OH_NativeImage_Destroy (OH_NativeImage ** image) +``` + +**Description** + +Destroys an **OH_NativeImage** instance created by calling **OH_NativeImage_Create**. After the instance is destroyed, the pointer to the **OH_NativeImage** instance is assigned **NULL**. + +\@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage + +**Parameters** + +| Name| Description| +| -------- | -------- | +| image | Pointer to an **OH_NativeImage** instance.| + + +### OH_NativeImage_DetachContext() + + +``` +int32_t OH_NativeImage_DetachContext (OH_NativeImage * image) +``` + +**Description** + +Detaches an **OH_NativeImage** instance from the current OpenGL ES context. + +\@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage + +**Parameters** + +| Name| Description| +| -------- | -------- | +| image | Pointer to an **OH_NativeImage** instance.| + +**Returns** + +Returns **0** if the operation is successful. + + +### OH_NativeImage_GetTimestamp() + + +``` +int64_t OH_NativeImage_GetTimestamp (OH_NativeImage * image) +``` + +**Description** + +Obtains the timestamp of the texture image that recently called the **OH_NativeImage_UpdateSurfaceImage** function. + +\@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage + +**Parameters** + +| Name| Description| +| -------- | -------- | +| image | Pointer to an **OH_NativeImage** instance.| + +**Returns** + +Returns the timestamp of the texture image. + + +### OH_NativeImage_GetTransformMatrix() + + +``` +int32_t OH_NativeImage_GetTransformMatrix (OH_NativeImage * image, float matrix[16] ) +``` + +**Description** + +Obtains the transform matrix of the texture image that recently called the **OH_NativeImage_UpdateSurfaceImage** function. + +\@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage + +**Parameters** + +| Name| Description| +| -------- | -------- | +| image | Pointer to an **OH_NativeImage** instance.| +| matrix | Buffer used to store the 4 \* 4 transform matrix obtained.| + +**Returns** + +Returns **0** if the operation is successful. + + +### OH_NativeImage_UpdateSurfaceImage() + + +``` +int32_t OH_NativeImage_UpdateSurfaceImage (OH_NativeImage * image) +``` + +**Description** + +Updates the OpenGL ES texture associated with the latest frame through an **OH_NativeImage** instance. + +\@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage + +**Parameters** + +| Name| Description| +| -------- | -------- | +| image | Pointer to an **OH_NativeImage** instance.| + +**Returns** + +Returns **0** if the operation is successful. diff --git a/en/application-dev/reference/native-apis/_o_h_audio.md b/en/application-dev/reference/native-apis/_o_h_audio.md new file mode 100644 index 0000000000..6107a06b17 --- /dev/null +++ b/en/application-dev/reference/native-apis/_o_h_audio.md @@ -0,0 +1,1493 @@ +# OHAudio + + +## Overview + +The **OHAudio** module provides native APIs of the audio module. + +\@syscap SystemCapability.Multimedia.Audio.Core + +**Since** + +10 + + +## Summary + + +### Files + +| Name| Description| +| -------- | -------- | +| [native_audiocapturer.h](native__audiocapturer_8h.md) | Declares the functions related to an audio capturer.
**File to include**: <ohaudio/native_audiocapturer.h>
**Library**: libohaudio.so| +| [native_audiorenderer.h](native__audiorenderer_8h.md) | Declares the functions related to an audio renderer.
**File to include**: <ohaudio/native_audiorenderer.h>
**Library**: libohaudio.so| +| [native_audiostream_base.h](native__audiostream__base_8h.md) | Declares the basic data structure of **OHAudio**.
**File to include**: <ohaudio/native_audiostream_base.h>
**Library**: libohaudio.so| +| [native_audiostreambuilder.h](native__audiostreambuilder_8h.md) | Declares the functions related to the audio stream builder.
**File to include**: <ohaudio/native_audiostreambuilder.h>
**Library**: libohaudio.so| + + +### Structs + +| Name| Description| +| -------- | -------- | +| [OH_AudioRenderer_Callbacks_Struct](_o_h___audio_renderer___callbacks___struct.md) | Defines a pointer to the callback functions related to an audio renderer.| +| [OH_AudioCapturer_Callbacks_Struct](_o_h___audio_capturer___callbacks___struct.md) | Defines a pointer to the callback functions related to an audio capturer.| + + +### Types + +| Name| Description| +| -------- | -------- | +| [OH_AudioStreamBuilder](#oh_audiostreambuilder) | Defines an audio stream builder.| +| [OH_AudioRenderer](#oh_audiorenderer) | Defines an audio renderer.| +| [OH_AudioCapturer](#oh_audiocapturer) | Defines an audio capturer.| +| [OH_AudioRenderer_Callbacks](#oh_audiorenderer_callbacks) | Defines a pointer to the callback functions related to an audio renderer.| +| [OH_AudioCapturer_Callbacks](#oh_audiocapturer_callbacks) | Defines a pointer to the callback functions related to an audio capturer.| + + +### Enums + +| Name| Description| +| -------- | -------- | +| [OH_AudioStream_Result](#oh_audiostream_result) { AUDIOSTREAM_SUCCESS, AUDIOSTREAM_ERROR_INVALID_PARAM, AUDIOSTREAM_ERROR_ILLEGAL_STATE, AUDIOSTREAM_ERROR_SYSTEM } | Enumerates the audio stream operation results.| +| [OH_AudioStream_Type](#oh_audiostream_type) { AUDIOSTREAM_TYPE_RENDERER = 1, AUDIOSTREAM_TYPE_CAPTURER = 2 } | Enumerates the audio stream types.| +| [OH_AudioStream_SampleFormat](#oh_audiostream_sampleformat) { AUDIOSTREAM_SAMPLE_U8 = 0, AUDIOSTREAM_SAMPLE_S16LE = 1, AUDIOSTREAM_SAMPLE_S24LE = 2, AUDIOSTREAM_SAMPLE_S32LE = 3 } | Enumerates the sampling formats of audio streams.| +| [OH_AudioStream_EncodingType](#oh_audiostream_encodingtype) { **AUDIOSTREAM_ENCODING_TYPE_RAW** = 0 } | Enumerates the encoding types of audio streams.| +| [OH_AudioStream_Usage](#oh_audiostream_usage) { **AUDIOSTREAM_USAGE_UNKNOWN** = 0, **AUDIOSTREAM_USAGE_MUSIC** = 1, **AUDIOSTREAM_USAGE_COMMUNICATION** = 2, **AUDIOSTREAM_USAGE_GAME** = 11 } | Enumerates the usage scenarios of audio output streams.| +| [OH_AudioStream_LatencyMode](#oh_audiostream_latencymode) { AUDIOSTREAM_LATENCY_MODE_NORMAL } | Enumerates the latency modes of audio streams.| +| [OH_AudioStream_State](#oh_audiostream_state) {
AUDIOSTREAM_STATE_INVALID = -1, AUDIOSTREAM_STATE_PREPARED = 1, AUDIOSTREAM_STATE_RUNNING = 2, AUDIOSTREAM_STATE_STOPPED = 3,
AUDIOSTREAM_STATE_RELEASED = 4, AUDIOSTREAM_STATE_PAUSED = 5
} | Enumerates the audio stream states.| +| [OH_AudioStream_SourceType](#oh_audiostream_sourcetype) { **AUDIOSTREAM_SOURCE_TYPE_INVALID** = -1, **AUDIOSTREAM_SOURCE_TYPE_MIC**, **AUDIOSTREAM_SOURCE_TYPE_VOICE_RECOGNITION** = 1, **AUDIOSTREAM_SOURCE_TYPE_VOICE_COMMUNICATION** = 7 } | Enumerates the usage scenarios of audio input streams.| + + +### Functions + +| Name| Description| +| -------- | -------- | +| [OH_AudioCapturer_Release](#oh_audiocapturer_release) ([OH_AudioCapturer](#oh_audiocapturer) \*capturer) | Releases an audio capturer.| +| [OH_AudioCapturer_Start](#oh_audiocapturer_start) ([OH_AudioCapturer](#oh_audiocapturer) \*capturer) | Starts an audio capturer.| +| [OH_AudioCapturer_Pause](#oh_audiocapturer_pause) ([OH_AudioCapturer](#oh_audiocapturer) \*capturer) | Pauses an audio capturer.| +| [OH_AudioCapturer_Stop](#oh_audiocapturer_stop) ([OH_AudioCapturer](#oh_audiocapturer) \*capturer) | Stops an audio capturer.| +| [OH_AudioCapturer_Flush](#oh_audiocapturer_flush) ([OH_AudioCapturer](#oh_audiocapturer) \*capturer) | Flushes obtained audio data.| +| [OH_AudioCapturer_GetCurrentState](#oh_audiocapturer_getcurrentstate) ([OH_AudioCapturer](#oh_audiocapturer) \*capturer, [OH_AudioStream_State](#oh_audiostream_state) \*state) | Obtains the state of an audio stream.| +| [OH_AudioCapturer_GetLatencyMode](#oh_audiocapturer_getlatencymode) ([OH_AudioCapturer](#oh_audiocapturer) \*capturer, [OH_AudioStream_LatencyMode](#oh_audiostream_latencymode) \*latencyMode) | Obtains the latency mode of an audio stream.| +| [OH_AudioCapturer_GetStreamId](#oh_audiocapturer_getstreamid) ([OH_AudioCapturer](#oh_audiocapturer) \*capturer, uint32_t \*streamId) | Obtains the stream ID of an audio stream.| +| [OH_AudioCapturer_GetSamplingRate](#oh_audiocapturer_getsamplingrate) ([OH_AudioCapturer](#oh_audiocapturer) \*capturer, int32_t \*rate) | Obtains the sampling rate of an audio stream.| +| [OH_AudioCapturer_GetChannelCount](#oh_audiocapturer_getchannelcount) ([OH_AudioCapturer](#oh_audiocapturer) \*capturer, int32_t \*channelCount) | Obtains the number of channels for an audio stream.| +| [OH_AudioCapturer_GetSampleFormat](#oh_audiocapturer_getsampleformat) ([OH_AudioCapturer](#oh_audiocapturer) \*capturer, [OH_AudioStream_SampleFormat](#oh_audiostream_sampleformat) \*sampleFormat) | Obtains the sampling format of an audio stream.| +| [OH_AudioCapturer_GetEncodingType](#oh_audiocapturer_getencodingtype) ([OH_AudioCapturer](#oh_audiocapturer) \*capturer, [OH_AudioStream_EncodingType](#oh_audiostream_encodingtype) \*encodingType) | Obtains the encoding type of an audio stream.| +| [OH_AudioCapturer_GetCapturerInfo](#oh_audiocapturer_getcapturerinfo) ([OH_AudioCapturer](#oh_audiocapturer) \*capturer, [OH_AudioStream_SourceType](#oh_audiostream_sourcetype) \*sourceType) | Obtains the usage scenario of an audio renderer.| +| [OH_AudioRenderer_Release](#oh_audiorenderer_release) ([OH_AudioRenderer](#oh_audiorenderer) \*renderer) | Releases an audio renderer.| +| [OH_AudioRenderer_Start](#oh_audiorenderer_start) ([OH_AudioRenderer](#oh_audiorenderer) \*renderer) | Starts an audio renderer.| +| [OH_AudioRenderer_Pause](#oh_audiorenderer_pause) ([OH_AudioRenderer](#oh_audiorenderer) \*renderer) | Pauses an audio renderer.| +| [OH_AudioRenderer_Stop](#oh_audiorenderer_stop) ([OH_AudioRenderer](#oh_audiorenderer) \*renderer) | Stops an audio renderer.| +| [OH_AudioRenderer_Flush](#oh_audiorenderer_flush) ([OH_AudioRenderer](#oh_audiorenderer) \*renderer) | Flushes written audio data.| +| [OH_AudioRenderer_GetCurrentState](#oh_audiorenderer_getcurrentstate) ([OH_AudioRenderer](#oh_audiorenderer) \*renderer, [OH_AudioStream_State](#oh_audiostream_state) \*state) | Obtains the state of an audio stream.| +| [OH_AudioRenderer_GetSamplingRate](#oh_audiorenderer_getsamplingrate) ([OH_AudioRenderer](#oh_audiorenderer) \*renderer, int32_t \*rate) | Obtains the sampling rate of an audio stream.| +| [OH_AudioRenderer_GetStreamId](#oh_audiorenderer_getstreamid) ([OH_AudioRenderer](#oh_audiorenderer) \*renderer, uint32_t \*streamId) | Obtains the stream ID of an audio stream.| +| [OH_AudioRenderer_GetChannelCount](#oh_audiorenderer_getchannelcount) ([OH_AudioRenderer](#oh_audiorenderer) \*renderer, int32_t \*channelCount) | Obtains the number of channels for an audio stream.| +| [OH_AudioRenderer_GetSampleFormat](#oh_audiorenderer_getsampleformat) ([OH_AudioRenderer](#oh_audiorenderer) \*renderer, [OH_AudioStream_SampleFormat](#oh_audiostream_sampleformat) \*sampleFormat) | Obtains the sampling format of an audio stream.| +| [OH_AudioRenderer_GetLatencyMode](#oh_audiorenderer_getlatencymode) ([OH_AudioRenderer](#oh_audiorenderer) \*renderer, [OH_AudioStream_LatencyMode](#oh_audiostream_latencymode) \*latencyMode) | Obtains the latency mode of an audio stream.| +| [OH_AudioRenderer_GetRendererInfo](#oh_audiorenderer_getrendererinfo) ([OH_AudioRenderer](#oh_audiorenderer) \*renderer, [OH_AudioStream_Usage](#oh_audiostream_usage) \*usage) | Obtains the usage scenario of an audio renderer.| +| [OH_AudioRenderer_GetEncodingType](#oh_audiorenderer_getencodingtype) ([OH_AudioRenderer](#oh_audiorenderer) \*renderer, [OH_AudioStream_EncodingType](#oh_audiostream_encodingtype) \*encodingType) | Obtains the encoding type of an audio stream.| +| [OH_AudioStreamBuilder_Create](#oh_audiostreambuilder_create) ([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*\*builder, [OH_AudioStream_Type](#oh_audiostream_type) type) | Creates an audio stream builder, which can be an audio renderer or capturer.| +| [OH_AudioStreamBuilder_Destroy](#oh_audiostreambuilder_destroy) ([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*builder) | Destroys an audio stream builder.| +| [OH_AudioStreamBuilder_SetSamplingRate](#oh_audiostreambuilder_setsamplingrate) ([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*builder, int32_t rate) | Sets the sampling rate of an audio stream.| +| [OH_AudioStreamBuilder_SetChannelCount](#oh_audiostreambuilder_setchannelcount) ([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*builder, int32_t channelCount) | Sets the number of channels for an audio stream.| +| [OH_AudioStreamBuilder_SetSampleFormat](#oh_audiostreambuilder_setsampleformat) ([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*builder, [OH_AudioStream_SampleFormat](#oh_audiostream_sampleformat) format) | Sets the sampling format of an audio stream.| +| [OH_AudioStreamBuilder_SetEncodingType](#oh_audiostreambuilder_setencodingtype) ([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*builder, [OH_AudioStream_EncodingType](#oh_audiostream_encodingtype) encodingType) | Sets the encoding type of an audio stream.| +| [OH_AudioStreamBuilder_SetLatencyMode](#oh_audiostreambuilder_setlatencymode) ([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*builder, [OH_AudioStream_LatencyMode](#oh_audiostream_latencymode) latencyMode) | Sets the latency mode of an audio stream.| +| [OH_AudioStreamBuilder_SetRendererInfo](#oh_audiostreambuilder_setrendererinfo) ([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*builder, [OH_AudioStream_Usage](#oh_audiostream_usage) usage) | Sets the usage scenario of an audio renderer.| +| [OH_AudioStreamBuilder_SetCapturerInfo](#oh_audiostreambuilder_setcapturerinfo) ([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*builder, [OH_AudioStream_SourceType](#oh_audiostream_sourcetype) sourceType) | Sets the usage scenario of an audio capturer.| +| [OH_AudioStreamBuilder_SetRendererCallback](#oh_audiostreambuilder_setrenderercallback) ([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*builder, [OH_AudioRenderer_Callbacks](#oh_audiorenderer_callbacks) callbacks, void \*userData) | Sets callbacks for an audio renderer.| +| [OH_AudioStreamBuilder_SetCapturerCallback](#oh_audiostreambuilder_setcapturercallback) ([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*builder, [OH_AudioCapturer_Callbacks](#oh_audiocapturer_callbacks) callbacks, void \*userData) | Sets callbacks for an audio capturer.| +| [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer) ([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*builder, [OH_AudioRenderer](#oh_audiorenderer) \*\*audioRenderer) | Creates an audio renderer instance.| +| [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer) ([OH_AudioStreamBuilder](#oh_audiostreambuilder) \*builder, [OH_AudioCapturer](#oh_audiocapturer) \*\*audioCapturer) | Creates an audio capturer instance.| + + +### Variables + +| Name| Description| +| -------- | -------- | +| (\*[OH_AudioRenderer_Callbacks_Struct::OH_AudioRenderer_OnWriteData](#oh_audiorenderer_onwritedata) )([OH_AudioRenderer](#oh_audiorenderer) \*renderer, void \*userData, void \*buffer, int32_t lenth) | Defines a function pointer to the callback function used to write audio data.| +| (\*[OH_AudioCapturer_Callbacks_Struct::OH_AudioCapturer_OnReadData](#oh_audiocapturer_onreaddata) )([OH_AudioCapturer](#oh_audiocapturer) \*capturer, void \*userData, void \*buffer, int32_t lenth) | Defines a function pointer to the callback function used to read audio data.| + + +## Type Description + + +### OH_AudioCapturer + + +``` +typedef struct OH_AudioCapturerStruct OH_AudioCapturer +``` + +**Description** + +Defines an audio capturer. + +An audio capturer instance is used to capture audio data. + +\@syscap SystemCapability.Multimedia.Audio.Core + +**Since** + +10 + + +### OH_AudioCapturer_Callbacks + + +``` +typedef struct OH_AudioCapturer_Callbacks_StructOH_AudioCapturer_Callbacks +``` + +**Description** + +Defines a pointer to the callback functions related to an audio capturer. + +\@syscap SystemCapability.Multimedia.Audio.Core + +**Since** + +10 + + +### OH_AudioRenderer + + +``` +typedef struct OH_AudioRendererStruct OH_AudioRenderer +``` + +**Description** + +Defines an audio renderer. + +An audio renderer instance is used to render audio data. + +\@syscap SystemCapability.Multimedia.Audio.Core + +**Since** + +10 + + +### OH_AudioRenderer_Callbacks + + +``` +typedef struct OH_AudioRenderer_Callbacks_StructOH_AudioRenderer_Callbacks +``` + +**Description** + +Defines a pointer to the callback functions related to an audio renderer. + +\@syscap SystemCapability.Multimedia.Audio.Core + +**Since** + +10 + + +### OH_AudioStreamBuilder + + +``` +typedef struct OH_AudioStreamBuilderStruct OH_AudioStreamBuilder +``` + +**Description** + +Defines an audio stream builder. + +An audio stream builder instance is often used to create an audio stream and set its attributes. + +\@syscap SystemCapability.Multimedia.Audio.Core + +**Since** + +10 + + +## Enum Description + + +### OH_AudioStream_EncodingType + + +``` +enum OH_AudioStream_EncodingType +``` + +**Description** + +Enumerates the encoding types of audio streams. + +\@syscap SystemCapability.Multimedia.Audio.Core + +**Since** + +10 + +| Value| Description| +| -------- | -------- | +| AUDIOSTREAM_ENCODING_TYPE_RAW | PCM encoding.| + + +### OH_AudioStream_LatencyMode + + +``` +enum OH_AudioStream_LatencyMode +``` + +**Description** + +Enumerates the latency modes of audio streams. + +\@syscap SystemCapability.Multimedia.Audio.Core + +**Since** + +10 + +| Value| Description| +| -------- | -------- | +| AUDIOSTREAM_LATENCY_MODE_NORMAL | Normal latency mode.| + + +### OH_AudioStream_Result + + +``` +enum OH_AudioStream_Result +``` + +**Description** + +Enumerates the audio stream operation results. + +\@syscap SystemCapability.Multimedia.Audio.Core + +**Since** + +10 + +| Value| Description| +| -------- | -------- | +| AUDIOSTREAM_SUCCESS | Operation successful.| +| AUDIOSTREAM_ERROR_INVALID_PARAM | Invalid input parameter.| +| AUDIOSTREAM_ERROR_ILLEGAL_STATE | Invalid state.| +| AUDIOSTREAM_ERROR_SYSTEM | System error.| + + +### OH_AudioStream_SampleFormat + + +``` +enum OH_AudioStream_SampleFormat +``` + +**Description** + +Enumerates the sampling formats of audio streams. + +\@syscap SystemCapability.Multimedia.Audio.Core + +**Since** + +10 + +| Value| Description| +| -------- | -------- | +| AUDIOSTREAM_SAMPLE_U8 | Unsigned 8-bit.| +| AUDIOSTREAM_SAMPLE_S16LE | Short 16-bit little-endian.| +| AUDIOSTREAM_SAMPLE_S24LE | Short 24-bit little-endian.| +| AUDIOSTREAM_SAMPLE_S32LE | Short 32-bit little-endian.| + + +### OH_AudioStream_SourceType + + +``` +enum OH_AudioStream_SourceType +``` + +**Description** + +Enumerates the usage scenarios of an audio capturer, that is, the usage scenarios of audio input streams. + +\@syscap SystemCapability.Multimedia.Audio.Core + +**Since** + +10 + +| Value| Description| +| -------- | -------- | +| AUDIOSTREAM_SOURCE_TYPE_INVALID | Invalid state.| +| AUDIOSTREAM_SOURCE_TYPE_MIC | Audio recording.| +| AUDIOSTREAM_SOURCE_TYPE_VOICE_RECOGNITION | Voice recognition.| +| AUDIOSTREAM_SOURCE_TYPE_VOICE_COMMUNICATION | Voice communication.| + + +### OH_AudioStream_State + + +``` +enum OH_AudioStream_State +``` + +**Description** + +Enumerates the audio stream states. + +\@syscap SystemCapability.Multimedia.Audio.Core + +**Since** + +10 + +| Value| Description| +| -------- | -------- | +| AUDIOSTREAM_STATE_INVALID | Invalid state.| +| AUDIOSTREAM_STATE_PREPARED | Prepared.| +| AUDIOSTREAM_STATE_RUNNING | Running.| +| AUDIOSTREAM_STATE_STOPPED | Stopped.| +| AUDIOSTREAM_STATE_RELEASED | Released.| +| AUDIOSTREAM_STATE_PAUSED | Paused.| + + +### OH_AudioStream_Type + + +``` +enum OH_AudioStream_Type +``` + +**Description** + +Enumerates the audio stream types. + +\@syscap SystemCapability.Multimedia.Audio.Core + +**Since** + +10 + +| Value| Description| +| -------- | -------- | +| AUDIOSTREAM_TYPE_RENDERER | The audio stream is an output stream.| +| AUDIOSTREAM_TYPE_CAPTURER | The audio stream is an input stream.| + + +### OH_AudioStream_Usage + + +``` +enum OH_AudioStream_Usage +``` + +**Description** + +Enumerates the usage scenarios of an audio renderer, that is, the usage scenarios of audio output streams. + +\@syscap SystemCapability.Multimedia.Audio.Core + +**Since** + +10 + +| Value| Description| +| -------- | -------- | +| AUDIOSTREAM_USAGE_UNKNOWN | Undefined.| +| AUDIOSTREAM_USAGE_MUSIC | Music.| +| AUDIOSTREAM_USAGE_COMMUNICATION | Voice communication.| +| AUDIOSTREAM_USAGE_GAME | Gaming.| + + +## Function Description + + +### OH_AudioCapturer_Flush() + + +``` +OH_AudioStream_Result OH_AudioCapturer_Flush (OH_AudioCapturer * capturer) +``` + +**Description** + +Flushes obtained audio data. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| capturer | Pointer to an audio capturer instance created by [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer).| + +**Returns** + +Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. + +**Since** + +10 + + +### OH_AudioCapturer_GetCapturerInfo() + + +``` +OH_AudioStream_Result OH_AudioCapturer_GetCapturerInfo (OH_AudioCapturer * capturer, OH_AudioStream_SourceType * sourceType ) +``` + +**Description** + +Obtains the usage scenario of an audio capturer. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| capturer | Pointer to an audio capturer instance created by [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer).| +| sourceType | Pointer to a variable used to receive the usage scenario.| + +**Returns** + +Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. + +**Since** + +10 + + +### OH_AudioCapturer_GetChannelCount() + + +``` +OH_AudioStream_Result OH_AudioCapturer_GetChannelCount (OH_AudioCapturer * capturer, int32_t * channelCount ) +``` + +**Description** + +Obtains the number of channels for an audio stream. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| capturer | Pointer to an audio capturer instance created by [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer).| +| channelCount | Pointer to a variable used to receive the number of channels.| + +**Returns** + +Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. + +**Since** + +10 + + +### OH_AudioCapturer_GetCurrentState() + + +``` +OH_AudioStream_Result OH_AudioCapturer_GetCurrentState (OH_AudioCapturer * capturer, OH_AudioStream_State * state ) +``` + +**Description** + +Obtains the state of an audio stream. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| capturer | Pointer to an audio capturer instance created by [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer).| +| state | Pointer to a variable used to receive the state.| + +**Returns** + +Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. + +**Since** + +10 + + +### OH_AudioCapturer_GetEncodingType() + + +``` +OH_AudioStream_Result OH_AudioCapturer_GetEncodingType (OH_AudioCapturer * capturer, OH_AudioStream_EncodingType * encodingType ) +``` + +**Description** + +Obtains the encoding type of an audio stream. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| capturer | Pointer to an audio capturer instance created by [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer).| +| encodingType | Pointer to a variable used to receive the encoding type.| + +**Returns** + +Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. + +**Since** + +10 + + +### OH_AudioCapturer_GetLatencyMode() + + +``` +OH_AudioStream_Result OH_AudioCapturer_GetLatencyMode (OH_AudioCapturer * capturer, OH_AudioStream_LatencyMode * latencyMode ) +``` + +**Description** + +Obtains the latency mode of an audio stream. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| capturer | Pointer to an audio capturer instance created by [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer).| +| latencyMode | Pointer to a variable used to receive the latency mode.| + +**Returns** + +Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. + +**Since** + +10 + + +### OH_AudioCapturer_GetSampleFormat() + + +``` +OH_AudioStream_Result OH_AudioCapturer_GetSampleFormat (OH_AudioCapturer * capturer, OH_AudioStream_SampleFormat * sampleFormat ) +``` + +**Description** + +Obtains the sampling format of an audio stream. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| capturer | Pointer to an audio capturer instance created by [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer).| +| sampleFormat | Pointer to a variable used to receive the sampling format.| + +**Returns** + +Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. + +**Since** + +10 + + +### OH_AudioCapturer_GetSamplingRate() + + +``` +OH_AudioStream_Result OH_AudioCapturer_GetSamplingRate (OH_AudioCapturer * capturer, int32_t * rate ) +``` + +**Description** + +Obtains the sampling rate of an audio stream. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| capturer | Pointer to an audio capturer instance created by [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer).| +| rate | Pointer to a variable used to receive the sampling rate.| + +**Returns** + +Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. + +**Since** + +10 + + +### OH_AudioCapturer_GetStreamId() + + +``` +OH_AudioStream_Result OH_AudioCapturer_GetStreamId (OH_AudioCapturer * capturer, uint32_t * streamId ) +``` + +**Description** + +Obtains the stream ID of an audio stream. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| capturer | Pointer to an audio capturer instance created by [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer).| +| streamId | Pointer to a variable used to receive the stream ID.| + +**Returns** + +Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. + +**Since** + +10 + + +### OH_AudioCapturer_Pause() + + +``` +OH_AudioStream_Result OH_AudioCapturer_Pause (OH_AudioCapturer * capturer) +``` + +**Description** + +Pauses an audio capturer. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| capturer | Pointer to an audio capturer instance created by [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer).| + +**Returns** + +Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. + +**Since** + +10 + + +### OH_AudioCapturer_Release() + + +``` +OH_AudioStream_Result OH_AudioCapturer_Release (OH_AudioCapturer * capturer) +``` + +**Description** + +Releases an audio capturer. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| capturer | Pointer to an audio capturer instance created by [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer).| + +**Returns** + +Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. + +**Since** + +10 + + +### OH_AudioCapturer_Start() + + +``` +OH_AudioStream_Result OH_AudioCapturer_Start (OH_AudioCapturer * capturer) +``` + +**Description** + +Starts an audio capturer. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| capturer | Pointer to an audio capturer instance created by [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer).| + +**Returns** + +Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. + +**Since** + +10 + + +### OH_AudioCapturer_Stop() + + +``` +OH_AudioStream_Result OH_AudioCapturer_Stop (OH_AudioCapturer * capturer) +``` + +**Description** + +Stops an audio capturer. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| capturer | Pointer to an audio capturer instance created by [OH_AudioStreamBuilder_GenerateCapturer](#oh_audiostreambuilder_generatecapturer).| + +**Returns** + +Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. + +**Since** + +10 + + +### OH_AudioRenderer_Flush() + + +``` +OH_AudioStream_Result OH_AudioRenderer_Flush (OH_AudioRenderer * renderer) +``` + +**Description** + +Flushes written audio data. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| renderer | Pointer to an audio renderer instance created by [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer).| + +**Returns** + +Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. + +**Since** + +10 + + +### OH_AudioRenderer_GetChannelCount() + + +``` +OH_AudioStream_Result OH_AudioRenderer_GetChannelCount (OH_AudioRenderer * renderer, int32_t * channelCount ) +``` + +**Description** + +Obtains the number of channels for an audio stream. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| renderer | Pointer to an audio renderer instance created by [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer).| +| channelCount | Pointer to a variable used to receive the number of channels.| + +**Returns** + +Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. + +**Since** + +10 + + +### OH_AudioRenderer_GetCurrentState() + + +``` +OH_AudioStream_Result OH_AudioRenderer_GetCurrentState (OH_AudioRenderer * renderer, OH_AudioStream_State * state ) +``` + +**Description** + +Obtains the state of an audio stream. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| renderer | Pointer to an audio renderer instance created by [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer).| +| state | Pointer to a variable used to receive the state.| + +**Returns** + +Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. + +**Since** + +10 + + +### OH_AudioRenderer_GetEncodingType() + + +``` +OH_AudioStream_Result OH_AudioRenderer_GetEncodingType (OH_AudioRenderer * renderer, OH_AudioStream_EncodingType * encodingType ) +``` + +**Description** + +Obtains the encoding type of an audio stream. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| renderer | Pointer to an audio renderer instance created by [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer).| +| encodingType | Pointer to a variable used to receive the encoding type.| + +**Returns** + +Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. + +**Since** + +10 + + +### OH_AudioRenderer_GetLatencyMode() + + +``` +OH_AudioStream_Result OH_AudioRenderer_GetLatencyMode (OH_AudioRenderer * renderer, OH_AudioStream_LatencyMode * latencyMode ) +``` + +**Description** + +Obtains the latency mode of an audio stream. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| renderer | Pointer to an audio renderer instance created by [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer).| +| latencyMode | Pointer to a variable used to receive the latency mode.| + +**Returns** + +Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. + +**Since** + +10 + + +### OH_AudioRenderer_GetRendererInfo() + + +``` +OH_AudioStream_Result OH_AudioRenderer_GetRendererInfo (OH_AudioRenderer * renderer, OH_AudioStream_Usage * usage ) +``` + +**Description** + +Obtains the usage scenario of an audio renderer. + +The renderer information includes the values of [OH_AudioStream_Usage](#oh_audiostream_usage) and **OH_AudioStream_Content**. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| renderer | Pointer to an audio renderer instance created by [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer).| +| usage | Pointer to a variable used to receive the usage scenario.| + +**Returns** + +Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. + +**Since** + +10 + + +### OH_AudioRenderer_GetSampleFormat() + + +``` +OH_AudioStream_Result OH_AudioRenderer_GetSampleFormat (OH_AudioRenderer * renderer, OH_AudioStream_SampleFormat * sampleFormat ) +``` + +**Description** + +Obtains the sampling format of an audio stream. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| renderer | Pointer to an audio renderer instance created by [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer).| +| sampleFormat | Pointer to a variable used to receive the sampling format.| + +**Returns** + +Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. + +**Since** + +10 + + +### OH_AudioRenderer_GetSamplingRate() + + +``` +OH_AudioStream_Result OH_AudioRenderer_GetSamplingRate (OH_AudioRenderer * renderer, int32_t * rate ) +``` + +**Description** + +Obtains the sampling rate of an audio stream. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| renderer | Pointer to an audio renderer instance created by [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer).| +| rate | Pointer to a variable used to receive the sampling rate.| + +**Returns** + +Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. + +**Since** + +10 + + +### OH_AudioRenderer_GetStreamId() + + +``` +OH_AudioStream_Result OH_AudioRenderer_GetStreamId (OH_AudioRenderer * renderer, uint32_t * streamId ) +``` + +**Description** + +Obtains the stream ID of an audio stream. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| renderer | Pointer to an audio renderer instance created by [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer).| +| streamId | Pointer to a variable used to receive the stream ID.| + +**Returns** + +Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. + +**Since** + +10 + + +### OH_AudioRenderer_Pause() + + +``` +OH_AudioStream_Result OH_AudioRenderer_Pause (OH_AudioRenderer * renderer) +``` + +**Description** + +Pauses an audio renderer. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| renderer | Pointer to an audio renderer instance created by [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer).| + +**Returns** + +Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. + +**Since** + +10 + + +### OH_AudioRenderer_Release() + + +``` +OH_AudioStream_Result OH_AudioRenderer_Release (OH_AudioRenderer * renderer) +``` + +**Description** + +Releases an audio renderer. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| renderer | Pointer to an audio renderer instance created by [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer).| + +**Returns** + +Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. + +**Since** + +10 + + +### OH_AudioRenderer_Start() + + +``` +OH_AudioStream_Result OH_AudioRenderer_Start (OH_AudioRenderer * renderer) +``` + +**Description** + +Starts an audio renderer. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| renderer | Pointer to an audio renderer instance created by [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer).| + +**Returns** + +Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. + +**Since** + +10 + + +### OH_AudioRenderer_Stop() + + +``` +OH_AudioStream_Result OH_AudioRenderer_Stop (OH_AudioRenderer * renderer) +``` + +**Description** + +Stops an audio renderer. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| renderer | Pointer to an audio renderer instance created by [OH_AudioStreamBuilder_GenerateRenderer](#oh_audiostreambuilder_generaterenderer).| + +**Returns** + +Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. + +**Since** + +10 + + +### OH_AudioStreamBuilder_Create() + + +``` +OH_AudioStream_Result OH_AudioStreamBuilder_Create (OH_AudioStreamBuilder ** builder, OH_AudioStream_Type type ) +``` + +**Description** + +Creates an audio stream builder, which can be an audio renderer or capturer. + +You need to call **OH_AudioStreamBuilder_Destroy()** to destroy the builder when it is no longer required. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| builder | Double pointer to the audio stream builder created.| +| type | Type of the audio stream builder, which can be **AUDIOSTREAM_TYPE_RENDERER** or **AUDIOSTREAM_TYPE_CAPTURER**.| + +**Returns** + +Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. + +**Since** + +10 + + +### OH_AudioStreamBuilder_Destroy() + + +``` +OH_AudioStream_Result OH_AudioStreamBuilder_Destroy (OH_AudioStreamBuilder * builder) +``` + +**Description** + +Destroys an audio stream builder when it is no longer required. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| builder | Pointer to an audio stream builder instance created by **OH_AudioStreamBuilder_Create()**.| + +**Returns** + +Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. + +**Since** + +10 + + +### OH_AudioStreamBuilder_GenerateCapturer() + + +``` +OH_AudioStream_Result OH_AudioStreamBuilder_GenerateCapturer (OH_AudioStreamBuilder * builder, OH_AudioCapturer ** audioCapturer ) +``` + +**Description** + +Creates an audio capturer instance. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| builder | Pointer to an audio stream builder instance created by **OH_AudioStreamBuilder_Create()**.| +| audioCapturer | Double pointer to the audio capturer instance created.| + +**Returns** + +Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. + +**Since** + +10 + + +### OH_AudioStreamBuilder_GenerateRenderer() + + +``` +OH_AudioStream_Result OH_AudioStreamBuilder_GenerateRenderer (OH_AudioStreamBuilder * builder, OH_AudioRenderer ** audioRenderer ) +``` + +**Description** + +Creates an audio renderer instance. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| builder | Pointer to an audio stream builder instance created by **OH_AudioStreamBuilder_Create()**.| +| audioRenderer | Double pointer to the audio renderer instance created.| + +**Returns** + +Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. + +**Since** + +10 + + +### OH_AudioStreamBuilder_SetCapturerCallback() + + +``` +OH_AudioStream_Result OH_AudioStreamBuilder_SetCapturerCallback (OH_AudioStreamBuilder * builder, OH_AudioCapturer_Callbacks callbacks, void * userData ) +``` + +**Description** + +Sets callbacks for an audio capturer. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| builder | Pointer to an audio stream builder instance created by **OH_AudioStreamBuilder_Create()**.| +| callbacks | Callback functions that will be used to process events related to input audio streams.| +| userData | Pointer to the application data passed through the callback functions.| + +**Returns** + +Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. + +**Since** + +10 + + +### OH_AudioStreamBuilder_SetCapturerInfo() + + +``` +OH_AudioStream_Result OH_AudioStreamBuilder_SetCapturerInfo (OH_AudioStreamBuilder * builder, OH_AudioStream_SourceType sourceType ) +``` + +**Description** + +Sets the usage scenario of an audio capturer. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| builder | Pointer to an audio stream builder instance created by **OH_AudioStreamBuilder_Create()**.| +| sourceType | Usage scenario of the audio capturer.| + +**Returns** + +Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. + +**Since** + +10 + + +### OH_AudioStreamBuilder_SetChannelCount() + + +``` +OH_AudioStream_Result OH_AudioStreamBuilder_SetChannelCount (OH_AudioStreamBuilder * builder, int32_t channelCount ) +``` + +**Description** + +Sets the number of channels for an audio stream. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| builder | Pointer to an audio stream builder instance created by **OH_AudioStreamBuilder_Create()**.| +| channelCount | Number of channels.| + +**Returns** + +Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. + +**Since** + +10 + + +### OH_AudioStreamBuilder_SetEncodingType() + + +``` +OH_AudioStream_Result OH_AudioStreamBuilder_SetEncodingType (OH_AudioStreamBuilder * builder, OH_AudioStream_EncodingType encodingType ) +``` + +**Description** + +Sets the encoding type of an audio stream. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| builder | Pointer to an audio stream builder instance created by **OH_AudioStreamBuilder_Create()**.| +| encodingType | Encoding type, which can be **AUDIOSTREAM_ENCODING_PCM**.| + +**Returns** + +Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. + +**Since** + +10 + + +### OH_AudioStreamBuilder_SetLatencyMode() + + +``` +OH_AudioStream_Result OH_AudioStreamBuilder_SetLatencyMode (OH_AudioStreamBuilder * builder, OH_AudioStream_LatencyMode latencyMode ) +``` + +**Description** + +Sets the latency mode of an audio stream. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| builder | Pointer to an audio stream builder instance created by **OH_AudioStreamBuilder_Create()**.| +| latencyMode | Latency mode.| + +**Returns** + +Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. + +**Since** + +10 + + +### OH_AudioStreamBuilder_SetRendererCallback() + + +``` +OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererCallback (OH_AudioStreamBuilder * builder, OH_AudioRenderer_Callbacks callbacks, void * userData ) +``` + +**Description** + +Sets callbacks for an audio renderer. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| builder | Pointer to an audio stream builder instance created by **OH_AudioStreamBuilder_Create()**.| +| callbacks | Callback functions that will be used to process events related to output audio streams.| +| userData | Pointer to the application data passed through the callback functions.| + +**Returns** + +Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. + +**Since** + +10 + + +### OH_AudioStreamBuilder_SetRendererInfo() + + +``` +OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererInfo (OH_AudioStreamBuilder * builder, OH_AudioStream_Usage usage ) +``` + +**Description** + +Sets the usage scenario of an audio renderer. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| builder | Pointer to an audio stream builder instance created by **OH_AudioStreamBuilder_Create()**.| +| usage | Usage scenario of the audio renderer.| + +**Returns** + +Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. + +**Since** + +10 + + +### OH_AudioStreamBuilder_SetSampleFormat() + + +``` +OH_AudioStream_Result OH_AudioStreamBuilder_SetSampleFormat (OH_AudioStreamBuilder * builder, OH_AudioStream_SampleFormat format ) +``` + +**Description** + +Sets the sampling format of an audio stream. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| builder | Pointer to an audio stream builder instance created by **OH_AudioStreamBuilder_Create()**.| +| format | Sampling format.| + +**Returns** + +Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. + +**Since** + +10 + + +### OH_AudioStreamBuilder_SetSamplingRate() + + +``` +OH_AudioStream_Result OH_AudioStreamBuilder_SetSamplingRate (OH_AudioStreamBuilder * builder, int32_t rate ) +``` + +**Description** + +Sets the sampling rate of an audio stream. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| builder | Pointer to an audio stream builder instance created by **OH_AudioStreamBuilder_Create()**.| +| channelCount | Sampling rate.| + +**Returns** + +Returns **AUDIOSTREAM_SUCCESS** if the operation is successful; returns an error code otherwise. + +**Since** + +10 + + +## Variable Description + + +### OH_AudioCapturer_OnReadData + + +``` +int32_t(* OH_AudioCapturer_Callbacks_Struct::OH_AudioCapturer_OnReadData) (OH_AudioCapturer *capturer, void *userData, void *buffer, int32_t lenth) +``` + +**Description** + +Defines a function pointer to the callback function used to read audio data. + +**Since** + +10 + + +### OH_AudioRenderer_OnWriteData + + +``` +int32_t(* OH_AudioRenderer_Callbacks_Struct::OH_AudioRenderer_OnWriteData) (OH_AudioRenderer *renderer, void *userData, void *buffer, int32_t lenth) +``` + +**Description** + +Defines a function pointer to the callback function used to write audio data. + +**Since** + +10 diff --git a/en/application-dev/reference/native-apis/_video_decoder.md b/en/application-dev/reference/native-apis/_video_decoder.md index c56dd9bfcb..56496df042 100644 --- a/en/application-dev/reference/native-apis/_video_decoder.md +++ b/en/application-dev/reference/native-apis/_video_decoder.md @@ -3,11 +3,12 @@ ## Overview -Provides the functions for video decoding. This module may not be supported on some devices. You can call [CanIUse](../syscap.md) to check whether this module is supported on your device. +The VideoDecoder module provides the functions for video decoding. -@syscap SystemCapability.Multimedia.Media.VideoDecoder +\@syscap SystemCapability.Multimedia.Media.VideoDecoder **Since** + 9 @@ -16,31 +17,32 @@ Provides the functions for video decoding. This module may not be supported on s ### Files - | Name| Description| +| Name| Description| | -------- | -------- | | [native_avcodec_videodecoder.h](native__avcodec__videodecoder_8h.md) | Declares the native APIs used for video decoding.
File to include: | ### Functions - | Name| Description| +| Name| Description| | -------- | -------- | -| [OH_VideoDecoder_CreateByMime](#oh_videodecoder_createbymime) (const char \*mime) | Creates a video decoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases. | -| [OH_VideoDecoder_CreateByName](#oh_videodecoder_createbyname) (const char \*name) | Creates a video decoder instance based on a video decoder name. To use this API, you must know the exact name of the video decoder. | -| [OH_VideoDecoder_Destroy](#oh_videodecoder_destroy) (OH_AVCodec \*codec) | Clears the internal resources of a video decoder and destroys the video decoder instance. | -| [OH_VideoDecoder_SetCallback](#oh_videodecoder_setcallback) (OH_AVCodec \*codec, [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) callback, void \*userData) | Sets an asynchronous callback so that your application can respond to events generated by a video decoder. This API must be called prior to **Prepare**. | -| [OH_VideoDecoder_SetSurface](#oh_videodecoder_setsurface) (OH_AVCodec \*codec, OHNativeWindow \*window) | Sets an output surface for a video decoder. This API must be called prior to **Prepare**. | -| [OH_VideoDecoder_Configure](#oh_videodecoder_configure) (OH_AVCodec \*codec, OH_AVFormat \*format) | Configures a video decoder. Typically, you need to configure the attributes, which can be extracted from the container, of the video track that can be decoded. This API must be called prior to **Prepare**. | -| [OH_VideoDecoder_Prepare](#oh_videodecoder_prepare) (OH_AVCodec \*codec) | Prepares internal resources for a video decoder. This API must be called after **Configure**. | -| [OH_VideoDecoder_Start](#oh_videodecoder_start) (OH_AVCodec \*codec) | Starts a video decoder. This API can be called only after the decoder is prepared successfully. After being started, the decoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. | -| [OH_VideoDecoder_Stop](#oh_videodecoder_stop) (OH_AVCodec \*codec) | Stops a video decoder. After the decoder is stopped, you can call **Start** to start it again. If you have passed codec-specific data in the previous **Start** for the decoder, you must pass it again. | -| [OH_VideoDecoder_Flush](#oh_videodecoder_flush) (OH_AVCodec \*codec) | Clears the input and output data in the internal buffer of a video decoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. | -| [OH_VideoDecoder_Reset](#oh_videodecoder_reset) (OH_AVCodec \*codec) | Resets a video decoder. To continue decoding, you must call **Configure** and **Start** to configure and start the decoder again. | -| [OH_VideoDecoder_GetOutputDescription](#oh_videodecoder_getoutputdescription) (OH_AVCodec \*codec) | Obtains the attributes of the output data of a video decoder. The **OH_AVFormat** instance in the return value will become invalid when this API is called again or when the **OH_AVCodec** instance is destroyed. | -| [OH_VideoDecoder_SetParameter](#oh_videodecoder_setparameter) (OH_AVCodec \*codec, OH_AVFormat \*format) | Sets dynamic parameters for a video decoder. This API can be called only after the decoder is started. Incorrect parameter settings may cause decoding failure. | -| [OH_VideoDecoder_PushInputData](#oh_videodecoder_pushinputdata) (OH_AVCodec \*codec, uint32_t index, [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) attr) | Pushes the input buffer filled with data to a video decoder. The [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback reports available input buffers and their indexes. After being pushed to the decoder, a buffer is not accessible until the buffer with the same index is reported again through the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback. In addition, some decoders require the input of codec-specific data, such as PPS/SPS data in H.264 format, to initialize the decoding process. | -| [OH_VideoDecoder_RenderOutputData](#oh_videodecoder_renderoutputdata) (OH_AVCodec \*codec, uint32_t index) | Frees an output buffer of a video decoder and instructs the decoder to render the decoded data in the buffer on the output surface. If no output surface is configured, calling this API only frees the output buffer. | -| [OH_VideoDecoder_FreeOutputData](#oh_videodecoder_freeoutputdata) (OH_AVCodec \*codec, uint32_t index) | Frees an output buffer of a video decoder. | +| \*[OH_VideoDecoder_CreateByMime](#oh_videodecoder_createbymime) (const char \*mime) | Creates a video decoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This function is recommended in most cases.| +| \*[OH_VideoDecoder_CreateByName](#oh_videodecoder_createbyname) (const char \*name) | Creates a video decoder instance based on a decoder name. To use this function, you must know the exact name of the decoder.| +| [OH_VideoDecoder_Destroy](#oh_videodecoder_destroy) (OH_AVCodec \*codec) | Clears the internal resources of a video decoder and destroys the decoder instance.| +| [OH_VideoDecoder_SetCallback](#oh_videodecoder_setcallback) (OH_AVCodec \*codec, OH_AVCodecAsyncCallback callback, void \*userData) | Sets an asynchronous callback so that your application can respond to events generated by a video decoder.| +| [OH_VideoDecoder_SetSurface](#oh_videodecoder_setsurface) (OH_AVCodec \*codec, OHNativeWindow \*window) | Sets an output surface for a video decoder. This function must be called prior to **Prepare**.| +| [OH_VideoDecoder_Configure](#oh_videodecoder_configure) (OH_AVCodec \*codec, OH_AVFormat \*format) | Configures a video decoder. Typically, you need to configure the video track description information that can be extracted from the container.| +| [OH_VideoDecoder_Prepare](#oh_videodecoder_prepare) (OH_AVCodec \*codec) | Prepares internal resources for a video decoder. This function must be called after **Configure**.| +| [OH_VideoDecoder_Start](#oh_videodecoder_start) (OH_AVCodec \*codec) | Starts a video decoder. This function can be called only after the decoder is prepared successfully.| +| [OH_VideoDecoder_Stop](#oh_videodecoder_stop) (OH_AVCodec \*codec) | Stops a video decoder.| +| [OH_VideoDecoder_Flush](#oh_videodecoder_flush) (OH_AVCodec \*codec) | Clears the input and output data in the internal buffer of a video decoder.| +| [OH_VideoDecoder_Reset](#oh_videodecoder_reset) (OH_AVCodec \*codec) | Resets a video decoder.| +| \*[OH_VideoDecoder_GetOutputDescription](#oh_videodecoder_getoutputdescription) (OH_AVCodec \*codec) | Obtains the description information about the output data of a video decoder.| +| [OH_VideoDecoder_SetParameter](#oh_videodecoder_setparameter) (OH_AVCodec \*codec, OH_AVFormat \*format) | Sets dynamic parameters for a video decoder.| +| [OH_VideoDecoder_PushInputData](#oh_videodecoder_pushinputdata) (OH_AVCodec \*codec, uint32_t index, OH_AVCodecBufferAttr attr) | Pushes the input buffer filled with data to a video decoder.| +| [OH_VideoDecoder_RenderOutputData](#oh_videodecoder_renderoutputdata) (OH_AVCodec \*codec, uint32_t index) | Frees an output buffer of a video decoder and instructs the decoder to render the decoded data in the buffer on the output surface.| +| [OH_VideoDecoder_FreeOutputData](#oh_videodecoder_freeoutputdata) (OH_AVCodec \*codec, uint32_t index) | Frees an output buffer of a video decoder.| +| [OH_VideoDecoder_IsValid](#oh_videodecoder_isvalid) (OH_AVCodec \*codec, bool \*isValid) | Checks whether a video codec instance is valid.| ## Function Description @@ -52,23 +54,29 @@ Provides the functions for video decoding. This module may not be supported on s ``` OH_AVErrCode OH_VideoDecoder_Configure (OH_AVCodec * codec, OH_AVFormat * format ) ``` -**Description**
-Configures a video decoder. Typically, you need to configure the attributes, which can be extracted from the container, of the video track that can be decoded. This API must be called prior to **Prepare**. -@syscap SystemCapability.Multimedia.Media.VideoDecoder +**Description** + +Configures a video decoder. Typically, you need to configure the video track description information that can be extracted from the container. + +This function must be called prior to **Prepare**. + +\@syscap SystemCapability.Multimedia.Media.VideoDecoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| format | Indicates the handle to an **OH_AVFormat** instance, which provides the attributes of the video track to be decoded. | +| codec | Pointer to an **OH_AVCodec** instance.| +| format | Pointer to an **OH_AVFormat** instance, which provides the description information about the video track to be decoded.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +**Since** + +9 ### OH_VideoDecoder_CreateByMime() @@ -77,21 +85,27 @@ Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the op ``` OH_AVCodec* OH_VideoDecoder_CreateByMime (const char * mime) ``` -**Description**
-Creates a video decoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases. -@syscap SystemCapability.Multimedia.Media.VideoDecoder +**Description** + +Creates a video decoder instance based on a MIME type. This function is recommended in most cases. + +\@syscap SystemCapability.Multimedia.Media.VideoDecoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| mime | Indicates the pointer to a MIME type. For details, see [OH_AVCODEC_MIMETYPE_VIDEO_AVC](_codec_base.md#oh_avcodec_mimetype_video_avc).| +| mime | Pointer to a string that describes the MIME type. For details, see **AVCODEC_MIME_TYPE**.| **Returns** Returns the pointer to an **OH_AVCodec** instance. +**Since** + +9 + ### OH_VideoDecoder_CreateByName() @@ -99,21 +113,27 @@ Returns the pointer to an **OH_AVCodec** instance. ``` OH_AVCodec* OH_VideoDecoder_CreateByName (const char * name) ``` -**Description**
-Creates a video decoder instance based on a video decoder name. To use this API, you must know the exact name of the video decoder. -@syscap SystemCapability.Multimedia.Media.VideoDecoder +**Description** + +Creates a video decoder instance based on a decoder name. To use this function, you must know the exact name of the decoder. + +\@syscap SystemCapability.Multimedia.Media.VideoDecoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| name | Indicates the pointer to a video decoder name. | +| name | Pointer to a video decoder name.| **Returns** Returns the pointer to an **OH_AVCodec** instance. +**Since** + +9 + ### OH_VideoDecoder_Destroy() @@ -121,22 +141,26 @@ Returns the pointer to an **OH_AVCodec** instance. ``` OH_AVErrCode OH_VideoDecoder_Destroy (OH_AVCodec * codec) ``` -**Description**
-Clears the internal resources of a video decoder and destroys the video decoder instance. -@syscap SystemCapability.Multimedia.Media.VideoDecoder +**Description** + +Clears the internal resources of a video decoder and destroys the decoder instance. + +\@syscap SystemCapability.Multimedia.Media.VideoDecoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Pointer to an **OH_AVCodec** instance.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +9 ### OH_VideoDecoder_Flush() @@ -145,22 +169,28 @@ Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the op ``` OH_AVErrCode OH_VideoDecoder_Flush (OH_AVCodec * codec) ``` -**Description**
-Clears the input and output data in the internal buffer of a video decoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. -@syscap SystemCapability.Multimedia.Media.VideoDecoder +**Description** + +Clears the input and output data in the internal buffer of a video decoder. + +This function invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this function, ensure that the buffers with the specified indexes are no longer required. + +\@syscap SystemCapability.Multimedia.Media.VideoDecoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Pointer to an **OH_AVCodec** instance.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +**Since** + +9 ### OH_VideoDecoder_FreeOutputData() @@ -169,23 +199,27 @@ Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the op ``` OH_AVErrCode OH_VideoDecoder_FreeOutputData (OH_AVCodec * codec, uint32_t index ) ``` -**Description**
+ +**Description** + Frees an output buffer of a video decoder. -@syscap SystemCapability.Multimedia.Media.VideoDecoder +\@syscap SystemCapability.Multimedia.Media.VideoDecoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| index | Indicates the index of an output buffer. | +| codec | Pointer to an **OH_AVCodec** instance.| +| index | Index of an output buffer.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +**Since** + +9 ### OH_VideoDecoder_GetOutputDescription() @@ -194,21 +228,58 @@ Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the op ``` OH_AVFormat* OH_VideoDecoder_GetOutputDescription (OH_AVCodec * codec) ``` -**Description**
-Obtains the attributes of the output data of a video decoder. The **OH_AVFormat** instance in the return value will become invalid when this API is called again or when the **OH_AVCodec** instance is destroyed. -@syscap SystemCapability.Multimedia.Media.VideoDecoder +**Description** + +Obtains the description information about the output data of a video decoder. For details, see **OH_AVFormat**. + +The caller must manually release the **OH_AVFormat** instance in the return value. + +\@syscap SystemCapability.Multimedia.Media.VideoDecoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Pointer to an **OH_AVCodec** instance.| **Returns** Returns the pointer to an **OH_AVFormat** instance. +**Since** + +9 + + +### OH_VideoDecoder_IsValid() + + +``` +OH_AVErrCode OH_VideoDecoder_IsValid (OH_AVCodec * codec, bool * isValid ) +``` + +**Description** + +Checks whether a video codec instance is valid. + +\@syscap SystemCapability.Multimedia.Media.VideoDecoder + +**Parameters** + +| Name| Description| +| -------- | -------- | +| codec | Pointer to an **OH_AVCodec** instance.| +| isVaild | Output parameter. Pointer to an instance of the Boolean type. The value **true** means that the decoder instance is valid and **false** means the opposite.| + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** + +10 + ### OH_VideoDecoder_Prepare() @@ -216,22 +287,26 @@ Returns the pointer to an **OH_AVFormat** instance. ``` OH_AVErrCode OH_VideoDecoder_Prepare (OH_AVCodec * codec) ``` -**Description**
-Prepares internal resources for a video decoder. This API must be called after **Configure**. -@syscap SystemCapability.Multimedia.Media.VideoDecoder +**Description** + +Prepares internal resources for a video decoder. This function must be called after **Configure**. + +\@syscap SystemCapability.Multimedia.Media.VideoDecoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Pointer to an **OH_AVCodec** instance.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +**Since** + +9 ### OH_VideoDecoder_PushInputData() @@ -240,24 +315,34 @@ Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the op ``` OH_AVErrCode OH_VideoDecoder_PushInputData (OH_AVCodec * codec, uint32_t index, OH_AVCodecBufferAttr attr ) ``` -**Description**
-Pushes the input buffer filled with data to a video decoder. The [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback reports available input buffers and their indexes. After being pushed to the decoder, a buffer is not accessible until the buffer with the same index is reported again through the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback. In addition, some decoders require the input of codec-specific data, such as PPS/SPS data in H.264 format, to initialize the decoding process. -@syscap SystemCapability.Multimedia.Media.VideoDecoder +**Description** + +Pushes the input buffer filled with data to a video decoder. + +The **OH_AVCodecOnNeedInputData** callback reports the available input buffer and the index. + +After being pushed to the decoder, a buffer is not accessible until the buffer with the same index is reported again through the **OH_AVCodecOnNeedInputData** callback. + +In addition, some decoders require the input of codec-specific data, such as PPS/SPS data in H.264 format, to initialize the decoding process. + +\@syscap SystemCapability.Multimedia.Media.VideoDecoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| index | Indicates the index of an input buffer. | -| attr | Indicates the attributes of the data contained in the buffer. | +| codec | Pointer to an **OH_AVCodec** instance.| +| index | Index of an input buffer.| +| attr | Description information about the data in the buffer.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +**Since** + +9 ### OH_VideoDecoder_RenderOutputData() @@ -266,23 +351,29 @@ Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the op ``` OH_AVErrCode OH_VideoDecoder_RenderOutputData (OH_AVCodec * codec, uint32_t index ) ``` -**Description**
-Frees an output buffer of a video decoder and instructs the decoder to render the decoded data in the buffer on the output surface. If no output surface is configured, calling this API only frees the output buffer. -@syscap SystemCapability.Multimedia.Media.VideoDecoder +**Description** + +Frees an output buffer of a video decoder and instructs the decoder to render the decoded data in the buffer on the output surface. + +If no output surface is configured, calling this function only frees the output buffer. + +\@syscap SystemCapability.Multimedia.Media.VideoDecoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| index | Indicates the index of an output buffer. | +| codec | Pointer to an **OH_AVCodec** instance.| +| index | Index of an output buffer.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +9 ### OH_VideoDecoder_Reset() @@ -291,22 +382,26 @@ Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the op ``` OH_AVErrCode OH_VideoDecoder_Reset (OH_AVCodec * codec) ``` -**Description**
-Resets a video decoder. To continue decoding, you must call **Configure** and **Start** to configure and start the decoder again. -@syscap SystemCapability.Multimedia.Media.VideoDecoder +**Description** + +Resets a video decoder. To continue decoding, you must call **Configure** to configure the decoder again. + +\@syscap SystemCapability.Multimedia.Media.VideoDecoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Pointer to an **OH_AVCodec** instance.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +**Since** + +9 ### OH_VideoDecoder_SetCallback() @@ -315,24 +410,30 @@ Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the op ``` OH_AVErrCode OH_VideoDecoder_SetCallback (OH_AVCodec * codec, OH_AVCodecAsyncCallback callback, void * userData ) ``` -**Description**
-Sets an asynchronous callback so that your application can respond to events generated by a video decoder. This API must be called prior to **Prepare**. -@syscap SystemCapability.Multimedia.Media.VideoDecoder +**Description** + +Sets an asynchronous callback so that your application can respond to events generated by a video decoder. + +This function must be called prior to **Prepare**. + +\@syscap SystemCapability.Multimedia.Media.VideoDecoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| callback | Indicates a collection of all callback functions. For details, see [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md).| -| userData | Indicates the pointer to user-specific data. | +| codec | Pointer to an **OH_AVCodec** instance.| +| callback | Callback function to set. For details, see **OH_AVCodecAsyncCallback**.| +| userData | User-specific data.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +**Since** + +9 ### OH_VideoDecoder_SetParameter() @@ -341,23 +442,29 @@ Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the op ``` OH_AVErrCode OH_VideoDecoder_SetParameter (OH_AVCodec * codec, OH_AVFormat * format ) ``` -**Description**
-Sets dynamic parameters for a video decoder. This API can be called only after the decoder is started. Incorrect parameter settings may cause decoding failure. -@syscap SystemCapability.Multimedia.Media.VideoDecoder +**Description** + +Sets dynamic parameters for a video decoder. + +This function can be called only after the decoder is started. Incorrect parameter settings may cause decoding failure. + +\@syscap SystemCapability.Multimedia.Media.VideoDecoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| format | Indicates the pointer to an **OH_AVFormat** instance. | +| codec | Pointer to an **OH_AVCodec** instance.| +| format | Pointer to an **OH_AVFormat** instance.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +9 ### OH_VideoDecoder_SetSurface() @@ -366,23 +473,27 @@ Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the op ``` OH_AVErrCode OH_VideoDecoder_SetSurface (OH_AVCodec * codec, OHNativeWindow * window ) ``` -**Description**
-Sets an output surface for a video decoder. This API must be called prior to **Prepare**. -@syscap SystemCapability.Multimedia.Media.VideoDecoder +**Description** + +Sets an output surface for a video decoder. This function must be called prior to **Prepare**. + +\@syscap SystemCapability.Multimedia.Media.VideoDecoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| window | Indicates the pointer to an **OHNativeWindow** instance. | +| codec | Pointer to an **OH_AVCodec** instance.| +| window | Pointer to an **OHNativeWindow** instance. For details, see **OHNativeWindow**.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +9 ### OH_VideoDecoder_Start() @@ -391,22 +502,28 @@ Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the op ``` OH_AVErrCode OH_VideoDecoder_Start (OH_AVCodec * codec) ``` -**Description**
-Starts a video decoder. This API can be called only after the decoder is prepared successfully. After being started, the decoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. -@syscap SystemCapability.Multimedia.Media.VideoDecoder +**Description** + +Starts a video decoder. This function can be called only after the decoder is prepared successfully. + +After being started, the decoder starts to report the **NeedInputData** event. + +\@syscap SystemCapability.Multimedia.Media.VideoDecoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Pointer to an **OH_AVCodec** instance.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +9 ### OH_VideoDecoder_Stop() @@ -415,19 +532,25 @@ Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the op ``` OH_AVErrCode OH_VideoDecoder_Stop (OH_AVCodec * codec) ``` -**Description**
-Stops a video decoder. After the decoder is stopped, you can call **Start** to start it again. If you have passed codec-specific data in the previous **Start** for the decoder, you must pass it again. -@syscap SystemCapability.Multimedia.Media.VideoDecoder +**Description** + +Stops a video decoder. After the encoder is stopped, you can call **Start** to start it again. + +If you have passed codec-specific data in the previous **Start** for the decoder, you must pass it again. + +\@syscap SystemCapability.Multimedia.Media.VideoDecoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Pointer to an **OH_AVCodec** instance.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +**Since** + +9 diff --git a/en/application-dev/reference/native-apis/_video_encoder.md b/en/application-dev/reference/native-apis/_video_encoder.md index 736adcdf7e..07a51ce127 100644 --- a/en/application-dev/reference/native-apis/_video_encoder.md +++ b/en/application-dev/reference/native-apis/_video_encoder.md @@ -3,56 +3,61 @@ ## Overview -Provides the functions and enums for video encoding. This module may not be supported on some devices. You can call [CanIUse](../syscap.md) to check whether this module is supported on your device. +The **VideoEncoder** module provides the functions for video encoding. -@syscap SystemCapability.Multimedia.Media.VideoEncoder +\@syscap SystemCapability.Multimedia.Avcodec.VideoEncoder **Since** + 9 + ## Summary ### Files - | Name| Description| +| Name| Description| | -------- | -------- | -| [native_avcodec_videoencoder.h](native__avcodec__videoencoder_8h.md) | Declares the native APIs used for video encoding.
File to include: | +| [native_avcodec_videoencoder.h](native__avcodec__videoencoder_8h.md) | Declares the native APIs used for video encoding.
File to include: | ### Types - | Name| Description| +| Name| Description| | -------- | -------- | -| [OH_VideoEncodeBitrateMode](#oh_videoencodebitratemode) | Enumerates the bit rate modes of video encoding. | +| [OH_VideoEncodeBitrateMode](#oh_videoencodebitratemode) | Defines an enum that enumerates the bit rate modes of a video encoder. | ### Enums - | Name| Description| +| Name| Description| | -------- | -------- | -| [OH_VideoEncodeBitrateMode](#oh_videoencodebitratemode) { **CBR** = 0, **VBR** = 1, **CQ** = 2 } | Enumerates the bit rate modes of video encoding. | +| [OH_VideoEncodeBitrateMode](#oh_videoencodebitratemode) { **CBR** = 0, **VBR** = 1, **CQ** = 2 } | Enumerates the bit rate modes of a video encoder.| ### Functions - | Name| Description| +| Name| Description| | -------- | -------- | -| [OH_VideoEncoder_CreateByMime](#oh_videoencoder_createbymime) (const char \*mime) | Creates a video encoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases. | -| [OH_VideoEncoder_CreateByName](#oh_videoencoder_createbyname) (const char \*name) | Creates a video encoder instance based on a video encoder name. To use this API, you must know the exact name of the video encoder. | -| [OH_VideoEncoder_Destroy](#oh_videoencoder_destroy) (OH_AVCodec \*codec) | Clears the internal resources of a video encoder and destroys the video encoder instance. | -| [OH_VideoEncoder_SetCallback](#oh_videoencoder_setcallback) (OH_AVCodec \*codec, [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) callback, void \*userData) | Sets an asynchronous callback so that your application can respond to events generated by a video encoder. This API must be called prior to **Prepare**. | -| [OH_VideoEncoder_Configure](#oh_videoencoder_configure) (OH_AVCodec \*codec, OH_AVFormat \*format) | Configures a video encoder. Typically, you need to configure the attributes of the video track that can be encoded. This API must be called prior to **Prepare**. | -| [OH_VideoEncoder_Prepare](#oh_videoencoder_prepare) (OH_AVCodec \*codec) | Prepares internal resources for a video encoder. This API must be called after **Configure**. | -| [OH_VideoEncoder_Start](#oh_videoencoder_start) (OH_AVCodec \*codec) | Starts a video encoder. This API can be called only after the encoder is prepared successfully. After being started, the encoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. | -| [OH_VideoEncoder_Stop](#oh_videoencoder_stop) (OH_AVCodec \*codec) | Stops a video encoder. After the encoder is stopped, you can call **Start** to start it again. | -| [OH_VideoEncoder_Flush](#oh_videoencoder_flush) (OH_AVCodec \*codec) | Clears the input and output data in the internal buffer of a video encoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. | -| [OH_VideoEncoder_Reset](#oh_videoencoder_reset) (OH_AVCodec \*codec) | Resets a video encoder. To continue encoding, you must call **Configure** and **Start** to configure and start the encoder again. | -| [OH_VideoEncoder_GetOutputDescription](#oh_videoencoder_getoutputdescription) (OH_AVCodec \*codec) | Obtains the attributes of the output data of a video encoder. The **OH_AVFormat** instance in the return value will become invalid when this API is called again or when the **OH_AVCodec** instance is destroyed. | -| [OH_VideoEncoder_SetParameter](#oh_videoencoder_setparameter) (OH_AVCodec \*codec, OH_AVFormat \*format) | Sets dynamic parameters for a video encoder. This API can be called only after the encoder is started. Incorrect parameter settings may cause encoding failure. | -| [OH_VideoEncoder_GetSurface](#oh_videoencoder_getsurface) (OH_AVCodec \*codec, OHNativeWindow \*\*window) | Obtains an input surface from a video encoder. This API must be called prior to **Prepare**. | -| [OH_VideoEncoder_FreeOutputData](#oh_videoencoder_freeoutputdata) (OH_AVCodec \*codec, uint32_t index) | Frees an output buffer of a video encoder. | -| [OH_VideoEncoder_NotifyEndOfStream](#oh_videoencoder_notifyendofstream) (OH_AVCodec \*codec) | Notifies a video encoder that input streams end. This API is recommended in surface mode. | +| \*[OH_VideoEncoder_CreateByMime](#oh_videoencoder_createbymime) (const char \*mime) | Creates a video encoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This function is recommended in most cases.| +| \*[OH_VideoEncoder_CreateByName](#oh_videoencoder_createbyname) (const char \*name) | Creates a video encoder instance based on an encoder name. To use this function, you must know the exact name of the encoder.| +| [OH_VideoEncoder_Destroy](#oh_videoencoder_destroy) (OH_AVCodec \*codec) | Clears the internal resources of a video encoder and destroys the encoder instance.| +| [OH_VideoEncoder_SetCallback](#oh_videoencoder_setcallback) (OH_AVCodec \*codec, OH_AVCodecAsyncCallback callback, void \*userData) | Sets an asynchronous callback so that your application can respond to events generated by a video encoder.| +| [OH_VideoEncoder_Configure](#oh_videoencoder_configure) (OH_AVCodec \*codec, OH_AVFormat \*format) | Configures a video encoder. Typically, you need to configure the description information about the video track to be encoded.| +| [OH_VideoEncoder_Prepare](#oh_videoencoder_prepare) (OH_AVCodec \*codec) | Prepares internal resources for a video encoder. This function must be called after **Configure**.| +| [OH_VideoEncoder_Start](#oh_videoencoder_start) (OH_AVCodec \*codec) | Starts a video encoder. This function can be called only after the encoder is prepared successfully.| +| [OH_VideoEncoder_Stop](#oh_videoencoder_stop) (OH_AVCodec \*codec) | Stops a video encoder.| +| [OH_VideoEncoder_Flush](#oh_videoencoder_flush) (OH_AVCodec \*codec) | Clears the input and output data in the internal buffer of a video encoder.| +| [OH_VideoEncoder_Reset](#oh_videoencoder_reset) (OH_AVCodec \*codec) | Resets a video encoder.| +| \*[OH_VideoEncoder_GetOutputDescription](#oh_videoencoder_getoutputdescription) (OH_AVCodec \*codec) | Obtains the description information about the output data of a video encoder. For details, see **OH_AVFormat**.| +| [OH_VideoEncoder_SetParameter](#oh_videoencoder_setparameter) (OH_AVCodec \*codec, OH_AVFormat \*format) | Sets dynamic parameters for a video encoder.| +| [OH_VideoEncoder_GetSurface](#oh_videoencoder_getsurface) (OH_AVCodec \*codec, OHNativeWindow \*\*window) | Sets an input surface for a video encoder. This function must be called prior to **Prepare**.| +| [OH_VideoEncoder_FreeOutputData](#oh_videoencoder_freeoutputdata) (OH_AVCodec \*codec, uint32_t index) | Frees an output buffer of a video encoder.| +| [OH_VideoEncoder_NotifyEndOfStream](#oh_videoencoder_notifyendofstream) (OH_AVCodec \*codec) | Notifies a video encoder that input streams end. You are advised to use this function for notification.| +| [OH_VideoEncoder_PushInputData](#oh_videoencoder_pushinputdata) (OH_AVCodec \*codec, uint32_t index, OH_AVCodecBufferAttr attr) | Pushes the input buffer filled with data to a video encoder.| +| \*[OH_VideoEncoder_GetInputDescription](#oh_videoencoder_getinputdescription) (OH_AVCodec \*codec) | Obtains the description information received by the video encoder. This function must be called after **Configure**. For details, see **OH_AVFormat**.| +| [OH_VideoEncoder_IsValid](#oh_videoencoder_isvalid) (OH_AVCodec \*codec, bool \*isValid) | Checks whether a video encoder instance is valid.| ## Type Description @@ -60,14 +65,20 @@ Provides the functions and enums for video encoding. This module may not be supp ### OH_VideoEncodeBitrateMode - + ``` typedef enum OH_VideoEncodeBitrateModeOH_VideoEncodeBitrateMode ``` -**Description**
-Enumerates the bit rate modes of video encoding. -@syscap SystemCapability.Multimedia.Media.VideoEncoder +**Description** + +Defines the bit rate mode of a video encoder. + +\@syscap SystemCapability.Multimedia.Media.VideoEncoder + +**Since** + +9 ## Enum Description @@ -75,20 +86,26 @@ Enumerates the bit rate modes of video encoding. ### OH_VideoEncodeBitrateMode - + ``` enum OH_VideoEncodeBitrateMode ``` -**Description**
-Enumerates the bit rate modes of video encoding. -@syscap SystemCapability.Multimedia.Media.VideoEncoder +**Description** + +Enumerates the bit rate modes of a video encoder. - | Value| Description| +\@syscap SystemCapability.Multimedia.Media.VideoEncoder + +**Since** + +9 + +| Value| Description| | -------- | -------- | -| CBR | Constant bit rate.| -| VBR | Variable bit rate.| -| CQ | Constant quality.| +| CBR | Constant bit rate.| +| VBR | Variable bit rate.| +| CQ | Constant quality.| ## Function Description @@ -96,359 +113,528 @@ Enumerates the bit rate modes of video encoding. ### OH_VideoEncoder_Configure() - + ``` OH_AVErrCode OH_VideoEncoder_Configure (OH_AVCodec * codec, OH_AVFormat * format ) ``` -**Description**
-Configures a video encoder. Typically, you need to configure the attributes of the video track that can be encoded. This API must be called prior to **Prepare**. -@syscap SystemCapability.Multimedia.Media.VideoEncoder +**Description** + +Configures a video encoder. Typically, you need to configure the description information about the video track to be encoded. + +This function must be called prior to **Prepare**. + +\@syscap SystemCapability.Multimedia.Media.VideoEncoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| format | Indicates the handle to an **OH_AVFormat** instance, which provides the attributes of the video track to be encoded. | +| codec | Pointer to an **OH_AVCodec** instance.| +| format | Pointer to an **OH_AVFormat** instance, which provides the description information about the video track to be encoded.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +9 ### OH_VideoEncoder_CreateByMime() - + ``` OH_AVCodec* OH_VideoEncoder_CreateByMime (const char * mime) ``` -**Description**
-Creates a video encoder instance based on a MIME type. This API is recommended in most cases. -@syscap SystemCapability.Multimedia.Media.VideoEncoder +**Description** + +Creates a video encoder instance based on a MIME type. This function is recommended in most cases. + +\@syscap SystemCapability.Multimedia.Media.VideoEncoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| mime | Indicates the pointer to a MIME type. For details, see [OH_AVCODEC_MIMETYPE_VIDEO_AVC](_codec_base.md#oh_avcodec_mimetype_video_avc).| +| mime | Pointer to a string that describes the MIME type. For details, see **AVCODEC_MIME_TYPE**.| **Returns** -Returns the pointer to an **OH_AVCodec** instance. +Returns the pointer to the **OH_AVCodec** instance created. You must call **OH_VideoEncoder_Destroy** to destroy the instance when it is no longer needed. + +**Since** + +9 ### OH_VideoEncoder_CreateByName() - + ``` OH_AVCodec* OH_VideoEncoder_CreateByName (const char * name) ``` -**Description**
-Creates a video encoder instance based on a video encoder name. To use this API, you must know the exact name of the video encoder. -@syscap SystemCapability.Multimedia.Media.VideoEncoder +**Description** + +Creates a video encoder instance based on an encoder name. To use this function, you must know the exact name of the encoder. + +\@syscap SystemCapability.Multimedia.Media.VideoEncoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| name | Indicates the pointer to a video encoder name. | +| name | Pointer to a video encoder name.| **Returns** Returns the pointer to an **OH_AVCodec** instance. +**Since** + +9 + ### OH_VideoEncoder_Destroy() - + ``` OH_AVErrCode OH_VideoEncoder_Destroy (OH_AVCodec * codec) ``` -**Description**
-Clears the internal resources of a video encoder and destroys the video encoder instance. -@syscap SystemCapability.Multimedia.Media.VideoEncoder +**Description** + +Clears the internal resources of a video encoder and destroys the encoder instance. + +\@syscap SystemCapability.Multimedia.Media.VideoEncoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Pointer to an **OH_AVCodec** instance.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +**Since** + +9 ### OH_VideoEncoder_Flush() - + ``` OH_AVErrCode OH_VideoEncoder_Flush (OH_AVCodec * codec) ``` -**Description**
-Clears the input and output data in the internal buffer of a video encoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. -@syscap SystemCapability.Multimedia.Media.VideoEncoder +**Description** + +Clears the input and output data in the internal buffer of a video encoder. + +This function invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this function, ensure that the buffers with the specified indexes are no longer required. + +\@syscap SystemCapability.Multimedia.Media.VideoEncoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Pointer to an **OH_AVCodec** instance.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +**Since** + +9 ### OH_VideoEncoder_FreeOutputData() - + ``` OH_AVErrCode OH_VideoEncoder_FreeOutputData (OH_AVCodec * codec, uint32_t index ) ``` -**Description**
+ +**Description** + Frees an output buffer of a video encoder. -@syscap SystemCapability.Multimedia.Media.VideoEncoder +\@syscap SystemCapability.Multimedia.Media.VideoEncoder + +**Parameters** + +| Name| Description| +| -------- | -------- | +| codec | Pointer to an **OH_AVCodec** instance.| +| index | Index of the output buffer.| + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** + +9 + + +### OH_VideoEncoder_GetInputDescription() + + +``` +OH_AVFormat* OH_VideoEncoder_GetInputDescription (OH_AVCodec * codec) +``` + +**Description** + +Obtains the description information received by the video encoder. This function must be called after **Configure**. For details, see **OH_AVFormat**. + +The caller must manually release the **OH_AVFormat** instance in the return value. + +\@syscap SystemCapability.Multimedia.Media.VideoEncoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| index | Indicates the index of an output buffer. | +| codec | Pointer to an **OH_AVCodec** instance.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns the pointer to an **OH_AVFormat** instance. + +**Since** -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +10 ### OH_VideoEncoder_GetOutputDescription() - + ``` OH_AVFormat* OH_VideoEncoder_GetOutputDescription (OH_AVCodec * codec) ``` -**Description**
-Obtains the attributes of the output data of a video encoder. The **OH_AVFormat** instance in the return value will become invalid when this API is called again or when the **OH_AVCodec** instance is destroyed. -@syscap SystemCapability.Multimedia.Media.VideoEncoder +**Description** + +Obtains the description information about the output data of a video encoder. For details, see **OH_AVFormat**. + +The caller must manually release the **OH_AVFormat** instance in the return value. + +\@syscap SystemCapability.Multimedia.Media.VideoEncoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Pointer to an **OH_AVCodec** instance.| **Returns** Returns the pointer to an **OH_AVFormat** instance. +**Since** + +9 + ### OH_VideoEncoder_GetSurface() - + ``` OH_AVErrCode OH_VideoEncoder_GetSurface (OH_AVCodec * codec, OHNativeWindow ** window ) ``` -**Description**
-Obtains an input surface from a video encoder. This API must be called prior to **Prepare**. -@syscap SystemCapability.Multimedia.Media.VideoEncoder +**Description** + +Sets an input surface for a video encoder. This function must be called prior to **Prepare**. + +\@syscap SystemCapability.Multimedia.Media.VideoEncoder + +**Parameters** + +| Name| Description| +| -------- | -------- | +| codec | Pointer to an **OH_AVCodec** instance.| +| window | Pointer to an **OHNativeWindow** instance. For details, see **OHNativeWindow**.| + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** + +9 + + +### OH_VideoEncoder_IsValid() + + +``` +OH_AVErrCode OH_VideoEncoder_IsValid (OH_AVCodec * codec, bool * isValid ) +``` + +**Description** + +Checks whether a video encoder instance is valid. + +\@syscap SystemCapability.Multimedia.Media.VideoEncoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| window | Indicates the double pointer to an **OHNativeWindow** instance. | +| codec | Pointer to an **OH_AVCodec** instance.| +| isValid | Pointer to an instance of the Boolean type. The value **true** means that the encoder instance is valid and **false** means the opposite.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +10 ### OH_VideoEncoder_NotifyEndOfStream() - + ``` OH_AVErrCode OH_VideoEncoder_NotifyEndOfStream (OH_AVCodec * codec) ``` -**Description**
-Notifies a video encoder that input streams end. This API is recommended in surface mode. -@syscap SystemCapability.Multimedia.Media.VideoEncoder +**Description** + +Notifies a video encoder that input streams end. You are advised to use this function for notification. + +This function is recommended in surface mode. + +\@syscap SystemCapability.Multimedia.Media.VideoEncoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Pointer to an **OH_AVCodec** instance.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +**Since** + +9 ### OH_VideoEncoder_Prepare() - + ``` OH_AVErrCode OH_VideoEncoder_Prepare (OH_AVCodec * codec) ``` -**Description**
-Prepares internal resources for a video encoder. This API must be called after **Configure**. -@syscap SystemCapability.Multimedia.Media.VideoEncoder +**Description** + +Prepares internal resources for a video encoder. This function must be called after **Configure**. + +\@syscap SystemCapability.Multimedia.Media.VideoEncoder + +**Parameters** + +| Name| Description| +| -------- | -------- | +| codec | Pointer to an **OH_AVCodec** instance.| + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** + +9 + + +### OH_VideoEncoder_PushInputData() + + +``` +OH_AVErrCode OH_VideoEncoder_PushInputData (OH_AVCodec * codec, uint32_t index, OH_AVCodecBufferAttr attr ) +``` + +**Description** + +Pushes the input buffer filled with data to a video encoder. + +\@syscap SystemCapability.Multimedia.Media.VideoEncoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Pointer to an **OH_AVCodec** instance.| +| index | Index of the input buffer.| +| attr | Description of the data contained in the buffer.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +10 ### OH_VideoEncoder_Reset() - + ``` OH_AVErrCode OH_VideoEncoder_Reset (OH_AVCodec * codec) ``` -**Description**
-Resets a video encoder. To continue encoding, you must call **Configure** and **Start** to configure and start the encoder again. -@syscap SystemCapability.Multimedia.Media.VideoEncoder +**Description** + +Resets a video encoder. To continue encoding, you must call **Configure** to configure the encoder again. + +\@syscap SystemCapability.Multimedia.Media.VideoEncoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Pointer to an **OH_AVCodec** instance.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +**Since** + +9 ### OH_VideoEncoder_SetCallback() - + ``` OH_AVErrCode OH_VideoEncoder_SetCallback (OH_AVCodec * codec, OH_AVCodecAsyncCallback callback, void * userData ) ``` -**Description**
-Sets an asynchronous callback so that your application can respond to events generated by a video encoder. This API must be called prior to **Prepare**. -@syscap SystemCapability.Multimedia.Media.VideoEncoder +**Description** + +Sets an asynchronous callback so that your application can respond to events generated by a video encoder. + +This function must be called prior to **Prepare**. + +\@syscap SystemCapability.Multimedia.Media.VideoEncoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| callback | Indicates a collection of all callback functions. For details, see [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md).| -| userData | Indicates the pointer to user-specific data. | +| codec | Pointer to an **OH_AVCodec** instance.| +| callback | Callback function to set. For details, see **OH_AVCodecAsyncCallback**.| +| userData | User-specific data.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +9 ### OH_VideoEncoder_SetParameter() - + ``` OH_AVErrCode OH_VideoEncoder_SetParameter (OH_AVCodec * codec, OH_AVFormat * format ) ``` -**Description**
-Sets dynamic parameters for a video encoder. This API can be called only after the encoder is started. Incorrect parameter settings may cause encoding failure. -@syscap SystemCapability.Multimedia.Media.VideoEncoder +**Description** + +Sets dynamic parameters for a video encoder. + +This function can be called only after the encoder is started. Incorrect parameter settings may cause encoding failure. + +\@syscap SystemCapability.Multimedia.Media.VideoEncoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| format | Indicates the handle to an **OH_AVFormat** instance. | +| codec | Pointer to an **OH_AVCodec** instance.| +| format | Handle to an **OH_AVFormat** instance.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +**Since** + +9 ### OH_VideoEncoder_Start() - + ``` OH_AVErrCode OH_VideoEncoder_Start (OH_AVCodec * codec) ``` -**Description**
-Starts a video encoder. This API can be called only after the encoder is prepared successfully. After being started, the encoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. -@syscap SystemCapability.Multimedia.Media.VideoEncoder +**Description** + +Starts a video encoder. This function can be called only after the encoder is prepared successfully. + +After being started, the encoder starts to report the **NeedInputData** event. + +\@syscap SystemCapability.Multimedia.Media.VideoEncoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Pointer to an **OH_AVCodec** instance.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. + +**Since** -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +9 ### OH_VideoEncoder_Stop() - + ``` OH_AVErrCode OH_VideoEncoder_Stop (OH_AVCodec * codec) ``` -**Description**
+ +**Description** + Stops a video encoder. After the encoder is stopped, you can call **Start** to start it again. -@syscap SystemCapability.Multimedia.Media.VideoEncoder +\@syscap SystemCapability.Multimedia.Media.VideoEncoder **Parameters** - | Name| Description| +| Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Pointer to an **OH_AVCodec** instance.| **Returns** -Returns **AV_ERR_OK** if the operation is successful. +Returns **AV_ERR_OK** if the operation is successful; returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) otherwise. -Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. +**Since** + +9 diff --git a/en/application-dev/reference/native-apis/avcodec__audio__channel__layout_8h.md b/en/application-dev/reference/native-apis/avcodec__audio__channel__layout_8h.md new file mode 100644 index 0000000000..2d924189d6 --- /dev/null +++ b/en/application-dev/reference/native-apis/avcodec__audio__channel__layout_8h.md @@ -0,0 +1,25 @@ +# avcodec_audio_channel_layout.h + + +## Overview + +The **avcodec_audio_channel_layout.h** file declares the enums used for audio codec. + +**Since** + +9 + +**Related Modules** + +[AudioDecoder](_audio_decoder.md) + + +## Summary + + +### Enums + +| Name| Description| +| -------- | -------- | +| [OHOS::Media::AudioChannelSet](_audio_decoder.md#audiochannelset) : uint64_t {
**FRONT_LEFT** = 1ULL << 0U, **FRONT_RIGHT** = 1ULL << 1U, **FRONT_CENTER** = 1ULL << 2U, **LOW_FREQUENCY** = 1ULL << 3U,
**BACK_LEFT** = 1ULL << 4U, **BACK_RIGHT** = 1ULL << 5U, **FRONT_LEFT_OF_CENTER** = 1ULL << 6U, **FRONT_RIGHT_OF_CENTER** = 1ULL << 7U,
**BACK_CENTER** = 1ULL << 8U, **SIDE_LEFT** = 1ULL << 9U, **SIDE_RIGHT** = 1ULL << 10U, **TOP_CENTER** = 1ULL << 11U,
**TOP_FRONT_LEFT** = 1ULL << 12U, **TOP_FRONT_CENTER** = 1ULL << 13U, **TOP_FRONT_RIGHT** = 1ULL << 14U, **TOP_BACK_LEFT** = 1ULL << 15U,
**TOP_BACK_CENTER** = 1ULL << 16U, **TOP_BACK_RIGHT** = 1ULL << 17U, **STEREO_LEFT** = 1ULL << 29U, **STEREO_RIGHT** = 1ULL << 30U,
**WIDE_LEFT** = 1ULL << 31U, **WIDE_RIGHT** = 1ULL << 32U, **SURROUND_DIRECT_LEFT** = 1ULL << 33U, **SURROUND_DIRECT_RIGHT** = 1ULL << 34U,
**LOW_FREQUENCY_2** = 1ULL << 35U, **TOP_SIDE_LEFT** = 1ULL << 36U, **TOP_SIDE_RIGHT** = 1ULL << 37U, **BOTTOM_FRONT_CENTER** = 1ULL << 38U,
**BOTTOM_FRONT_LEFT** = 1ULL << 39U, **BOTTOM_FRONT_RIGHT** = 1ULL << 40U, **AMBISONICS_ACN0** = 1ULL << 41U, OHOS::Media::AMBISONICS_ACN1 = 1ULL << 42U,
OHOS::Media::AMBISONICS_ACN2 = 1ULL << 43U, OHOS::Media::AMBISONICS_ACN3 = 1ULL << 44U, OHOS::Media::AMBISONICS_W = AMBISONICS_ACN0, OHOS::Media::AMBISONICS_Y = AMBISONICS_ACN1,
OHOS::Media::AMBISONICS_Z = AMBISONICS_ACN2, OHOS::Media::AMBISONICS_X = AMBISONICS_ACN3, OHOS::Media::AMBISONICS_ACN4 = 1ULL << 45U, OHOS::Media::AMBISONICS_ACN5 = 1ULL << 46U,
OHOS::Media::AMBISONICS_ACN6 = 1ULL << 47U, OHOS::Media::AMBISONICS_ACN7 = 1ULL << 48U, OHOS::Media::AMBISONICS_ACN8 = 1ULL << 49U, OHOS::Media::AMBISONICS_ACN9 = 1ULL << 50U,
OHOS::Media::AMBISONICS_ACN10 = 1ULL << 51U, OHOS::Media::AMBISONICS_ACN11 = 1ULL << 52U, OHOS::Media::AMBISONICS_ACN12 = 1ULL << 53U, OHOS::Media::AMBISONICS_ACN13 = 1ULL << 54U,
OHOS::Media::AMBISONICS_ACN14 = 1ULL << 55U, OHOS::Media::AMBISONICS_ACN15 = 1ULL << 56U
} | Enumerates the audio channel numbers. Each channel number is mapped to a variable of int64.| +| [OHOS::Media::AudioChannelLayout](_audio_decoder.md#audiochannellayout) : uint64_t {
**UNKNOWN_CHANNEL_LAYOUT** = 0, **MONO** = (AudioChannelSet::FRONT_CENTER), **STEREO** = (AudioChannelSet::FRONT_LEFT \| AudioChannelSet::FRONT_RIGHT), **CH_2POINT1** = (STEREO \| AudioChannelSet::LOW_FREQUENCY),
**CH_2_1** = (STEREO \| AudioChannelSet::BACK_CENTER), **SURROUND** = (STEREO \| AudioChannelSet::FRONT_CENTER), **CH_3POINT1** = (SURROUND \| AudioChannelSet::LOW_FREQUENCY), **CH_4POINT0** = (SURROUND \| AudioChannelSet::BACK_CENTER),
**CH_4POINT1** = (CH_4POINT0 \| AudioChannelSet::LOW_FREQUENCY), **CH_2_2** = (STEREO \| AudioChannelSet::SIDE_LEFT \| AudioChannelSet::SIDE_RIGHT), **QUAD** = (STEREO \| AudioChannelSet::BACK_LEFT \| AudioChannelSet::BACK_RIGHT), **CH_5POINT0** = (SURROUND \| AudioChannelSet::SIDE_LEFT \| AudioChannelSet::SIDE_RIGHT),
**CH_5POINT1** = (CH_5POINT0 \| AudioChannelSet::LOW_FREQUENCY), **CH_5POINT0_BACK** = (SURROUND \| AudioChannelSet::BACK_LEFT \| AudioChannelSet::BACK_RIGHT), **CH_5POINT1_BACK** = (CH_5POINT0_BACK \| AudioChannelSet::LOW_FREQUENCY), **CH_6POINT0** = (CH_5POINT0 \| AudioChannelSet::BACK_CENTER),
**CH_6POINT0_FRONT** = (CH_2_2 \| AudioChannelSet::FRONT_LEFT_OF_CENTER \| AudioChannelSet::FRONT_RIGHT_OF_CENTER), **HEXAGONAL** = (CH_5POINT0_BACK \| AudioChannelSet::BACK_CENTER), **CH_6POINT1** = (CH_5POINT1 \| AudioChannelSet::BACK_CENTER), **CH_6POINT1_BACK** = (CH_5POINT1_BACK \| AudioChannelSet::BACK_CENTER),
**CH_6POINT1_FRONT** = (CH_6POINT0_FRONT \| AudioChannelSet::LOW_FREQUENCY), **CH_7POINT0** = (CH_5POINT0 \| AudioChannelSet::BACK_LEFT \| AudioChannelSet::BACK_RIGHT), **CH_7POINT0_FRONT** = (CH_5POINT0 \| AudioChannelSet::FRONT_LEFT_OF_CENTER \| AudioChannelSet::FRONT_RIGHT_OF_CENTER), **CH_7POINT1** = (CH_5POINT1 \| AudioChannelSet::BACK_LEFT \| AudioChannelSet::BACK_RIGHT),
**CH_7POINT1_WIDE** = (CH_5POINT1 \| AudioChannelSet::FRONT_LEFT_OF_CENTER \| AudioChannelSet::FRONT_RIGHT_OF_CENTER), **CH_7POINT1_WIDE_BACK**, **CH_3POINT1POINT2** = (CH_3POINT1 \| AudioChannelSet::TOP_FRONT_LEFT \| AudioChannelSet::TOP_FRONT_RIGHT), **CH_5POINT1POINT2** = (CH_5POINT1 \| AudioChannelSet::TOP_SIDE_LEFT \| AudioChannelSet::TOP_SIDE_RIGHT),
**CH_5POINT1POINT4**, **CH_7POINT1POINT2** = (CH_7POINT1 \| AudioChannelSet::TOP_SIDE_LEFT \| AudioChannelSet::TOP_SIDE_RIGHT), **CH_7POINT1POINT4**, **CH_9POINT1POINT4** = (CH_7POINT1POINT4 \| AudioChannelSet::WIDE_LEFT \| AudioChannelSet::WIDE_RIGHT),
**CH_9POINT1POINT6** = (CH_9POINT1POINT4 \| AudioChannelSet::TOP_SIDE_LEFT \| AudioChannelSet::TOP_SIDE_RIGHT), **CH_10POINT2**, **CH_22POINT2**, **OCTAGONAL** = (CH_5POINT0 \| AudioChannelSet::BACK_LEFT \| AudioChannelSet::BACK_CENTER \| AudioChannelSet::BACK_RIGHT),
**HEXADECAGONAL**, **STEREO_DOWNMIX** = (AudioChannelSet::STEREO_LEFT \| AudioChannelSet::STEREO_RIGHT), **HOA_FIRST**, **HOA_SECOND**,
**HOA_THIRD**
} | Enumerates the types of the audio channel numbers. The output format of the decoder is represented as the channel type of the codec.| diff --git a/en/application-dev/reference/native-apis/native__audiocapturer_8h.md b/en/application-dev/reference/native-apis/native__audiocapturer_8h.md new file mode 100644 index 0000000000..36487a3d2e --- /dev/null +++ b/en/application-dev/reference/native-apis/native__audiocapturer_8h.md @@ -0,0 +1,38 @@ +# native_audiocapturer.h + + +## Overview + +The **native_audiocapturer.h** file declares the functions related to an audio capturer. + +\@syscap SystemCapability.Multimedia.Audio.Core + +**Since** + +10 + +**Related Modules** + +[OHAudio](_o_h_audio.md) + + +## Summary + + +### Functions + +| Name| Description| +| -------- | -------- | +| [OH_AudioCapturer_Release](_o_h_audio.md#oh_audiocapturer_release) ([OH_AudioCapturer](_o_h_audio.md#oh_audiocapturer) \*capturer) | Releases an audio capturer.| +| [OH_AudioCapturer_Start](_o_h_audio.md#oh_audiocapturer_start) ([OH_AudioCapturer](_o_h_audio.md#oh_audiocapturer) \*capturer) | Starts an audio capturer.| +| [OH_AudioCapturer_Pause](_o_h_audio.md#oh_audiocapturer_pause) ([OH_AudioCapturer](_o_h_audio.md#oh_audiocapturer) \*capturer) | Pauses an audio capturer.| +| [OH_AudioCapturer_Stop](_o_h_audio.md#oh_audiocapturer_stop) ([OH_AudioCapturer](_o_h_audio.md#oh_audiocapturer) \*capturer) | Stops an audio capturer.| +| [OH_AudioCapturer_Flush](_o_h_audio.md#oh_audiocapturer_flush) ([OH_AudioCapturer](_o_h_audio.md#oh_audiocapturer) \*capturer) | Flushes obtained audio data.| +| [OH_AudioCapturer_GetCurrentState](_o_h_audio.md#oh_audiocapturer_getcurrentstate) ([OH_AudioCapturer](_o_h_audio.md#oh_audiocapturer) \*capturer, [OH_AudioStream_State](_o_h_audio.md#oh_audiostream_state) \*state) | Obtains the state of an audio stream.| +| [OH_AudioCapturer_GetLatencyMode](_o_h_audio.md#oh_audiocapturer_getlatencymode) ([OH_AudioCapturer](_o_h_audio.md#oh_audiocapturer) \*capturer, [OH_AudioStream_LatencyMode](_o_h_audio.md#oh_audiostream_latencymode) \*latencyMode) | Obtains the latency mode of an audio stream.| +| [OH_AudioCapturer_GetStreamId](_o_h_audio.md#oh_audiocapturer_getstreamid) ([OH_AudioCapturer](_o_h_audio.md#oh_audiocapturer) \*capturer, uint32_t \*streamId) | Obtains the stream ID of an audio stream.| +| [OH_AudioCapturer_GetSamplingRate](_o_h_audio.md#oh_audiocapturer_getsamplingrate) ([OH_AudioCapturer](_o_h_audio.md#oh_audiocapturer) \*capturer, int32_t \*rate) | Obtains the sampling rate of an audio stream.| +| [OH_AudioCapturer_GetChannelCount](_o_h_audio.md#oh_audiocapturer_getchannelcount) ([OH_AudioCapturer](_o_h_audio.md#oh_audiocapturer) \*capturer, int32_t \*channelCount) | Obtains the number of channels for an audio stream.| +| [OH_AudioCapturer_GetSampleFormat](_o_h_audio.md#oh_audiocapturer_getsampleformat) ([OH_AudioCapturer](_o_h_audio.md#oh_audiocapturer) \*capturer, [OH_AudioStream_SampleFormat](_o_h_audio.md#oh_audiostream_sampleformat) \*sampleFormat) | Obtains the sampling format of an audio stream.| +| [OH_AudioCapturer_GetEncodingType](_o_h_audio.md#oh_audiocapturer_getencodingtype) ([OH_AudioCapturer](_o_h_audio.md#oh_audiocapturer) \*capturer, [OH_AudioStream_EncodingType](_o_h_audio.md#oh_audiostream_encodingtype) \*encodingType) | Obtains the encoding type of an audio stream.| +| [OH_AudioCapturer_GetCapturerInfo](_o_h_audio.md#oh_audiocapturer_getcapturerinfo) ([OH_AudioCapturer](_o_h_audio.md#oh_audiocapturer) \*capturer, [OH_AudioStream_SourceType](_o_h_audio.md#oh_audiostream_sourcetype) \*sourceType) | Obtains the usage scenario of an audio capturer.| diff --git a/en/application-dev/reference/native-apis/native__audiorenderer_8h.md b/en/application-dev/reference/native-apis/native__audiorenderer_8h.md new file mode 100644 index 0000000000..c8ec0ee2f9 --- /dev/null +++ b/en/application-dev/reference/native-apis/native__audiorenderer_8h.md @@ -0,0 +1,38 @@ +# native_audiorenderer.h + + +## Overview + +The **native_audiorenderer.h** file declares the functions related to an audio renderer. + +\@syscap SystemCapability.Multimedia.Audio.Core + +**Since** + +10 + +**Related Modules** + +[OHAudio](_o_h_audio.md) + + +## Summary + + +### Functions + +| Name| Description| +| -------- | -------- | +| [OH_AudioRenderer_Release](_o_h_audio.md#oh_audiorenderer_release) ([OH_AudioRenderer](_o_h_audio.md#oh_audiorenderer) \*renderer) | Releases an audio renderer.| +| [OH_AudioRenderer_Start](_o_h_audio.md#oh_audiorenderer_start) ([OH_AudioRenderer](_o_h_audio.md#oh_audiorenderer) \*renderer) | Starts an audio renderer.| +| [OH_AudioRenderer_Pause](_o_h_audio.md#oh_audiorenderer_pause) ([OH_AudioRenderer](_o_h_audio.md#oh_audiorenderer) \*renderer) | Pauses an audio renderer.| +| [OH_AudioRenderer_Stop](_o_h_audio.md#oh_audiorenderer_stop) ([OH_AudioRenderer](_o_h_audio.md#oh_audiorenderer) \*renderer) | Stops an audio renderer.| +| [OH_AudioRenderer_Flush](_o_h_audio.md#oh_audiorenderer_flush) ([OH_AudioRenderer](_o_h_audio.md#oh_audiorenderer) \*renderer) | Flushes written audio data.| +| [OH_AudioRenderer_GetCurrentState](_o_h_audio.md#oh_audiorenderer_getcurrentstate) ([OH_AudioRenderer](_o_h_audio.md#oh_audiorenderer) \*renderer, [OH_AudioStream_State](_o_h_audio.md#oh_audiostream_state) \*state) | Obtains the state of an audio stream.| +| [OH_AudioRenderer_GetSamplingRate](_o_h_audio.md#oh_audiorenderer_getsamplingrate) ([OH_AudioRenderer](_o_h_audio.md#oh_audiorenderer) \*renderer, int32_t \*rate) | Obtains the sampling rate of an audio stream.| +| [OH_AudioRenderer_GetStreamId](_o_h_audio.md#oh_audiorenderer_getstreamid) ([OH_AudioRenderer](_o_h_audio.md#oh_audiorenderer) \*renderer, uint32_t \*streamId) | Obtains the stream ID of an audio stream.| +| [OH_AudioRenderer_GetChannelCount](_o_h_audio.md#oh_audiorenderer_getchannelcount) ([OH_AudioRenderer](_o_h_audio.md#oh_audiorenderer) \*renderer, int32_t \*channelCount) | Obtains the number of channels for an audio stream.| +| [OH_AudioRenderer_GetSampleFormat](_o_h_audio.md#oh_audiorenderer_getsampleformat) ([OH_AudioRenderer](_o_h_audio.md#oh_audiorenderer) \*renderer, [OH_AudioStream_SampleFormat](_o_h_audio.md#oh_audiostream_sampleformat) \*sampleFormat) | Obtains the sampling format of an audio stream.| +| [OH_AudioRenderer_GetLatencyMode](_o_h_audio.md#oh_audiorenderer_getlatencymode) ([OH_AudioRenderer](_o_h_audio.md#oh_audiorenderer) \*renderer, [OH_AudioStream_LatencyMode](_o_h_audio.md#oh_audiostream_latencymode) \*latencyMode) | Obtains the latency mode of an audio stream.| +| [OH_AudioRenderer_GetRendererInfo](_o_h_audio.md#oh_audiorenderer_getrendererinfo) ([OH_AudioRenderer](_o_h_audio.md#oh_audiorenderer) \*renderer, [OH_AudioStream_Usage](_o_h_audio.md#oh_audiostream_usage) \*usage) | Obtains the usage scenario of an audio renderer.| +| [OH_AudioRenderer_GetEncodingType](_o_h_audio.md#oh_audiorenderer_getencodingtype) ([OH_AudioRenderer](_o_h_audio.md#oh_audiorenderer) \*renderer, [OH_AudioStream_EncodingType](_o_h_audio.md#oh_audiostream_encodingtype) \*encodingType) | Obtains the encoding type of an audio stream.| diff --git a/en/application-dev/reference/native-apis/native__audiostream__base_8h.md b/en/application-dev/reference/native-apis/native__audiostream__base_8h.md new file mode 100644 index 0000000000..b3a91fedcb --- /dev/null +++ b/en/application-dev/reference/native-apis/native__audiostream__base_8h.md @@ -0,0 +1,52 @@ +# native_audiostream_base.h + + +## Overview + +The **native_audiostream_base.h** file declares the basic data structure of **OHAudio**. + +\@syscap SystemCapability.Multimedia.Audio.Core + +**Since** + +10 + +**Related Modules** + +[OHAudio](_o_h_audio.md) + + +## Summary + + +### Structs + +| Name| Description| +| -------- | -------- | +| [OH_AudioRenderer_Callbacks_Struct](_o_h___audio_renderer___callbacks___struct.md) | Defines a pointer to the callback functions related to an audio renderer.| +| [OH_AudioCapturer_Callbacks_Struct](_o_h___audio_capturer___callbacks___struct.md) | Defines a pointer to the callback functions related to an audio capturer.| + + +### Types + +| Name| Description| +| -------- | -------- | +| [OH_AudioStreamBuilder](_o_h_audio.md#oh_audiostreambuilder) | Defines an audio stream builder.| +| [OH_AudioRenderer](_o_h_audio.md#oh_audiorenderer) | Defines an audio renderer.| +| [OH_AudioCapturer](_o_h_audio.md#oh_audiocapturer) | Defines an audio capturer.| +| [OH_AudioRenderer_Callbacks](_o_h_audio.md#oh_audiorenderer_callbacks) | Defines a pointer to the callback functions related to an audio renderer.| +| [OH_AudioCapturer_Callbacks](_o_h_audio.md#oh_audiocapturer_callbacks) | Defines a pointer to the callback functions related to an audio capturer.| + + +### Enum + +| Name| Description| +| -------- | -------- | +| [OH_AudioStream_Result](_o_h_audio.md#oh_audiostream_result) { [AUDIOSTREAM_SUCCESS](_o_h_audio.md), [AUDIOSTREAM_ERROR_INVALID_PARAM](_o_h_audio.md), [AUDIOSTREAM_ERROR_ILLEGAL_STATE](_o_h_audio.md), [AUDIOSTREAM_ERROR_SYSTEM](_o_h_audio.md) } | Enumerates the audio stream operation results.| +| [OH_AudioStream_Type](_o_h_audio.md#oh_audiostream_type) { [AUDIOSTREAM_TYPE_RENDERER](_o_h_audio.md) = 1, [AUDIOSTREAM_TYPE_CAPTURER](_o_h_audio.md) = 2 } | Enumerates the audio stream types.| +| [OH_AudioStream_SampleFormat](_o_h_audio.md#oh_audiostream_sampleformat) { [AUDIOSTREAM_SAMPLE_U8](_o_h_audio.md) = 0, [AUDIOSTREAM_SAMPLE_S16LE](_o_h_audio.md) = 1, [AUDIOSTREAM_SAMPLE_S24LE](_o_h_audio.md) = 2, [AUDIOSTREAM_SAMPLE_S32LE](_o_h_audio.md) = 3 } | Enumerates the sampling formats of audio streams.| +| [OH_AudioStream_EncodingType](_o_h_audio.md#oh_audiostream_encodingtype) { **AUDIOSTREAM_ENCODING_TYPE_RAW** = 0 } | Enumerates the encoding types of audio streams.| +| [OH_AudioStream_Usage](_o_h_audio.md#oh_audiostream_usage) { **AUDIOSTREAM_USAGE_UNKNOWN** = 0, **AUDIOSTREAM_USAGE_MUSIC** = 1, **AUDIOSTREAM_USAGE_COMMUNICATION** = 2, **AUDIOSTREAM_USAGE_GAME** = 11 } | Enumerates the usage scenarios of audio output streams.| +| [OH_AudioStream_LatencyMode](_o_h_audio.md#oh_audiostream_latencymode) { [AUDIOSTREAM_LATENCY_MODE_NORMAL](_o_h_audio.md) } | Enumerates the latency modes of audio streams.| +| [OH_AudioStream_State](_o_h_audio.md#oh_audiostream_state) {
[AUDIOSTREAM_STATE_INVALID](_o_h_audio.md) = -1, [AUDIOSTREAM_STATE_PREPARED](_o_h_audio.md) = 1, [AUDIOSTREAM_STATE_RUNNING](_o_h_audio.md) = 2, [AUDIOSTREAM_STATE_STOPPED](_o_h_audio.md) = 3,
[AUDIOSTREAM_STATE_RELEASED](_o_h_audio.md) = 4, [AUDIOSTREAM_STATE_PAUSED](_o_h_audio.md) = 5
} | Enumerates the audio stream states.| +| [OH_AudioStream_SourceType](_o_h_audio.md#oh_audiostream_sourcetype) { **AUDIOSTREAM_SOURCE_TYPE_INVALID** = -1, **AUDIOSTREAM_SOURCE_TYPE_MIC**, **AUDIOSTREAM_SOURCE_TYPE_VOICE_RECOGNITION** = 1, **AUDIOSTREAM_SOURCE_TYPE_VOICE_COMMUNICATION** = 7 } | Enumerates the usage scenarios of audio input streams.| diff --git a/en/application-dev/reference/native-apis/native__audiostreambuilder_8h.md b/en/application-dev/reference/native-apis/native__audiostreambuilder_8h.md new file mode 100644 index 0000000000..4d147760c7 --- /dev/null +++ b/en/application-dev/reference/native-apis/native__audiostreambuilder_8h.md @@ -0,0 +1,40 @@ +# native_audiostreambuilder.h + + +## Overview + +The **native_audiostreambuilder.h** file declares the functions related to the audio stream builder. + +You can use the functions to create and destroy an audio stream builder, set audio stream attributes, and set callbacks. + +\@syscap SystemCapability.Multimedia.Audio.Core + +**Since** + +10 + +**Related Modules** + +[OHAudio](_o_h_audio.md) + + +## Summary + + +### Functions + +| Name| Description| +| -------- | -------- | +| [OH_AudioStreamBuilder_Create](_o_h_audio.md#oh_audiostreambuilder_create) ([OH_AudioStreamBuilder](_o_h_audio.md#oh_audiostreambuilder) \*\*builder, [OH_AudioStream_Type](_o_h_audio.md#oh_audiostream_type) type) | Creates an audio stream builder, which can be an audio renderer or capturer.| +| [OH_AudioStreamBuilder_Destroy](_o_h_audio.md#oh_audiostreambuilder_destroy) ([OH_AudioStreamBuilder](_o_h_audio.md#oh_audiostreambuilder) \*builder) | Destroys an audio stream builder.| +| [OH_AudioStreamBuilder_SetSamplingRate](_o_h_audio.md#oh_audiostreambuilder_setsamplingrate) ([OH_AudioStreamBuilder](_o_h_audio.md#oh_audiostreambuilder) \*builder, int32_t rate) | Sets the sampling rate of an audio stream.| +| [OH_AudioStreamBuilder_SetChannelCount](_o_h_audio.md#oh_audiostreambuilder_setchannelcount) ([OH_AudioStreamBuilder](_o_h_audio.md#oh_audiostreambuilder) \*builder, int32_t channelCount) | Sets the number of channels for an audio stream.| +| [OH_AudioStreamBuilder_SetSampleFormat](_o_h_audio.md#oh_audiostreambuilder_setsampleformat) ([OH_AudioStreamBuilder](_o_h_audio.md#oh_audiostreambuilder) \*builder, [OH_AudioStream_SampleFormat](_o_h_audio.md#oh_audiostream_sampleformat) format) | Sets the sampling format of an audio stream.| +| [OH_AudioStreamBuilder_SetEncodingType](_o_h_audio.md#oh_audiostreambuilder_setencodingtype) ([OH_AudioStreamBuilder](_o_h_audio.md#oh_audiostreambuilder) \*builder, [OH_AudioStream_EncodingType](_o_h_audio.md#oh_audiostream_encodingtype) encodingType) | Sets the encoding type of an audio stream.| +| [OH_AudioStreamBuilder_SetLatencyMode](_o_h_audio.md#oh_audiostreambuilder_setlatencymode) ([OH_AudioStreamBuilder](_o_h_audio.md#oh_audiostreambuilder) \*builder, [OH_AudioStream_LatencyMode](_o_h_audio.md#oh_audiostream_latencymode) latencyMode) | Sets the latency mode of an audio stream.| +| [OH_AudioStreamBuilder_SetRendererInfo](_o_h_audio.md#oh_audiostreambuilder_setrendererinfo) ([OH_AudioStreamBuilder](_o_h_audio.md#oh_audiostreambuilder) \*builder, [OH_AudioStream_Usage](_o_h_audio.md#oh_audiostream_usage) usage) | Sets the usage scenario of an audio renderer.| +| [OH_AudioStreamBuilder_SetCapturerInfo](_o_h_audio.md#oh_audiostreambuilder_setcapturerinfo) ([OH_AudioStreamBuilder](_o_h_audio.md#oh_audiostreambuilder) \*builder, [OH_AudioStream_SourceType](_o_h_audio.md#oh_audiostream_sourcetype) sourceType) | Sets the usage scenario of an audio capturer.| +| [OH_AudioStreamBuilder_SetRendererCallback](_o_h_audio.md#oh_audiostreambuilder_setrenderercallback) ([OH_AudioStreamBuilder](_o_h_audio.md#oh_audiostreambuilder) \*builder, [OH_AudioRenderer_Callbacks](_o_h_audio.md#oh_audiorenderer_callbacks) callbacks, void \*userData) | Sets callbacks for an audio renderer.| +| [OH_AudioStreamBuilder_SetCapturerCallback](_o_h_audio.md#oh_audiostreambuilder_setcapturercallback) ([OH_AudioStreamBuilder](_o_h_audio.md#oh_audiostreambuilder) \*builder, [OH_AudioCapturer_Callbacks](_o_h_audio.md#oh_audiocapturer_callbacks) callbacks, void \*userData) | Sets callbacks for an audio capturer.| +| [OH_AudioStreamBuilder_GenerateRenderer](_o_h_audio.md#oh_audiostreambuilder_generaterenderer) ([OH_AudioStreamBuilder](_o_h_audio.md#oh_audiostreambuilder) \*builder, [OH_AudioRenderer](_o_h_audio.md#oh_audiorenderer) \*\*audioRenderer) | Creates an audio renderer instance.| +| [OH_AudioStreamBuilder_GenerateCapturer](_o_h_audio.md#oh_audiostreambuilder_generatecapturer) ([OH_AudioStreamBuilder](_o_h_audio.md#oh_audiostreambuilder) \*builder, [OH_AudioCapturer](_o_h_audio.md#oh_audiocapturer) \*\*audioCapturer) | Creates an audio capturer instance.| diff --git a/en/application-dev/reference/native-apis/native__avcapability_8h.md b/en/application-dev/reference/native-apis/native__avcapability_8h.md new file mode 100644 index 0000000000..3182bae505 --- /dev/null +++ b/en/application-dev/reference/native-apis/native__avcapability_8h.md @@ -0,0 +1,72 @@ +# native_avcapability.h + + +## Overview + +The **native_avcapability.h** file declares the native APIs used to query the codec capability. + +**Since** + +10 + +**Related Modules** + +[AVCapability](_a_v_capability.md) + + +## Summary + + +### Structs + +| Name| Description| +| -------- | -------- | +| [OH_AVRange](_o_h___a_v_range.md) | Defines the value range, which contains the minimum value and maximum value.| + + +### Types + +| Name| Description| +| -------- | -------- | +| [OH_BitrateMode](_a_v_capability.md#oh_bitratemode) | Defines an enum that enumerates the bit rate modes of an encoder.| +| [OH_AVRange](_a_v_capability.md#oh_avrange) | Defines a struct for the value range, which contains the minimum value and maximum value.| +| [OH_AVCodecCategory](_a_v_capability.md#oh_avcodeccategory) | Defines an enum that enumerates the codec categories.| + + +### Enums + +| Name| Description| +| -------- | -------- | +| [OH_BitrateMode](_a_v_capability.md#oh_bitratemode) { **BITRATE_MODE_CBR** = 0, **BITRATE_MODE_VBR** = 1, **BITRATE_MODE_CQ** = 2 } | Enumerates the bit rate modes of an encoder.| +| [OH_AVCodecCategory](_a_v_capability.md#oh_avcodeccategory) { **HARDWARE** = 0, **SOFTWARE** } | Enumerates the codec categories.| + + +### Functions + +| Name| Description| +| -------- | -------- | +| \*[OH_AVCodec_GetCapability](_a_v_capability.md#oh_avcodec_getcapability) (const char \*mime, bool isEncoder) | Obtains the codec capability recommended by the system.| +| \*[OH_AVCodec_GetCapabilityByCategory](_a_v_capability.md#oh_avcodec_getcapabilitybycategory) (const char \*mime, bool isEncoder, [OH_AVCodecCategory](_a_v_capability.md#oh_avcodeccategory) category) | Obtains the codec capability by category, which can be a hardware codec or software codec.| +| [OH_AVCapability_IsHardware](_a_v_capability.md#oh_avcapability_ishardware) (OH_AVCapability \*capability) | Checks whether a codec capability instance describes a hardware codec.| +| \*[OH_AVCapability_GetName](_a_v_capability.md#oh_avcapability_getname) (OH_AVCapability \*capability) | Obtains the codec name.| +| [OH_AVCapability_GetMaxSupportedInstances](_a_v_capability.md#oh_avcapability_getmaxsupportedinstances) (OH_AVCapability \*capability) | Obtains the maximum number of codec instances supported by a codec.| +| [OH_AVCapability_GetEncoderBitrateRange](_a_v_capability.md#oh_avcapability_getencoderbitraterange) (OH_AVCapability \*capability, [OH_AVRange](_o_h___a_v_range.md) \*bitrateRange) | Obtains the bit rate range supported by an encoder.| +| [OH_AVCapability_IsEncoderBitrateModeSupported](_a_v_capability.md#oh_avcapability_isencoderbitratemodesupported) (OH_AVCapability \*capability, [OH_BitrateMode](_a_v_capability.md#oh_bitratemode) bitrateMode) | Checks whether an encoder supports a specific bit rate mode.| +| [OH_AVCapability_GetEncoderQualityRange](_a_v_capability.md#oh_avcapability_getencoderqualityrange) (OH_AVCapability \*capability, [OH_AVRange](_o_h___a_v_range.md) \*qualityRange) | Obtains the quality range supported by an encoder.| +| [OH_AVCapability_GetEncoderComplexityRange](_a_v_capability.md#oh_avcapability_getencodercomplexityrange) (OH_AVCapability \*capability, [OH_AVRange](_o_h___a_v_range.md) \*complexityRange) | Obtains the complexity range supported by an encoder.| +| [OH_AVCapability_GetAudioSupportedSampleRates](_a_v_capability.md#oh_avcapability_getaudiosupportedsamplerates) (OH_AVCapability \*capability, const int32_t \*\*sampleRates, uint32_t \*sampleRateNum) | Obtains the sampling rates supported by an audio codec.| +| [OH_AVCapability_GetAudioChannelCountRange](_a_v_capability.md#oh_avcapability_getaudiochannelcountrange) (OH_AVCapability \*capability, [OH_AVRange](_o_h___a_v_range.md) \*channelCountRange) | Obtains the count range of audio channels supported by an audio codec.| +| [OH_AVCapability_GetVideoWidthAlignment](_a_v_capability.md#oh_avcapability_getvideowidthalignment) (OH_AVCapability \*capability, int32_t \*widthAlignment) | Obtains the video width alignment supported by a video codec.| +| [OH_AVCapability_GetVideoHeightAlignment](_a_v_capability.md#oh_avcapability_getvideoheightalignment) (OH_AVCapability \*capability, int32_t \*heightAlignment) | Obtains the video height alignment supported by a video codec.| +| [OH_AVCapability_GetVideoWidthRangeForHeight](_a_v_capability.md#oh_avcapability_getvideowidthrangeforheight) (OH_AVCapability \*capability, int32_t height, [OH_AVRange](_o_h___a_v_range.md) \*widthRange) | Obtains the video width range supported by a video codec based on a given height.| +| [OH_AVCapability_GetVideoHeightRangeForWidth](_a_v_capability.md#oh_avcapability_getvideoheightrangeforwidth) (OH_AVCapability \*capability, int32_t width, [OH_AVRange](_o_h___a_v_range.md) \*heightRange) | Obtains the video height range supported by a video codec based on a given width.| +| [OH_AVCapability_GetVideoWidthRange](_a_v_capability.md#oh_avcapability_getvideowidthrange) (OH_AVCapability \*capability, [OH_AVRange](_o_h___a_v_range.md) \*widthRange) | Obtains the video width range supported by a video codec.| +| [OH_AVCapability_GetVideoHeightRange](_a_v_capability.md#oh_avcapability_getvideoheightrange) (OH_AVCapability \*capability, [OH_AVRange](_o_h___a_v_range.md) \*heightRange) | Obtains the video height range supported by a video codec.| +| [OH_AVCapability_IsVideoSizeSupported](_a_v_capability.md#oh_avcapability_isvideosizesupported) (OH_AVCapability \*capability, int32_t width, int32_t height) | Checks whether a video codec supports a specific video size.| +| [OH_AVCapability_GetVideoFrameRateRange](_a_v_capability.md#oh_avcapability_getvideoframeraterange) (OH_AVCapability \*capability, [OH_AVRange](_o_h___a_v_range.md) \*frameRateRange) | Obtains the video frame rate range supported by a video codec.| +| [OH_AVCapability_GetVideoFrameRateRangeForSize](_a_v_capability.md#oh_avcapability_getvideoframeraterangeforsize) (OH_AVCapability \*capability, int32_t width, int32_t height, [OH_AVRange](_o_h___a_v_range.md) \*frameRateRange) | Obtains the video frame rate range supported by a video codec based on a given video size.| +| [OH_AVCapability_AreVideoSizeAndFrameRateSupported](_a_v_capability.md#oh_avcapability_arevideosizeandframeratesupported) (OH_AVCapability \*capability, int32_t width, int32_t height, int32_t frameRate) | Checks whether a video codec supports the combination of a video size and frame rate.| +| [OH_AVCapability_GetVideoSupportedPixelFormats](_a_v_capability.md#oh_avcapability_getvideosupportedpixelformats) (OH_AVCapability \*capability, const int32_t \*\*pixelFormats, uint32_t \*pixelFormatNum) | Obtains the video pixel formats supported by a video codec.| +| [OH_AVCapability_GetSupportedProfiles](_a_v_capability.md#oh_avcapability_getsupportedprofiles) (OH_AVCapability \*capability, const int32_t \*\*profiles, uint32_t \*profileNum) | Obtains the profiles supported by a codec.| +| [OH_AVCapability_GetSupportedLevelsForProfile](_a_v_capability.md#oh_avcapability_getsupportedlevelsforprofile) (OH_AVCapability \*capability, int32_t profile, const int32_t \*\*levels, uint32_t \*levelNum) | Obtains the codec levels supported by a profile.| +| [OH_AVCapability_AreProfileAndLevelSupported](_a_v_capability.md#oh_avcapability_areprofileandlevelsupported) (OH_AVCapability \*capability, int32_t profile, int32_t level) | Checks whether a codec supports the combination of a profile and level.| diff --git a/en/application-dev/reference/native-apis/native__avcodec__audiodecoder_8h.md b/en/application-dev/reference/native-apis/native__avcodec__audiodecoder_8h.md index 7de3cf3ee6..da13a59955 100644 --- a/en/application-dev/reference/native-apis/native__avcodec__audiodecoder_8h.md +++ b/en/application-dev/reference/native-apis/native__avcodec__audiodecoder_8h.md @@ -3,12 +3,13 @@ ## Overview -Declares the native APIs used for audio decoding. +The **native_avcodec_audiodecoder.h** file declares the native APIs used for audio decoding. + +**Since** -**Since:** 9 -**Related Modules:** +**Related Modules** [AudioDecoder](_audio_decoder.md) @@ -18,19 +19,20 @@ Declares the native APIs used for audio decoding. ### Functions -| Name | Description | +| Name| Description| | -------- | -------- | -| [OH_AudioDecoder_CreateByMime](_audio_decoder.md#oh_audiodecoder_createbymime) (const char \*mime) | Creates an audio decoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases. | -| [OH_AudioDecoder_CreateByName](_audio_decoder.md#oh_audiodecoder_createbyname) (const char \*name) | Creates an audio decoder instance based on an audio decoder name. To use this API, you must know the exact name of the audio decoder. | -| [OH_AudioDecoder_Destroy](_audio_decoder.md#oh_audiodecoder_destroy) (OH_AVCodec \*codec) | Clears the internal resources of an audio decoder and destroys the audio decoder instance. | -| [OH_AudioDecoder_SetCallback](_audio_decoder.md#oh_audiodecoder_setcallback) (OH_AVCodec \*codec, [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) callback, void \*userData) | Sets an asynchronous callback so that your application can respond to events generated by an audio decoder. This API must be called prior to **Prepare**. | -| [OH_AudioDecoder_Configure](_audio_decoder.md#oh_audiodecoder_configure) (OH_AVCodec \*codec, OH_AVFormat \*format) | Configures an audio decoder. Typically, you need to configure the attributes, which can be extracted from the container, of the audio track that can be decoded. This API must be called prior to **Prepare**. | -| [OH_AudioDecoder_Prepare](_audio_decoder.md#oh_audiodecoder_prepare) (OH_AVCodec \*codec) | Prepares internal resources for an audio decoder. This API must be called after **Configure**. | -| [OH_AudioDecoder_Start](_audio_decoder.md#oh_audiodecoder_start) (OH_AVCodec \*codec) | Starts an audio decoder. This API can be called only after the decoder is prepared successfully. After being started, the decoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. | -| [OH_AudioDecoder_Stop](_audio_decoder.md#oh_audiodecoder_stop) (OH_AVCodec \*codec) | Stops an audio decoder. After the decoder is stopped, you can call **Start** to start it again. If you have passed codec-specific data in the previous **Start** for the decoder, you must pass it again. | -| [OH_AudioDecoder_Flush](_audio_decoder.md#oh_audiodecoder_flush) (OH_AVCodec \*codec) | Clears the input and output data in the internal buffer of an audio decoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. | -| [OH_AudioDecoder_Reset](_audio_decoder.md#oh_audiodecoder_reset) (OH_AVCodec \*codec) | Resets an audio decoder. To continue decoding, you must call **Configure** and **Start** to configure and start the decoder again. | -| [OH_AudioDecoder_GetOutputDescription](_audio_decoder.md#oh_audiodecoder_getoutputdescription) (OH_AVCodec \*codec) | Obtains the attributes of the output data of an audio decoder. The caller must manually release the **OH_AVFormat** instance in the return value. | -| [OH_AudioDecoder_SetParameter](_audio_decoder.md#oh_audiodecoder_setparameter) (OH_AVCodec \*codec, OH_AVFormat \*format) | Sets dynamic parameters for an audio decoder. This API can be called only after the decoder is started. Incorrect parameter settings may cause decoding failure. | -| [OH_AudioDecoder_PushInputData](_audio_decoder.md#oh_audiodecoder_pushinputdata) (OH_AVCodec \*codec, uint32_t index, [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) attr) | Pushes the input buffer filled with data to an audio decoder. The [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback reports available input buffers and their indexes. After being pushed to the decoder, a buffer is not accessible until the buffer with the same index is reported again through the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback. In addition, some decoders require the input of codec-specific data to initialize the decoding process. | -| [OH_AudioDecoder_FreeOutputData](_audio_decoder.md#oh_audiodecoder_freeoutputdata) (OH_AVCodec \*codec, uint32_t index) | Frees an output buffer of an audio decoder. | +| \*[OHOS::Media::OH_AudioDecoder_CreateByMime](_audio_decoder.md#oh_audiodecoder_createbymime) (const char \*mime) | Creates an audio decoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This function is recommended in most cases.| +| \*[OHOS::Media::OH_AudioDecoder_CreateByName](_audio_decoder.md#oh_audiodecoder_createbyname) (const char \*name) | Creates an audio decoder instance based on a decoder name. To use this function, you must know the exact name of the decoder.| +| [OHOS::Media::OH_AudioDecoder_Destroy](_audio_decoder.md#oh_audiodecoder_destroy) (OH_AVCodec \*codec) | Clears the internal resources of an audio decoder and destroys the decoder instance.| +| [OHOS::Media::OH_AudioDecoder_SetCallback](_audio_decoder.md#oh_audiodecoder_setcallback) (OH_AVCodec \*codec, OH_AVCodecAsyncCallback callback, void \*userData) | Sets an asynchronous callback so that your application can respond to events generated by an audio decoder.| +| [OHOS::Media::OH_AudioDecoder_Configure](_audio_decoder.md#oh_audiodecoder_configure) (OH_AVCodec \*codec, OH_AVFormat \*format) | Configures an audio decoder. Typically, you need to configure the audio description information that can be extracted from the container.| +| [OHOS::Media::OH_AudioDecoder_Prepare](_audio_decoder.md#oh_audiodecoder_prepare) (OH_AVCodec \*codec) | Prepares internal resources for an audio decoder. This function must be called after **Configure**.| +| [OHOS::Media::OH_AudioDecoder_Start](_audio_decoder.md#oh_audiodecoder_start) (OH_AVCodec \*codec) | Starts an audio decoder. This function can be called only after the decoder is prepared successfully.| +| [OHOS::Media::OH_AudioDecoder_Stop](_audio_decoder.md#oh_audiodecoder_stop) (OH_AVCodec \*codec) | Stops an audio decoder.| +| [OHOS::Media::OH_AudioDecoder_Flush](_audio_decoder.md#oh_audiodecoder_flush) (OH_AVCodec \*codec) | Clears the input and output data in the internal buffer of an audio decoder.| +| [OHOS::Media::OH_AudioDecoder_Reset](_audio_decoder.md#oh_audiodecoder_reset) (OH_AVCodec \*codec) | Resets an audio decoder. To continue decoding, you must call **Configure** to configure the decoder again.| +| \*[OHOS::Media::OH_AudioDecoder_GetOutputDescription](_audio_decoder.md#oh_audiodecoder_getoutputdescription) (OH_AVCodec \*codec) | Obtains the description information about the output data of an audio decoder. For details, see **OH_AVFormat**.| +| [OHOS::Media::OH_AudioDecoder_SetParameter](_audio_decoder.md#oh_audiodecoder_setparameter) (OH_AVCodec \*codec, OH_AVFormat \*format) | Sets dynamic parameters for an audio decoder. This function can be called only after the decoder is started. Incorrect parameter settings may cause decoding failure.| +| [OHOS::Media::OH_AudioDecoder_PushInputData](_audio_decoder.md#oh_audiodecoder_pushinputdata) (OH_AVCodec \*codec, uint32_t index, OH_AVCodecBufferAttr attr) | Pushes the input buffer filled with data to an audio decoder.| +| [OHOS::Media::OH_AudioDecoder_FreeOutputData](_audio_decoder.md#oh_audiodecoder_freeoutputdata) (OH_AVCodec \*codec, uint32_t index) | Frees an output buffer of an audio decoder.| +| [OHOS::Media::OH_AudioDecoder_IsValid](_audio_decoder.md#oh_audiodecoder_isvalid) (OH_AVCodec \*codec, bool \*isValid) | Checks whether an audio decoder instance is valid.| diff --git a/en/application-dev/reference/native-apis/native__avcodec__audioencoder_8h.md b/en/application-dev/reference/native-apis/native__avcodec__audioencoder_8h.md index 719009d67a..d501dddfc1 100644 --- a/en/application-dev/reference/native-apis/native__avcodec__audioencoder_8h.md +++ b/en/application-dev/reference/native-apis/native__avcodec__audioencoder_8h.md @@ -3,12 +3,13 @@ ## Overview -Declares the native APIs used for audio encoding. +The **native_avcodec_audioencoder.h** file declares the native APIs used for audio encoding. + +**Since** -**Since:** 9 -**Related Modules:** +**Related Modules** [AudioEncoder](_audio_encoder.md) @@ -18,19 +19,20 @@ Declares the native APIs used for audio encoding. ### Functions -| Name | Description | +| Name| Description| | -------- | -------- | -| [OH_AudioEncoder_CreateByMime](_audio_encoder.md#oh_audioencoder_createbymime) (const char \*mime) | Creates an audio encoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases. | -| [OH_AudioEncoder_CreateByName](_audio_encoder.md#oh_audioencoder_createbyname) (const char \*name) | Creates an audio encoder instance based on an audio encoder name. To use this API, you must know the exact name of the audio encoder. | -| [OH_AudioEncoder_Destroy](_audio_encoder.md#oh_audioencoder_destroy) (OH_AVCodec \*codec) | Clears the internal resources of an audio encoder and destroys the audio encoder instance. | -| [OH_AudioEncoder_SetCallback](_audio_encoder.md#oh_audioencoder_setcallback) (OH_AVCodec \*codec, [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) callback, void \*userData) | Sets an asynchronous callback so that your application can respond to events generated by an audio encoder. This API must be called prior to **Prepare**. | -| [OH_AudioEncoder_Configure](_audio_encoder.md#oh_audioencoder_configure) (OH_AVCodec \*codec, OH_AVFormat \*format) | Configures an audio encoder. Typically, you need to configure the attributes of the audio track that can be encoded. This API must be called prior to **Prepare**. | -| [OH_AudioEncoder_Prepare](_audio_encoder.md#oh_audioencoder_prepare) (OH_AVCodec \*codec) | Prepares internal resources for an audio encoder. This API must be called after **Configure**. | -| [OH_AudioEncoder_Start](_audio_encoder.md#oh_audioencoder_start) (OH_AVCodec \*codec) | Starts an audio encoder. This API can be called only after the encoder is prepared successfully. After being started, the encoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. | -| [OH_AudioEncoder_Stop](_audio_encoder.md#oh_audioencoder_stop) (OH_AVCodec \*codec) | Stops an audio encoder. After the encoder is stopped, you can call **Start** to start it again. | -| [OH_AudioEncoder_Flush](_audio_encoder.md#oh_audioencoder_flush) (OH_AVCodec \*codec) | Clears the input and output data in the internal buffer of an audio encoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. | -| [OH_AudioEncoder_Reset](_audio_encoder.md#oh_audioencoder_reset) (OH_AVCodec \*codec) | Resets an audio encoder. To continue encoding, you must call **Configure** and **Start** to configure and start the encoder again. | -| [OH_AudioEncoder_GetOutputDescription](_audio_encoder.md#oh_audioencoder_getoutputdescription) (OH_AVCodec \*codec) | Obtains the attributes of the output data of an audio encoder. The caller must manually release the **OH_AVFormat** instance in the return value. | -| [OH_AudioEncoder_SetParameter](_audio_encoder.md#oh_audioencoder_setparameter) (OH_AVCodec \*codec, OH_AVFormat \*format) | Sets dynamic parameters for an audio encoder. This API can be called only after the encoder is started. Incorrect parameter settings may cause encoding failure. | -| [OH_AudioEncoder_PushInputData](_audio_encoder.md#oh_audioencoder_pushinputdata) (OH_AVCodec \*codec, uint32_t index, [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) attr) | Pushes the input buffer filled with data to an audio encoder. The [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback reports available input buffers and their indexes. After being pushed to the decoder, a buffer is not accessible until the buffer with the same index is reported again through the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback. | -| [OH_AudioEncoder_FreeOutputData](_audio_encoder.md#oh_audioencoder_freeoutputdata) (OH_AVCodec \*codec, uint32_t index) | Frees an output buffer of an audio encoder. | +| \*[OHOS::Media::OH_AudioEncoder_CreateByMime](_audio_encoder.md#oh_audioencoder_createbymime) (const char \*mime) | Creates an audio encoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This function is recommended in most cases.| +| \*[OHOS::Media::OH_AudioEncoder_CreateByName](_audio_encoder.md#oh_audioencoder_createbyname) (const char \*name) | Creates an audio encoder instance based on an encoder name. To use this function, you must know the exact name of the encoder.| +| [OHOS::Media::OH_AudioEncoder_Destroy](_audio_encoder.md#oh_audioencoder_destroy) (OH_AVCodec \*codec) | Clears the internal resources of an audio encoder and destroys the encoder instance.| +| [OHOS::Media::OH_AudioEncoder_SetCallback](_audio_encoder.md#oh_audioencoder_setcallback) (OH_AVCodec \*codec, OH_AVCodecAsyncCallback callback, void \*userData) | Sets an asynchronous callback so that your application can respond to events generated by an audio encoder.| +| [OHOS::Media::OH_AudioEncoder_Configure](_audio_encoder.md#oh_audioencoder_configure) (OH_AVCodec \*codec, OH_AVFormat \*format) | Configures an audio encoder. Typically, you need to configure the description information about the audio track to be encoded.| +| [OHOS::Media::OH_AudioEncoder_Prepare](_audio_encoder.md#oh_audioencoder_prepare) (OH_AVCodec \*codec) | Prepares internal resources for an audio encoder. This function must be called after **Configure**.| +| [OHOS::Media::OH_AudioEncoder_Start](_audio_encoder.md#oh_audioencoder_start) (OH_AVCodec \*codec) | Starts an audio encoder. This function can be called only after the encoder is prepared successfully.| +| [OHOS::Media::OH_AudioEncoder_Stop](_audio_encoder.md#oh_audioencoder_stop) (OH_AVCodec \*codec) | Stops an audio encoder.| +| [OHOS::Media::OH_AudioEncoder_Flush](_audio_encoder.md#oh_audioencoder_flush) (OH_AVCodec \*codec) | Clears the input and output data in the internal buffer of an audio encoder.| +| [OHOS::Media::OH_AudioEncoder_Reset](_audio_encoder.md#oh_audioencoder_reset) (OH_AVCodec \*codec) | Resets an audio encoder.| +| \*[OHOS::Media::OH_AudioEncoder_GetOutputDescription](_audio_encoder.md#oh_audioencoder_getoutputdescription) (OH_AVCodec \*codec) | Obtains the description information about the output data of an audio encoder. For details, see **OH_AVFormat**.| +| [OHOS::Media::OH_AudioEncoder_SetParameter](_audio_encoder.md#oh_audioencoder_setparameter) (OH_AVCodec \*codec, OH_AVFormat \*format) | Sets dynamic parameters for an audio encoder.| +| [OHOS::Media::OH_AudioEncoder_PushInputData](_audio_encoder.md#oh_audioencoder_pushinputdata) (OH_AVCodec \*codec, uint32_t index, OH_AVCodecBufferAttr attr) | Pushes the input buffer filled with data to an audio encoder.| +| [OHOS::Media::OH_AudioEncoder_FreeOutputData](_audio_encoder.md#oh_audioencoder_freeoutputdata) (OH_AVCodec \*codec, uint32_t index) | Frees an output buffer of an audio encoder.| +| [OHOS::Media::OH_AudioEncoder_IsValid](_audio_encoder.md#oh_audioencoder_isvalid) (OH_AVCodec \*codec, bool \*isValid) | Checks whether an audio encoder instance is valid.| diff --git a/en/application-dev/reference/native-apis/native__avcodec__base_8h.md b/en/application-dev/reference/native-apis/native__avcodec__base_8h.md index 51b5a5e373..34ea191f75 100644 --- a/en/application-dev/reference/native-apis/native__avcodec__base_8h.md +++ b/en/application-dev/reference/native-apis/native__avcodec__base_8h.md @@ -3,12 +3,13 @@ ## Overview -Declares the common structs, character constants, and enums for running **OH_AVCodec** instances. +The **native_avcodec_base.h** file declares the common structs, character constants, and enums for running **OH_AVCodec** instances. + +**Since** -**Since:** 9 -**Related Modules:** +**Related Modules** [CodecBase](_codec_base.md) @@ -18,59 +19,115 @@ Declares the common structs, character constants, and enums for running **OH_AVC ### Structs -| Name | Description | +| Name| Description| | -------- | -------- | -| [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) | Defines the buffer attributes of an **OH_AVCodec** instance. | -| [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) | Defines a collection of asynchronous callback functions for an **OH_AVCodec** instance. You must register this struct instance for an **OH_AVCodec** instance and process the information reported through these callbacks to ensure the normal running of the instance. | +| [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) | Defines the description information about the buffer of an **OH_AVCodec** instance.| +| [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) | Defines all the asynchronous callback function pointers of an **OH_AVCodec** instance.| ### Types -| Name | Description | +| Name| Description| | -------- | -------- | -| [OH_AVCodecBufferFlags](_codec_base.md#oh_avcodecbufferflags) | Enumerates the buffer flags of an **OH_AVCodec** instance. | -| [OH_AVCodecBufferAttr](_codec_base.md#oh_avcodecbufferattr) | Defines the buffer attributes of an **OH_AVCodec** instance. | -| [OH_AVCodecOnError](_codec_base.md#oh_avcodeconerror)) (OH_AVCodec \*codec, int32_t errorCode, void \*userData) | Defines the function pointer that is called to report error information when an error occurs during the running of an **OH_AVCodec** instance. | -| [OH_AVCodecOnStreamChanged](_codec_base.md#oh_avcodeconstreamchanged)) (OH_AVCodec \*codec, OH_AVFormat \*format, void \*userData) | Defines the function pointer that is called to report the attributes of the new stream when the output stream changes. Note that the lifecycle of the pointer to the **OH_AVFormat** instance is valid only when the function pointer is being called. Do not access the pointer to the instance after the function pointer is called. | -| [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata)) (OH_AVCodec \*codec, uint32_t index, OH_AVMemory \*data, void \*userData) | Defines the function pointer that is called, with a new buffer to fill in new input data, when new input data is required during the running of an **OH_AVCodec** instance. | -| [OH_AVCodecOnNewOutputData](_codec_base.md#oh_avcodeconnewoutputdata)) (OH_AVCodec \*codec, uint32_t index, OH_AVMemory \*data, [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) \*attr, void \*userData) | Defines the function pointer that is called, with a buffer containing new output data, when the new output data is generated during the running of an **OH_AVCodec** instance. Note that the lifecycle of the pointer to the **[OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md)** instance is valid only when the function pointer is being called. Do not access the pointer to the instance after the function pointer is called. | -| [OH_AVCodecAsyncCallback](_codec_base.md#oh_avcodecasynccallback) | Defines a collection of asynchronous callback functions for an **OH_AVCodec** instance. You must register this struct instance for an **OH_AVCodec** instance and process the information reported through these callbacks to ensure the normal running of the instance. | -| [OH_MediaType](_codec_base.md#oh_mediatype) | Enumerates the media types. | -| [OH_AVCProfile](_codec_base.md#oh_avcprofile) | Enumerates the AVC profiles. | -| [OH_AACProfile](_codec_base.md#oh_aacprofile) | Enumerates the AAC profiles. | +| [OH_AVCodecBufferFlags](_codec_base.md#oh_avcodecbufferflags) | Defines an enum that enumerates the flags for the buffer of an **OH_AVCodec** instance.| +| [OH_AVOutputFormat](_codec_base.md#oh_avoutputformat) | Defines an enum that enumerates the output file formats of a muxer.| +| [OH_AVCodecBufferAttr](_codec_base.md#oh_avcodecbufferattr) | Defines a struct for the description information about the buffer of an **OH_AVCodec** instance.| +| (\*[OH_AVCodecOnError](_codec_base.md#oh_avcodeconerror)) (OH_AVCodec \*codec, int32_t errorCode, void \*userData) | Defines the pointer to the function that is called to report error information when an error occurs during the running of an **OH_AVCodec** instance.| +| (\*[OH_AVCodecOnStreamChanged](_codec_base.md#oh_avcodeconstreamchanged)) (OH_AVCodec \*codec, OH_AVFormat \*format, void \*userData) | Defines the pointer to the function that is called to report the new stream description when the output stream changes.| +| (\*[OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata)) (OH_AVCodec \*codec, uint32_t index, OH_AVMemory \*data, void \*userData) | Defines the pointer to the function that is called when new input data is required during the running of an **OH_AVCodec** instance. The function carries a buffer to fill in new input data.| +| (\*[OH_AVCodecOnNewOutputData](_codec_base.md#oh_avcodeconnewoutputdata)) (OH_AVCodec \*codec, uint32_t index, OH_AVMemory \*data, [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) \*attr, void \*userData) | Defines the pointer to the function that is called when new output data is generated during the running of an **OH_AVCodec** instance. The function carries a buffer filled with new output data.| +| [OH_AVCodecAsyncCallback](_codec_base.md#oh_avcodecasynccallback) | Defines a struct for all the asynchronous callback function pointers of an **OH_AVCodec** instance.| +| [OH_MediaType](_codec_base.md#oh_mediatype) | Defines an enum that enumerates the media types.| +| [OH_AVCProfile](_codec_base.md#oh_avcprofile) | Defines an enum that enumerates the Advanced Video Coding (AVC) profiles.| +| [OH_HEVCProfile](_codec_base.md#oh_hevcprofile) | Defines an enum that enumerates the High Efficiency Video Coding (HEVC) profiles.| +| [OH_AACProfile](_codec_base.md#oh_aacprofile) | Defines an enum that enumerates the Advanced Audio Coding (AAC) profiles.| +| [OH_AVSeekMode](_codec_base.md#oh_avseekmode) | Defines an enum that enumerates the seek modes.| +| [OH_ColorPrimary](_codec_base.md#oh_colorprimary) | Defines an enum that enumerates the primary colors.| +| [OH_TransferCharacteristic](_codec_base.md#oh_transfercharacteristic) | Defines an enum that enumerates the transfer characteristics.| +| [OH_MatrixCoefficient](_codec_base.md#oh_matrixcoefficient) | Defines an enum that enumerates the matrix coefficients.| +| [OH_BitsPerSample](_codec_base.md#oh_bitspersample) | Defines an enum that enumerates the number of audio bits for each coded sample.| ### Enums -| Name | Description | +| Name| Description| | -------- | -------- | -| [OH_AVCodecBufferFlags](_codec_base.md#oh_avcodecbufferflags) {
AVCODEC_BUFFER_FLAGS_NONE = 0, AVCODEC_BUFFER_FLAGS_EOS = 1 << 0, AVCODEC_BUFFER_FLAGS_SYNC_FRAME = 1 << 1, AVCODEC_BUFFER_FLAGS_INCOMPLETE_FRAME = 1 << 2,
AVCODEC_BUFFER_FLAGS_CODEC_DATA = 1 << 3
} | Enumerates the buffer flags of an **OH_AVCodec** instance. | -| [OH_MediaType](_codec_base.md#oh_mediatype) { MEDIA_TYPE_AUD = 0, MEDIA_TYPE_VID = 1 } | Enumerates the media types. | -| [OH_AVCProfile](_codec_base.md#oh_avcprofile) { AVC_PROFILE_BASELINE = 0, AVC_PROFILE_HIGH = 4, AVC_PROFILE_MAIN = 8 } | Enumerates the AVC profiles. | -| [OH_AACProfile](_codec_base.md#oh_aacprofile) { AAC_PROFILE_LC = 0 } | Enumerates the AAC profiles. | +| [OH_AVCodecBufferFlags](_codec_base.md#oh_avcodecbufferflags) {
**AVCODEC_BUFFER_FLAGS_NONE** = 0, **AVCODEC_BUFFER_FLAGS_EOS** = 1 << 0, **AVCODEC_BUFFER_FLAGS_SYNC_FRAME** = 1 << 1, **AVCODEC_BUFFER_FLAGS_INCOMPLETE_FRAME** = 1 << 2,
**AVCODEC_BUFFER_FLAGS_CODEC_DATA** = 1 << 3
} | Enumerates the flags for the buffer of an **OH_AVCodec** instance.| +| [OH_AVOutputFormat](_codec_base.md#oh_avoutputformat) { **AV_OUTPUT_FORMAT_DEFAULT** = 0, **AV_OUTPUT_FORMAT_MPEG_4** = 2, **AV_OUTPUT_FORMAT_M4A** = 6 } | Enumerates the output file formats of a muxer.| +| [OH_MediaType](_codec_base.md#oh_mediatype) { **MEDIA_TYPE_AUD** = 0, **MEDIA_TYPE_VID** = 1 } | Enumerates the media types.| +| [OH_AVCProfile](_codec_base.md#oh_avcprofile) { **AVC_PROFILE_BASELINE** = 0, **AVC_PROFILE_HIGH** = 4, **AVC_PROFILE_MAIN** = 8 } | Enumerates the AVC profiles.| +| [OH_HEVCProfile](_codec_base.md#oh_hevcprofile) {
**HEVC_PROFILE_MAIN** = 0, **HEVC_PROFILE_MAIN_10** = 1, **HEVC_PROFILE_MAIN_STILL** = 2, **HEVC_PROFILE_MAIN_10_HDR10** = 3,
**HEVC_PROFILE_MAIN_10_HDR10_PLUS** = 4
} | Enumerates the HEVC profiles.| +| [OH_AACProfile](_codec_base.md#oh_aacprofile) { **AAC_PROFILE_LC** = 0 } | Enumerates the AAC profiles.| +| [OH_AVSeekMode](_codec_base.md#oh_avseekmode) { **SEEK_MODE_NEXT_SYNC** = 0, **SEEK_MODE_PREVIOUS_SYNC**, **SEEK_MODE_CLOSEST_SYNC** } | Enumerates the seek modes.| +| [OH_ColorPrimary](_codec_base.md#oh_colorprimary) {
**COLOR_PRIMARY_BT709** = 1, **COLOR_PRIMARY_UNSPECIFIED** = 2, **COLOR_PRIMARY_BT470_M** = 4, **COLOR_PRIMARY_BT601_625** = 5,
**COLOR_PRIMARY_BT601_525** = 6, **COLOR_PRIMARY_SMPTE_ST240** = 7, **COLOR_PRIMARY_GENERIC_FILM** = 8, **COLOR_PRIMARY_BT2020** = 9,
**COLOR_PRIMARY_SMPTE_ST428** = 10, **COLOR_PRIMARY_P3DCI** = 11, **COLOR_PRIMARY_P3D65** = 12
} | Enumerates the primary colors.| +| [OH_TransferCharacteristic](_codec_base.md#oh_transfercharacteristic) {
**TRANSFER_CHARACTERISTIC_BT709** = 1, **TRANSFER_CHARACTERISTIC_UNSPECIFIED** = 2, **TRANSFER_CHARACTERISTIC_GAMMA_2_2** = 4, **TRANSFER_CHARACTERISTIC_GAMMA_2_8** = 5,
**TRANSFER_CHARACTERISTIC_BT601** = 6, **TRANSFER_CHARACTERISTIC_SMPTE_ST240** = 7, **TRANSFER_CHARACTERISTIC_LINEAR** = 8, **TRANSFER_CHARACTERISTIC_LOG** = 9,
**TRANSFER_CHARACTERISTIC_LOG_SQRT** = 10, **TRANSFER_CHARACTERISTIC_IEC_61966_2_4** = 11, **TRANSFER_CHARACTERISTIC_BT1361** = 12, **TRANSFER_CHARACTERISTIC_IEC_61966_2_1** = 13,
**TRANSFER_CHARACTERISTIC_BT2020_10BIT** = 14, **TRANSFER_CHARACTERISTIC_BT2020_12BIT** = 15, **TRANSFER_CHARACTERISTIC_PQ** = 16, **TRANSFER_CHARACTERISTIC_SMPTE_ST428** = 17,
**TRANSFER_CHARACTERISTIC_HLG** = 18
} | Enumerates the transfer characteristics.| +| [OH_MatrixCoefficient](_codec_base.md#oh_matrixcoefficient) {
**MATRIX_COEFFICIENT_IDENTITY** = 0, **MATRIX_COEFFICIENT_BT709** = 1, **MATRIX_COEFFICIENT_UNSPECIFIED** = 2, **MATRIX_COEFFICIENT_FCC** = 4,
**MATRIX_COEFFICIENT_BT601_625** = 5, **MATRIX_COEFFICIENT_BT601_525** = 6, **MATRIX_COEFFICIENT_SMPTE_ST240** = 7, **MATRIX_COEFFICIENT_YCGCO** = 8,
**MATRIX_COEFFICIENT_BT2020_NCL** = 9, **MATRIX_COEFFICIENT_BT2020_CL** = 10, **MATRIX_COEFFICIENT_SMPTE_ST2085** = 11, **MATRIX_COEFFICIENT_CHROMATICITY_NCL** = 12,
**MATRIX_COEFFICIENT_CHROMATICITY_CL** = 13, **MATRIX_COEFFICIENT_ICTCP** = 14
} | Enumerates the matrix coefficients.| +| [OH_BitsPerSample](_codec_base.md#oh_bitspersample) {
**SAMPLE_U8** = 0, **SAMPLE_S16LE** = 1, **SAMPLE_S24LE** = 2, **SAMPLE_S32LE** = 3,
**SAMPLE_F32LE** = 4, **SAMPLE_U8P** = 5, **SAMPLE_S16P** = 6, **SAMPLE_S24P** = 7,
**SAMPLE_S32P** = 8, **SAMPLE_F32P** = 9, **INVALID_WIDTH** = -1
} | Enumerates the number of audio bits for each coded sample.| ### Variables -| Name | Description | +| Name| Description| | -------- | -------- | -| [OH_AVCODEC_MIMETYPE_VIDEO_AVC](_codec_base.md#oh_avcodec_mimetype_video_avc) | Defines the Multipurpose Internet Mail Extension (MIME) type for Advanced Video Coding (AVC). | -| [OH_AVCODEC_MIMETYPE_AUDIO_AAC](_codec_base.md#oh_avcodec_mimetype_audio_aac) | Defines the MIME type for Advanced Audio Coding (AAC). | -| [OH_ED_KEY_TIME_STAMP](_codec_base.md#oh_ed_key_time_stamp) | Provides unified character descriptors for the auxiliary data of the surface buffer. | -| [OH_ED_KEY_EOS](_codec_base.md#oh_ed_key_eos) | Character descriptor of the end-of-stream in the surface auxiliary data. The value type is bool.| -| [OH_MD_KEY_TRACK_TYPE](_codec_base.md#oh_md_key_track_type) | Provides unified character descriptors for the media playback framework. | -| [OH_MD_KEY_CODEC_MIME](_codec_base.md#oh_md_key_codec_mime) | Character descriptor of the MIME type. The value type is string.| -| [OH_MD_KEY_DURATION](_codec_base.md#oh_md_key_duration) | Character descriptor of duration. The value type is int64_t.| -| [OH_MD_KEY_BITRATE](_codec_base.md#oh_md_key_bitrate) | Character descriptor of the bit rate. The value type is uint32_t. | -| [OH_MD_KEY_MAX_INPUT_SIZE](_codec_base.md#oh_md_key_max_input_size) | Character descriptor of the maximum input size. The value type is uint32_t. | -| [OH_MD_KEY_WIDTH](_codec_base.md#oh_md_key_width) | Character descriptor of the video width. The value type is uint32_t. | -| [OH_MD_KEY_HEIGHT](_codec_base.md#oh_md_key_height) | Character descriptor of the video height. The value type is uint32_t. | -| [OH_MD_KEY_PIXEL_FORMAT](_codec_base.md#oh_md_key_pixel_format) | Character descriptor of the video pixel format. The value type is int32_t. | -| [OH_MD_KEY_AUDIO_SAMPLE_FORMAT](_codec_base.md#oh_md_key_audio_sample_format) | Character descriptor of the audio sample format. The value type is uint32_t. | -| [OH_MD_KEY_FRAME_RATE](_codec_base.md#oh_md_key_frame_rate) | Character descriptor of the video frame rate. The value type is double. | -| [OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE](_codec_base.md#oh_md_key_video_encode_bitrate_mode) | Character descriptor of the video encoding bit rate mode. The value type is int32_t. | -| [OH_MD_KEY_PROFILE](_codec_base.md#oh_md_key_profile) | Character descriptor of the audio/video encoding capability. The value type is int32_t. | -| [OH_MD_KEY_AUD_CHANNEL_COUNT](_codec_base.md#oh_md_key_aud_channel_count) | Character descriptor of the number of audio channels. The value type is uint32_t. | -| [OH_MD_KEY_AUD_SAMPLE_RATE](_codec_base.md#oh_md_key_aud_sample_rate) | Character descriptor of the audio sampling rate. The value type is uint32_t. | -| [OH_MD_KEY_I_FRAME_INTERVAL](_codec_base.md#oh_md_key_i_frame_interval) | Character descriptor of the I-frame interval. The value type is int32_t, and the unit is ms. | -| [OH_MD_KEY_ROTATION](_codec_base.md#oh_md_key_rotation) | Character descriptor of the surface rotation angle. The value type is int32_t. The value range is {0, 90, 180, 270}. The default value is 0. | +| [OH_AVCodecBufferAttr::pts](_o_h___a_v_codec_buffer_attr.md#pts) | Defines the display timestamp of the buffer, in microseconds.| +| [OH_AVCodecBufferAttr::size](_o_h___a_v_codec_buffer_attr.md#size) | Defines the size of data contained in the buffer, in bytes.| +| [OH_AVCodecBufferAttr::offset](_o_h___a_v_codec_buffer_attr.md#offset) | Defines the offset of valid data in the buffer.| +| [OH_AVCodecBufferAttr::flags](_o_h___a_v_codec_buffer_attr.md#flags) | Defines the flags of the buffer. It is a combination of multiple [OH_AVCodecBufferFlags](_codec_base.md#oh_avcodecbufferflags).| +| [OH_AVCodecAsyncCallback::onError](_o_h___a_v_codec_async_callback.md#onerror) | Defines the callback used to report a codec operation error. For details, see [OH_AVCodecOnError](_codec_base.md#oh_avcodeconerror).| +| [OH_AVCodecAsyncCallback::onStreamChanged](_o_h___a_v_codec_async_callback.md#onstreamchanged) | Defines the callback used to report a codec stream change. For details, see [OH_AVCodecOnStreamChanged](_codec_base.md#oh_avcodeconstreamchanged).| +| [OH_AVCodecAsyncCallback::onNeedInputData](_o_h___a_v_codec_async_callback.md#onneedinputdata) | Defines the callback used to report input data required. For details, see [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata).| +| [OH_AVCodecAsyncCallback::onNeedOutputData](_o_h___a_v_codec_async_callback.md#onneedinputdata) | Defines the callback used to report output data generated. For details, see [OH_AVCodecOnNewOutputData](_codec_base.md#oh_avcodeconnewoutputdata).| +| \*[OH_AVCODEC_MIMETYPE_VIDEO_AVC](_codec_base.md#oh_avcodec_mimetype_video_avc) | Defines the pointer to the Multipurpose Internet Mail Extension (MIME) type for AVC video codec.| +| \*[OH_AVCODEC_MIMETYPE_AUDIO_AAC](_codec_base.md#oh_avcodec_mimetype_audio_aac) | Defines the pointer to the MIME type for AAC audio codec.| +| \*[OH_AVCODEC_MIMETYPE_VIDEO_MPEG4](_codec_base.md#oh_avcodec_mimetype_video_mpeg4) | Defines the pointer to the MIME type for MPEG4 video codec.| +| \*[OH_AVCODEC_MIMETYPE_VIDEO_HEVC](_codec_base.md#oh_avcodec_mimetype_video_hevc) | Defines the pointer to the MIME type for HEVC video codec.| +| \*[OH_AVCODEC_MIMETYPE_AUDIO_MPEG](_codec_base.md#oh_avcodec_mimetype_audio_mpeg) | Defines the pointer to the MIME type for MPEG audio codec.| +| \*[OH_AVCODEC_MIMETYPE_IMAGE_JPG](_codec_base.md#oh_avcodec_mimetype_image_jpg) | Defines the pointer to the MIME type for JPG image codec.| +| \*[OH_AVCODEC_MIMETYPE_IMAGE_PNG](_codec_base.md#oh_avcodec_mimetype_image_png) | Defines the pointer to the MIME type for PNG image codec.| +| \*[OH_AVCODEC_MIMETYPE_IMAGE_BMP](_codec_base.md#oh_avcodec_mimetype_image_bmp) | Defines the pointer to the MIME type for BMP image codec.| +| \*[OH_AVCODEC_MIMETYPE_AUDIO_FLAC](_codec_base.md#oh_avcodec_mimetype_audio_flac) | Defines the pointer to the MIME type for FLAC audio codec.| +| \*[OH_AVCODEC_MIMETYPE_AUDIO_VORBIS](_codec_base.md#oh_avcodec_mimetype_audio_vorbis) | Defines the pointer to the MIME type for VORBIS audio codec.| +| \*[OH_ED_KEY_TIME_STAMP](_codec_base.md#oh_ed_key_time_stamp) | Defines the pointer to the timestamp in the extra data of the surface. The value type is int64.| +| \*[OH_ED_KEY_EOS](_codec_base.md#oh_ed_key_eos) | Defines the pointer to the end of stream (EOS) in the extra data of the surface. The value type is Boolean.| +| \*[OH_MD_KEY_TRACK_TYPE](_codec_base.md#oh_md_key_track_type) | Defines the pointer to a container for storing media descriptions.| +| \*[OH_MD_KEY_CODEC_MIME](_codec_base.md#oh_md_key_codec_mime) | Define the pointer to the MIME type of codec. The value is a string.| +| \*[OH_MD_KEY_DURATION](_codec_base.md#oh_md_key_duration) | Defines the pointer to the duration. The value type is int64_t.| +| \*[OH_MD_KEY_BITRATE](_codec_base.md#oh_md_key_bitrate) | Defines the pointer to the bit rate. The value type is uint32_t.| +| \*[OH_MD_KEY_MAX_INPUT_SIZE](_codec_base.md#oh_md_key_max_input_size) | Defines the pointer to the maximum input size. The value type is uint32_t.| +| \*[OH_MD_KEY_WIDTH](_codec_base.md#oh_md_key_width) | Defines the pointer to the video width. The value type is uint32_t.| +| \*[OH_MD_KEY_HEIGHT](_codec_base.md#oh_md_key_height) | Defines the pointer to the video height. The value type is uint32_t.| +| \*[OH_MD_KEY_PIXEL_FORMAT](_codec_base.md#oh_md_key_pixel_format) | Defines the pointer to the video pixel format. The value type is int32_t. For details, see [OH_AVPixelFormat](_core.md#oh_avpixelformat).| +| \*[OH_MD_KEY_RANGE_FLAG](_codec_base.md#oh_md_key_range_flag) | Defines the pointer to the video YUV value range flag. The value type is Boolean.| +| \*[OH_MD_KEY_COLOR_PRIMARIES](_codec_base.md#oh_md_key_color_primaries) | Defines the pointer to the primary color of the video. The value type is int32_t.| +| \*[OH_MD_KEY_TRANSFER_CHARACTERISTICS](_codec_base.md#oh_md_key_transfer_characteristics) | Defines the pointer to the video transfer characteristics. The value type is int32_t.| +| \*[OH_MD_KEY_MATRIX_COEFFICIENTS](_codec_base.md#oh_md_key_matrix_coefficients) | Defines the pointer to the video matrix coefficient. The value type is int32_t.| +| \*[OH_MD_KEY_AUDIO_SAMPLE_FORMAT](_codec_base.md#oh_md_key_audio_sample_format) | Defines the pointer to the original audio format. The value type is uint32_t.| +| \*[OH_MD_KEY_FRAME_RATE](_codec_base.md#oh_md_key_frame_rate) | Defines the pointer to the video frame rate. The value is a double-precision floating point number.| +| \*[OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE](_codec_base.md#oh_md_key_video_encode_bitrate_mode) | Defines the pointer to the video encoding bit rate mode. The value type is int32_t. For details, see [OH_VideoEncodeBitrateMode](_video_encoder.md#oh_videoencodebitratemode).| +| \*[OH_MD_KEY_PROFILE](_codec_base.md#oh_md_key_profile) | Defines the pointer to the encoding template. The value is a number. For details, see [OH_AVCProfile](_codec_base.md#oh_avcprofile), [OH_AACProfile](_codec_base.md#oh_aacprofile), or [CodecBase](_codec_base.md#oh_hevcprofile).| +| \*[OH_MD_KEY_AUD_CHANNEL_COUNT](_codec_base.md#oh_md_key_aud_channel_count) | Defines the pointer to the number of audio channels. The value type is uint32_t.| +| \*[OH_MD_KEY_AUD_SAMPLE_RATE](_codec_base.md#oh_md_key_aud_sample_rate) | Defines the pointer to the audio sampling rate. The value type is uint32_t.| +| \*[OH_MD_KEY_I_FRAME_INTERVAL](_codec_base.md#oh_md_key_i_frame_interval) | Defines the pointer to the key frame interval, in milliseconds. The value type is int32_t.| +| \*[OH_MD_KEY_ROTATION](_codec_base.md#oh_md_key_rotation) | Defines the pointer to the rotation angle of the surface. The value type is int32_t, and the value range is {0, 90, 180, 270}. The default value is 0.| +| \*[OH_MD_KEY_CODEC_CONFIG](_codec_base.md#oh_md_key_codec_config) | Defines the pointer to the codec-specific data. The value type is uint8_t\*.| +| \*[OH_MD_KEY_REQUEST_I_FRAME](_codec_base.md#oh_md_key_request_i_frame) | Defines the pointer to the request for immediate encoding of I-frames. The value type is Boolean.| +| \*[OH_MD_KEY_QUALITY](_codec_base.md#oh_md_key_quality) | Defines the pointer to the required encoding quality. The value type is uint32_t. This key applies only to encoders configured in constant quality mode.| +| \*[OH_MD_KEY_CHANNEL_LAYOUT](_codec_base.md#oh_md_key_channel_layout) | Defines the pointer to the required encoding channel layout. The value type is int64_t. This key applies only to encoders.| +| \*[OH_MD_KEY_BITS_PER_CODED_SAMPLE](_codec_base.md#oh_md_key_bits_per_coded_sample) | Defines the pointer to the number of bits for each coded sample. The value type is uint32_t. This key applies to FLAC encoders.| +| \*[OH_MD_KEY_AAC_IS_ADTS](_codec_base.md#oh_md_key_aac_is_adts) | Defines the pointer to the AAC format. The value type is uint32_t. This key applies to AAC decoders.| +| \*[OH_MD_KEY_SBR](_codec_base.md#oh_md_key_sbr) | Defines the pointer to the AAC SBR format. The value type is uint32_t. This key applies to AAC encoders.| +| \*[OH_MD_KEY_COMPLIANCE_LEVEL](_codec_base.md#oh_md_key_compliance_level) | Defines the pointer to the FLAC compliance level. The value type is int32_t.| +| \*[OH_MD_KEY_IDENTIFICATION_HEADER](_codec_base.md#oh_md_key_identification_header) | Defines the pointer to the VORBIS identification header. The value type is uint8_t\*. This key applies only to VORBIS decoders.| +| \*[OH_MD_KEY_SETUP_HEADER](_codec_base.md#oh_md_key_setup_header) | Defines the pointer to the VORBIS setup header. The value type is uint8_t\*. This key applies only to VORBIS decoders.| +| \*[OH_MD_KEY_TITLE](_codec_base.md#oh_md_key_title) | Defines the pointer to the title of the input media. The value is a string.| +| \*[OH_MD_KEY_ARTIST](_codec_base.md#oh_md_key_artist) | Defines the pointer to the artist of the input media. The value is a string.| +| \*[OH_MD_KEY_ALBUM](_codec_base.md#oh_md_key_album) | Defines the pointer to the album of the input media. The value is a string.| +| \*[OH_MD_KEY_ALBUM_ARTIST](_codec_base.md#oh_md_key_album_artist) | Defines the pointer to the album_artist of the input media. The value is a string.| +| \*[OH_MD_KEY_DATE](_codec_base.md#oh_md_key_date) | Defines the pointer to the date of the input media. The value is a string.| +| \*[OH_MD_KEY_COMMENT](_codec_base.md#oh_md_key_comment) | Defines the pointer to the comment of the input media. The value is a string.| +| \*[OH_MD_KEY_GENRE](_codec_base.md#oh_md_key_genre) | Defines the pointer to the genre of the input media. The value is a string.| +| \*[OH_MD_KEY_COPYRIGHT](_codec_base.md#oh_md_key_copyright) | Defines the pointer to the copyright of the input media. The value is a string.| +| \*[OH_MD_KEY_LANGUAGE](_codec_base.md#oh_md_key_language) | Defines the pointer to the language of the input media. The value is a string.| +| \*[OH_MD_KEY_DESCRIPTION](_codec_base.md#oh_md_key_description) | Defines the pointer to the description of the input media. The value is a string.| +| \*[OH_MD_KEY_LYRICS](_codec_base.md#oh_md_key_lyrics) | Defines the pointer to the lyrics of the input media. The value is a string.| +| \*[OH_MD_KEY_TRACK_COUNT](_codec_base.md#oh_md_key_track_count) | Defines the pointer to the track count of the input media. The value type is uint32_t.| diff --git a/en/application-dev/reference/native-apis/native__avcodec__videodecoder_8h.md b/en/application-dev/reference/native-apis/native__avcodec__videodecoder_8h.md index ef449f4102..81793e5169 100644 --- a/en/application-dev/reference/native-apis/native__avcodec__videodecoder_8h.md +++ b/en/application-dev/reference/native-apis/native__avcodec__videodecoder_8h.md @@ -3,12 +3,13 @@ ## Overview -Declares the native APIs used for video decoding. +The **native_avcodec_videodecoder.h** file declares the native APIs used for video decoding. + +**Since** -**Since:** 9 -**Related Modules:** +**Related Modules** [VideoDecoder](_video_decoder.md) @@ -18,21 +19,22 @@ Declares the native APIs used for video decoding. ### Functions -| Name | Description | +| Name| Description| | -------- | -------- | -| [OH_VideoDecoder_CreateByMime](_video_decoder.md#oh_videodecoder_createbymime) (const char \*mime) | Creates a video decoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases. | -| [OH_VideoDecoder_CreateByName](_video_decoder.md#oh_videodecoder_createbyname) (const char \*name) | Creates a video decoder instance based on a video decoder name. To use this API, you must know the exact name of the video decoder. | -| [OH_VideoDecoder_Destroy](_video_decoder.md#oh_videodecoder_destroy) (OH_AVCodec \*codec) | Clears the internal resources of a video decoder and destroys the video decoder instance. | -| [OH_VideoDecoder_SetCallback](_video_decoder.md#oh_videodecoder_setcallback) (OH_AVCodec \*codec, [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) callback, void \*userData) | Sets an asynchronous callback so that your application can respond to events generated by a video decoder. This API must be called prior to **Prepare**. | -| [OH_VideoDecoder_SetSurface](_video_decoder.md#oh_videodecoder_setsurface) (OH_AVCodec \*codec, [OHNativeWindow](_native_window.md) \*window) | Sets an output surface for a video decoder. This API must be called prior to **Prepare**. | -| [OH_VideoDecoder_Configure](_video_decoder.md#oh_videodecoder_configure) (OH_AVCodec \*codec, OH_AVFormat \*format) | Configures a video decoder. Typically, you need to configure the attributes, which can be extracted from the container, of the video track that can be decoded. This API must be called prior to **Prepare**. | -| [OH_VideoDecoder_Prepare](_video_decoder.md#oh_videodecoder_prepare) (OH_AVCodec \*codec) | Prepares internal resources for a video decoder. This API must be called after **Configure**. | -| [OH_VideoDecoder_Start](_video_decoder.md#oh_videodecoder_start) (OH_AVCodec \*codec) | Starts a video decoder. This API can be called only after the decoder is prepared successfully. After being started, the decoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. | -| [OH_VideoDecoder_Stop](_video_decoder.md#oh_videodecoder_stop) (OH_AVCodec \*codec) | Stops a video decoder. After the decoder is stopped, you can call **Start** to start it again. If you have passed codec-specific data in the previous **Start** for the decoder, you must pass it again. | -| [OH_VideoDecoder_Flush](_video_decoder.md#oh_videodecoder_flush) (OH_AVCodec \*codec) | Clears the input and output data in the internal buffer of a video decoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. | -| [OH_VideoDecoder_Reset](_video_decoder.md#oh_videodecoder_reset) (OH_AVCodec \*codec) | Resets a video decoder. To continue decoding, you must call **Configure** and **Start** to configure and start the decoder again. | -| [OH_VideoDecoder_GetOutputDescription](_video_decoder.md#oh_videodecoder_getoutputdescription) (OH_AVCodec \*codec) | Obtains the attributes of the output data of a video decoder. The **OH_AVFormat** instance in the return value will become invalid when this API is called again or when the **OH_AVCodec** instance is destroyed. | -| [OH_VideoDecoder_SetParameter](_video_decoder.md#oh_videodecoder_setparameter) (OH_AVCodec \*codec, OH_AVFormat \*format) | Sets dynamic parameters for a video decoder. This API can be called only after the decoder is started. Incorrect parameter settings may cause decoding failure. | -| [OH_VideoDecoder_PushInputData](_video_decoder.md#oh_videodecoder_pushinputdata) (OH_AVCodec \*codec, uint32_t index, [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) attr) | Pushes the input buffer filled with data to a video decoder. The [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback reports available input buffers and their indexes. After being pushed to the decoder, a buffer is not accessible until the buffer with the same index is reported again through the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback. In addition, some decoders require the input of codec-specific data, such as PPS/SPS data in H.264 format, to initialize the decoding process. | -| [OH_VideoDecoder_RenderOutputData](_video_decoder.md#oh_videodecoder_renderoutputdata) (OH_AVCodec \*codec, uint32_t index) | Frees an output buffer of a video decoder and instructs the decoder to render the decoded data in the buffer on the output surface. If no output surface is configured, calling this API only frees the output buffer. | -| [OH_VideoDecoder_FreeOutputData](_video_decoder.md#oh_videodecoder_freeoutputdata) (OH_AVCodec \*codec, uint32_t index) | Frees an output buffer of a video decoder. | +| \*[OH_VideoDecoder_CreateByMime](_video_decoder.md#oh_videodecoder_createbymime) (const char \*mime) | Creates a video decoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This function is recommended in most cases.| +| \*[OH_VideoDecoder_CreateByName](_video_decoder.md#oh_videodecoder_createbyname) (const char \*name) | Creates a video decoder instance based on a decoder name. To use this function, you must know the exact name of the decoder.| +| [OH_VideoDecoder_Destroy](_video_decoder.md#oh_videodecoder_destroy) (OH_AVCodec \*codec) | Clears the internal resources of a video decoder and destroys the decoder instance.| +| [OH_VideoDecoder_SetCallback](_video_decoder.md#oh_videodecoder_setcallback) (OH_AVCodec \*codec, OH_AVCodecAsyncCallback callback, void \*userData) | Sets an asynchronous callback so that your application can respond to events generated by a video decoder.| +| [OH_VideoDecoder_SetSurface](_video_decoder.md#oh_videodecoder_setsurface) (OH_AVCodec \*codec, OHNativeWindow \*window) | Sets an output surface for a video decoder. This function must be called prior to **Prepare**.| +| [OH_VideoDecoder_Configure](_video_decoder.md#oh_videodecoder_configure) (OH_AVCodec \*codec, OH_AVFormat \*format) | Configures a video decoder. Typically, you need to configure the video track description information that can be extracted from the container.| +| [OH_VideoDecoder_Prepare](_video_decoder.md#oh_videodecoder_prepare) (OH_AVCodec \*codec) | Prepares internal resources for a video decoder. This function must be called after **Configure**.| +| [OH_VideoDecoder_Start](_video_decoder.md#oh_videodecoder_start) (OH_AVCodec \*codec) | Starts a video decoder. This function can be called only after the decoder is prepared successfully.| +| [OH_VideoDecoder_Stop](_video_decoder.md#oh_videodecoder_stop) (OH_AVCodec \*codec) | Stops a video decoder.| +| [OH_VideoDecoder_Flush](_video_decoder.md#oh_videodecoder_flush) (OH_AVCodec \*codec) | Clears the input and output data in the internal buffer of a video decoder.| +| [OH_VideoDecoder_Reset](_video_decoder.md#oh_videodecoder_reset) (OH_AVCodec \*codec) | Resets a video decoder.| +| \*[OH_VideoDecoder_GetOutputDescription](_video_decoder.md#oh_videodecoder_getoutputdescription) (OH_AVCodec \*codec) | Obtains the description information about the output data of a video decoder.| +| [OH_VideoDecoder_SetParameter](_video_decoder.md#oh_videodecoder_setparameter) (OH_AVCodec \*codec, OH_AVFormat \*format) | Sets dynamic parameters for a video decoder.| +| [OH_VideoDecoder_PushInputData](_video_decoder.md#oh_videodecoder_pushinputdata) (OH_AVCodec \*codec, uint32_t index, OH_AVCodecBufferAttr attr) | Pushes the input buffer filled with data to a video decoder.| +| [OH_VideoDecoder_RenderOutputData](_video_decoder.md#oh_videodecoder_renderoutputdata) (OH_AVCodec \*codec, uint32_t index) | Frees an output buffer of a video decoder and instructs the decoder to render the decoded data in the buffer on the output surface.| +| [OH_VideoDecoder_FreeOutputData](_video_decoder.md#oh_videodecoder_freeoutputdata) (OH_AVCodec \*codec, uint32_t index) | Frees an output buffer of a video decoder.| +| [OH_VideoDecoder_IsValid](_video_decoder.md#oh_videodecoder_isvalid) (OH_AVCodec \*codec, bool \*isValid) | Checks whether a video codec instance is valid.| diff --git a/en/application-dev/reference/native-apis/native__avcodec__videoencoder_8h.md b/en/application-dev/reference/native-apis/native__avcodec__videoencoder_8h.md index 4870d9ce8d..373c59db66 100644 --- a/en/application-dev/reference/native-apis/native__avcodec__videoencoder_8h.md +++ b/en/application-dev/reference/native-apis/native__avcodec__videoencoder_8h.md @@ -3,12 +3,13 @@ ## Overview -Declares the native APIs used for video encoding. +The **native_avcodec_videoencoder.h** file declares the native APIs used for video encoding. + +**Since** -**Since:** 9 -**Related Modules:** +**Related Modules** [VideoEncoder](_video_encoder.md) @@ -18,34 +19,37 @@ Declares the native APIs used for video encoding. ### Types -| Name | Description | +| Name| Description| | -------- | -------- | -| [OH_VideoEncodeBitrateMode](_video_encoder.md#oh_videoencodebitratemode) | Enumerates the bit rate modes of video encoding. | +| [OH_VideoEncodeBitrateMode](_video_encoder.md#oh_videoencodebitratemode) | Defines an enum that enumerates the bit rate modes of a video encoder.| ### Enums -| Name | Description | +| Name| Description| | -------- | -------- | -| [OH_VideoEncodeBitrateMode](_video_encoder.md#oh_videoencodebitratemode) { CBR = 0, VBR = 1, CQ = 2 } | Enumerates the bit rate modes of video encoding. | +| [OH_VideoEncodeBitrateMode](_video_encoder.md#oh_videoencodebitratemode) { **CBR** = 0, **VBR** = 1, **CQ** = 2 } | Enumerates the bit rate modes of a video encoder.| ### Functions -| Name | Description | +| Name| Description| | -------- | -------- | -| [OH_VideoEncoder_CreateByMime](_video_encoder.md#oh_videoencoder_createbymime) (const char \*mime) | Creates a video encoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases. | -| [OH_VideoEncoder_CreateByName](_video_encoder.md#oh_videoencoder_createbyname) (const char \*name) | Creates a video encoder instance based on a video encoder name. To use this API, you must know the exact name of the video encoder. | -| [OH_VideoEncoder_Destroy](_video_encoder.md#oh_videoencoder_destroy) (OH_AVCodec \*codec) | Clears the internal resources of a video encoder and destroys the video encoder instance. | -| [OH_VideoEncoder_SetCallback](_video_encoder.md#oh_videoencoder_setcallback) (OH_AVCodec \*codec, [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) callback, void \*userData) | Sets an asynchronous callback so that your application can respond to events generated by a video encoder. This API must be called prior to **Prepare**. | -| [OH_VideoEncoder_Configure](_video_encoder.md#oh_videoencoder_configure) (OH_AVCodec \*codec, OH_AVFormat \*format) | Configures a video encoder. Typically, you need to configure the attributes of the video track that can be encoded. This API must be called prior to **Prepare**. | -| [OH_VideoEncoder_Prepare](_video_encoder.md#oh_videoencoder_prepare) (OH_AVCodec \*codec) | Prepares internal resources for a video encoder. This API must be called after **Configure**. | -| [OH_VideoEncoder_Start](_video_encoder.md#oh_videoencoder_start) (OH_AVCodec \*codec) | Starts a video encoder. This API can be called only after the encoder is prepared successfully. After being started, the encoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. | -| [OH_VideoEncoder_Stop](_video_encoder.md#oh_videoencoder_stop) (OH_AVCodec \*codec) | Stops a video encoder. After the encoder is stopped, you can call **Start** to start it again. | -| [OH_VideoEncoder_Flush](_video_encoder.md#oh_videoencoder_flush) (OH_AVCodec \*codec) | Clears the input and output data in the internal buffer of a video encoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. | -| [OH_VideoEncoder_Reset](_video_encoder.md#oh_videoencoder_reset) (OH_AVCodec \*codec) | Resets a video encoder. To continue encoding, you must call **Configure** and **Start** to configure and start the encoder again. | -| [OH_VideoEncoder_GetOutputDescription](_video_encoder.md#oh_videoencoder_getoutputdescription) (OH_AVCodec \*codec) | Obtains the attributes of the output data of a video encoder. The **OH_AVFormat** instance in the return value will become invalid when this API is called again or when the **OH_AVCodec** instance is destroyed. | -| [OH_VideoEncoder_SetParameter](_video_encoder.md#oh_videoencoder_setparameter) (OH_AVCodec \*codec, OH_AVFormat \*format) | Sets dynamic parameters for a video encoder. This API can be called only after the encoder is started. Incorrect parameter settings may cause encoding failure. | -| [OH_VideoEncoder_GetSurface](_video_encoder.md#oh_videoencoder_getsurface) (OH_AVCodec \*codec, [OHNativeWindow](_native_window.md) \*\*window) | Obtains an input surface from a video encoder. This API must be called prior to **Prepare**. | -| [OH_VideoEncoder_FreeOutputData](_video_encoder.md#oh_videoencoder_freeoutputdata) (OH_AVCodec \*codec, uint32_t index) | Frees an output buffer of a video encoder. | -| [OH_VideoEncoder_NotifyEndOfStream](_video_encoder.md#oh_videoencoder_notifyendofstream) (OH_AVCodec \*codec) | Notifies a video encoder that input streams end. This API is recommended in surface mode. | +| \*[OH_VideoEncoder_CreateByMime](_video_encoder.md#oh_videoencoder_createbymime) (const char \*mime) | Creates a video encoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This function is recommended in most cases.| +| \*[OH_VideoEncoder_CreateByName](_video_encoder.md#oh_videoencoder_createbyname) (const char \*name) | Creates a video encoder instance based on an encoder name. To use this function, you must know the exact name of the encoder.| +| [OH_VideoEncoder_Destroy](_video_encoder.md#oh_videoencoder_destroy) (OH_AVCodec \*codec) | Clears the internal resources of a video encoder and destroys the encoder instance.| +| [OH_VideoEncoder_SetCallback](_video_encoder.md#oh_videoencoder_setcallback) (OH_AVCodec \*codec, OH_AVCodecAsyncCallback callback, void \*userData) | Sets an asynchronous callback so that your application can respond to events generated by a video encoder.| +| [OH_VideoEncoder_Configure](_video_encoder.md#oh_videoencoder_configure) (OH_AVCodec \*codec, OH_AVFormat \*format) | Configures a video encoder. Typically, you need to configure the description information about the video track to be encoded.| +| [OH_VideoEncoder_Prepare](_video_encoder.md#oh_videoencoder_prepare) (OH_AVCodec \*codec) | Prepares internal resources for a video encoder. This function must be called after **Configure**.| +| [OH_VideoEncoder_Start](_video_encoder.md#oh_videoencoder_start) (OH_AVCodec \*codec) | Starts a video encoder. This function can be called only after the encoder is prepared successfully.| +| [OH_VideoEncoder_Stop](_video_encoder.md#oh_videoencoder_stop) (OH_AVCodec \*codec) | Stops a video encoder.| +| [OH_VideoEncoder_Flush](_video_encoder.md#oh_videoencoder_flush) (OH_AVCodec \*codec) | Clears the input and output data in the internal buffer of a video encoder.| +| [OH_VideoEncoder_Reset](_video_encoder.md#oh_videoencoder_reset) (OH_AVCodec \*codec) | Resets a video encoder.| +| \*[OH_VideoEncoder_GetOutputDescription](_video_encoder.md#oh_videoencoder_getoutputdescription) (OH_AVCodec \*codec) | Obtains the description information about the output data of a video encoder. For details, see **OH_AVFormat**.| +| [OH_VideoEncoder_SetParameter](_video_encoder.md#oh_videoencoder_setparameter) (OH_AVCodec \*codec, OH_AVFormat \*format) | Sets dynamic parameters for a video encoder.| +| [OH_VideoEncoder_GetSurface](_video_encoder.md#oh_videoencoder_getsurface) (OH_AVCodec \*codec, OHNativeWindow \*\*window) | Sets an input surface for a video encoder. This function must be called prior to **Prepare**.| +| [OH_VideoEncoder_FreeOutputData](_video_encoder.md#oh_videoencoder_freeoutputdata) (OH_AVCodec \*codec, uint32_t index) | Frees an output buffer of a video encoder.| +| [OH_VideoEncoder_NotifyEndOfStream](_video_encoder.md#oh_videoencoder_notifyendofstream) (OH_AVCodec \*codec) | Notifies a video encoder that input streams end. You are advised to use this function for notification.| +| [OH_VideoEncoder_PushInputData](_video_encoder.md#oh_videoencoder_pushinputdata) (OH_AVCodec \*codec, uint32_t index, OH_AVCodecBufferAttr attr) | Pushes the input buffer filled with data to a video encoder.| +| \*[OH_VideoEncoder_GetInputDescription](_video_encoder.md#oh_videoencoder_getinputdescription) (OH_AVCodec \*codec) | Obtains the description information received by the video encoder. This function must be called after **Configure**. For details, see **OH_AVFormat**.| +| [OH_VideoEncoder_IsValid](_video_encoder.md#oh_videoencoder_isvalid) (OH_AVCodec \*codec, bool \*isValid) | Checks whether a video encoder instance is valid.| diff --git a/en/application-dev/reference/native-apis/native__avdemuxer_8h.md b/en/application-dev/reference/native-apis/native__avdemuxer_8h.md new file mode 100644 index 0000000000..8c10bbf04b --- /dev/null +++ b/en/application-dev/reference/native-apis/native__avdemuxer_8h.md @@ -0,0 +1,29 @@ +# native_avdemuxer.h + + +## Overview + +The **native_avdemuxer.h** file declares the native APIs used for audio and video decapsulation. + +**Since** + +10 + +**Related Modules** + +[AVDemuxer](_a_v_demuxer.md) + + +## Summary + + +### Functions + +| Name| Description| +| -------- | -------- | +| \*[OH_AVDemuxer_CreateWithSource](_a_v_demuxer.md#oh_avdemuxer_createwithsource) (OH_AVSource \*source) | Creates an **OH_AVDemuxer** instance based on an **OH_AVSource** instance.| +| [OH_AVDemuxer_Destroy](_a_v_demuxer.md#oh_avdemuxer_destroy) (OH_AVDemuxer \*demuxer) | Destroys an **OH_AVDemuxer** instance and clears internal resources.| +| [OH_AVDemuxer_SelectTrackByID](_a_v_demuxer.md#oh_avdemuxer_selecttrackbyid) (OH_AVDemuxer \*demuxer, uint32_t trackIndex) | Selects a track, from which the demuxer reads data.| +| [OH_AVDemuxer_UnselectTrackByID](_a_v_demuxer.md#oh_avdemuxer_unselecttrackbyid) (OH_AVDemuxer \*demuxer, uint32_t trackIndex) | Deselects a track. The demuxer no longer reads data from a track after it is deselected.| +| [OH_AVDemuxer_ReadSample](_a_v_demuxer.md#oh_avdemuxer_readsample) (OH_AVDemuxer \*demuxer, uint32_t trackIndex, OH_AVMemory \*sample, OH_AVCodecBufferAttr \*info) | Obtains the compressed frame and related information at the current position from the selected track.| +| [OH_AVDemuxer_SeekToTime](_a_v_demuxer.md#oh_avdemuxer_seektotime) (OH_AVDemuxer \*demuxer, int64_t millisecond, OH_AVSeekMode mode) | Seeks to the specified time for all the selected tracks based on a seek mode.| diff --git a/en/application-dev/reference/native-apis/native__averrors_8h.md b/en/application-dev/reference/native-apis/native__averrors_8h.md index 0ee77c10bb..94436441c9 100644 --- a/en/application-dev/reference/native-apis/native__averrors_8h.md +++ b/en/application-dev/reference/native-apis/native__averrors_8h.md @@ -3,12 +3,13 @@ ## Overview -Declares the error codes used by the media playback framework. +The **native_averrors.h** file declares the error codes used by the media playback framework. + +**Since** -**Since:** 9 -**Related Modules:** +**Related Modules** [Core](_core.md) @@ -18,13 +19,13 @@ Declares the error codes used by the media playback framework. ### Types -| Name | Description | +| Name| Description| | -------- | -------- | -| [OH_AVErrCode](_core.md#oh_averrcode) | Enumerates the audio and video error codes. | +| [OH_AVErrCode](_core.md#oh_averrcode) | Defines an enum that enumerates the audio and video error codes.| ### Enums -| Name | Description | +| Name| Description| | -------- | -------- | -| [OH_AVErrCode](_core.md#oh_averrcode) {
AV_ERR_OK = 0, AV_ERR_NO_MEMORY = 1, AV_ERR_OPERATE_NOT_PERMIT = 2, AV_ERR_INVALID_VAL = 3,
AV_ERR_IO = 4, AV_ERR_TIMEOUT = 5, AV_ERR_UNKNOWN = 6, AV_ERR_SERVICE_DIED = 7,
AV_ERR_INVALID_STATE = 8, AV_ERR_UNSUPPORT = 9, AV_ERR_EXTEND_START = 100
} | Enumerates the audio and video error codes. | +| [OH_AVErrCode](_core.md#oh_averrcode) {
AV_ERR_OK = 0, AV_ERR_NO_MEMORY = 1, AV_ERR_OPERATE_NOT_PERMIT = 2, AV_ERR_INVALID_VAL = 3,
AV_ERR_IO = 4, AV_ERR_TIMEOUT = 5, AV_ERR_UNKNOWN = 6, AV_ERR_SERVICE_DIED = 7,
AV_ERR_INVALID_STATE = 8, AV_ERR_UNSUPPORT = 9, AV_ERR_EXTEND_START = 100
} | Enumerates the audio and video error codes.| diff --git a/en/application-dev/reference/native-apis/native__avformat_8h.md b/en/application-dev/reference/native-apis/native__avformat_8h.md index 36f3abe69c..ac80fbc159 100644 --- a/en/application-dev/reference/native-apis/native__avformat_8h.md +++ b/en/application-dev/reference/native-apis/native__avformat_8h.md @@ -3,12 +3,13 @@ ## Overview -Declares the format-related functions and enums. +The **native_avformat.h** file declares the format-related functions and enums. + +**Since** -**Since:** 9 -**Related Modules:** +**Related Modules** [Core](_core.md) @@ -18,35 +19,37 @@ Declares the format-related functions and enums. ### Types -| Name | Description | +| Name| Description| | -------- | -------- | -| [OH_AVPixelFormat](_core.md#oh_avpixelformat) | Enumerates the audio and video pixel formats. | +| [OH_AVPixelFormat](_core.md#oh_avpixelformat) | Defines an enum that enumerates the video pixel formats.| ### Enums -| Name | Description | +| Name| Description| | -------- | -------- | -| [OH_AVPixelFormat](_core.md#oh_avpixelformat) {
AV_PIXEL_FORMAT_YUVI420 = 1, AV_PIXEL_FORMAT_NV12 = 2, AV_PIXEL_FORMAT_NV21 = 3, AV_PIXEL_FORMAT_SURFACE_FORMAT = 4,
AV_PIXEL_FORMAT_RGBA = 5
} | Enumerates the audio and video pixel formats. | +| [OH_AVPixelFormat](_core.md#oh_avpixelformat) {
AV_PIXEL_FORMAT_YUVI420 = 1, AV_PIXEL_FORMAT_NV12 = 2, AV_PIXEL_FORMAT_NV21 = 3, AV_PIXEL_FORMAT_SURFACE_FORMAT = 4,
AV_PIXEL_FORMAT_RGBA = 5
} | Enumerates the video pixel formats.| ### Functions -| Name | Description | +| Name| Description| | -------- | -------- | -| [OH_AVFormat_Create](_core.md#oh_avformat_create) (void) | Creates an **OH_AVFormat** instance for reading and writing data. | -| [OH_AVFormat_Destroy](_core.md#oh_avformat_destroy) (struct OH_AVFormat \*format) | Destroys an **OH_AVFormat** instance. | -| [OH_AVFormat_Copy](_core.md#oh_avformat_copy) (struct OH_AVFormat \*to, struct OH_AVFormat \*from) | Copies the resources from an **OH_AVFormat** instance to another. | -| [OH_AVFormat_SetIntValue](_core.md#oh_avformat_setintvalue) (struct OH_AVFormat \*format, const char \*key, int32_t value) | Writes data of the int type to an **OH_AVFormat** instance. | -| [OH_AVFormat_SetLongValue](_core.md#oh_avformat_setlongvalue) (struct OH_AVFormat \*format, const char \*key, int64_t value) | Writes data of the long type to an **OH_AVFormat** instance. | -| [OH_AVFormat_SetFloatValue](_core.md#oh_avformat_setfloatvalue) (struct OH_AVFormat \*format, const char \*key, float value) | Writes data of the float type to an **OH_AVFormat** instance. | -| [OH_AVFormat_SetDoubleValue](_core.md#oh_avformat_setdoublevalue) (struct OH_AVFormat \*format, const char \*key, double value) | Writes data of the double type to an **OH_AVFormat** instance. | -| [OH_AVFormat_SetStringValue](_core.md#oh_avformat_setstringvalue) (struct OH_AVFormat \*format, const char \*key, const char \*value) | Writes data of the string type to an **OH_AVFormat** instance. | -| [OH_AVFormat_SetBuffer](_core.md#oh_avformat_setbuffer) (struct OH_AVFormat \*format, const char \*key, const uint8_t \*addr, size_t size) | Writes data with a specified size to an **OH_AVFormat** instance. | -| [OH_AVFormat_GetIntValue](_core.md#oh_avformat_getintvalue) (struct OH_AVFormat \*format, const char \*key, int32_t \*out) | Reads data of the int type from an **OH_AVFormat** instance. | -| [OH_AVFormat_GetLongValue](_core.md#oh_avformat_getlongvalue) (struct OH_AVFormat \*format, const char \*key, int64_t \*out) | Reads data of the long type from an **OH_AVFormat** instance. | -| [OH_AVFormat_GetFloatValue](_core.md#oh_avformat_getfloatvalue) (struct OH_AVFormat \*format, const char \*key, float \*out) | Reads data of the float type from an **OH_AVFormat** instance. | -| [OH_AVFormat_GetDoubleValue](_core.md#oh_avformat_getdoublevalue) (struct OH_AVFormat \*format, const char \*key, double \*out) | Reads data of the double type from an **OH_AVFormat** instance. | -| [OH_AVFormat_GetStringValue](_core.md#oh_avformat_getstringvalue) (struct OH_AVFormat \*format, const char \*key, const char \*\*out) | Reads data of the double type from an **OH_AVFormat** instance. | -| [OH_AVFormat_GetBuffer](_core.md#oh_avformat_getbuffer) (struct OH_AVFormat \*format, const char \*key, uint8_t \*\*addr, size_t \*size) | Reads data with a specified size from an **OH_AVFormat** instance. | -| [OH_AVFormat_DumpInfo](_core.md#oh_avformat_dumpinfo) (struct OH_AVFormat \*format) | Dumps the information contained in an **OH_AVFormat** instance as a string. | +| \*[OH_AVFormat_Create](_core.md#oh_avformat_create) (void) | Creates an **OH_AVFormat** instance for reading data.| +| \*[OH_AVFormat_CreateAudioFormat](_core.md#oh_avformat_createaudioformat) (const char \*mimeType, int32_t sampleRate, int32_t channelCount) | Creates an audio **OH_AVFormat** instance for reading and writing data.| +| \*[OH_AVFormat_CreateVideoFormat](_core.md#oh_avformat_createvideoformat) (const char \*mimeType, int32_t width, int32_t height) | Creates a video **OH_AVFormat** instance for reading and writing data.| +| [OH_AVFormat_Destroy](_core.md#oh_avformat_destroy) (struct OH_AVFormat \*format) | Destroys an **OH_AVFormat** instance.| +| [OH_AVFormat_Copy](_core.md#oh_avformat_copy) (struct OH_AVFormat \*to, struct OH_AVFormat \*from) | Copies an **OH_AVFormat** instance.| +| [OH_AVFormat_SetIntValue](_core.md#oh_avformat_setintvalue) (struct OH_AVFormat \*format, const char \*key, int32_t value) | Writes data of the int type to an **OH_AVFormat** instance.| +| [OH_AVFormat_SetLongValue](_core.md#oh_avformat_setlongvalue) (struct OH_AVFormat \*format, const char \*key, int64_t value) | Writes data of the long type to an **OH_AVFormat** instance.| +| [OH_AVFormat_SetFloatValue](_core.md#oh_avformat_setfloatvalue) (struct OH_AVFormat \*format, const char \*key, float value) | Writes data of the float type to an **OH_AVFormat** instance.| +| [OH_AVFormat_SetDoubleValue](_core.md#oh_avformat_setdoublevalue) (struct OH_AVFormat \*format, const char \*key, double value) | Writes data of the double type to an **OH_AVFormat** instance.| +| [OH_AVFormat_SetStringValue](_core.md#oh_avformat_setstringvalue) (struct OH_AVFormat \*format, const char \*key, const char \*value) | Writes data of the string type to an **OH_AVFormat** instance.| +| [OH_AVFormat_SetBuffer](_core.md#oh_avformat_setbuffer) (struct OH_AVFormat \*format, const char \*key, const uint8_t \*addr, size_t size) | Writes data blocks of a specified length to an **OH_AVFormat** instance.| +| [OH_AVFormat_GetIntValue](_core.md#oh_avformat_getintvalue) (struct OH_AVFormat \*format, const char \*key, int32_t \*out) | Reads data of the int type from an **OH_AVFormat** instance.| +| [OH_AVFormat_GetLongValue](_core.md#oh_avformat_getlongvalue) (struct OH_AVFormat \*format, const char \*key, int64_t \*out) | Reads data of the long type from an **OH_AVFormat** instance.| +| [OH_AVFormat_GetFloatValue](_core.md#oh_avformat_getfloatvalue) (struct OH_AVFormat \*format, const char \*key, float \*out) | Reads data of the float type from an **OH_AVFormat** instance.| +| [OH_AVFormat_GetDoubleValue](_core.md#oh_avformat_getdoublevalue) (struct OH_AVFormat \*format, const char \*key, double \*out) | Reads data of the double type from an **OH_AVFormat** instance.| +| [OH_AVFormat_GetStringValue](_core.md#oh_avformat_getstringvalue) (struct OH_AVFormat \*format, const char \*key, const char \*\*out) | Reads data of the string type from an **OH_AVFormat** instance.| +| [OH_AVFormat_GetBuffer](_core.md#oh_avformat_getbuffer) (struct OH_AVFormat \*format, const char \*key, uint8_t \*\*addr, size_t \*size) | Reads data blocks of a specified length from an **OH_AVFormat** instance.| +| \*[OH_AVFormat_DumpInfo](_core.md#oh_avformat_dumpinfo) (struct OH_AVFormat \*format) | Dumps the information contained in an **OH_AVFormat** instance as a string.| diff --git a/en/application-dev/reference/native-apis/native__avmemory_8h.md b/en/application-dev/reference/native-apis/native__avmemory_8h.md index b1842e1213..1ca8a7c0be 100644 --- a/en/application-dev/reference/native-apis/native__avmemory_8h.md +++ b/en/application-dev/reference/native-apis/native__avmemory_8h.md @@ -3,12 +3,13 @@ ## Overview -Declares the memory-related functions. +The **native_avmemory.h** file declares the memory-related functions. + +**Since** -**Since:** 9 -**Related Modules:** +**Related Modules** [Core](_core.md) @@ -16,10 +17,11 @@ Declares the memory-related functions. ## Summary - ### Functions -| Name | Description | +| Name| Description| | -------- | -------- | -| [OH_AVMemory_GetAddr](_core.md#oh_avmemory_getaddr) (struct OH_AVMemory \*mem) | Obtains the virtual memory address of an **OH_AVMemory** instance. | -| [OH_AVMemory_GetSize](_core.md#oh_avmemory_getsize) (struct OH_AVMemory \*mem) | Obtains the memory size of an **OH_AVMemory** instance. | +| \*[OH_AVMemory_Create](_core.md#oh_avmemory_create) (int32_t size) | Creates an **OH_AVMemory** instance.| +| \*[OH_AVMemory_GetAddr](_core.md#oh_avmemory_getaddr) (struct OH_AVMemory \*mem) | Obtains the virtual memory address of an **OH_AVMemory** instance.| +| [OH_AVMemory_GetSize](_core.md#oh_avmemory_getsize) (struct OH_AVMemory \*mem) | Obtains the memory size of an **OH_AVMemory** instance.| +| [OH_AVMemory_Destroy](_core.md#oh_avmemory_destroy) (struct OH_AVMemory \*mem) | Releases an **OH_AVMemory** instance.| diff --git a/en/application-dev/reference/native-apis/native__avmuxer_8h.md b/en/application-dev/reference/native-apis/native__avmuxer_8h.md new file mode 100644 index 0000000000..5f3dbf4667 --- /dev/null +++ b/en/application-dev/reference/native-apis/native__avmuxer_8h.md @@ -0,0 +1,30 @@ +# native_avmuxer.h + + +## Overview + +The **native_avmuxer.h** file declares native APIs used for audio and video encapsulation. + +**Since** + +10 + +**Related Modules** + +[AVMuxer](_a_v_muxer.md) + + +## Summary + + +### Functions + +| Name| Description| +| -------- | -------- | +| \*[OH_AVMuxer_Create](_a_v_muxer.md#oh_avmuxer_create) (int32_t fd, OH_AVOutputFormat format) | Creates an **OH_AVMuxer** instance by using the file descriptor and encapsulation format.| +| [OH_AVMuxer_SetRotation](_a_v_muxer.md#oh_avmuxer_setrotation) (OH_AVMuxer \*muxer, int32_t rotation) | Sets the rotation angle (clockwise) of an output video.| +| [OH_AVMuxer_AddTrack](_a_v_muxer.md#oh_avmuxer_addtrack) (OH_AVMuxer \*muxer, int32_t \*trackIndex, OH_AVFormat \*trackFormat) | Adds a media track to the muxer.| +| [OH_AVMuxer_Start](_a_v_muxer.md#oh_avmuxer_start) (OH_AVMuxer \*muxer) | Starts encapsulation.| +| [OH_AVMuxer_WriteSample](_a_v_muxer.md#oh_avmuxer_writesample) (OH_AVMuxer \*muxer, uint32_t trackIndex, OH_AVMemory \*sample, OH_AVCodecBufferAttr info) | Writes data to the muxer.| +| [OH_AVMuxer_Stop](_a_v_muxer.md#oh_avmuxer_stop) (OH_AVMuxer \*muxer) | Stops encapsulation.| +| [OH_AVMuxer_Destroy](_a_v_muxer.md#oh_avmuxer_destroy) (OH_AVMuxer \*muxer) | Clears internal resources and destroys an **OH_AVMuxer** instance.| diff --git a/en/application-dev/reference/native-apis/native__avsource_8h.md b/en/application-dev/reference/native-apis/native__avsource_8h.md new file mode 100644 index 0000000000..fbe6ead6d5 --- /dev/null +++ b/en/application-dev/reference/native-apis/native__avsource_8h.md @@ -0,0 +1,28 @@ +# native_avsource.h + + +## Overview + +The **native_avsource.h** file declares the native APIs used to construct audio and video resource objects. + +**Since** + +10 + +**Related Modules** + +[AVSource](_a_v_source.md) + + +## Summary + + +### Functions + +| Name| Description| +| -------- | -------- | +| \*[OH_AVSource_CreateWithURI](_a_v_source.md#oh_avsource_createwithuri) (char \*uri) | Creates an **OH_AVSource** instance based on a URI.| +| \*[OH_AVSource_CreateWithFD](_a_v_source.md#oh_avsource_createwithfd) (int32_t fd, int64_t offset, int64_t size) | Creates an **OH_AVSource** instance based on a file descriptor (FD).| +| [OH_AVSource_Destroy](_a_v_source.md#oh_avsource_destroy) (OH_AVSource \*source) | Destroys an **OH_AVSource** instance and clears internal resources. An instance can be destroyed only once.| +| \*[OH_AVSource_GetSourceFormat](_a_v_source.md#oh_avsource_getsourceformat) (OH_AVSource \*source) | Obtains the basic information about a media resource.| +| \*[OH_AVSource_GetTrackFormat](_a_v_source.md#oh_avsource_gettrackformat) (OH_AVSource \*source, uint32_t trackIndex) | Obtains the basic information about a track.| diff --git a/en/application-dev/reference/native-apis/native__buffer_8h.md b/en/application-dev/reference/native-apis/native__buffer_8h.md new file mode 100644 index 0000000000..8c07b91281 --- /dev/null +++ b/en/application-dev/reference/native-apis/native__buffer_8h.md @@ -0,0 +1,44 @@ +# native_buffer.h + + +## Overview + +The **native_buffer.h** file declares the functions for obtaining and using **NativeBuffer**. + +**Since** + +9 + +**Related Modules** + +[OH_NativeBuffer](_o_h___native_buffer.md) + + +## Summary + + +### Structs + +| Name| Description:| +| -------- | -------- | +| [OH_NativeBuffer_Config](_o_h___native_buffer___config.md) | Defines the **OH_NativeBuffer** attribute configuration, which is used when you apply for a new **OH_NativeBuffer** instance or query the attributes of an existing instance.| + + +### Types + +| Name| Description:| +| -------- | -------- | +| [OH_NativeBuffer](_o_h___native_buffer.md#oh_nativebuffer) | Provides the declaration of an **OH_NativeBuffer** struct.| + + +### Functions + +| Name| Description:| +| -------- | -------- | +| [OH_NativeBuffer_Alloc](_o_h___native_buffer.md#oh_nativebuffer_alloc) (const OH_NativeBuffer_Config \*config) | Creates an **OH_NativeBuffer** instance based on an **OH_NativeBuffer_Config** struct. A new **OH_NativeBuffer** instance is created each time this function is called.| +| [OH_NativeBuffer_Reference](_o_h___native_buffer.md#oh_nativebuffer_reference) (OH_NativeBuffer \*buffer) | Increases the reference count of an **OH_NativeBuffer** instance by 1.| +| [OH_NativeBuffer_Unreference](_o_h___native_buffer.md#oh_nativebuffer_unreference) (OH_NativeBuffer \*buffer) | Decreases the reference count of an **OH_NativeBuffer** instance by 1 and, when the reference count reaches 0, destroys the instance.| +| [OH_NativeBuffer_GetConfig](_o_h___native_buffer.md#oh_nativebuffer_getconfig) (OH_NativeBuffer \*buffer, OH_NativeBuffer_Config \*config) | Obtains the attributes of an **OH_NativeBuffer** instance.| +| [OH_NativeBuffer_Map](_o_h___native_buffer.md#oh_nativebuffer_map) (OH_NativeBuffer \*buffer, void \*\*virAddr) | Maps the ION memory corresponding to an **OH_NativeBuffer** instance to the process address space.| +| [OH_NativeBuffer_Unmap](_o_h___native_buffer.md#oh_nativebuffer_unmap) (OH_NativeBuffer \*buffer) | Unmaps the ION memory corresponding to an **OH_NativeBuffer** instance from the process address space.| +| [OH_NativeBuffer_GetSeqNum](_o_h___native_buffer.md#oh_nativebuffer_getseqnum) (OH_NativeBuffer \*buffer) | Obtains the sequence number of an **OH_NativeBuffer** instance.| diff --git a/en/application-dev/reference/native-apis/native__image_8h.md b/en/application-dev/reference/native-apis/native__image_8h.md new file mode 100644 index 0000000000..ba0f3a6d84 --- /dev/null +++ b/en/application-dev/reference/native-apis/native__image_8h.md @@ -0,0 +1,39 @@ +# native_image.h + + +## Overview + +The **native_image.h** file declares the functions for obtaining and using **NativeImage**. + +**Since** + +9 + +**Related Modules** + +[OH_NativeImage](_o_h___native_image.md) + + +## Summary + + +### Types + +| Name| Description| +| -------- | -------- | +| [OH_NativeImage](_o_h___native_image.md#oh_nativeimage) | Provides the declaration of an **OH_NativeImage** struct.| +| [OHNativeWindow](_o_h___native_image.md#ohnativewindow) | Provides the capability of accessing the **NativeWindow**.| + + +### Functions + +| Name| Description| +| -------- | -------- | +| [OH_NativeImage_Create](_o_h___native_image.md#oh_nativeimage_create) (uint32_t textureId, uint32_t textureTarget) | Creates an **OH_NativeImage** instance to be associated with the OpenGL ES texture ID and target.| +| [OH_NativeImage_AcquireNativeWindow](_o_h___native_image.md#oh_nativeimage_acquirenativewindow) (OH_NativeImage \*image) | Obtains an **OHNativeWindow** instance associated with an **OH_NativeImage** instance. You need to call **OH_NativeWindow_DestroyNativeWindow** to release the **OHNativeWindow** instance when it is no longer required. | +| [OH_NativeImage_AttachContext](_o_h___native_image.md#oh_nativeimage_attachcontext) (OH_NativeImage \*image, uint32_t textureId) | Attaches an **OH_NativeImage** instance to the current OpenGL ES context.
The OpenGL ES texture will be bound to an **GL_TEXTURE_EXTERNAL_OES** instance and updated through the **OH_NativeImage** instance.| +| [OH_NativeImage_DetachContext](_o_h___native_image.md#oh_nativeimage_detachcontext) (OH_NativeImage \*image) | Detaches an **OH_NativeImage** instance from the current OpenGL ES context.| +| [OH_NativeImage_UpdateSurfaceImage](_o_h___native_image.md#oh_nativeimage_updatesurfaceimage) (OH_NativeImage \*image) | Updates the OpenGL ES texture associated with the latest frame through an **OH_NativeImage** instance.| +| [OH_NativeImage_GetTimestamp](_o_h___native_image.md#oh_nativeimage_gettimestamp) (OH_NativeImage \*image) | Obtains the timestamp of the texture image that recently called the **OH_NativeImage_UpdateSurfaceImage** function.| +| [OH_NativeImage_GetTransformMatrix](_o_h___native_image.md#oh_nativeimage_gettransformmatrix) (OH_NativeImage \*image, float matrix[16]) | Obtains the transform matrix of the texture image that recently called the **OH_NativeImage_UpdateSurfaceImage** function.| +| [OH_NativeImage_Destroy](_o_h___native_image.md#oh_nativeimage_destroy) (OH_NativeImage \*\*image) | Destroys an **OH_NativeImage** instance created by calling **OH_NativeImage_Create**. After the instance is destroyed, the pointer to the **OH_NativeImage** instance is assigned **NULL**. | diff --git a/en/application-dev/reference/native-apis/native__vsync_8h.md b/en/application-dev/reference/native-apis/native__vsync_8h.md new file mode 100644 index 0000000000..867760ea09 --- /dev/null +++ b/en/application-dev/reference/native-apis/native__vsync_8h.md @@ -0,0 +1,34 @@ +# native_vsync.h + + +## Overview + +The **native_vsync.h** file declares the functions for obtaining and using native virtual synchronization (VSync). + +**Since** + +9 + +**Related Modules** + +[NativeVsync](_native_vsync.md) + + +## Summary + + +### Types + +| Name| Description| +| -------- | -------- | +| [OH_NativeVSync](_native_vsync.md#oh_nativevsync) | Provides the declaration of an **OH_NativeVSync** struct. | +| (\*[OH_NativeVSync_FrameCallback](_native_vsync.md#oh_nativevsync_framecallback)) (long long timestamp, void \*data) | Defines the pointer to a VSync callback function.| + + +### Functions + +| Name| Description| +| -------- | -------- | +| [OH_NativeVSync_Create](_native_vsync.md#oh_nativevsync_create) (const char \*name, unsigned int length) | Creates an **OH_NativeVSync** instance. A new **OH_NativeVSync** instance is created each time this function is called.| +| [OH_NativeVSync_Destroy](_native_vsync.md#oh_nativevsync_destroy) (OH_NativeVSync \*nativeVsync) | Destroys an **OH_NativeVSync** instance.| +| [OH_NativeVSync_RequestFrame](_native_vsync.md#oh_nativevsync_requestframe) (OH_NativeVSync \*nativeVsync, OH_NativeVSync_FrameCallback callback, void \*data) | Requests the next VSync signal. When the signal arrives, a callback function is invoked.| -- GitLab