是否有任何iOS的高级audio队列logging服务库?
我正在尝试开发一个关于VOIP的应用程序,
是否有任何iOS的高级audio队列服务库?
因为我不擅长处理扩展名“.mm”,
使用开源将是一个更好的select。
或者有人可以给我一些提示如何从AudioQueueBufferRef获取缓冲区?
理想的方式就像一个代表:
- (void)audioRecorderDidReceivedBuffer:(Buffer) { do something for other operations }
-
更新我发现了一篇关于使用RemoteIOaudio单元的文章
也许inputcallback是我所需要的。
Overvier
- 识别audio组件(kAudioUnitType_Output / kAudioUnitSubType_RemoteIO / kAudioUnitManufacturerApple)
- 使用AudioComponentFindNext(NULL,&descriptionOfAudioComponent)获取AudioComponent,就像获得audio单元的工厂
- 使用AudioComponentInstanceNew(ourComponent,&audioUnit)创buildaudio单元的一个实例
- 启用IO进行录制,并可能使用AudioUnitSetProperty进行播放
- 描述AudioStreamBasicDescription结构中的audio格式,并使用AudioUnitSetProperty应用格式
- 使用AudioUnitSetProperty提供callback以进行录制和可能的回放
- 分配一些缓冲区
- 初始化audio单元
- 启动audio单元
- 麾
// Enable IO for recording UInt32 flag = 1; status = AudioUnitSetProperty(audioUnit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Input, kInputBus, &flag, sizeof(flag)); // Set input callback AURenderCallbackStruct callbackStruct; callbackStruct.inputProc = recordingCallback; callbackStruct.inputProcRefCon = self; status = AudioUnitSetProperty(audioUnit, kAudioOutputUnitProperty_SetInputCallback, kAudioUnitScope_Global, kInputBus, &callbackStruct, sizeof(callbackStruct)); //recordingCallback static OSStatus recordingCallback(void *inRefCon, AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList *ioData) { // TODO: Use inRefCon to access our interface object to do stuff // Then, use inNumberFrames to figure out how much data is available, and make // that much space available in buffers in an AudioBufferList. AudioBufferList *bufferList; // <- Fill this up with buffers (you will want to malloc it, as it's a dynamic-length list) // Then: // Obtain recorded samples OSStatus status; status = AudioUnitRender([audioInterface audioUnit], ioActionFlags, inTimeStamp, inBusNumber, inNumberFrames, bufferList); checkStatus(status); // Now, we have the samples we just read sitting in buffers in bufferList DoStuffWithTheRecordedAudio(bufferList); return noErr; }
这里是如何从logging中获取audio缓冲区的方法
(参考: http : //atastypixel.com/blog/using-remoteio-audio-unit/ )
static OSStatus recordingCallback(void *inRefCon, AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList *ioData) { // TODO: Use inRefCon to access our interface object to do stuff // Then, use inNumberFrames to figure out how much data is available, and make // that much space available in buffers in an AudioBufferList. AudioBufferList *bufferList; // <- Fill this up with buffers (you will want to malloc it, as it's a dynamic-length list) // Then: // Obtain recorded samples OSStatus status; status = AudioUnitRender([audioInterface audioUnit], ioActionFlags, inTimeStamp, inBusNumber, inNumberFrames, bufferList); checkStatus(status); // Now, we have the samples we just read sitting in buffers in bufferList DoStuffWithTheRecordedAudio(bufferList); return noErr; }