iphone . processing frames that are being recorded by the camera
<p>I have this app the records video and I need to fire a method every time a frame is grabbed. After banging my head on the wall, I decided to try the following: create a dispatch queue, as I would grab a video from the output, just to have a method called when the frame is recorded by the camera.</p>

<p>I am trying to understand a section of code created by Apple to record videos to figure out how I should add the dispatch queue. This is the apple code and the section marked between asterisks is what I have added, in order to create the queue. It compiles without errors, but <strong>captureOutput: didOutputSampleBuffer: fromConnection:</strong> is never called.</p>

<pre><code>- (BOOL) setupSessionWithPreset:(NSString *)sessionPreset error:(NSError **)error
{
    BOOL success = NO;

    // Init the device inputs
    AVCaptureDeviceInput *videoInput = [[[AVCaptureDeviceInput alloc] initWithDevice:[self backFacingCamera] error:error] autorelease];
    [self setVideoInput:videoInput]; // stash this for later use if we need to switch cameras

    AVCaptureDeviceInput *audioInput = [[[AVCaptureDeviceInput alloc] initWithDevice:[self audioDevice] error:error] autorelease];
    [self setAudioInput:audioInput];

    AVCaptureMovieFileOutput *movieFileOutput = [[AVCaptureMovieFileOutput alloc] init];
    [self setMovieFileOutput:movieFileOutput];
    [movieFileOutput release];


    // Setup and start the capture session
    AVCaptureSession *session = [[AVCaptureSession alloc] init];

    if ([session canAddInput:videoInput]) {
        [session addInput:videoInput];
    }
    if ([session canAddInput:audioInput]) {
        [session addInput:audioInput];
    }
    if ([session canAddOutput:movieFileOutput]) {
        [session addOutput:movieFileOutput];
    }

    [session setSessionPreset:sessionPreset];


    //  I added this *****************
    dispatch_queue_t queue = dispatch_queue_create("myqueue", NULL);
    [[self videoDataOutput] setSampleBufferDelegate:self queue:queue];
    dispatch_release(queue);
    // ******************** end of my code      

    [session startRunning];
    [self setSession:session];
    [session release];
    success = YES;
    return success;
}
</code></pre>

<p>What I need is just a method where I can process every frame that is being recorded.</p>

<p>thanks</p>
