AgoraAudioParams
设置音频数据格式。
Objective-C
@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:channelId: 回调的音频数据格式。
- getPlaybackAudioParams:设置
onPlaybackAudioFrame:回调的音频数据格式。 - getMixedAudioParams:设置 onMixedAudioFrame:channelId: 回调的音频数据格式。
- getEarMonitoringAudioParams:设置 onEarMonitoringAudioFrame: 回调的音频数据格式。
信息
SDK 会通过 AgoraAudioParams 中的
samplesPerCall、sampleRate 和 channel 参数计算采样间隔,并根据采样间隔触发 onRecordAudioFrame:channelId:、onPlaybackAudioFrame:、onMixedAudioFrame:channelId: 和 onEarMonitoringAudioFrame: 回调。 采样间隔(秒) = samplesPerCall / (sampleRate × channel)。 请确保采样间隔 ≥ 0.01 秒。sampleRate
音频采样率(Hz),可设置为以下值之一:
- 8000。
- (默认)16000。
- 32000。
- 44100。
- 48000。
channel
音频声道数,可设置为以下值之一:
- 1:(默认)单声道。
- 2:立体声。
mode
音频数据的使用模式。详见 AgoraAudioRawFrameOperationMode。
samplesPerCall
每次回调的采样点数量,例如媒体推流时为 1024。