pub struct VTDecompressionSession { /* private fields */ }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
impl VTDecompressionSession
Sourcepub 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.
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
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_specificationgenerics must be of the correct type.destination_image_buffer_attributesgenerics must be of the correct type.output_callbackmust be a valid pointer or null.decompression_session_outmust be a valid pointer.
Sourcepub unsafe fn invalidate(&self)
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
impl VTDecompressionSession
Sourcepub 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.
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
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_conmust be a valid pointer or null.info_flags_outmust be a valid pointer or null.
Source§impl VTDecompressionSession
impl VTDecompressionSession
Sourcepub 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.
pub unsafe fn decode_frame_with_output_handler( &self, sample_buffer: &CMSampleBuffer, decode_flags: VTDecodeFrameFlags, info_flags_out: *mut VTDecodeInfoFlags, output_handler: VTDecompressionOutputHandler, ) -> i32
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_outmust be a valid pointer or null.output_handlermust be a valid pointer.
Sourcepub unsafe fn finish_delayed_frames(&self) -> i32
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.
Sourcepub unsafe fn can_accept_format_description(
&self,
new_format_desc: &CMFormatDescription,
) -> bool
Available on crate feature objc2-core-media only.
pub unsafe fn can_accept_format_description( &self, new_format_desc: &CMFormatDescription, ) -> bool
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.
Sourcepub unsafe fn wait_for_asynchronous_frames(&self) -> i32
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.
Sourcepub unsafe fn copy_black_pixel_buffer(
&self,
pixel_buffer_out: NonNull<*mut CVPixelBuffer>,
) -> i32
Available on crate feature objc2-core-video only.
pub unsafe fn copy_black_pixel_buffer( &self, pixel_buffer_out: NonNull<*mut CVPixelBuffer>, ) -> i32
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
impl VTDecompressionSession
Sourcepub 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.
pub unsafe fn set_multi_image_callback( &self, output_multi_image_callback: VTDecompressionOutputMultiImageCallback, output_multi_image_refcon: *mut c_void, ) -> i32
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_callbackmust be implemented correctly.output_multi_image_refconmust be a valid pointer or null.
Source§impl VTDecompressionSession
impl VTDecompressionSession
Sourcepub 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.
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
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_outmust be a valid pointer or null.multi_image_capable_output_handlermust be a valid pointer.
Sourcepub 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.
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
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_optionsgenerics must be of the correct type.source_frame_ref_conmust be a valid pointer or null.info_flags_outmust be a valid pointer or null.
Sourcepub 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.
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
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_optionsgenerics must be of the correct type.info_flags_outmust be a valid pointer or null.output_handlermust be a valid pointer.
Methods from Deref<Target = CFType>§
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: ConcreteType,
Available on crate feature VTSession only.
pub fn downcast_ref<T>(&self) -> Option<&T>where
T: ConcreteType,
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.
Sourcepub fn retain_count(&self) -> usize
Available on crate feature VTSession only.
pub fn retain_count(&self) -> usize
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
impl AsRef<AnyObject> for VTDecompressionSession
Source§impl AsRef<CFType> for VTDecompressionSession
impl AsRef<CFType> for VTDecompressionSession
Source§impl Borrow<AnyObject> for VTDecompressionSession
impl Borrow<AnyObject> for VTDecompressionSession
Source§impl Borrow<CFType> for VTDecompressionSession
impl Borrow<CFType> for VTDecompressionSession
Source§impl Debug for VTDecompressionSession
impl Debug for VTDecompressionSession
Source§impl Deref for VTDecompressionSession
impl Deref for VTDecompressionSession
Source§impl Hash for VTDecompressionSession
impl Hash for VTDecompressionSession
Source§impl Message for VTDecompressionSession
impl Message for VTDecompressionSession
Source§impl PartialEq for VTDecompressionSession
impl PartialEq for VTDecompressionSession
Source§impl RefEncode for VTDecompressionSession
impl RefEncode for VTDecompressionSession
Source§const ENCODING_REF: Encoding
const ENCODING_REF: Encoding
Source§impl Type for VTDecompressionSession
impl Type for VTDecompressionSession
Source§fn retain(&self) -> CFRetained<Self>where
Self: Sized,
fn retain(&self) -> CFRetained<Self>where
Self: Sized,
Source§fn as_concrete_TypeRef(&self) -> &Self
fn as_concrete_TypeRef(&self) -> &Self
core-foundation crate.Source§unsafe fn wrap_under_get_rule(ptr: *const Self) -> CFRetained<Self>where
Self: Sized,
unsafe fn wrap_under_get_rule(ptr: *const Self) -> CFRetained<Self>where
Self: Sized,
core-foundation crate. Read moreSource§fn as_CFTypeRef(&self) -> &CFType
fn as_CFTypeRef(&self) -> &CFType
core-foundation crate.Source§unsafe fn wrap_under_create_rule(ptr: *const Self) -> CFRetained<Self>where
Self: Sized,
unsafe fn wrap_under_create_rule(ptr: *const Self) -> CFRetained<Self>where
Self: Sized,
core-foundation crate. Read more