我想使用 iOS 在 iOS 上流式传输音频AVAudioEngine。目前我不知道该怎么做。
我从网络获取 RTP 数据并想要播放此音频数据AVAudioEngine。
我正在使用iOSNetwork.Framework接收网络数据。然后,我对语音数据进行解码,现在想使用 来播放它AVAudioEngine。
这是我的接收代码:
connection.receiveMessage { (data, context, isComplete, error) in
if isComplete {
// decode the raw network data with Audio codec G711/G722
let decodedData = AudioDecoder.decode(enc: data, frames: 160)
// create PCMBuffer for audio data for playback
let format = AVAudioFormat(standardFormatWithSampleRate: 8000, channels: 1)
let buffer = AVAudioPCMBuffer(pcmFormat: format!, frameCapacity: 160)!
buffer.frameLength = buffer.frameCapacity
// TODO: now I have to copy the decodedData …Run Code Online (Sandbox Code Playgroud)