AVCaptureVideoDataOutputSampleBufferDelegate

Trait AVCaptureVideoDataOutputSampleBufferDelegate 

Source
pub unsafe trait AVCaptureVideoDataOutputSampleBufferDelegate: NSObjectProtocol {
    // Provided methods
    unsafe fn captureOutput_didOutputSampleBuffer_fromConnection(
        &self,
        output: &AVCaptureOutput,
        sample_buffer: &CMSampleBuffer,
        connection: &AVCaptureConnection,
    )
       where Self: Sized + Message { ... }
    unsafe fn captureOutput_didDropSampleBuffer_fromConnection(
        &self,
        output: &AVCaptureOutput,
        sample_buffer: &CMSampleBuffer,
        connection: &AVCaptureConnection,
    )
       where Self: Sized + Message { ... }
}
Available on crate feature AVCaptureVideoDataOutput only.
Expand description

Defines an interface for delegates of AVCaptureVideoDataOutput to receive captured video sample buffers and be notified of late sample buffers that were dropped.

See also Apple’s documentation

Provided Methods§

Source

unsafe fn captureOutput_didOutputSampleBuffer_fromConnection( &self, output: &AVCaptureOutput, sample_buffer: &CMSampleBuffer, connection: &AVCaptureConnection, )
where Self: Sized + Message,

Available on crate features AVCaptureOutputBase and AVCaptureSession and objc2-core-media only.

Called whenever an AVCaptureVideoDataOutput instance outputs a new video frame.

Parameter output: The AVCaptureVideoDataOutput instance that output the frame.

Parameter sampleBuffer: A CMSampleBuffer object containing the video frame data and additional information about the frame, such as its format and presentation time.

Parameter connection: The AVCaptureConnection from which the video was received.

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 will be called on the dispatch queue specified by the output’s sampleBufferCallbackQueue property. This method is called periodically, so it must be efficient to prevent capture performance problems, including dropped frames.

Clients that need to reference the CMSampleBuffer object outside of the scope of this method must CFRetain it and then CFRelease it when they are finished with it.

Note that 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 calling CFRelease on the sample buffer if it was previously retained so that the memory it references can be reused.

Source

unsafe fn captureOutput_didDropSampleBuffer_fromConnection( &self, output: &AVCaptureOutput, sample_buffer: &CMSampleBuffer, connection: &AVCaptureConnection, )
where Self: Sized + Message,

Available on crate features AVCaptureOutputBase and AVCaptureSession and objc2-core-media only.

Called once for each frame that is discarded.

Parameter output: The AVCaptureVideoDataOutput instance that dropped the frame.

Parameter sampleBuffer: A CMSampleBuffer object containing information about the dropped frame, such as its format and presentation time. This sample buffer will contain none of the original video data.

Parameter connection: The AVCaptureConnection from which the dropped video frame was received.

Delegates receive this message whenever a video frame is dropped. This method is called once for each dropped frame. The CMSampleBuffer object passed to this delegate method will contain metadata about the dropped video frame, such as its duration and presentation time stamp, but will contain no actual video data. On iOS, Included in the sample buffer attachments is the kCMSampleBufferAttachmentKey_DroppedFrameReason, which indicates why the frame was dropped. This method will be called on the dispatch queue specified by the output’s sampleBufferCallbackQueue property. Because this method will be 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.

Trait Implementations§

Source§

impl ProtocolType for dyn AVCaptureVideoDataOutputSampleBufferDelegate

Source§

const NAME: &'static str = "AVCaptureVideoDataOutputSampleBufferDelegate"

The name of the Objective-C protocol that this type represents. Read more
Source§

fn protocol() -> Option<&'static AnyProtocol>

Get a reference to the Objective-C protocol object that this type represents. Read more
Source§

impl<T> ImplementedBy<T> for dyn AVCaptureVideoDataOutputSampleBufferDelegate

Implementations on Foreign Types§

Source§

impl<T> AVCaptureVideoDataOutputSampleBufferDelegate for ProtocolObject<T>

Implementors§