CMBufferQueue

Struct CMBufferQueue 

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

A reference to a CMBufferQueue, a CF object that implements a queue of timed buffers.

See also Apple’s documentation

Implementations§

Source§

impl CMBufferQueue

Source

pub unsafe fn callbacks_for_unsorted_sample_buffers() -> NonNull<CMBufferCallbacks>

Available on crate feature CMTime only.

Returns a pointer to a callback struct for unsorted CMSampleBuffers, provided as a convenience.

Source

pub unsafe fn callbacks_for_sample_buffers_sorted_by_output_pts() -> NonNull<CMBufferCallbacks>

Available on crate feature CMTime only.

Returns a pointer to a callback struct for CMSampleBuffers sorted by output presentation timestamp, provided as a convenience.

Source

pub unsafe fn create( allocator: Option<&CFAllocator>, capacity: CMItemCount, callbacks: NonNull<CMBufferCallbacks>, queue_out: NonNull<*mut CMBufferQueue>, ) -> i32

Available on crate features CMBase and CMTime only.

Creates a CMBufferQueue object.

On return, the caller owns the returned CMBufferQueue, and must release it when done with it.

§Safety
  • callbacks must be a valid pointer.
  • queue_out must be a valid pointer.
Source

pub unsafe fn create_with_handlers( allocator: Option<&CFAllocator>, capacity: CMItemCount, handlers: NonNull<CMBufferHandlers>, queue_out: NonNull<*mut CMBufferQueue>, ) -> i32

Available on crate features CMBase and CMTime and block2 only.

Creates a CMBufferQueue object.

On return, the caller owns the returned CMBufferQueue, and must release it when done with it.

§Safety
  • handlers must be a valid pointer.
  • queue_out must be a valid pointer.
Source§

impl CMBufferQueue

Source

pub unsafe fn enqueue(&self, buf: &CMBuffer) -> i32

Enqueues a buffer onto a CMBufferQueue.

The buffer is retained by the queue, so the client can safely release the buffer if it has no further use for it. If the compare callback is non-NULL, this API performs an insertion sort using that compare operation. If the validation callback is non-NULL, this API calls it; if it returns a nonzero OSStatus, the buffer will not be enqueued and this API will return the same error OSStatus.

§Safety

buf should be of the correct type.

Source

pub unsafe fn dequeue_and_retain(&self) -> Option<CFRetained<CMBuffer>>

Dequeues a buffer from a CMBufferQueue.

The buffer is released by the queue, but it is also retained for the client. Buffer ownership is thereby transferred from queue to client. The client need not retain the buffer, but is responsible to release it when done with it.

Returns: The dequeued buffer. Will be NULL if the queue is empty.

Source

pub unsafe fn dequeue_if_data_ready_and_retain( &self, ) -> Option<CFRetained<CMBuffer>>

Dequeues a buffer from a CMBufferQueue if it is ready.

The buffer is released by the queue, but it is also retained for the client. Buffer ownership is thereby transferred from queue to client. The client need not retain the buffer, but is responsible to release it when done with it.

Returns: The dequeued buffer. Will be NULL if the queue is empty, or if the buffer to be dequeued is not yet ready.

Source

pub unsafe fn get_head(&self) -> Option<CFRetained<CMBuffer>>

👎Deprecated

Retrieves the next-to-dequeue buffer from a CMBufferQueue but leaves it in the queue.

This follows CF “Get” semantics – it does not retain the returned buffer. Note that with non-FIFO queues it’s not guaranteed that the next dequeue will return this particular buffer (if an intervening Enqueue adds a buffer that will dequeue next). This function is deprecated in favor of CMBufferQueueCopyHead() which returns a retained buffer. When adopting CMBufferQueueCopyHead(), existing CFRetain() call on the buffer returned from this function must be removed.

Returns: The buffer. Will be NULL if the queue is empty.

Source

pub unsafe fn head(&self) -> Option<CFRetained<CMBuffer>>

Retrieves & retains the next-to-dequeue buffer from a CMBufferQueue but leaves it in the queue.

This follows CF “Copy” semantics – it retains the returned buffer. Note that with non-FIFO queues it’s not guaranteed that the next dequeue will return this particular buffer (if an intervening Enqueue adds a buffer that will dequeue next).

Returns: The retained buffer. Will be NULL if the queue is empty.

Source

pub unsafe fn is_empty(&self) -> bool

Returns whether or not a CMBufferQueue is empty.

Returns: Whether or not the CMBufferQueue is empty. If queue is NULL, true is returned.

Source

pub unsafe fn mark_end_of_data(&self) -> i32

Marks a CMBufferQueue with EOD.

All subsequent Enqueues will be rejected until CMBufferQueueReset is called. Subsequent Dequeues will succeed as long as the queue is not empty.

Source

pub unsafe fn contains_end_of_data(&self) -> bool

Returns whether or not a CMBufferQueue has been marked with EOD.

Returns: Whether or not the CMBufferQueue has been marked with EOD. If queue is NULL, true is returned (a NULL queue is considered to be empty, and permanently at EOD).

Source

pub unsafe fn is_at_end_of_data(&self) -> bool

Returns whether or not a CMBufferQueue has been marked with EOD, and is now empty.

Returns: Whether or not the CMBufferQueue has been marked with EOD, and is now empty. If queue is NULL, true is returned (a NULL queue is considered to be empty, and permanently at EOD).

Source

pub unsafe fn reset(&self) -> i32

Resets a CMBufferQueue. Empties the queue, and clears any EOD mark.

All buffers in the queue are released. Triggers are not removed, however, and will be called appropriately as the queue duration goes to zero.

Source

pub unsafe fn reset_with_callback( &self, callback: unsafe extern "C-unwind" fn(NonNull<CMBuffer>, *mut c_void), refcon: *mut c_void, ) -> i32

Calls a function for every buffer in a queue, then resets the queue.

§Safety
  • callback must be implemented correctly.
  • refcon must be a valid pointer or null.
Source

pub unsafe fn buffer_count(&self) -> CMItemCount

Available on crate feature CMBase only.

Gets the number of buffers in the queue.

Source

pub unsafe fn duration(&self) -> CMTime

Available on crate feature CMTime only.

Gets the duration of a CMBufferQueue.

The duration of the CMBufferQueue is the sum of all the individual buffer durations, as reported by the getDuration callback (provided to CMBufferQueueCreate). If there are no buffers in the queue, kCMTimeZero will be returned.

Source

pub unsafe fn min_decode_time_stamp(&self) -> CMTime

Available on crate feature CMTime only.

Gets the earliest decode timestamp of a CMBufferQueue.

The search for earliest decode timstamp is performed in this API. If you know your queue is in decode order, GetFirstDecodeTimeStamp is a faster alternative. If the getDecodeTimeStamp callback is NULL, kCMTimeInvalid will be returned.

Source

pub unsafe fn first_decode_time_stamp(&self) -> CMTime

Available on crate feature CMTime only.

Gets the decode timestamp of the first buffer in a CMBufferQueue.

This API is is a faster alternative to GetMinDecodeTimeStamp, but only gives the same answer if your queue is in decode order. If the getDecodeTimeStamp callback is NULL, kCMTimeInvalid will be returned.

Source

pub unsafe fn min_presentation_time_stamp(&self) -> CMTime

Available on crate feature CMTime only.

Gets the earliest presentation timestamp of a CMBufferQueue.

The search for earliest presentation timstamp is performed in this API. If you know your queue is sorted by presentation time, GetFirstPresentationTimeStamp is a faster alternative. If the getPresentationTimeStamp callback is NULL, kCMTimeInvalid will be returned.

Source

pub unsafe fn first_presentation_time_stamp(&self) -> CMTime

Available on crate feature CMTime only.

Gets the presentation timestamp of the first buffer in a CMBufferQueue.

This API is is a faster alternative to GetMinPresentationTimeStamp, but only works if you know your queue is sorted by presentation timestamp. If the getPresentationTimeStamp callback is NULL, kCMTimeInvalid will be returned.

Source

pub unsafe fn max_presentation_time_stamp(&self) -> CMTime

Available on crate feature CMTime only.

Gets the greatest presentation timestamp of a CMBufferQueue.

If the getPresentationTimeStamp callback is NULL, kCMTimeInvalid will be returned.

Source

pub unsafe fn end_presentation_time_stamp(&self) -> CMTime

Available on crate feature CMTime only.

Gets the greatest end presentation timestamp of a CMBufferQueue.

This is the maximum end time (PTS + duration) of buffers in the queue. If the getPresentationTimeStamp callback is NULL, kCMTimeInvalid will be returned.

Source

pub unsafe fn total_size(&self) -> usize

Gets the total size of all sample buffers of a CMBufferQueue.

The total size of the CMBufferQueue is the sum of all the individual buffer sizes, as reported by the getTotalSize callback (provided to CMBufferQueueCreate). If there are no buffers in the queue, 0 will be returned.

Source§

impl CMBufferQueue

Source

pub unsafe fn install_trigger( &self, callback: CMBufferQueueTriggerCallback, refcon: *mut c_void, condition: CMBufferQueueTriggerCondition, time: CMTime, trigger_token_out: *mut CMBufferQueueTriggerToken, ) -> i32

Available on crate feature CMTime only.

Installs a trigger on a CMBufferQueue.

The returned trigger token can be passed to CMBufferQueueTestTrigger and CMBufferQueueRemoveTrigger. The triggerTokenOut parameter can be NULL (client doesn’t need to test or remove trigger), and the callback parameter can be NULL (client doesn’t need callbacks, but rather will explicitly test the trigger). One of these two parameters must be non-NULL, however, since an untestable trigger that does not perform a callback is meaningless. If the trigger condition is already true, CMBufferQueueInstallTrigger will call the callback. If it does this, it will first write the trigger token to *triggerTokenOut.

§Safety
  • callback must be implemented correctly.
  • refcon must be a valid pointer or null.
  • trigger_token_out must be a valid pointer or null.
Source

pub unsafe fn install_trigger_with_integer_threshold( &self, callback: CMBufferQueueTriggerCallback, refcon: *mut c_void, condition: CMBufferQueueTriggerCondition, threshold: CMItemCount, trigger_token_out: *mut CMBufferQueueTriggerToken, ) -> i32

Available on crate feature CMBase only.

Installs a trigger on a CMBufferQueue.

This function behaves the same way as CMBufferQueueInstallTrigger() except the trigger is evaluated against the integer value rather than the time value.

§Safety
  • callback must be implemented correctly.
  • refcon must be a valid pointer or null.
  • trigger_token_out must be a valid pointer or null.
Source

pub unsafe fn install_trigger_handler( &self, condition: CMBufferQueueTriggerCondition, time: CMTime, trigger_token_out: *mut CMBufferQueueTriggerToken, handler: CMBufferQueueTriggerHandler, ) -> i32

Available on crate features CMTime and block2 only.

Installs a trigger on a CMBufferQueue.

The returned trigger token can be passed to CMBufferQueueTestTrigger and CMBufferQueueRemoveTrigger. The triggerTokenOut parameter can be NULL (client doesn’t need to test or remove trigger), and the handler parameter can be NULL (client doesn’t need callbacks, but rather will explicitly test the trigger). One of these two parameters must be non-NULL, however, since an untestable trigger that does not perform a callback is meaningless. If the trigger condition is already true, CMBufferQueueInstallTrigger will call the handler. If it does this, it will first write the trigger token to *triggerTokenOut.

§Safety
  • trigger_token_out must be a valid pointer or null.
  • handler must be a valid pointer or null.
Source

pub unsafe fn install_trigger_handler_with_integer_threshold( &self, condition: CMBufferQueueTriggerCondition, threshold: CMItemCount, trigger_token_out: *mut CMBufferQueueTriggerToken, handler: CMBufferQueueTriggerHandler, ) -> i32

Available on crate features CMBase and block2 only.

Installs a trigger on a CMBufferQueue.

This function behaves the same way as CMBufferQueueInstallTriggerHandler() except the trigger is evaluated against the integer value rather than the time value.

§Safety
  • trigger_token_out must be a valid pointer or null.
  • handler must be a valid pointer or null.
Source

pub unsafe fn remove_trigger( &self, trigger_token: CMBufferQueueTriggerToken, ) -> i32

Removes a previously installed trigger from a CMBufferQueue.

Triggers will automatically be removed when a queue is finalized. However, if more than one module has access to a queue, it may be hard for an individual module to know when the queue is finalized since other modules may retain it. To address this concern, modules should remove their triggers before they themselves are finalized.

§Safety

trigger_token must be a valid pointer.

Source

pub unsafe fn test_trigger( &self, trigger_token: CMBufferQueueTriggerToken, ) -> bool

Tests whether the trigger condition is true.

Whereas the trigger callback will only be called when the condition goes from false to true, CMBufferQueueTestTrigger always returns the condition’s current status. The triggerToken must be one that has been installed on this queue.

§Safety

trigger_token must be a valid pointer.

Source

pub unsafe fn call_for_each_buffer( &self, callback: unsafe extern "C-unwind" fn(NonNull<CMBuffer>, *mut c_void) -> i32, refcon: *mut c_void, ) -> i32

Calls a function for every buffer in a queue.

If the callback function returns an error, iteration will stop immediately and the error will be returned.

§Safety
  • callback must be implemented correctly.
  • refcon must be a valid pointer or null.
Source§

impl CMBufferQueue

Source

pub unsafe fn set_validation_callback( &self, callback: CMBufferValidationCallback, refcon: *mut c_void, ) -> i32

Sets a function that CMBufferQueueEnqueue will call to validate buffers before adding them to the queue.

§Safety
  • callback must be implemented correctly.
  • refcon must be a valid pointer or null.
Source

pub unsafe fn set_validation_handler( &self, handler: CMBufferValidationHandler, ) -> i32

Available on crate feature block2 only.

Sets a block that CMBufferQueueEnqueue will call to validate buffers before adding them to the queue.

Both a validation callback and a validation handler can be set at the same time, in which case they will both be called when enqueueing buffers. They both need to return noErr for the buffer to be enqueued.

§Safety

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 CMAttachment 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 CMAttachment 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 CMBufferQueue

Source§

fn as_ref(&self) -> &AnyObject

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

impl AsRef<CFType> for CMBufferQueue

Source§

fn as_ref(&self) -> &CFType

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

impl AsRef<CMBufferQueue> for CMBufferQueue

Source§

fn as_ref(&self) -> &Self

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

impl Borrow<AnyObject> for CMBufferQueue

Source§

fn borrow(&self) -> &AnyObject

Immutably borrows from an owned value. Read more
Source§

impl Borrow<CFType> for CMBufferQueue

Source§

fn borrow(&self) -> &CFType

Immutably borrows from an owned value. Read more
Source§

impl ConcreteType for CMBufferQueue

Source§

fn type_id() -> CFTypeID

Returns the CFTypeID of CMBufferQueue objects.

You can check if a CFTypeRef object is actually a CMBufferQueue by comparing CFGetTypeID(object) with CMBufferQueueGetTypeID().

Returns: CFTypeID of CMBufferQueue objects.

Source§

impl Debug for CMBufferQueue

Source§

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

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

impl Deref for CMBufferQueue

Source§

type Target = CFType

The resulting type after dereferencing.
Source§

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

Dereferences the value.
Source§

impl Hash for CMBufferQueue

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 CMBufferQueue

Source§

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

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

impl PartialEq for CMBufferQueue

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 CMBufferQueue

Source§

const ENCODING_REF: Encoding

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

impl Type for CMBufferQueue

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 CMBufferQueue

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,