当前位置:编程学习 > wap >>

视频聊天中的语音聊天 AVCaptureAudioDataOutput

小弟最近在做一个视频聊天的应用,我用AVCaptureVidioDataOutput获取到了视频数据,并把数据转成图片通过socket发送到服务器了,在客户端也已经能接收到数据可以显示了。但是现在这个语音发送我一点也不知道该怎么解决,先把数据转成nsdata我是这么做的 这个是我写的一个小例子 把数据放到array中然后在播放
- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection
{
   // NSLog(@"CaptureOutPut~~~~~~~~~");
    AudioBufferList audioBufferList;
    NSMutableData *data = [[NSMutableData alloc] init];
    CMBlockBufferRef blockBuffer;
    CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer(sampleBuffer, NULL, &audioBufferList, sizeof(audioBufferList), NULL, NULL, 0, &blockBuffer);
    
    for (int y = 0; y < audioBufferList.mNumberBuffers; y++) {
        AudioBuffer audioBuffer = audioBufferList.mBuffers[y];
        Float32 *frame = (Float32 *)audioBuffer.mData;
        [data appendBytes:frame length:audioBuffer.mDataByteSize];
    }
    
    CFRelease(blockBuffer);
    blockBuffer = NULL;
    
    if (_isRecording) {
        NSLog(@"CaptureOutPut~~~~~~~~~%d",[data length]);
        [_audioDataArr addObject:data];
    }
    
}

然后播放我是看到论坛里面的CBBopenALsound这个类 但是还是不能播放 没有声音 有没有人能帮我解决这个问题啊,不胜感激
本人qq523031393
/Users/Yalin/Desktop/TEST/AudioTest.zip
话题是不是不能发源码呀 如果需要源码 告诉我吧 --------------------编程问答-------------------- 试试 Game Kit 的 Adding Voice Chat 一节的例子 --------------------编程问答--------------------
引用 1 楼 ybh37 的回复:
试试 Game Kit 的 Adding Voice Chat 一节的例子


game kit 不是蓝牙语音聊天吗,这个我知道。小弟现在是想用tcp协议 通过服务器实现的语音聊天,这个不太适合啊! --------------------编程问答-------------------- 代码发过来look look 再说
补充:移动开发 ,  iPhone
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,