Struct CMSampleBuffer
pub struct CMSampleBuffer(/* private fields */);Expand description
Re-exported CMSampleBuffer — same opaque-pointer wrapper used across
the doom-fish suite.
Owned reference to a CoreMedia CMSampleBufferRef.
Cloning increments the underlying refcount via CFRetain; dropping
releases via CFRelease. The pointer is opaque to safe Rust — accessor
methods on this type are the only sanctioned way to inspect it.
Implementations§
§impl CMSampleBuffer
impl CMSampleBuffer
pub const unsafe fn from_ptr(ptr: *mut c_void) -> CMSampleBuffer
pub const unsafe fn from_ptr(ptr: *mut c_void) -> CMSampleBuffer
Wrap a raw CMSampleBufferRef without bumping its refcount or
checking for NULL.
§Safety
The caller must ensure ptr is a valid CMSampleBufferRef retained
at +1 (the wrapper will release on drop). For NULL-tolerant
construction prefer Self::from_raw.
pub fn from_raw(ptr: *mut c_void) -> Option<CMSampleBuffer>
pub fn from_raw(ptr: *mut c_void) -> Option<CMSampleBuffer>
Wrap a raw CMSampleBufferRef without bumping its refcount.
Use this when the caller has just received a +1 retained pointer
(e.g. a Swift Unmanaged.passRetained(...).toOpaque()). The
returned CMSampleBuffer will release the pointer when dropped.
Returns None for a NULL pointer.
pub unsafe fn from_raw_retained(ptr: *mut c_void) -> Option<CMSampleBuffer>
pub unsafe fn from_raw_retained(ptr: *mut c_void) -> Option<CMSampleBuffer>
Wrap a raw CMSampleBufferRef, calling CFRetain to bump its
refcount before taking ownership.
Use this when the caller holds a borrowed (non-owning) reference and wants to take ownership without affecting the source.
§Safety
ptr must be a valid CMSampleBufferRef (or NULL). Passing a
dangling or wrong-type pointer is undefined behaviour.
pub const fn as_ptr(&self) -> *mut c_void
pub const fn as_ptr(&self) -> *mut c_void
Borrow the underlying CMSampleBufferRef for hand-off to other
Apple bindings without changing its refcount. The pointer remains
valid for the lifetime of self.
pub fn data_is_ready(&self) -> bool
pub fn data_is_ready(&self) -> bool
Whether the sample buffer’s data is ready for consumption.
pub fn num_samples(&self) -> i64
pub fn num_samples(&self) -> i64
Number of samples carried by this buffer (1 for video, N for audio).
pub fn presentation_timestamp(&self) -> CMTime
pub fn presentation_timestamp(&self) -> CMTime
Presentation timestamp of the first sample.
Returns CMTime::INVALID if the buffer has no PTS.
pub fn decode_timestamp(&self) -> CMTime
pub fn decode_timestamp(&self) -> CMTime
Decode timestamp of the first sample (matters when there’s B-frame reordering between PTS and DTS).
pub fn data_buffer(&self) -> Option<CMBlockBuffer>
pub fn data_buffer(&self) -> Option<CMBlockBuffer>
The attached CMBlockBuffer holding the encoded sample data, if
the sample buffer is data-bearing (as opposed to image-bearing).
Video frames from VTCompressionSession always have a data buffer
(the encoded NAL units / ProRes frame data). Decoded video frames
from a capture pipeline typically use an image buffer instead — see
Self::image_buffer_ptr.
pub fn format_description(&self) -> Option<CMFormatDescription>
pub fn format_description(&self) -> Option<CMFormatDescription>
Format description (codec, dimensions, audio params, …) attached to this sample buffer.
pub fn image_buffer_ptr(&self) -> *mut c_void
pub fn image_buffer_ptr(&self) -> *mut c_void
Raw CVImageBufferRef if the sample is image-bearing (decoded
video frames from a capture pipeline). Use a CV crate’s wrapper to
turn this into a safe CVPixelBuffer.
Returns NULL for sample buffers that don’t carry an image buffer
(e.g. compressed video from VideoToolbox, audio samples).
Trait Implementations§
Source§impl CMSampleBufferDataBufferExt for CMSampleBuffer
impl CMSampleBufferDataBufferExt for CMSampleBuffer
fn data_buffer_local(&self) -> Option<CMBlockBuffer>
Source§impl CMSampleBufferExt for CMSampleBuffer
impl CMSampleBufferExt for CMSampleBuffer
Source§fn create_for_image_buffer(
image_buffer: &CVPixelBuffer,
presentation_time: CMTime,
duration: CMTime,
) -> Result<Self, i32>
fn create_for_image_buffer( image_buffer: &CVPixelBuffer, presentation_time: CMTime, duration: CMTime, ) -> Result<Self, i32>
CVPixelBuffer. Read moreSource§fn image_buffer(&self) -> Option<CVPixelBuffer>
fn image_buffer(&self) -> Option<CVPixelBuffer>
CVPixelBuffer, if any.Source§fn audio_buffer_list(&self) -> Option<AudioBufferList>
fn audio_buffer_list(&self) -> Option<AudioBufferList>
AudioBufferList, if any.Source§fn output_presentation_timestamp(&self) -> CMTime
fn output_presentation_timestamp(&self) -> CMTime
Source§fn set_output_presentation_timestamp(&self, time: CMTime) -> Result<(), i32>
fn set_output_presentation_timestamp(&self, time: CMTime) -> Result<(), i32>
Source§fn sample_size(&self, index: usize) -> usize
fn sample_size(&self, index: usize) -> usize
index in bytes.Source§fn total_sample_size(&self) -> usize
fn total_sample_size(&self) -> usize
Source§fn is_data_ready(&self) -> bool
fn is_data_ready(&self) -> bool
Source§fn make_data_ready(&self) -> Result<(), i32>
fn make_data_ready(&self) -> Result<(), i32>
Source§fn sample_timing_info(&self, index: usize) -> Result<CMSampleTimingInfo, i32>
fn sample_timing_info(&self, index: usize) -> Result<CMSampleTimingInfo, i32>
index. Read moreSource§impl CMSampleBufferSCExt for CMSampleBuffer
impl CMSampleBufferSCExt for CMSampleBuffer
Source§fn frame_status(&self) -> Option<SCFrameStatus>
fn frame_status(&self) -> Option<SCFrameStatus>
SCStreamFrameInfo.status attachment.Source§fn display_time(&self) -> Option<u64>
fn display_time(&self) -> Option<u64>
SCStreamFrameInfo.displayTime attachment.Source§fn scale_factor(&self) -> Option<f64>
fn scale_factor(&self) -> Option<f64>
SCStreamFrameInfo.scaleFactor attachment.Source§fn content_scale(&self) -> Option<f64>
fn content_scale(&self) -> Option<f64>
SCStreamFrameInfo.contentScale attachment.Source§fn content_rect(&self) -> Option<CGRect>
fn content_rect(&self) -> Option<CGRect>
SCStreamFrameInfo.contentRect attachment.Source§fn bounding_rect(&self) -> Option<CGRect>
fn bounding_rect(&self) -> Option<CGRect>
SCStreamFrameInfo.boundingRect attachment.Source§fn screen_rect(&self) -> Option<CGRect>
fn screen_rect(&self) -> Option<CGRect>
SCStreamFrameInfo.screenRect attachment.Source§fn presenter_overlay_content_rect(&self) -> Option<CGRect>
fn presenter_overlay_content_rect(&self) -> Option<CGRect>
SCStreamFrameInfo.presenterOverlayContentRect attachment.Source§fn frame_info(&self) -> Option<FrameInfo>
fn frame_info(&self) -> Option<FrameInfo>
SCStreamFrameInfo attachment in a single
FFI round-trip.§impl Clone for CMSampleBuffer
impl Clone for CMSampleBuffer
§fn clone(&self) -> CMSampleBuffer
fn clone(&self) -> CMSampleBuffer
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more