pub struct CMBufferQueue { /* private fields */ }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
impl CMBufferQueue
Sourcepub unsafe fn callbacks_for_unsorted_sample_buffers() -> NonNull<CMBufferCallbacks>
Available on crate feature CMTime only.
pub unsafe fn callbacks_for_unsorted_sample_buffers() -> NonNull<CMBufferCallbacks>
CMTime only.Returns a pointer to a callback struct for unsorted CMSampleBuffers, provided as a convenience.
Sourcepub unsafe fn callbacks_for_sample_buffers_sorted_by_output_pts() -> NonNull<CMBufferCallbacks>
Available on crate feature CMTime only.
pub unsafe fn callbacks_for_sample_buffers_sorted_by_output_pts() -> NonNull<CMBufferCallbacks>
CMTime only.Returns a pointer to a callback struct for CMSampleBuffers sorted by output presentation timestamp, provided as a convenience.
Sourcepub 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.
pub unsafe fn create( allocator: Option<&CFAllocator>, capacity: CMItemCount, callbacks: NonNull<CMBufferCallbacks>, queue_out: NonNull<*mut CMBufferQueue>, ) -> i32
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
callbacksmust be a valid pointer.queue_outmust be a valid pointer.
Sourcepub 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.
pub unsafe fn create_with_handlers( allocator: Option<&CFAllocator>, capacity: CMItemCount, handlers: NonNull<CMBufferHandlers>, queue_out: NonNull<*mut CMBufferQueue>, ) -> i32
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
handlersmust be a valid pointer.queue_outmust be a valid pointer.
Source§impl CMBufferQueue
impl CMBufferQueue
Sourcepub unsafe fn enqueue(&self, buf: &CMBuffer) -> i32
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.
Sourcepub unsafe fn dequeue_and_retain(&self) -> Option<CFRetained<CMBuffer>>
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.
Sourcepub unsafe fn dequeue_if_data_ready_and_retain(
&self,
) -> Option<CFRetained<CMBuffer>>
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.
Sourcepub unsafe fn get_head(&self) -> Option<CFRetained<CMBuffer>>
👎Deprecated
pub unsafe fn get_head(&self) -> Option<CFRetained<CMBuffer>>
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.
Sourcepub unsafe fn head(&self) -> Option<CFRetained<CMBuffer>>
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.
Sourcepub unsafe fn is_empty(&self) -> bool
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.
Sourcepub unsafe fn mark_end_of_data(&self) -> i32
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.
Sourcepub unsafe fn contains_end_of_data(&self) -> bool
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).
Sourcepub unsafe fn is_at_end_of_data(&self) -> bool
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).
Sourcepub unsafe fn reset(&self) -> i32
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.
Sourcepub unsafe fn reset_with_callback(
&self,
callback: unsafe extern "C-unwind" fn(NonNull<CMBuffer>, *mut c_void),
refcon: *mut c_void,
) -> i32
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
callbackmust be implemented correctly.refconmust be a valid pointer or null.
Sourcepub unsafe fn buffer_count(&self) -> CMItemCount
Available on crate feature CMBase only.
pub unsafe fn buffer_count(&self) -> CMItemCount
CMBase only.Gets the number of buffers in the queue.
Sourcepub unsafe fn duration(&self) -> CMTime
Available on crate feature CMTime only.
pub unsafe fn duration(&self) -> CMTime
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.
Sourcepub unsafe fn min_decode_time_stamp(&self) -> CMTime
Available on crate feature CMTime only.
pub unsafe fn min_decode_time_stamp(&self) -> CMTime
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.
Sourcepub unsafe fn first_decode_time_stamp(&self) -> CMTime
Available on crate feature CMTime only.
pub unsafe fn first_decode_time_stamp(&self) -> CMTime
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.
Sourcepub unsafe fn min_presentation_time_stamp(&self) -> CMTime
Available on crate feature CMTime only.
pub unsafe fn min_presentation_time_stamp(&self) -> CMTime
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.
Sourcepub unsafe fn first_presentation_time_stamp(&self) -> CMTime
Available on crate feature CMTime only.
pub unsafe fn first_presentation_time_stamp(&self) -> CMTime
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.
Sourcepub unsafe fn max_presentation_time_stamp(&self) -> CMTime
Available on crate feature CMTime only.
pub unsafe fn max_presentation_time_stamp(&self) -> CMTime
CMTime only.Gets the greatest presentation timestamp of a CMBufferQueue.
If the getPresentationTimeStamp callback is NULL, kCMTimeInvalid will be returned.
Sourcepub unsafe fn end_presentation_time_stamp(&self) -> CMTime
Available on crate feature CMTime only.
pub unsafe fn end_presentation_time_stamp(&self) -> CMTime
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.
Sourcepub unsafe fn total_size(&self) -> usize
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
impl CMBufferQueue
Sourcepub 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.
pub unsafe fn install_trigger( &self, callback: CMBufferQueueTriggerCallback, refcon: *mut c_void, condition: CMBufferQueueTriggerCondition, time: CMTime, trigger_token_out: *mut CMBufferQueueTriggerToken, ) -> i32
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
callbackmust be implemented correctly.refconmust be a valid pointer or null.trigger_token_outmust be a valid pointer or null.
Sourcepub 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.
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
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
callbackmust be implemented correctly.refconmust be a valid pointer or null.trigger_token_outmust be a valid pointer or null.
Sourcepub 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.
pub unsafe fn install_trigger_handler( &self, condition: CMBufferQueueTriggerCondition, time: CMTime, trigger_token_out: *mut CMBufferQueueTriggerToken, handler: CMBufferQueueTriggerHandler, ) -> i32
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_outmust be a valid pointer or null.handlermust be a valid pointer or null.
Sourcepub 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.
pub unsafe fn install_trigger_handler_with_integer_threshold( &self, condition: CMBufferQueueTriggerCondition, threshold: CMItemCount, trigger_token_out: *mut CMBufferQueueTriggerToken, handler: CMBufferQueueTriggerHandler, ) -> i32
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_outmust be a valid pointer or null.handlermust be a valid pointer or null.
Sourcepub unsafe fn remove_trigger(
&self,
trigger_token: CMBufferQueueTriggerToken,
) -> i32
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.
Sourcepub unsafe fn test_trigger(
&self,
trigger_token: CMBufferQueueTriggerToken,
) -> bool
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.
Sourcepub unsafe fn call_for_each_buffer(
&self,
callback: unsafe extern "C-unwind" fn(NonNull<CMBuffer>, *mut c_void) -> i32,
refcon: *mut c_void,
) -> i32
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
callbackmust be implemented correctly.refconmust be a valid pointer or null.
Source§impl CMBufferQueue
impl CMBufferQueue
Sourcepub unsafe fn set_validation_callback(
&self,
callback: CMBufferValidationCallback,
refcon: *mut c_void,
) -> i32
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
callbackmust be implemented correctly.refconmust be a valid pointer or null.
Sourcepub unsafe fn set_validation_handler(
&self,
handler: CMBufferValidationHandler,
) -> i32
Available on crate feature block2 only.
pub unsafe fn set_validation_handler( &self, handler: CMBufferValidationHandler, ) -> i32
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>§
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: ConcreteType,
Available on crate feature CMAttachment only.
pub fn downcast_ref<T>(&self) -> Option<&T>where
T: ConcreteType,
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.
Sourcepub fn retain_count(&self) -> usize
Available on crate feature CMAttachment only.
pub fn retain_count(&self) -> usize
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
impl AsRef<AnyObject> for CMBufferQueue
Source§impl AsRef<CFType> for CMBufferQueue
impl AsRef<CFType> for CMBufferQueue
Source§impl AsRef<CMBufferQueue> for CMBufferQueue
impl AsRef<CMBufferQueue> for CMBufferQueue
Source§impl Borrow<AnyObject> for CMBufferQueue
impl Borrow<AnyObject> for CMBufferQueue
Source§impl Borrow<CFType> for CMBufferQueue
impl Borrow<CFType> for CMBufferQueue
Source§impl ConcreteType for CMBufferQueue
impl ConcreteType for CMBufferQueue
Source§impl Debug for CMBufferQueue
impl Debug for CMBufferQueue
Source§impl Deref for CMBufferQueue
impl Deref for CMBufferQueue
Source§impl Hash for CMBufferQueue
impl Hash for CMBufferQueue
Source§impl Message for CMBufferQueue
impl Message for CMBufferQueue
Source§impl PartialEq for CMBufferQueue
impl PartialEq for CMBufferQueue
Source§impl RefEncode for CMBufferQueue
impl RefEncode for CMBufferQueue
Source§const ENCODING_REF: Encoding
const ENCODING_REF: Encoding
Source§impl Type for CMBufferQueue
impl Type for CMBufferQueue
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