小编Tim*_*Tim的帖子

使用 AVAudioengine 播放流媒体音频 (iOS)

我想使用 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)

audio streaming playback ios avaudioengine

5
推荐指数
2
解决办法
2611
查看次数

标签 统计

audio ×1

avaudioengine ×1

ios ×1

playback ×1

streaming ×1