我在我的应用程序中实现了QuickBlox并通过Mic工作进行了音频聊天但是我想从音频单元发送一个AudioBuffer渲染回调mp3。我认为这与格式有关,所以我将音频播放器的格式设置为:
AudioStreamBasicDescription inputASBL = {0};
inputASBL.mSampleRate = static_cast<Float64>(8000);
inputASBL.mFormatID = kAudioFormatLinearPCM;
inputASBL.mFormatFlags = kAudioFormatFlagIsPacked | kAudioFormatFlagIsSignedInteger,
inputASBL.mFramesPerPacket = 1;
inputASBL.mChannelsPerFrame = 2;
inputASBL.mBitsPerChannel = sizeof(short) * 8;
inputASBL.mBytesPerPacket = sizeof(short) * 2;
inputASBL.mBytesPerFrame = sizeof(short) * 2;
inputASBL.mReserved = 0;
[ioNode setStreamFormat:&inputASBL scope:kAudioUnitScope_Input bus:0];
我发送AudioBuffer像这样:
OSStatus MyAURenderCallback(void *inRefCon,
AudioUnitRenderActionFlags *actionFlags,
const AudioTimeStamp *inTimeStamp,
UInt32 inBusNumber,
UInt32 inNumberFrames,
AudioBufferList *ioData) {
AudioUnit mixerUnit = mixerNode.audioUnit;
AudioUnitRender(mixerUnit,actionFlags,inTimeStamp,inBusNumber,inNumberFrames,ioData);
if(isStreaming){
AudioBufferList ab = *ioData;
[[AppDelegate del].videoChat processVideoChatCaptureAudioBuffer:ab.mBuffers[0]];
}
//renderCoundt++;
return noErr;
}
接收设备无法获取任何内容,但我知道它设置正确,因为当我关闭麦克风时,它可以正常播放。