title: How to process a GPUImageVideoCamera as CMSampleBufferRef for QuickBlox SDK
body: <p>I am currently using the VideoChat functionality of Quickblox SDK. Following the Custom Capture Session tutorial, I am able to create a custom video chat session between two users. However, I would like to apply filters to the stream before sending/forwarding the stream to quickblox.</p>
  
  <p>Using an AVCaptureSession I create a serial queue to handle the processing of the frames with the following code:</p>
  
  <pre><code>dispatch_queue_t callbackQueue= dispatch_queue_create("cameraQueue", NULL);
  [videoCaptureOutput setSampleBufferDelegate:self queue:callbackQueue];
  </code></pre>
  
  <p>Which then calls the function: </p>
  
  <pre><code>- (void)captureOutput:(AVCaptureOutput *)captureOutput  didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection {
  [self.videoChat processVideoChatCaptureVideoSample:sampleBuffer];
  }
  </code></pre>
  
  <p>Where 'self.videoChat' is of type QBVideoChat. 
  I would like to take the output of 'GPUImageVideoCamera' and pass it through a filter, and finally forward the processed video to quickblox.</p>
  
  <p>So far I can get the filter working by adding a target to the 'GPUImageVideoCamera', then adding a 'GPUImageView' as the target to the processed video as so:</p>
  
  <pre><code>[_liveVideo addTarget:myFilter];
  [myFilter addTarget:_ImageView];
  [_liveVideo startCameraCapture];
  </code></pre>
  
  <p>So, in conclusion, I cannot seem to figure out how to get the output from 'myFilter' forwarded to QuickBlox videoChat and was hoping someone can point me in the right direction. I hope this question was descriptive enough, and thanks in advance. </p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Okay so when I asked the above question, for some reason when I set the GPUImageVideoCamera delegate to self, it wasn't working. However I gutted my code, down to the basics and now have the delegate firing on every frame. However, inside the function</p>
  
  <pre><code>-(void) WillOutputSampleBuffer (CMSampleBufferRef)sampleBuffer 
  </code></pre>
  
  <p>I call</p>
  
  <pre><code>[self.videoChat processVideoChatCaptureVideoSample:sampleBuffer];
  </code></pre>
  
  <p>but my opponent still sees a blank screen. I am positive that the GPUImageVideoCamera is working because I am able to initialize a GPUImage and add it as a target to the camera and add the GPUImage as a sublayer to my viewController. Any and all advice would be greatly appreciated. Thanks.</p>