AudioParams
Used to set the audio data format.
struct AudioParams {
int sample_rate;
int channels;
rtc::RAW_AUDIO_FRAME_OP_MODE_TYPE mode;
int samples_per_call;
};
You can pass the AudioParams object in the following APIs to set the audio data format for the corresponding callback:
- getRecordAudioParams: Sets the audio data format for the onRecordAudioFrame callback.
- getPlaybackAudioParams: Sets the audio data format for the onPlaybackAudioFrame callback.
- getMixedAudioParams: Sets the audio data format for the onMixedAudioFrame callback.
- getEarMonitoringAudioParams: Sets the audio data format for the onEarMonitoringAudioFrame callback.
Note: The SDK calculates the sampling interval using the
samplesPerCall, sampleRate, and channel parameters in AudioParams, and triggers the onRecordAudioFrame, onPlaybackAudioFrame, onMixedAudioFrame, and onEarMonitoringAudioFrame callbacks based on the sampling interval.
Sampling interval (seconds) = samplesPerCall / (sampleRate × channel).
Make sure the sampling interval is ≥ 0.01 seconds.Properties
- sample_rate
- Audio sample rate (Hz). Can be set to one of the following values: 8000, 16000 (default), 32000, 44100, 48000.
- channels
- Number of audio channels. Can be set to one of the following values:
- 1: Mono (default).
- 2: Stereo.
- mode
- Usage mode of the audio data. See RAW_AUDIO_FRAME_OP_MODE_TYPE.
- samples_per_call
- Number of samples per call, e.g., 1024 for media streaming.