MultiMedia_AudioCapturer
Since:
1.0
Version:
1.0
Summary
Files
Data Structures
Enumerations
: int32_t { OHOS::Audio::Timestamp::Timebase::MONOTONIC = 0, = 1 } |
Enumerates the time base of this Timestamp. Different timing methods are supported. |
OHOS::Audio::State : uint32_t { , OHOS::Audio::RECORDING, , OHOS::Audio::RELEASED } |
Functions
Details
Enumeration Type Documentation
State
Description:
Enumerates the recording states of the current device.
PREPPARED | |
RECORDING | |
STOPPED | |
RELEASED |
Description:
Enumerates the time base of this . Different timing methods are supported.
MONOTONIC | Monotonically increasing time, excluding the system sleep time |
BOOTTIME | Monotonically increasing time, including the system sleep time |
Function Documentation
GetAudioTime()
bool OHOS::Audio::AudioCapturer::GetAudioTime ([Timestamp]($api-api-SmartVision-Devices-OHOS-Audio-Timestamp.md) & timestamp, [Timestamp::Timebase]($api-api-SmartVision-Devices-MultiMedia_AudioCapturer.md#gacdafb362a7da91799fa96163bca2a619) base )
Description:
Obtains the timestamp.
Parameters:
Returns:
Returns true if the timestamp is successfully obtained; returns false otherwise.
GetCapturerInfo()
int32_t OHOS::Audio::AudioCapturer::GetCapturerInfo ([AudioCapturerInfo]($api-api-SmartVision-Devices-OHOS-Audio-AudioCapturerInfo.md) & info)
Description:
Obtains audio capture parameters.
This function can be called after SetCapturerInfo is successful.
Parameters:
info | Indicates information about audio capture parameters. For details, see AudioCapturerInfo. |
Returns:
Returns SUCCESS if the parameter information is successfully obtained; returns an error code defined in otherwise.
GetFrameCount()
uint64_t OHOS::Audio::AudioCapturer::GetFrameCount ()
Description:
Obtains the number of frames required in the current condition, in bytes per sample.
Returns:
Returns the number of frames (in bytes per sample) if the operation is successful; returns -1 if an exception occurs.
GetMinFrameCount()
static bool OHOS::Audio::AudioCapturer::GetMinFrameCount (int32_t sampleRate, int32_t channelCount, [AudioCodecFormat]($api-api-SmartVision-Devices-MultiMedia_MediaCommon.md#gaa4ea6f314644ed287e0704be26c768b7) audioFormat, size_t & frameCount )
Description:
Obtains the minimum number of frames required in a specified condition, in bytes per sample.
Parameters:
sampleRate | Indicates the audio sampling rate, in Hz. |
channelCount | Indicates the number of audio recording channels. |
audioFormat | Indicates the audio data format. |
frameCount | Indicates the minimum number of frames, in bytes per sample. |
Returns:
Returns true if the minimum number of frames is successfully obtained; returns false otherwise.
GetStatus()
Description:
Obtains the audio capture state.
Returns:
Returns the audio capture state defined in .
Read()
Description:
Reads audio data.
Parameters:
Returns:
Returns the size of the audio data read from the device. The value ranges from 0 to userSize. If the reading fails, one of the following error codes is returned: ERR_INVALID_PARAM: The input parameter is incorrect. ERR_ILLEGAL_STATE: The instance is not initialized. ERR_SOURCE_NOT_SET: The state of hardware device instance is abnormal.
Release()
bool OHOS::Audio::AudioCapturer::Release ()
Description:
Releases a local AudioCapturer object.
Returns:
Returns true if the object is successfully released; returns false otherwise.
int32_t OHOS::Audio::AudioCapturer::SetCapturerInfo (const [AudioCapturerInfo]($api-api-SmartVision-Devices-OHOS-Audio-AudioCapturerInfo.md) info)
Description:
Sets audio capture parameters.
Parameters:
info | Indicates information about audio capture parameters to set. For details, see AudioCapturerInfo. |
Returns:
Returns SUCCESS if the setting is successful; returns an error code defined in otherwise.
Start()
bool OHOS::Audio::AudioCapturer::Start ()
Description:
Starts audio recording.
Returns:
Returns true if the recording is successfully started; returns false otherwise.
Stop()
bool OHOS::Audio::AudioCapturer::Stop ()
Description:
Stops audio recording.
Returns:
Returns true if the recording is successfully stopped; returns false otherwise.
Variable Documentation
audioFormat
Description:
Audio codec format
bitRate
Description:
Bit rate
bitWidth
[AudioBitWidth](MultiMedia_MediaCommon.md#gae3e35ee2a2222a667fdebbc5b793ca7c) OHOS::Audio::AudioCapturerInfo::bitWidth = [BIT_WIDTH_16](MultiMedia_MediaCommon.md#ggae3e35ee2a2222a667fdebbc5b793ca7ca036f0b45813f96cb6b0f90de1722a780)
Description:
Bit width
channelCount
int32_t OHOS::Audio::AudioCapturerInfo::channelCount = 0
Description:
Number of audio channels
inputSource
[AudioSourceType](MultiMedia_MediaCommon.md#gadc3158e093b995ca7b9b6aa32388ccdd) OHOS::Audio::AudioCapturerInfo::inputSource = [AUDIO_MIC](MultiMedia_MediaCommon.md#ggadc3158e093b995ca7b9b6aa32388ccdda732604b3a24d137429e2b83b31849bce)
Description:
Audio source type
int32_t OHOS::Audio::AudioCapturerInfo::sampleRate = 0
Description:
Sampling rate
streamType
Description:
Audio stream type