Protocol: AVCaptureVideoDataOutputSampleBufferDelegate
Overview
This protocol defines an interface for delegates of an AVCaptureVideoDataOutput object to receive captured video sample buffers and be notified of late sample buffers that were dropped.Notifies the delegate that a video frame was discarded.Notifies the delegate that a new video frame was written.
Instance Method Summary (collapse)
-
- captureOutput:didDropSampleBuffer:fromConnection:
Notifies the delegate that a video frame was discarded.
-
- captureOutput:didOutputSampleBuffer:fromConnection:
Notifies the delegate that a new video frame was written.
Instance Method Details
- (Object) captureOutput(captureOutput, didDropSampleBuffer:sampleBuffer, fromConnection:connection)
Notifies the delegate that a video frame was discarded. Delegates receive this message whenever a late video frame is dropped. This method is called once for each dropped frame. It is called on the dispatch queue specified by the output’s sampleBufferCallbackQueue property.Because this method is called on the same dispatch queue that is responsible for outputting video frames, it must be efficient to prevent further capture performance problems, such as additional dropped video frames.
- (Object) captureOutput(captureOutput, didOutputSampleBuffer:sampleBuffer, fromConnection:connection)
Notifies the delegate that a new video frame was written. Delegates receive this message whenever the output captures and outputs a new video frame, decoding or re-encoding it as specified by its videoSettings property. Delegates can use the provided video frame in conjunction with other APIs for further processing.This method is called on the dispatch queue specified by the output’s sampleBufferCallbackQueue property. It is called periodically, so it must be efficient to prevent capture performance problems, including dropped frames.If you need to reference the CMSampleBuffer object outside of the scope of this method, you must CFRetain it and then CFRelease it when you are finished with it.To maintain optimal performance, some sample buffers directly reference pools of memory that may need to be reused by the device system and other capture inputs. This is frequently the case for uncompressed device native capture where memory blocks are copied as little as possible. If multiple sample buffers reference such pools of memory for too long, inputs will no longer be able to copy new samples into memory and those samples will be dropped.If your application is causing samples to be dropped by retaining the provided CMSampleBuffer objects for too long, but it needs access to the sample data for a long period of time, consider copying the data into a new buffer and then releasing the sample buffer (if it was previously retained) so that the memory it references can be reused.