openharmony 鸿蒙 capi-native-audiocapturer-h

2026-08-25 浏览 (1)

native_audiocapturer.h

Overview

The file declares the functions related to an audio capturer.

File to include: <ohaudio/native_audiocapturer.h>

Library: libohaudio.so

System capability: SystemCapability.Multimedia.Audio.Core

Since: 10

Related module: OHAudio

Summary

Functions

Nametypedef KeywordDescription
OH_AudioStream_Result OH_AudioCapturer_Release(OH_AudioCapturer* capturer)-Releases an audio capturer.
OH_AudioStream_Result OH_AudioCapturer_Start(OH_AudioCapturer* capturer)-Starts an audio capturer to start capturing audio data.
OH_AudioStream_Result OH_AudioCapturer_Pause(OH_AudioCapturer* capturer)-Pauses an audio capturer. You are advised to use the pause function if you need to resume audio recording later.
OH_AudioStream_Result OH_AudioCapturer_Stop(OH_AudioCapturer* capturer)-Stops an audio capturer, ceasing the input audio stream. You are advised to use the stop function if you need to terminate recording completely.
OH_AudioStream_Result OH_AudioCapturer_Flush(OH_AudioCapturer* capturer)-Flushes audio data captured by an audio capturer.
OH_AudioStream_Result OH_AudioCapturer_GetCurrentState(OH_AudioCapturer* capturer, OH_AudioStream_State* state)-Obtains the state of an audio capturer.
OH_AudioStream_Result OH_AudioCapturer_GetLatencyMode(OH_AudioCapturer* capturer, OH_AudioStream_LatencyMode* latencyMode)-Obtains the latency mode of an audio capturer.
OH_AudioStream_Result OH_AudioCapturer_GetStreamId(OH_AudioCapturer* capturer, uint32_t* streamId)-Obtains the stream ID of an audio capturer.
OH_AudioStream_Result OH_AudioCapturer_GetSamplingRate(OH_AudioCapturer* capturer, int32_t* rate)-Obtains the sampling rate of an audio capturer.
OH_AudioStream_Result OH_AudioCapturer_GetChannelCount(OH_AudioCapturer* capturer, int32_t* channelCount)-Obtains the number of channels for an audio capturer.
OH_AudioStream_Result OH_AudioCapturer_GetSampleFormat(OH_AudioCapturer* capturer, OH_AudioStream_SampleFormat* sampleFormat)-Obtains the sampling format of an audio capturer.
OH_AudioStream_Result OH_AudioCapturer_GetEncodingType(OH_AudioCapturer* capturer, OH_AudioStream_EncodingType* encodingType)-Obtains the encoding type of an audio capturer.
OH_AudioStream_Result OH_AudioCapturer_GetCapturerInfo(OH_AudioCapturer* capturer, OH_AudioStream_SourceType* sourceType)-Obtains the usage scenario of an audio capturer.
OH_AudioStream_Result OH_AudioCapturer_GetFrameSizeInCallback(OH_AudioCapturer* capturer, int32_t* frameSize)-Obtains the frame size in the callback. The frame size is the fixed length of the buffer returned by each callback.
OH_AudioStream_Result OH_AudioCapturer_GetTimestamp(OH_AudioCapturer* capturer, clockid_t clockId,int64_t* framePosition, int64_t* timestamp)-Obtains the information about the input audio stream timestamp and the current data frame position.
This function obtains the actual recording position (specified by framePosition) of the audio channel and the timestamp when recording to that position (specified by timestamp, in nanoseconds).
OH_AudioStream_Result OH_AudioCapturer_GetFramesRead(OH_AudioCapturer* capturer, int64_t* frames)-Obtains the number of frames that have been read since the stream was created.
OH_AudioStream_Result OH_AudioCapturer_GetOverflowCount(OH_AudioCapturer* capturer, uint32_t* count)-Obtains the number of overloaded audio streams of an audio capturer.
typedef void (*OH_AudioCapturer_OnReadDataCallback)(OH_AudioCapturer* capturer, void* userData, void* audioData, int32_t audioDataSize)OH_AudioCapturer_OnReadDataCallbackDefines the callback used to read audio data. To eliminate power-on noise caused by the microphone hardware design, the first 100 ms of data after recording starts is typically muted.
typedef void (*OH_AudioCapturer_OnDeviceChangeCallback)(OH_AudioCapturer* capturer, void* userData, OH_AudioDeviceDescriptorArray* deviceArray)OH_AudioCapturer_OnDeviceChangeCallbackDefines the callback for audio capturer device change events.
typedef void (*OH_AudioCapturer_OnInterruptCallback)(OH_AudioCapturer* capturer, void* userData, OH_AudioInterrupt_ForceType type, OH_AudioInterrupt_Hint hint)OH_AudioCapturer_OnInterruptCallbackDefines the callback for interruption events of an audio capturer.
typedef void (*OH_AudioCapturer_OnErrorCallback)(OH_AudioCapturer* capturer, void* userData, OH_AudioStream_Result error)OH_AudioCapturer_OnErrorCallbackDefines the callback for error events of an audio capturer.
OH_AudioStream_Result OH_AudioCapturer_GetFastStatus(OH_AudioCapturer* capturer, OH_AudioStream_FastStatus* status)-Obtains the running status of an audio capturer to determine whether it is running in low-latency mode.
typedef void (*OH_AudioCapturer_OnFastStatusChange)(OH_AudioCapturer* capturer, void* userData, OH_AudioStream_FastStatus status)OH_AudioCapturer_OnFastStatusChangeDefines a callback function for low-latency status changes during audio recording.
typedef void (*OH_AudioCapturer_OnPlaybackCaptureStartCallback)(OH_AudioCapturer* capturer, void* userData, OH_AudioStream_PlaybackCaptureStartState state)OH_AudioCapturer_OnPlaybackCaptureStartCallbackDefines the callback function for the starting result of internal audio recording (capturing sound from the applications on the device) during audio recording. This API is currently not available for public use.
OH_AudioStream_Result OH_AudioCapturer_RequestPlaybackCaptureStart(OH_AudioCapturer* capturer, OH_AudioCapturer_OnPlaybackCaptureStartCallback callback, void* userData)-Asynchronously requests to start the internal recording stream. This API works in non-blocking mode, which means that the system continues to process user authorization and start the internal recording stream after receiving a start request.
The final result is returned through a callback. This API is currently not available for public use.
OH_AudioStream_Result OH_AudioCapturer_SetIndependentAudioSessionStrategy(OH_AudioCapturer* capturer, const OH_AudioSession_Strategy* strategy, uint32_t behavior)-Sets the independent audio session policy and behavior parameters. If this API is called while an audio capturer is running, you must call the OH_AudioCapturer_Start API again for the settings to take effect.

Function Description

OH_AudioCapturer_Release()

OH_AudioStream_Result OH_AudioCapturer_Release(OH_AudioCapturer* capturer)

Description

Releases an audio capturer.

Required permissions: ohos.permission.MICROPHONE

Since: 10

Parameters

NameDescription
OH_AudioCapturer* capturerPointer to an audio capturer instance, which is created by calling OH_AudioStreamBuilder_GenerateCapturer.

Returns

TypeDescription
OH_AudioStream_ResultAUDIOSTREAM_SUCCESS: The function is executed successfully.
AUDIOSTREAM_ERROR_INVALID_PARAM: The capturer parameter is nullptr.
AUDIOSTREAM_ERROR_ILLEGAL_STATE: The execution status is abnormal.

OH_AudioCapturer_Start()

OH_AudioStream_Result OH_AudioCapturer_Start(OH_AudioCapturer* capturer)

Description

Starts an audio capturer to start capturing audio data.

Required permissions: ohos.permission.MICROPHONE

Since: 10

Parameters

NameDescription
OH_AudioCapturer* capturerPointer to an audio capturer instance, which is created by calling OH_AudioStreamBuilder_GenerateCapturer.

Returns

TypeDescription
OH_AudioStream_ResultAUDIOSTREAM_SUCCESS: The function is executed successfully.
AUDIOSTREAM_ERROR_INVALID_PARAM: The capturer parameter is nullptr.
AUDIOSTREAM_ERROR_ILLEGAL_STATE: The execution status is abnormal.

OH_AudioCapturer_Pause()

OH_AudioStream_Result OH_AudioCapturer_Pause(OH_AudioCapturer* capturer)

Description

Pauses an audio capturer. You are advised to use the pause function if you need to resume audio recording later.

Required permissions: ohos.permission.MICROPHONE

Since: 10

Parameters

NameDescription
OH_AudioCapturer* capturerPointer to an audio capturer instance, which is created by calling OH_AudioStreamBuilder_GenerateCapturer.

Returns

TypeDescription
OH_AudioStream_ResultAUDIOSTREAM_SUCCESS: The function is executed successfully.
AUDIOSTREAM_ERROR_INVALID_PARAM: The capturer parameter is nullptr.
AUDIOSTREAM_ERROR_ILLEGAL_STATE: The execution status is abnormal.

OH_AudioCapturer_Stop()

OH_AudioStream_Result OH_AudioCapturer_Stop(OH_AudioCapturer* capturer)

Description

Stops an audio capturer, ceasing the input audio stream. You are advised to use the stop function if you need to terminate recording completely.

Required permissions: ohos.permission.MICROPHONE

Since: 10

Parameters

NameDescription
OH_AudioCapturer* capturerPointer to an audio capturer instance, which is created by calling OH_AudioStreamBuilder_GenerateCapturer.

Returns

TypeDescription
OH_AudioStream_ResultAUDIOSTREAM_SUCCESS: The function is executed successfully.
AUDIOSTREAM_ERROR_INVALID_PARAM: The capturer parameter is nullptr.
AUDIOSTREAM_ERROR_ILLEGAL_STATE: The execution status is abnormal.

OH_AudioCapturer_Flush()

OH_AudioStream_Result OH_AudioCapturer_Flush(OH_AudioCapturer* capturer)

Description

Flushes audio data captured by an audio capturer.

Since: 10

Parameters

NameDescription
OH_AudioCapturer* capturerPointer to an audio capturer instance, which is created by calling OH_AudioStreamBuilder_GenerateCapturer.

Returns

TypeDescription
OH_AudioStream_ResultAUDIOSTREAM_SUCCESS: The function is executed successfully.
AUDIOSTREAM_ERROR_INVALID_PARAM: The capturer parameter is nullptr.
AUDIOSTREAM_ERROR_ILLEGAL_STATE: The execution status is abnormal.

OH_AudioCapturer_GetCurrentState()

OH_AudioStream_Result OH_AudioCapturer_GetCurrentState(OH_AudioCapturer* capturer, OH_AudioStream_State* state)

Description

Obtains the state of an audio capturer.

Since: 10

Parameters

NameDescription
OH_AudioCapturer* capturerPointer to an audio capturer instance, which is created by calling OH_AudioStreamBuilder_GenerateCapturer.
OH_AudioStream_State* statePointer to a variable used to receive the state.

Returns

TypeDescription
OH_AudioStream_ResultAUDIOSTREAM_SUCCESS: The function is executed successfully.
AUDIOSTREAM_ERROR_INVALID_PARAM: The capturer parameter is nullptr.

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.

Since: 10

Parameters

NameDescription
OH_AudioCapturer* capturerPointer to an audio capturer instance, which is created by calling OH_AudioStreamBuilder_GenerateCapturer.
OH_AudioStream_LatencyMode* latencyModePointer to a variable used to receive the latency mode.

Returns

TypeDescription
OH_AudioStream_ResultAUDIOSTREAM_SUCCESS: The function is executed successfully.
AUDIOSTREAM_ERROR_INVALID_PARAM: The capturer parameter is nullptr.

OH_AudioCapturer_GetStreamId()

OH_AudioStream_Result OH_AudioCapturer_GetStreamId(OH_AudioCapturer* capturer, uint32_t* streamId)

Description

Obtains the stream ID of an audio capturer.

Since: 10

Parameters

NameDescription
OH_AudioCapturer* capturerPointer to an audio capturer instance, which is created by calling OH_AudioStreamBuilder_GenerateCapturer.
uint32_t* streamIdPointer to a variable used to receive the stream ID.

Returns

TypeDescription
OH_AudioStream_ResultAUDIOSTREAM_SUCCESS: The function is executed successfully.
AUDIOSTREAM_ERROR_INVALID_PARAM: The capturer parameter is nullptr.

OH_AudioCapturer_GetSamplingRate()

OH_AudioStream_Result OH_AudioCapturer_GetSamplingRate(OH_AudioCapturer* capturer, int32_t* rate)

Description

Obtains the sampling rate of an audio capturer.

Since: 10

Parameters

NameDescription
OH_AudioCapturer* capturerPointer to an audio capturer instance, which is created by calling OH_AudioStreamBuilder_GenerateCapturer.
int32_t* ratePointer to a variable used to receive the sampling rate.

Returns

TypeDescription
OH_AudioStream_ResultAUDIOSTREAM_SUCCESS: The function is executed successfully.
AUDIOSTREAM_ERROR_INVALID_PARAM: The capturer parameter is nullptr.

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.

Since: 10

Parameters

NameDescription
OH_AudioCapturer* capturerPointer to an audio capturer instance, which is created by calling OH_AudioStreamBuilder_GenerateCapturer.
int32_t* channelCountPointer to a variable used to receive the channel count.

Returns

TypeDescription
OH_AudioStream_ResultAUDIOSTREAM_SUCCESS: The function is executed successfully.
AUDIOSTREAM_ERROR_INVALID_PARAM: The capturer parameter is nullptr.

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.

Since: 10

Parameters

NameDescription
OH_AudioCapturer* capturerPointer to an audio capturer instance, which is created by calling OH_AudioStreamBuilder_GenerateCapturer.
OH_AudioStream_SampleFormat* sampleFormatPointer to a variable used to receive the sampling format.

Returns

TypeDescription
OH_AudioStream_ResultAUDIOSTREAM_SUCCESS: The function is executed successfully.
AUDIOSTREAM_ERROR_INVALID_PARAM: The capturer parameter is nullptr.

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.

Since: 10

Parameters

NameDescription
OH_AudioCapturer* capturerPointer to an audio capturer instance, which is created by calling OH_AudioStreamBuilder_GenerateCapturer.
OH_AudioStream_EncodingType* encodingTypePointer to a variable used to receive the encoding type.

Returns

TypeDescription
OH_AudioStream_ResultAUDIOSTREAM_SUCCESS: The function is executed successfully.
AUDIOSTREAM_ERROR_INVALID_PARAM: The capturer parameter is nullptr.

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.

Since: 10

Parameters

NameDescription
OH_AudioCapturer* capturerPointer to an audio capturer instance, which is created by calling OH_AudioStreamBuilder_GenerateCapturer.
OH_AudioStream_SourceType* sourceTypePointer to a variable used to receive the usage scenario.

Returns

TypeDescription
OH_AudioStream_ResultAUDIOSTREAM_SUCCESS: The function is executed successfully.
AUDIOSTREAM_ERROR_INVALID_PARAM: The capturer parameter is nullptr.

OH_AudioCapturer_GetFrameSizeInCallback()

OH_AudioStream_Result OH_AudioCapturer_GetFrameSizeInCallback(OH_AudioCapturer* capturer,int32_t* frameSize)

Description

Obtains the frame size in the callback. The frame size is the fixed length of the buffer returned by each callback.

Since: 10

Parameters

NameDescription
OH_AudioCapturer* capturerPointer to an audio capturer instance, which is created by calling OH_AudioStreamBuilder_GenerateCapturer.
int32_t* frameSizePointer to a variable used to receive the frame size.

Returns

TypeDescription
OH_AudioStream_ResultAUDIOSTREAM_SUCCESS: The function is executed successfully.
AUDIOSTREAM_ERROR_INVALID_PARAM: The capturer parameter is nullptr.
AUDIOSTREAM_ERROR_ILLEGAL_STATE: The execution status is abnormal.

OH_AudioCapturer_GetTimestamp()

OH_AudioStream_Result OH_AudioCapturer_GetTimestamp(OH_AudioCapturer* capturer, clockid_t clockId,int64_t* framePosition, int64_t* timestamp)

Description

Obtains the information about the input audio stream timestamp and the current data frame position.
This function obtains the actual recording position (specified by framePosition) of the audio channel and the timestamp when recording to that position (specified by timestamp, in nanoseconds).

Since: 10

Parameters

NameDescription
OH_AudioCapturer* capturerPointer to an audio capturer instance, which is created by calling OH_AudioStreamBuilder_GenerateCapturer.
clockid_t clockIdClock identifier. Use CLOCK_MONOTONIC.
int64_t* framePositionPointer to a variable used to receive the position information.
int64_t* timestampPointer to a variable used to receive the timestamp, in nanoseconds.

Returns

TypeDescription
OH_AudioStream_ResultAUDIOSTREAM_SUCCESS: The function is executed successfully.
AUDIOSTREAM_ERROR_INVALID_PARAM:
1. The capturer parameter is nullptr.
2. The clockId parameter is invalid.
AUDIOSTREAM_ERROR_ILLEGAL_STATE: The execution status is abnormal.

OH_AudioCapturer_GetFramesRead()

OH_AudioStream_Result OH_AudioCapturer_GetFramesRead(OH_AudioCapturer* capturer, int64_t* frames)

Description

Obtains the number of frames that have been read since the stream was created.

Since: 10

Parameters

NameDescription
OH_AudioCapturer* capturerPointer to an audio capturer instance, which is created by calling OH_AudioStreamBuilder_GenerateCapturer.
int64_t* framesPointer to a variable used to receive the frame count.

Returns

TypeDescription
OH_AudioStream_ResultAUDIOSTREAM_SUCCESS: The function is executed successfully.
AUDIOSTREAM_ERROR_INVALID_PARAM: The capturer parameter is nullptr.

OH_AudioCapturer_GetOverflowCount()

OH_AudioStream_Result OH_AudioCapturer_GetOverflowCount(OH_AudioCapturer* capturer, uint32_t* count)

Description

Obtains the number of overloaded audio streams of an audio capturer.

Since: 12

Parameters

NameDescription
OH_AudioCapturer* capturerPointer to an audio capturer instance, which is created by calling OH_AudioStreamBuilder_GenerateCapturer.
uint32_t* countPointer to a variable used to receive the number of overloaded audio streams.

Returns

TypeDescription
OH_AudioStream_ResultAUDIOSTREAM_SUCCESS: The function is executed successfully.
AUDIOSTREAM_ERROR_INVALID_PARAM: The capturer parameter is nullptr.

OH_AudioCapturer_OnReadDataCallback()

typedef void (*OH_AudioCapturer_OnReadDataCallback)(OH_AudioCapturer* capturer, void* userData, void* audioData,int32_t audioDataSize)

Description

Defines the callback used to read audio data. To eliminate power-on noise caused by the microphone hardware design, the first 100 ms of data after recording starts is typically muted.

Since: 20

Parameters

NameDescription
OH_AudioCapturer* capturerPointer to an audio capturer instance, which is created by calling OH_AudioStreamBuilder_GenerateCapturer.
void* userDataPointer to the data storage region customized by an application, allowing the application to transfer data to itself.
void* audioDataPointer to the captured data storage area, which is used by the application to read captured data.
int32_t audioDataSizeLength of the captured data, in bytes.

OH_AudioCapturer_OnDeviceChangeCallback()

typedef void (*OH_AudioCapturer_OnDeviceChangeCallback)(OH_AudioCapturer* capturer, void* userData,OH_AudioDeviceDescriptorArray* deviceArray)

Description

Defines the callback for audio capturer device change events.

Since: 20

Parameters

NameDescription
OH_AudioCapturer* capturerPointer to an audio capturer instance, which is created by calling OH_AudioStreamBuilder_GenerateCapturer.
void* userDataPointer to the data storage area customized by the application.
OH_AudioDeviceDescriptorArray* deviceArrayPointer to the audio device descriptors in the array.

OH_AudioCapturer_OnInterruptCallback()

typedef void (*OH_AudioCapturer_OnInterruptCallback)(OH_AudioCapturer* capturer, void* userData,OH_AudioInterrupt_ForceType type, OH_AudioInterrupt_Hint hint)

Description

Defines the callback for interruption events of an audio capturer.

Since: 20

Parameters

NameDescription
OH_AudioCapturer* capturerPointer to an audio capturer instance, which is created by calling OH_AudioStreamBuilder_GenerateCapturer.
void* userDataPointer to the data storage area customized by the application.
OH_AudioInterrupt_ForceType typeType of force that causes audio interruption.
OH_AudioInterrupt_Hint hintHint provided along with audio interruption.

OH_AudioCapturer_OnErrorCallback()

typedef void (*OH_AudioCapturer_OnErrorCallback)(OH_AudioCapturer* capturer, void* userData,OH_AudioStream_Result error)

Description

Defines the callback for error events of an audio capturer.

Since: 20

Parameters

NameDescription
OH_AudioCapturer* capturerPointer to an audio capturer instance, which is created by calling OH_AudioStreamBuilder_GenerateCapturer.
void* userDataPointer to the data storage area customized by the application.
OH_AudioStream_Result errorAudio capturer error.

OH_AudioCapturer_GetFastStatus()

OH_AudioStream_Result OH_AudioCapturer_GetFastStatus(OH_AudioCapturer* capturer,OH_AudioStream_FastStatus* status)

Description

Obtains the running status of an audio capturer to determine whether it is running in low-latency mode.

Since: 20

Parameters

NameDescription
OH_AudioCapturer* capturerPointer to an audio capturer instance, which is created by calling OH_AudioStreamBuilder_GenerateCapturer.
OH_AudioStream_FastStatus* statusPointer to the running status.

Returns

TypeDescription
OH_AudioStream_ResultAUDIOSTREAM_SUCCESS: The function is executed successfully.
AUDIOSTREAM_ERROR_INVALID_PARAM: The capturer parameter is nullptr.
AUDIOSTREAM_ERROR_ILLEGAL_STATE: The function is called in an incorrect state.

OH_AudioCapturer_OnFastStatusChange()

typedef void (*OH_AudioCapturer_OnFastStatusChange)(OH_AudioCapturer* capturer,void* userData,OH_AudioStream_FastStatus status)

Description

Defines a callback function for low-latency status changes during audio recording.

Since: 20

Parameters

NameDescription
OH_AudioCapturer* capturerPointer to an audio capturer instance, which is created by calling OH_AudioStreamBuilder_GenerateCapturer.
void* userDataPointer to the data storage area customized by the application.
OH_AudioStream_FastStatus statusLow-latency status.

OH_AudioCapturer_OnPlaybackCaptureStartCallback()

typedef void (*OH_AudioCapturer_OnPlaybackCaptureStartCallback)(OH_AudioCapturer* capturer, void* userData, OH_AudioStream_PlaybackCaptureStartState state)

Description

Defines the callback function for the starting result of internal audio recording (capturing sound from the applications on the device) during audio recording. This API is currently not available for public use.

Since: 23

Parameters

NameDescription
OH_AudioCapturer* capturerPointer to an audio capturer instance, which is created by calling OH_AudioStreamBuilder_GenerateCapturer.
void* userDataPointer to the custom data storage region of an application via OH_AudioCapturer_RequestPlaybackCaptureStart.
OH_AudioStream_PlaybackCaptureStartState stateWhether the internal recording request is successful.

OH_AudioCapturer_RequestPlaybackCaptureStart()

OH_AudioStream_Result OH_AudioCapturer_RequestPlaybackCaptureStart(OH_AudioCapturer* capturer, OH_AudioCapturer_OnPlaybackCaptureStartCallback callback, void* userData)

Description

Asynchronously requests to start the internal recording stream. This API works in non-blocking mode, which means that the system continues to process user authorization and start the internal recording stream after receiving a start request.
The final result is returned through a callback. This API is currently not available for public use.

Since: 23

Parameters

NameDescription
OH_AudioCapturer* capturerPointer to an audio capturer instance, which is created by calling OH_AudioStreamBuilder_GenerateCapturer.
OH_AudioCapturer_OnPlaybackCaptureStartCallback callbackCallback function used to receive the final result of the start request.
void* userDataPointer to the data storage region customized by an application. This struct will be passed to the callback function.

Returns

TypeDescription
OH_AudioStream_ResultAUDIOSTREAM_SUCCESS: The function is executed successfully.
AUDIOSTREAM_ERROR_INVALID_PARAM: Invalid capturer or callback.
AUDIOSTREAM_ERROR_ILLEGAL_STATE: The stream is either active or has been released.
AUDIOSTREAM_ERROR_SYSTEM: Internal system error, for example, abnormal audio error.

OH_AudioCapturer_SetIndependentAudioSessionStrategy()

OH_AudioStream_Result OH_AudioCapturer_SetIndependentAudioSessionStrategy(OH_AudioCapturer* capturer, const OH_AudioSession_Strategy* strategy, uint32_t behavior)

Description

Sets the independent audio session policy and behavior parameters. If this API is called while an audio capturer is running, you must call the OH_AudioCapturer_Start API again for the settings to take effect.

Since: 24

Parameters

NameDescription
OH_AudioCapturer* capturerPointer to an audio capturer instance, which is created by calling OH_AudioStreamBuilder_GenerateCapturer.
const OH_AudioSession_Strategy* strategyPointer to the independent audio session policy.
uint32_t behaviorAudio session behavior flag. This can be a single flag or a bitwise OR combination of multiple flags. For details about the supported audio session behaviors, see OH_AudioSession_BehaviorFlags.

Returns

TypeDescription
OH_AudioStream_ResultAUDIOSTREAM_SUCCESS: The function is executed successfully.
AUDIOSTREAM_ERROR_INVALID_PARAM: The parameter value is a null pointer or out of range.
AUDIOSTREAM_ERROR_ILLEGAL_STATE: The execution status is abnormal.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 capi-native-audiostreambuilder-h

openharmony 鸿蒙 capi-ohaudiosuite

openharmony 鸿蒙 js-apis-inner-multimedia-systemSoundPlayer

openharmony 鸿蒙 arkts-apis-audio-i

openharmony 鸿蒙 capi-ohaudio

openharmony 鸿蒙 capi-ohmidi

openharmony 鸿蒙 arkts-apis-audio-AudioManager

openharmony 鸿蒙 capi-ohaudiosuite-oh-audiosuite-spacerenderpositionparams

openharmony 鸿蒙 capi-ohaudio-oh-audiostreaminfo

openharmony 鸿蒙 errorcode-ringtone

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