VTDecompressionSession

Struct VTDecompressionSession 

Source
pub struct VTDecompressionSession { /* private fields */ }
Available on crate feature VTDecompressionSession only.
Expand description

A reference to a Video Toolbox Decompression Session.

A decompression session supports the decompression of a sequence of video frames. The session reference is a reference-counted CF object. To create a decompression session, call VTDecompressionSessionCreate; then you can optionally configure the session using VTSessionSetProperty; then to decode frames, call VTDecompressionSessionDecodeFrame. When you are done with the session, you should call VTDecompressionSessionInvalidate to tear it down and CFRelease to release your object reference.

See also Apple’s documentation

Implementations§

Source§

impl VTDecompressionSession

Source

pub unsafe fn create( allocator: Option<&CFAllocator>, video_format_description: &CMVideoFormatDescription, video_decoder_specification: Option<&CFDictionary>, destination_image_buffer_attributes: Option<&CFDictionary>, output_callback: *const VTDecompressionOutputCallbackRecord, decompression_session_out: NonNull<*mut VTDecompressionSession>, ) -> i32

Available on crate features VTErrors and objc2-core-media and objc2-core-video only.

Creates a session for decompressing video frames.

Decompressed frames will be emitted through calls to outputCallback.

Parameter allocator: An allocator for the session. Pass NULL to use the default allocator.

Parameter videoFormatDescription: Describes the source video frames.

Parameter videoDecoderSpecification: Specifies a particular video decoder that must be used. Pass NULL to let the video toolbox choose a decoder.

Parameter destinationImageBufferAttributes: Describes requirements for emitted pixel buffers. Pass NULL to set no requirements.

Parameter outputCallback: The callback to be called with decompressed frames. Pass NULL if and only if you will be calling VTDecompressionSessionDecodeFrameWithOutputHandler for decoding frames.

Parameter decompressionSessionOut: Points to a variable to receive the new decompression session.

§Safety
  • video_decoder_specification generics must be of the correct type.
  • destination_image_buffer_attributes generics must be of the correct type.
  • output_callback must be a valid pointer or null.
  • decompression_session_out must be a valid pointer.
Source

pub unsafe fn invalidate(&self)

Tears down a decompression session.

When you are done with a decompression session you created, call VTDecompressionSessionInvalidate to tear it down and then CFRelease to release your object reference. When a decompression session’s retain count reaches zero, it is automatically invalidated, but since sessions may be retained by multiple parties, it can be hard to predict when this will happen. Calling VTDecompressionSessionInvalidate ensures a deterministic, orderly teardown.

Source§

impl VTDecompressionSession

Source

pub unsafe fn decode_frame( &self, sample_buffer: &CMSampleBuffer, decode_flags: VTDecodeFrameFlags, source_frame_ref_con: *mut c_void, info_flags_out: *mut VTDecodeInfoFlags, ) -> i32

Available on crate features VTErrors and objc2-core-media only.

Decompresses a video frame.

If an error is returned from this function, there will be no callback. Otherwise the callback provided during VTDecompressionSessionCreate will be called.

Parameter session: The decompression session.

Parameter sampleBuffer: A CMSampleBuffer containing one or more video frames.

Parameter decodeFlags: A bitfield of directives to the decompression session and decoder. The kVTDecodeFrame_EnableAsynchronousDecompression bit indicates whether the video decoder may decompress the frame asynchronously. The kVTDecodeFrame_EnableTemporalProcessing bit indicates whether the decoder may delay calls to the output callback so as to enable processing in temporal (display) order. If both flags are clear, the decompression shall complete and your output callback function will be called before VTDecompressionSessionDecodeFrame returns. If either flag is set, VTDecompressionSessionDecodeFrame may return before the output callback function is called.

Parameter sourceFrameRefCon: Your reference value for the frame. Note that if sampleBuffer contains multiple frames, the output callback function will be called multiple times with this sourceFrameRefCon.

Parameter infoFlagsOut: Points to a VTDecodeInfoFlags to receive information about the decode operation. The kVTDecodeInfo_Asynchronous bit may be set if the decode is (or was) running asynchronously. The kVTDecodeInfo_FrameDropped bit may be set if the frame was dropped (synchronously). Pass NULL if you do not want to receive this information.

§Safety
  • source_frame_ref_con must be a valid pointer or null.
  • info_flags_out must be a valid pointer or null.
Source§

impl VTDecompressionSession

Source

pub unsafe fn decode_frame_with_output_handler( &self, sample_buffer: &CMSampleBuffer, decode_flags: VTDecodeFrameFlags, info_flags_out: *mut VTDecodeInfoFlags, output_handler: VTDecompressionOutputHandler, ) -> i32

Available on crate features VTErrors and block2 and objc2-core-media and objc2-core-video only.

Decompresses a video frame.

Cannot be called with a session created with a VTDecompressionOutputCallbackRecord. If the VTDecompressionSessionDecodeFrameWithOutputHandler call returns an error, the block will not be called.

Parameter session: The decompression session.

Parameter sampleBuffer: A CMSampleBuffer containing one or more video frames.

Parameter decodeFlags: A bitfield of directives to the decompression session and decoder. The kVTDecodeFrame_EnableAsynchronousDecompression bit indicates whether the video decoder may decompress the frame asynchronously. The kVTDecodeFrame_EnableTemporalProcessing bit indicates whether the decoder may delay calls to the output callback so as to enable processing in temporal (display) order. If both flags are clear, the decompression shall complete and your output callback function will be called before VTDecompressionSessionDecodeFrame returns. If either flag is set, VTDecompressionSessionDecodeFrame may return before the output callback function is called.

Parameter infoFlagsOut: Points to a VTDecodeInfoFlags to receive information about the decode operation. The kVTDecodeInfo_Asynchronous bit may be set if the decode is (or was) running asynchronously. The kVTDecodeInfo_FrameDropped bit may be set if the frame was dropped (synchronously). Pass NULL if you do not want to receive this information.

Parameter outputHandler: The block to be called when decoding the frame is completed. If the VTDecompressionSessionDecodeFrameWithOutputHandler call returns an error, the block will not be called.

§Safety
  • info_flags_out must be a valid pointer or null.
  • output_handler must be a valid pointer.
Source

pub unsafe fn finish_delayed_frames(&self) -> i32

Directs the decompression session to emit all delayed frames.

By default, the decompression session may not delay frames indefinitely; frames may only be indefinitely delayed if the client opts in via kVTDecodeFrame_EnableTemporalProcessing. IMPORTANT NOTE: This function may return before all delayed frames are emitted. To wait for them, call VTDecompressionSessionWaitForAsynchronousFrames instead.

Source

pub unsafe fn can_accept_format_description( &self, new_format_desc: &CMFormatDescription, ) -> bool

Available on crate feature objc2-core-media only.

Indicates whether the session can decode frames with the given format description.

Some video decoders are able to accommodate minor changes in format without needing to be completely reset in a new session. This function can be used to test whether a format change is sufficiently minor.

Source

pub unsafe fn wait_for_asynchronous_frames(&self) -> i32

Waits for any and all outstanding asynchronous and delayed frames to complete, then returns.

This function automatically calls VTDecompressionSessionFinishDelayedFrames, so clients don’t have to call both.

Source

pub unsafe fn copy_black_pixel_buffer( &self, pixel_buffer_out: NonNull<*mut CVPixelBuffer>, ) -> i32

Available on crate feature objc2-core-video only.

Copies a black pixel buffer from the decompression session.

The pixel buffer is in the same format that the session is decompressing to.

Parameter session: The decompression session.

Parameter pixelBufferOut: Points to a variable to receive the copied pixel buffer.

§Safety

pixel_buffer_out must be a valid pointer.

Source§

impl VTDecompressionSession

Source

pub unsafe fn set_multi_image_callback( &self, output_multi_image_callback: VTDecompressionOutputMultiImageCallback, output_multi_image_refcon: *mut c_void, ) -> i32

Available on crate features VTErrors and objc2-core-media only.

Provides a callback capable of receiving multiple images for individual DecodeFrame requests.

The outputMultiImageCallback will be used when the video decoder outputs CMTaggedBufferGroups. When installed, outputMultiImageCallback will also be used when DecodeFrame operations fail and return a nonzero status. The original single-image callback will only be used in the case where the video decoder outputs a CVImageBuffer instead of a CMTaggedBufferGroup. Terminology note: in multi-image decompression, a single video sample (from one CMSampleBuffer) contains a single frame (with one PTS) that is decoded to produce multiple images.

§Safety
  • output_multi_image_callback must be implemented correctly.
  • output_multi_image_refcon must be a valid pointer or null.
Source§

impl VTDecompressionSession

Source

pub unsafe fn decode_frame_with_multi_image_capable_output_handler( &self, sample_buffer: &CMSampleBuffer, decode_flags: VTDecodeFrameFlags, info_flags_out: *mut VTDecodeInfoFlags, multi_image_capable_output_handler: VTDecompressionMultiImageCapableOutputHandler, ) -> i32

Available on crate features VTErrors and block2 and objc2-core-media and objc2-core-video only.

Decompresses a video frame.

Cannot be called with a session created with a VTDecompressionOutputCallbackRecord. If the VTDecompressionSessionDecodeFrameWithOutputHandler call returns an error, the block will not be called.

Parameter session: The decompression session.

Parameter sampleBuffer: A CMSampleBuffer containing one or more video frames.

Parameter decodeFlags: A bitfield of directives to the decompression session and decoder. The kVTDecodeFrame_EnableAsynchronousDecompression bit indicates whether the video decoder may decompress the frame asynchronously. The kVTDecodeFrame_EnableTemporalProcessing bit indicates whether the decoder may delay calls to the output callback so as to enable processing in temporal (display) order. If both flags are clear, the decompression shall complete and your output callback function will be called before VTDecompressionSessionDecodeFrame returns. If either flag is set, VTDecompressionSessionDecodeFrame may return before the output callback function is called.

Parameter infoFlagsOut: Points to a VTDecodeInfoFlags to receive information about the decode operation. The kVTDecodeInfo_Asynchronous bit may be set if the decode is (or was) running asynchronously. The kVTDecodeInfo_FrameDropped bit may be set if the frame was dropped (synchronously). Pass NULL if you do not want to receive this information.

Parameter multiImageCapableOutputHandler: The block to be called when decoding the frame is completed. If the VTDecompressionSessionDecodeFrameWithMultiImageCapableOutputHandler call returns an error, the block will not be called.

§Safety
  • info_flags_out must be a valid pointer or null.
  • multi_image_capable_output_handler must be a valid pointer.
Source

pub unsafe fn decode_frame_with_options( &self, sample_buffer: &CMSampleBuffer, decode_flags: VTDecodeFrameFlags, frame_options: Option<&CFDictionary>, source_frame_ref_con: *mut c_void, info_flags_out: *mut VTDecodeInfoFlags, ) -> i32

Available on crate features VTErrors and objc2-core-media only.

Decompresses a video frame.

If an error is returned from this function, there will be no callback. Otherwise the callback provided during VTDecompressionSessionCreate will be called.

Parameter session: The decompression session.

Parameter sampleBuffer: A CMSampleBuffer containing one or more video frames.

Parameter decodeFlags: A bitfield of directives to the decompression session and decoder. The kVTDecodeFrame_EnableAsynchronousDecompression bit indicates whether the video decoder may decompress the frame asynchronously. The kVTDecodeFrame_EnableTemporalProcessing bit indicates whether the decoder may delay calls to the output callback so as to enable processing in temporal (display) order. If both flags are clear, the decompression shall complete and your output callback function will be called before VTDecompressionSessionDecodeFrameWithOptions returns. If either flag is set, VTDecompressionSessionDecodeFrameWithOptions may return before the output callback function is called.

Parameter frameOptions: Contains key/value pairs specifying additional options for decoding this frame. Only keys with kVTDecodeFrameOptionKey_ prefix should be used in this dictionary.

Parameter sourceFrameRefCon: Your reference value for the frame. Note that if sampleBuffer contains multiple frames, the output callback function will be called multiple times with this sourceFrameRefCon.

Parameter infoFlagsOut: Points to a VTDecodeInfoFlags to receive information about the decode operation. The kVTDecodeInfo_Asynchronous bit may be set if the decode is (or was) running asynchronously. The kVTDecodeInfo_FrameDropped bit may be set if the frame was dropped (synchronously). Pass NULL if you do not want to receive this information.

§Safety
  • frame_options generics must be of the correct type.
  • source_frame_ref_con must be a valid pointer or null.
  • info_flags_out must be a valid pointer or null.
Source

pub unsafe fn decode_frame_with_options_and_output_handler( &self, sample_buffer: &CMSampleBuffer, decode_flags: VTDecodeFrameFlags, frame_options: Option<&CFDictionary>, info_flags_out: *mut VTDecodeInfoFlags, output_handler: VTDecompressionOutputHandler, ) -> i32

Available on crate features VTErrors and block2 and objc2-core-media and objc2-core-video only.

Decompresses a video frame.

Cannot be called with a session created with a VTDecompressionOutputCallbackRecord. If the VTDecompressionSessionDecodeFrameWithOptionsAndOutputHandler call returns an error, the block will not be called.

Parameter session: The decompression session.

Parameter sampleBuffer: A CMSampleBuffer containing one or more video frames.

Parameter decodeFlags: A bitfield of directives to the decompression session and decoder. The kVTDecodeFrame_EnableAsynchronousDecompression bit indicates whether the video decoder may decompress the frame asynchronously. The kVTDecodeFrame_EnableTemporalProcessing bit indicates whether the decoder may delay calls to the output callback so as to enable processing in temporal (display) order. If both flags are clear, the decompression shall complete and your output callback function will be called before VTDecompressionSessionDecodeFrameWithOptionsAndOutputHandler returns. If either flag is set, VTDecompressionSessionDecodeFrameWithOptionsAndOutputHandler may return before the output callback function is called.

Parameter frameOptions: Contains key/value pairs specifying additional options for decoding this frame. Only keys with kVTDecodeFrameOptionKey_ prefix should be used in this dictionary.

Parameter infoFlagsOut: Points to a VTDecodeInfoFlags to receive information about the decode operation. The kVTDecodeInfo_Asynchronous bit may be set if the decode is (or was) running asynchronously. The kVTDecodeInfo_FrameDropped bit may be set if the frame was dropped (synchronously). Pass NULL if you do not want to receive this information.

Parameter outputHandler: The block to be called when decoding the frame is completed. If the VTDecompressionSessionDecodeFrameWithOptionsAndOutputHandler call returns an error, the block will not be called.

§Safety
  • frame_options generics must be of the correct type.
  • info_flags_out must be a valid pointer or null.
  • output_handler must be a valid pointer.

Methods from Deref<Target = CFType>§

Source

pub fn downcast_ref<T>(&self) -> Option<&T>
where T: ConcreteType,

Available on crate feature VTSession only.

Attempt to downcast the type to that of type T.

This is the reference-variant. Use CFRetained::downcast if you want to convert a retained type. See also ConcreteType for more details on which types support being converted to.

Source

pub fn retain_count(&self) -> usize

Available on crate feature VTSession only.

Get the reference count of the object.

This function may be useful for debugging. You normally do not use this function otherwise.

Beware that some things (like CFNumbers, small CFStrings etc.) may not have a normal retain count for optimization purposes, and can return usize::MAX in that case.

Trait Implementations§

Source§

impl AsRef<AnyObject> for VTDecompressionSession

Source§

fn as_ref(&self) -> &AnyObject

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<CFType> for VTDecompressionSession

Source§

fn as_ref(&self) -> &CFType

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<VTDecompressionSession> for VTDecompressionSession

Source§

fn as_ref(&self) -> &Self

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Borrow<AnyObject> for VTDecompressionSession

Source§

fn borrow(&self) -> &AnyObject

Immutably borrows from an owned value. Read more
Source§

impl Borrow<CFType> for VTDecompressionSession

Source§

fn borrow(&self) -> &CFType

Immutably borrows from an owned value. Read more
Source§

impl ConcreteType for VTDecompressionSession

Source§

fn type_id() -> CFTypeID

Returns the CFTypeID for decompression sessions.

Source§

impl Debug for VTDecompressionSession

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for VTDecompressionSession

Source§

type Target = CFType

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl Hash for VTDecompressionSession

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Message for VTDecompressionSession

Source§

fn retain(&self) -> Retained<Self>
where Self: Sized,

Increment the reference count of the receiver. Read more
Source§

impl PartialEq for VTDecompressionSession

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl RefEncode for VTDecompressionSession

Source§

const ENCODING_REF: Encoding

The Objective-C type-encoding for a reference of this type. Read more
Source§

impl Type for VTDecompressionSession

Source§

fn retain(&self) -> CFRetained<Self>
where Self: Sized,

Increment the reference count of the receiver. Read more
Source§

fn as_concrete_TypeRef(&self) -> &Self

👎Deprecated: this is redundant
Helper for easier transition from the core-foundation crate.
Source§

unsafe fn wrap_under_get_rule(ptr: *const Self) -> CFRetained<Self>
where Self: Sized,

👎Deprecated: use CFRetained::retain
Helper for easier transition from the core-foundation crate. Read more
Source§

fn as_CFTypeRef(&self) -> &CFType
where Self: AsRef<CFType>,

👎Deprecated: this is redundant (CF types deref to CFType)
Helper for easier transition from the core-foundation crate.
Source§

unsafe fn wrap_under_create_rule(ptr: *const Self) -> CFRetained<Self>
where Self: Sized,

👎Deprecated: use CFRetained::from_raw
Helper for easier transition from the core-foundation crate. Read more
Source§

impl Eq for VTDecompressionSession

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> AutoreleaseSafe for T
where T: ?Sized,