AgoraAudioParams
音频数据格式。
Objective-C
__attribute__((visibility("default"))) @interface AgoraAudioParams : NSObject
@property (assign, nonatomic) NSInteger sampleRate;
@property (assign, nonatomic) NSInteger channel;
@property (assign, nonatomic) AgoraAudioRawFrameOperationMode mode;
@property (assign, nonatomic) NSInteger samplesPerCall;
@end
你可以在以下 API 中传入 AgoraAudioParams
对象,用于设置对应回调报告的音频数据格式:
-
getRecordAudioParams
:设置onRecordAudioFrame
回调的数据格式。 -
getPlaybackAudioParams
:设置onPlaybackAudioFrame
回调的数据格式。 -
getMixedAudioParams
:设置onMixedAudioFrame
回调的数据格式。 -
getEarMonitoringAudioParams
:设置onEarMonitoringAudioFrame
回调的数据格式。
注意:
-
SDK 会通过
AgoraAudioParams
中的samplesPerCall
、sampleRate
和channel
参数计算采样间隔,并根据该采样间隔触发onRecordAudioFrame
、onPlaybackAudioFrame
、onMixedAudioFrame
和onEarMonitoringAudioFrame
回调。 -
采样间隔 =
samplesPerCall
/(sampleRate
×channel
)。 -
请确保采样间隔不得小于 0.01 (s)。
sampleRate
数据的采样率,单位为 Hz,取值如下:
- 8000
- 16000(默认值)
- 32000
- 44100
- 48000
channel
数据的声道数,取值如下:
- 1:单声道(默认值)
- 2:双声道
mode
数据的使用模式。详见 AgoraAudioRawFrameOperationMode
。
samplesPerCall
数据的采样点数,如旁路推流应用中通常为 1024。