AudioFrame
用于描述原始音频帧数据。
C++
struct AudioFrame {
AUDIO_FRAME_TYPE type;
int samplesPerChannel;
agora::rtc::BYTES_PER_SAMPLE bytesPerSample;
int channels;
int samplesPerSec;
void* buffer;
int64_t renderTimeMs;
int avsync_type;
int64_t presentationMs;
int audioTrackNumber;
uint32_t rtpTimestamp;
};
type
音频帧的类型。详见 AUDIO_FRAME_TYPE。
samplesPerChannel
每个声道中的采样点数量。
bytesPerSample
每个采样点的字节数。对于 PCM,通常为 16 位(2 字节)。详见
BYTES_PER_SAMPLE。channels
音频通道数(立体声时为交错格式)。
- 1:单声道。
- 2:立体声。
samplesPerSec
每个声道的采样率(每秒采样数)。
buffer
输出参数,表示音频帧的数据缓冲区。当使用立体声通道时,数据为交错格式。缓冲区大小计算方式为:samples × channels × bytesPerSample。
renderTimeMs
外部音频帧的时间戳(毫秒)。你可以使用该时间戳恢复采集顺序,并在视频场景中与视频帧同步,包括使用自定义视频源的场景。
avsync_type
保留参数,供未来使用。
presentationMs
该音频帧的 PTS 时间戳,用于指示帧的原始 PTS 时间,并通过该时间戳与视频帧同步。
audioTrackNumber
音频轨道编号。
rtpTimestamp
音频帧中第一个采样点的 RTP 时间戳。