我已经研究了aurio touch apple示例代码并实现了音频传输.
我也通过AVCaptureSession实现了录像.
以上功能单独完成和工作完美.
但是当我合并功能音频通过不工作,因为AVCapturesession的音频会话.
我也试图通过我从AVCaptureSession代理方法得到的音频数据.以下是我的代码:
Osstatus err = noErr;audiobufferlist audiobufferlist;CMBlockBufferRef blockBuffer;CMSampleBufferGetaudiobufferlistWithRetainedBlockBuffer(sampleBuffer,NulL,&audiobufferlist,sizeof(audiobufferlist),&blockBuffer);CMItemCount numberOfFrames = CMSampleBufferGetNumSamples(sampleBuffer); // corresponds to the number of CoreAudio audio framescurrentSampleTime += (double)numberOfFrames;AudioTimeStamp timeStamp;memset(&timeStamp,sizeof(AudioTimeStamp));timeStamp.mSampleTime = currentSampleTime;timeStamp.mFlags |= kAudioTimeStampSampleTimeValID;AudioUnitRenderActionFlags flags = 0;auriotouchAppDelegate *THIS = (auriotouchAppDelegate *)[[UIApplication sharedApplication]delegate]; err = AudioUnitRender(self.rIoUnit,&flags,&timeStamp,1,numberOfFrames,&audiobufferlist);if (err) { printf("PerformThru: error %d\n",(int)err); }
但它是给错误.请告知可以尽快做些进一步的工作.我已经研究了很多文档和许多代码,但找不到任何解决方案.请帮忙..
解决方法 这里有一些更好的错误处理代码.它返回什么错误?您可以在文档中搜索错误描述.static voID Checkerror (Osstatus error,const char *operation) { if (error == noErr) return; char str[20] = {}; // see if it appears to be a 4 char code *(UInt32*)(str + 1) = CFSwAPInt32HostToBig(error); if (isprint(str[1]) && isprint(str[2]) && isprint(str[3]) && isprint(str[4])) { str[0] = str[5] = '\''; str[6] = ''; } else { sprintf(str,"%d",(int)error); } fprintf(stderr,"Error: %s(%s)\n",operation,str); exit(1);}- (voID)yourFunction{ audiobufferlist audiobufferlist; CMBlockBufferRef blockBuffer; CMSampleBufferGetaudiobufferlistWithRetainedBlockBuffer(sampleBuffer,&blockBuffer); CMItemCount numberOfFrames = CMSampleBufferGetNumSamples(sampleBuffer); // corresponds to the number of CoreAudio audio frames currentSampleTime += (double)numberOfFrames; AudioTimeStamp timeStamp; memset(&timeStamp,sizeof(AudioTimeStamp)); timeStamp.mSampleTime = currentSampleTime; timeStamp.mFlags |= kAudioTimeStampSampleTimeValID; AudioUnitRenderActionFlags flags = 0; auriotouchAppDelegate *THIS = (auriotouchAppDelegate *)[[UIApplication sharedApplication]delegate]; Checkerror(AudioUnitRender(self.rIoUnit,&audiobufferlist),"Error with AudioUnitRender");}总结
以上是内存溢出为你收集整理的ios – 通过CMSampleBufferRef数据传输到音频输出插孔全部内容,希望文章能够帮你解决ios – 通过CMSampleBufferRef数据传输到音频输出插孔所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)