如何使用自定义VideoChat CaptureSession进行视频聊天?

时间:2013-08-05 09:56:06

标签: quickblox

我需要为QuickBlox视频聊天应用视频或auido过滤器。任何人都有这方面的工作示例代码吗?

如何为此目的使用setCustomVideoChatCaptureSession和processVideoChatCaptureVideoSample?

1 个答案:

答案 0 :(得分:0)

您可以在应用程序中使用自己的AVCaptureSession对象,并将所有视频数据包转发到SDK。所以SDK只会发送数据包而不进行任何处理。这是一种方式。

- (void)setup{
    // Create video Chat
    QBVideoChat *videoChat = [[QBChat instance] createAndRegisterVideoChatInstance];
    [videoChat setIsUseCustomVideoChatCaptureSession:YES];

    // Create capture session
    self.captureSession = [[AVCaptureSession alloc] init];
    //
    // ... setup capture session here   

    /*We create a serial queue to handle the processing of our frames*/
    dispatch_queue_t callbackQueue= dispatch_queue_create("cameraQueue", NULL);
    [videoCaptureOutput setSampleBufferDelegate:self queue:callbackQueue];

    /*We start the capture*/
    [self.captureSession startRunning];
}

- (void)captureOutput:(AVCaptureOutput *)captureOutput  didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection {

    // Do something with samples
    // ...

    // forward video samples to SDK
    [videoChat processVideoChatCaptureVideoSample:sampleBuffer];
}

其他方式是在接收方应用过滤器。只需覆盖view.layer setContent:您想要的方法和流程内容