How to use setCustomVideoChatCaptureSession for video chat?

左心房为你撑大大i 提交于 2020-02-06 23:52:09

问题


I need to apply video or auido filter for QuickBlox video chat. Anyone has a working sample code for this?

How to use setCustomVideoChatCaptureSession and processVideoChatCaptureVideoSample for this purpose?


回答1:


you can use own AVCaptureSession object in your application and forward all video packets to SDK. So SDK will just send packet without any processing. This is one way.

- (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];
}

Other way is to apply filters on receiver side. Just override view.layer setContent: method and process content as you want



来源:https://stackoverflow.com/questions/18055298/how-to-use-setcustomvideochatcapturesession-for-video-chat

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!