录制直播音频 [英] record live streaming audio
问题描述
我实际上正在制作一个必须在ipad上播放和录制来自互联网的流媒体音频的应用。音频的流媒体已经完成,我将很快到录音部分,我不知道如何继续。
I'm actually making an app which has to play and record streaming audio from internet on ipad. The streaming of the audio is done, I will have to come to the recording part very soon and I don't have any idea on how to proceed.
你能不能给我暗示一下???理念?它必须在录制到AAC或MP3的同时播放。
Could you give me a hint??? Idea? It will have to play while simultaneously recording into AAC or MP3.
谢谢。
推荐答案
您需要使用较低级别的AudioQueue API,并使用AudioSession API设置音频会话。
You'll need to use the lower-level AudioQueue API, and use the AudioSession API to set up the audio session.
然后您需要填写 AudioStreamBasicDescription
结构并使用 AudioQueueNewInput()
创建一个新的输入队列,并包含用于处理输入的回调函数缓冲区。
Then you'll need to fill out an AudioStreamBasicDescription
struct and create a new input queue with AudioQueueNewInput()
and include your callback function for handling input buffers.
然后你需要使用 AudioQueueAllocateBuffer()
和 AudioQueueEnqueueBuffer()
。只有这样你才能准备好打电话给 AudioQueueStart()
。您还应该处理音频会话中断,并处理停止音频队列。
And then you'll need to create 3 buffers using AudioQueueAllocateBuffer()
and AudioQueueEnqueueBuffer()
. And only then will you be ready to call AudioQueueStart()
. You should also handle audio session interruptions, and handle stopping the audio queue.
这将为您提供包含未压缩的16位整数PCM音频数据的缓冲区流。你仍然需要压缩数据,这是另一种涉及使用 AudioConverter
API的蠕虫,我还没有在iPhone OS上做过,所以我不知道什么会在那里工作。
That will just get you a stream of buffers containing uncompressed 16-bit integer PCM audio data. You still need to compress the data, which is another can of worms that involves using the AudioConverter
API, which I haven't done on the iPhone OS so I don't know what will work there.
这篇关于录制直播音频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!