AgoraAudioParams
- macOS
更新时间
设置音频数据格式。
@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),可设置为以下值之一:
|
channel | 音频声道数,可设置为以下值之一:
|
mode | 音频数据的使用模式。详见 AgoraAudioRawFrameOperationMode。 |
samplesPerCall | 每次回调的采样点数量,例如媒体推流时为 1024。 |