harmony 鸿蒙OHAudio

2023-10-30 浏览 (1069)

OHAudio

Overview

The OHAudio module provides native APIs of the audio module.

@syscap SystemCapability.Multimedia.Audio.Core

Since

10

Summary

Files

NameDescription
native_audiocapturer.hDeclares the functions related to an audio capturer.
File to include: <ohaudio/native_audiocapturer.h>
Library: libohaudio.so
native_audiorenderer.hDeclares the functions related to an audio renderer.
File to include: <ohaudio/native_audiorenderer.h>
Library: libohaudio.so
native_audiostream_base.hDeclares the basic data structure of OHAudio.
File to include: <ohaudio/native_audiostream_base.h>
Library: libohaudio.so
native_audiostreambuilder.hDeclares the functions related to the audio stream builder.
File to include: <ohaudio/native_audiostreambuilder.h>
Library: libohaudio.so

Structs

NameDescription
OH_AudioRenderer_Callbacks_StructDefines a pointer to the callback functions related to an audio renderer.
OH_AudioCapturer_Callbacks_StructDefines a pointer to the callback functions related to an audio capturer.

Types

NameDescription
OH_AudioStreamBuilderDefines an audio stream builder.
OH_AudioRendererDefines an audio renderer.
OH_AudioCapturerDefines an audio capturer.
OH_AudioRenderer_CallbacksDefines a pointer to the callback functions related to an audio renderer.
OH_AudioCapturer_CallbacksDefines a pointer to the callback functions related to an audio capturer.

Enums

NameDescription
OH_AudioStream_Result { AUDIOSTREAM_SUCCESS, AUDIOSTREAM_ERROR_INVALID_PARAM, AUDIOSTREAM_ERROR_ILLEGAL_STATE, AUDIOSTREAM_ERROR_SYSTEM }Enumerates the audio stream result codes.
OH_AudioStream_Type { AUDIOSTREAM_TYPE_RENDERER = 1, AUDIOSTREAM_TYPE_CAPTURER = 2 }Enumerates the audio stream types.
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 { AUDIOSTREAM_ENCODING_TYPE_RAW = 0 }Enumerates the encoding types of audio streams.
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 { AUDIOSTREAM_LATENCY_MODE_NORMAL = 0, AUDIOSTREAM_LATENCY_MODE_FAST = 1}Enumerates the latency modes of audio streams.
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 { 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

NameDescription
OH_AudioCapturer_Release (OH_AudioCapturer *capturer)Releases an audio capturer.
OH_AudioCapturer_Start (OH_AudioCapturer *capturer)Starts an audio capturer.
OH_AudioCapturer_Pause (OH_AudioCapturer *capturer)Pauses an audio capturer.
OH_AudioCapturer_Stop (OH_AudioCapturer *capturer)Stops an audio capturer.
OH_AudioCapturer_Flush (OH_AudioCapturer *capturer)Flushes obtained audio data.
OH_AudioCapturer_GetCurrentState (OH_AudioCapturer *capturer, OH_AudioStream_State *state)Obtains the state of an audio capturer.
OH_AudioCapturer_GetLatencyMode (OH_AudioCapturer *capturer, OH_AudioStream_LatencyMode *latencyMode)Obtains the latency mode of an audio capturer.
OH_AudioCapturer_GetStreamId (OH_AudioCapturer *capturer, uint32_t *streamId)Obtains the stream ID of an audio capturer.
OH_AudioCapturer_GetSamplingRate (OH_AudioCapturer *capturer, int32_t *rate)Obtains the sampling rate of an audio capturer.
OH_AudioCapturer_GetChannelCount (OH_AudioCapturer *capturer, int32_t *channelCount)Obtains the number of channels for an audio capturer.
OH_AudioCapturer_GetSampleFormat (OH_AudioCapturer *capturer, OH_AudioStream_SampleFormat *sampleFormat)Obtains the sampling format of an audio capturer.
OH_AudioCapturer_GetEncodingType (OH_AudioCapturer *capturer, OH_AudioStream_EncodingType *encodingType)Obtains the encoding type of an audio capturer.
OH_AudioCapturer_GetCapturerInfo (OH_AudioCapturer *capturer, OH_AudioStream_SourceType *sourceType)Obtains the usage scenario of an audio capturer.
OH_AudioRenderer_Release (OH_AudioRenderer *renderer)Releases an audio renderer.
OH_AudioRenderer_Start (OH_AudioRenderer *renderer)Starts an audio renderer.
OH_AudioRenderer_Pause (OH_AudioRenderer *renderer)Pauses an audio renderer.
OH_AudioRenderer_Stop (OH_AudioRenderer *renderer)Stops an audio renderer.
OH_AudioRenderer_Flush (OH_AudioRenderer *renderer)Flushes written audio data.
OH_AudioRenderer_GetCurrentState (OH_AudioRenderer *renderer, OH_AudioStream_State *state)Obtains the state of an audio renderer.
OH_AudioRenderer_GetSamplingRate (OH_AudioRenderer *renderer, int32_t *rate)Obtains the sampling rate of an audio renderer.
OH_AudioRenderer_GetStreamId (OH_AudioRenderer *renderer, uint32_t *streamId)Obtains the stream ID of an audio renderer.
OH_AudioRenderer_GetChannelCount (OH_AudioRenderer *renderer, int32_t *channelCount)Obtains the number of channels for an audio renderer.
OH_AudioRenderer_GetSampleFormat (OH_AudioRenderer *renderer, OH_AudioStream_SampleFormat *sampleFormat)Obtains the sampling format of an audio renderer.
OH_AudioRenderer_GetLatencyMode (OH_AudioRenderer *renderer, OH_AudioStream_LatencyMode *latencyMode)Obtains the latency mode of an audio renderer.
OH_AudioRenderer_GetRendererInfo (OH_AudioRenderer *renderer, OH_AudioStream_Usage *usage)Obtains the usage scenario of an audio renderer.
OH_AudioRenderer_GetEncodingType (OH_AudioRenderer *renderer, OH_AudioStream_EncodingType *encodingType)Obtains the encoding type of an audio renderer.
OH_AudioStreamBuilder_Create (OH_AudioStreamBuilder **builder, OH_AudioStream_Type type)Creates an audio stream builder, which can be an audio renderer or capturer.
OH_AudioStreamBuilder_Destroy (OH_AudioStreamBuilder *builder)Destroys an audio stream builder.
OH_AudioStreamBuilder_SetSamplingRate (OH_AudioStreamBuilder *builder, int32_t rate)Sets the sampling rate of an audio stream.
OH_AudioStreamBuilder_SetChannelCount (OH_AudioStreamBuilder *builder, int32_t channelCount)Sets the number of channels for an audio stream.
OH_AudioStreamBuilder_SetSampleFormat (OH_AudioStreamBuilder *builder, OH_AudioStream_SampleFormat format)Sets the sampling format of an audio stream.
OH_AudioStreamBuilder_SetEncodingType (OH_AudioStreamBuilder *builder, OH_AudioStream_EncodingType encodingType)Sets the encoding type of an audio stream.
OH_AudioStreamBuilder_SetLatencyMode (OH_AudioStreamBuilder *builder, OH_AudioStream_LatencyMode latencyMode)Sets the latency mode of an audio stream.
OH_AudioStreamBuilder_SetRendererInfo (OH_AudioStreamBuilder *builder, OH_AudioStream_Usage usage)Sets the usage scenario of an audio renderer.
OH_AudioStreamBuilder_SetCapturerInfo (OH_AudioStreamBuilder *builder, OH_AudioStream_SourceType sourceType)Sets the usage scenario of an audio capturer.
OH_AudioStreamBuilder_SetRendererCallback (OH_AudioStreamBuilder *builder, OH_AudioRenderer_Callbacks callbacks, void *userData)Sets callbacks for an audio renderer.
OH_AudioStreamBuilder_SetCapturerCallback (OH_AudioStreamBuilder *builder, OH_AudioCapturer_Callbacks callbacks, void *userData)Sets callbacks for an audio capturer.
OH_AudioStreamBuilder_GenerateRenderer (OH_AudioStreamBuilder *builder, OH_AudioRenderer **audioRenderer)Creates an audio renderer instance.
OH_AudioStreamBuilder_GenerateCapturer (OH_AudioStreamBuilder *builder, OH_AudioCapturer **audioCapturer)Creates an audio capturer instance.

Variables

NameDescription
(*OH_AudioRenderer_Callbacks_Struct::OH_AudioRenderer_OnWriteData )(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 *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_Struct OH_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_Struct OH_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

ValueDescription
AUDIOSTREAM_ENCODING_TYPE_RAWPCM encoding.

OH_AudioStream_LatencyMode

enum OH_AudioStream_LatencyMode

Description

Enumerates the latency modes of audio streams.

@syscap SystemCapability.Multimedia.Audio.Core

Since

10

ValueDescription
AUDIOSTREAM_LATENCY_MODE_NORMALNormal latency mode.
AUDIOSTREAM_LATENCY_MODE_FASTLow latency mode.

OH_AudioStream_Result

enum OH_AudioStream_Result

Description

Enumerates the audio stream result codes.

@syscap SystemCapability.Multimedia.Audio.Core

Since

10

ValueDescription
AUDIOSTREAM_SUCCESSOperation successful.
AUDIOSTREAM_ERROR_INVALID_PARAMInvalid input parameter.
AUDIOSTREAM_ERROR_ILLEGAL_STATEInvalid state.
AUDIOSTREAM_ERROR_SYSTEMSystem error.

OH_AudioStream_SampleFormat

enum OH_AudioStream_SampleFormat

Description

Enumerates the sampling formats of audio streams.

@syscap SystemCapability.Multimedia.Audio.Core

Since

10

ValueDescription
AUDIOSTREAM_SAMPLE_U8Unsigned 8-bit.
AUDIOSTREAM_SAMPLE_S16LEShort 16-bit little-endian.
AUDIOSTREAM_SAMPLE_S24LEShort 24-bit little-endian.
AUDIOSTREAM_SAMPLE_S32LEShort 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

ValueDescription
AUDIOSTREAM_SOURCE_TYPE_INVALIDInvalid state.
AUDIOSTREAM_SOURCE_TYPE_MICAudio recording.
AUDIOSTREAM_SOURCE_TYPE_VOICE_RECOGNITIONVoice recognition.
AUDIOSTREAM_SOURCE_TYPE_VOICE_COMMUNICATIONVoice communication.

OH_AudioStream_State

enum OH_AudioStream_State

Description

Enumerates the audio stream states.

@syscap SystemCapability.Multimedia.Audio.Core

Since

10

ValueDescription
AUDIOSTREAM_STATE_INVALIDInvalid state.
AUDIOSTREAM_STATE_PREPAREDPrepared.
AUDIOSTREAM_STATE_RUNNINGRunning.
AUDIOSTREAM_STATE_STOPPEDStopped.
AUDIOSTREAM_STATE_RELEASEDReleased.
AUDIOSTREAM_STATE_PAUSEDPaused.

OH_AudioStream_Type

enum OH_AudioStream_Type

Description

Enumerates the audio stream types.

@syscap SystemCapability.Multimedia.Audio.Core

Since

10

ValueDescription
AUDIOSTREAM_TYPE_RENDERERThe audio stream is an output stream.
AUDIOSTREAM_TYPE_CAPTURERThe 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

ValueDescription
AUDIOSTREAM_USAGE_UNKNOWNUndefined.
AUDIOSTREAM_USAGE_MUSICMusic.
AUDIOSTREAM_USAGE_COMMUNICATIONVoice communication.
AUDIOSTREAM_USAGE_GAMEGaming.

Function Description

OH_AudioCapturer_Flush()

OH_AudioStream_Result OH_AudioCapturer_Flush (OH_AudioCapturer * capturer)

Description

Flushes obtained audio data.

Parameters

NameDescription
capturerPointer to an audio capturer instance created by 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

NameDescription
capturerPointer to an audio capturer instance created by OH_AudioStreamBuilder_GenerateCapturer.
sourceTypePointer 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 capturer.

Parameters

NameDescription
capturerPointer to an audio capturer instance created by OH_AudioStreamBuilder_GenerateCapturer.
channelCountPointer 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 capturer.

Parameters

NameDescription
capturerPointer to an audio capturer instance created by OH_AudioStreamBuilder_GenerateCapturer.
statePointer 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 capturer.

Parameters

NameDescription
capturerPointer to an audio capturer instance created by OH_AudioStreamBuilder_GenerateCapturer.
encodingTypePointer 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 capturer.

Parameters

NameDescription
capturerPointer to an audio capturer instance created by OH_AudioStreamBuilder_GenerateCapturer.
latencyModePointer 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 capturer.

Parameters

NameDescription
capturerPointer to an audio capturer instance created by OH_AudioStreamBuilder_GenerateCapturer.
sampleFormatPointer 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 capturer.

Parameters

NameDescription
capturerPointer to an audio capturer instance created by OH_AudioStreamBuilder_GenerateCapturer.
ratePointer 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 capturer.

Parameters

NameDescription
capturerPointer to an audio capturer instance created by OH_AudioStreamBuilder_GenerateCapturer.
streamIdPointer 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

NameDescription
capturerPointer to an audio capturer instance created by 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

NameDescription
capturerPointer to an audio capturer instance created by 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

NameDescription
capturerPointer to an audio capturer instance created by 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

NameDescription
capturerPointer to an audio capturer instance created by 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

NameDescription
rendererPointer to an audio renderer instance created by 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 renderer.

Parameters

NameDescription
rendererPointer to an audio renderer instance created by OH_AudioStreamBuilder_GenerateRenderer.
channelCountPointer 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 renderer.

Parameters

NameDescription
rendererPointer to an audio renderer instance created by OH_AudioStreamBuilder_GenerateRenderer.
statePointer 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 renderer.

Parameters

NameDescription
rendererPointer to an audio renderer instance created by OH_AudioStreamBuilder_GenerateRenderer.
encodingTypePointer 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 renderer.

Parameters

NameDescription
rendererPointer to an audio renderer instance created by OH_AudioStreamBuilder_GenerateRenderer.
latencyModePointer 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.

Parameters

NameDescription
rendererPointer to an audio renderer instance created by OH_AudioStreamBuilder_GenerateRenderer.
usagePointer 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 renderer.

Parameters

NameDescription
rendererPointer to an audio renderer instance created by OH_AudioStreamBuilder_GenerateRenderer.
sampleFormatPointer 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 renderer.

Parameters

NameDescription
rendererPointer to an audio renderer instance created by OH_AudioStreamBuilder_GenerateRenderer.
ratePointer 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 renderer.

Parameters

NameDescription
rendererPointer to an audio renderer instance created by OH_AudioStreamBuilder_GenerateRenderer.
streamIdPointer 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

NameDescription
rendererPointer to an audio renderer instance created by 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

NameDescription
rendererPointer to an audio renderer instance created by 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

NameDescription
rendererPointer to an audio renderer instance created by 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

NameDescription
rendererPointer to an audio renderer instance created by 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

NameDescription
builderDouble pointer to the audio stream builder created.
typeType 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

NameDescription
builderPointer 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

NameDescription
builderPointer to an audio stream builder instance created by OH_AudioStreamBuilder_Create().
audioCapturerDouble 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

NameDescription
builderPointer to an audio stream builder instance created by OH_AudioStreamBuilder_Create().
audioRendererDouble 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

NameDescription
builderPointer to an audio stream builder instance created by OH_AudioStreamBuilder_Create().
callbacksCallback functions that will be used to process events related to input audio streams.
userDataPointer 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

NameDescription
builderPointer to an audio stream builder instance created by OH_AudioStreamBuilder_Create().
sourceTypeUsage 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

NameDescription
builderPointer to an audio stream builder instance created by OH_AudioStreamBuilder_Create().
channelCountNumber 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

NameDescription
builderPointer to an audio stream builder instance created by OH_AudioStreamBuilder_Create().
encodingTypeEncoding 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

NameDescription
builderPointer to an audio stream builder instance created by OH_AudioStreamBuilder_Create().
latencyModeLatency 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

NameDescription
builderPointer to an audio stream builder instance created by OH_AudioStreamBuilder_Create().
callbacksCallback functions that will be used to process events related to output audio streams.
userDataPointer 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

NameDescription
builderPointer to an audio stream builder instance created by OH_AudioStreamBuilder_Create().
usageUsage 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

NameDescription
builderPointer to an audio stream builder instance created by OH_AudioStreamBuilder_Create().
formatSampling 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

NameDescription
builderPointer to an audio stream builder instance created by OH_AudioStreamBuilder_Create().
channelCountSampling 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

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Native APIs

harmony 鸿蒙AVCapability

harmony 鸿蒙AVDemuxer

harmony 鸿蒙AVMuxer

harmony 鸿蒙AVScreenCapture

harmony 鸿蒙AVSource

harmony 鸿蒙AudioDecoder

harmony 鸿蒙AudioEncoder

harmony 鸿蒙CodecBase

harmony 鸿蒙Core

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/a153db9433ad486abaa53f905f91e45a