AVAssetReaderVideoCompositionOutput

Struct AVAssetReaderVideoCompositionOutput 

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

AVAssetReaderVideoCompositionOutput is a concrete subclass of AVAssetReaderOutput that defines an interface for reading video frames that have been composited together from the frames in one or more AVAssetTracks of an AVAssetReader’s AVAsset.

Clients can read the video frames composited from one or more asset tracks by adding an instance of AVAssetReaderVideoCompositionOutput to an AVAssetReader using the -[AVAssetReader addOutput:] method.

See also Apple’s documentation

Implementations§

Source§

impl AVAssetReaderVideoCompositionOutput

Source

pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>

Source

pub unsafe fn new() -> Retained<Self>

Source

pub unsafe fn assetReaderVideoCompositionOutputWithVideoTracks_videoSettings( video_tracks: &NSArray<AVAssetTrack>, video_settings: Option<&NSDictionary<NSString, AnyObject>>, ) -> Retained<Self>

Available on crate feature AVAssetTrack only.

Creates an instance of AVAssetReaderVideoCompositionOutput for reading composited video from the specified video tracks and supplying media data according to the specified video settings.

Parameter tracks: An NSArray of AVAssetTrack objects from which the resulting AVAssetReaderVideoCompositionOutput should read video frames for compositing.

Parameter videoSettings: An NSDictionary of video settings to be used for video output. See AVVideoSettings.h for more information about how to construct a video settings dictionary.

Returns: An instance of AVAssetReaderVideoCompositionOutput.

Each track must be one of the tracks owned by the target AVAssetReader’s asset and must be of media type AVMediaTypeVideo.

A value of nil for videoSettings configures the output to return samples in a convenient uncompressed format, with properties determined according to the properties of the specified video tracks. Initialization will fail if the video settings cannot be used with the specified tracks.

AVAssetReaderVideoCompositionOutput can only produce uncompressed output. This means that the video settings dictionary must follow the rules for uncompressed video output, as laid out in AVVideoSettings.h. In addition, the following keys are not supported:

AVVideoCleanApertureKey AVVideoPixelAspectRatioKey AVVideoScalingModeKey

§Safety

video_settings generic should be of the correct type.

Source

pub unsafe fn initWithVideoTracks_videoSettings( this: Allocated<Self>, video_tracks: &NSArray<AVAssetTrack>, video_settings: Option<&NSDictionary<NSString, AnyObject>>, ) -> Retained<Self>

Available on crate feature AVAssetTrack only.

Creates an instance of AVAssetReaderVideoCompositionOutput for reading composited video from the specified video tracks and supplying media data according to the specified video settings.

Parameter tracks: An NSArray of AVAssetTrack objects from which the resulting AVAssetReaderVideoCompositionOutput should read video frames for compositing.

Parameter videoSettings: An NSDictionary of video settings to be used for video output. See AVVideoSettings.h for more information about how to construct a video settings dictionary.

Returns: An instance of AVAssetReaderVideoCompositionOutput.

Each track must be one of the tracks owned by the target AVAssetReader’s asset and must be of media type AVMediaTypeVideo.

A value of nil for videoSettings configures the output to return samples in a convenient uncompressed format, with properties determined according to the properties of the specified video tracks. Initialization will fail if the video settings cannot be used with the specified tracks.

AVAssetReaderVideoCompositionOutput can only produce uncompressed output. This means that the video settings dictionary must follow the rules for uncompressed video output, as laid out in AVVideoSettings.h.

This method throws an exception for any of the following reasons:

  • any video track is not of media type AVMediaTypeVideo
  • any video track is not part of this asset reader output’s AVAsset
  • track output settings would cause the output to yield compressed samples
  • video settings does not follow the rules for uncompressed video output (AVVideoSettings.h)
  • video settings contains any of the following keys:
  • AVVideoCleanApertureKey
  • AVVideoPixelAspectRatioKey
  • AVVideoScalingModeKey
  • AVVideoDecompressionPropertiesKey
§Safety

video_settings generic should be of the correct type.

Source

pub unsafe fn videoTracks(&self) -> Retained<NSArray<AVAssetTrack>>

Available on crate feature AVAssetTrack only.

The tracks from which the receiver reads composited video.

The value of this property is an NSArray of AVAssetTracks owned by the target AVAssetReader’s asset.

Source

pub unsafe fn videoSettings( &self, ) -> Option<Retained<NSDictionary<NSString, AnyObject>>>

The video settings used by the receiver.

The value of this property is an NSDictionary that contains values for keys as specified by AVVideoSettings.h. A value of nil indicates that the receiver will return video frames in a convenient uncompressed format, with properties determined according to the properties of the receiver’s video tracks.

Source

pub unsafe fn videoComposition(&self) -> Option<Retained<AVVideoComposition>>

Available on crate feature AVVideoComposition only.

The composition of video used by the receiver.

The value of this property is an AVVideoComposition that can be used to specify the visual arrangement of video frames read from each source track over the timeline of the source asset.

This property throws an exception if a value is set after reading has started.

Source

pub unsafe fn setVideoComposition( &self, video_composition: Option<&AVVideoComposition>, )

Available on crate feature AVVideoComposition only.

Setter for videoComposition.

This is copied when set.

Source

pub unsafe fn customVideoCompositor( &self, ) -> Option<Retained<ProtocolObject<dyn AVVideoCompositing>>>

Available on crate feature AVVideoCompositing only.

Indicates the custom video compositor instance used by the receiver.

This property is nil if there is no video compositor, or if the internal video compositor is in use.

Methods from Deref<Target = AVAssetReaderOutput>§

Source

pub unsafe fn mediaType(&self) -> Retained<AVMediaType>

Available on crate feature AVMediaFormat only.

The media type of the samples that can be read from the receiver.

The value of this property is one of the media type strings defined in AVMediaFormat.h.

Source

pub unsafe fn alwaysCopiesSampleData(&self) -> bool

Indicates whether or not the data in buffers gets copied before being vended to the client.

When the value of this property is YES, the AVAssetReaderOutput will always vend a buffer with copied data to the client. Data in such buffers can be freely modified by the client. When the value of this property is NO, the buffers vended to the client may not be copied. Such buffers may still be referenced by other entities. The result of modifying a buffer whose data hasn’t been copied is undefined. Requesting buffers whose data hasn’t been copied when possible can lead to performance improvements.

The default value is YES.

This property throws an exception if a value is set after reading has started (the asset reader has progressed beyond AVAssetReaderStatusUnknown).

Source

pub unsafe fn setAlwaysCopiesSampleData(&self, always_copies_sample_data: bool)

Source

pub unsafe fn copyNextSampleBuffer(&self) -> Option<Retained<CMSampleBuffer>>

Available on crate feature objc2-core-media only.

Copies the next sample buffer for the output synchronously.

Returns: A CMSampleBuffer object referencing the output sample buffer.

The client is responsible for calling CFRelease on the returned CMSampleBuffer object when finished with it. This method will return NULL if there are no more sample buffers available for the receiver within the time range specified by its AVAssetReader’s timeRange property, or if there is an error that prevents the AVAssetReader from reading more media data. When this method returns NULL, clients should check the value of the associated AVAssetReader’s status property to determine why no more samples could be read.

In certain configurations, such as when outputSettings is nil, copyNextSampleBuffer may return marker-only sample buffers as well as sample buffers containing media data. Marker-only sample buffers can be identified by CMSampleBufferGetNumSamples returning 0. Clients who do not need the information attached to marker-only sample buffers may skip them.

This method throws an exception if this output is not added to an instance of AVAssetReader (using -addOutput:) and -startReading is not called on that asset reader.

Source

pub unsafe fn supportsRandomAccess(&self) -> bool

Indicates whether the asset reader output supports reconfiguration of the time ranges to read.

When the value of this property is YES, the time ranges read by the asset reader output can be reconfigured during reading using the -resetForReadingTimeRanges: method. This also prevents the attached AVAssetReader from progressing to AVAssetReaderStatusCompleted until -markConfigurationAsFinal has been invoked.

The default value is NO, which means that the asset reader output may not be reconfigured once reading has begun. When the value of this property is NO, AVAssetReader may be able to read media data more efficiently, particularly when multiple asset reader outputs are attached.

This property throws an exception if a value is set after reading has started (the asset reader has progressed beyond AVAssetReaderStatusUnknown) or after an AVAssetReaderOutput.Provider is attached.

Source

pub unsafe fn setSupportsRandomAccess(&self, supports_random_access: bool)

Source

pub unsafe fn resetForReadingTimeRanges(&self, time_ranges: &NSArray<NSValue>)

Starts reading over with a new set of time ranges.

Parameter timeRanges: An NSArray of NSValue objects, each representing a single CMTimeRange structure

This method may only be used if supportsRandomAccess has been set to YES and may not be called after -markConfigurationAsFinal has been invoked.

This method is often used in conjunction with AVAssetWriter multi-pass (see AVAssetWriterInput category AVAssetWriterInputMultiPass). In this usage, the caller will invoke -copyNextSampleBuffer until that method returns NULL and then ask the AVAssetWriterInput for a set of time ranges from which it thinks media data should be re-encoded. These time ranges are then given to this method to set up the asset reader output for the next pass.

The time ranges set here override the time range set on AVAssetReader.timeRange. Just as with that property, for each time range in the array the intersection of that time range and CMTimeRangeMake(kCMTimeZero, asset.duration) will take effect.

If this method is invoked after the status of the attached AVAssetReader has become AVAssetReaderStatusFailed or AVAssetReaderStatusCancelled, no change in status will occur and the result of the next call to -copyNextSampleBuffer will be NULL.

This method throws an exception if the following conditions are not honored:

  • each item in time ranges must be an NSValue
  • the start of each time range must be numeric - see CMTIME_IS_NUMERIC
  • the duration of each time range must be nonnegative and numeric, or kCMTimePositiveInfinity
  • the start of each time range must be greater than or equal to the end of the previous time range
  • start times must be strictly increasing
  • time ranges must not overlap
  • cannot be called before -startReading has been invoked on the attached asset reader
  • cannot be called until all samples of media data have been read (i.e. copyNextSampleBuffer returns NULL and the asset reader has not entered a failure state)
  • cannot be called without setting “supportsRandomAccess” to YES
  • cannot be called after calling -markConfigurationAsFinal
Source

pub unsafe fn markConfigurationAsFinal(&self)

Informs the receiver that no more reconfiguration of time ranges is necessary and allows the attached AVAssetReader to advance to AVAssetReaderStatusCompleted.

When the value of supportsRandomAccess is YES, the attached asset reader will not advance to AVAssetReaderStatusCompleted until this method is called.

When the destination of media data vended by the receiver is an AVAssetWriterInput configured for multi-pass encoding, a convenient time to invoke this method is after the asset writer input indicates that no more passes will be performed.

Once this method has been called, further invocations of -resetForReadingTimeRanges: are disallowed.

Methods from Deref<Target = NSObject>§

Source

pub fn doesNotRecognizeSelector(&self, sel: Sel) -> !

Handle messages the object doesn’t recognize.

See Apple’s documentation for details.

Methods from Deref<Target = AnyObject>§

Source

pub fn class(&self) -> &'static AnyClass

Dynamically find the class of this object.

§Panics

May panic if the object is invalid (which may be the case for objects returned from unavailable init/new methods).

§Example

Check that an instance of NSObject has the precise class NSObject.

use objc2::ClassType;
use objc2::runtime::NSObject;

let obj = NSObject::new();
assert_eq!(obj.class(), NSObject::class());
Source

pub unsafe fn get_ivar<T>(&self, name: &str) -> &T
where T: Encode,

👎Deprecated: this is difficult to use correctly, use Ivar::load instead.

Use Ivar::load instead.

§Safety

The object must have an instance variable with the given name, and it must be of type T.

See Ivar::load_ptr for details surrounding this.

Source

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

Attempt to downcast the object to a class of type T.

This is the reference-variant. Use Retained::downcast if you want to convert a retained object to another type.

§Mutable classes

Some classes have immutable and mutable variants, such as NSString and NSMutableString.

When some Objective-C API signature says it gives you an immutable class, it generally expects you to not mutate that, even though it may technically be mutable “under the hood”.

So using this method to convert a NSString to a NSMutableString, while not unsound, is generally frowned upon unless you created the string yourself, or the API explicitly documents the string to be mutable.

See Apple’s documentation on mutability and on isKindOfClass: for more details.

§Generic classes

Objective-C generics are called “lightweight generics”, and that’s because they aren’t exposed in the runtime. This makes it impossible to safely downcast to generic collections, so this is disallowed by this method.

You can, however, safely downcast to generic collections where all the type-parameters are AnyObject.

§Panics

This works internally by calling isKindOfClass:. That means that the object must have the instance method of that name, and an exception will be thrown (if CoreFoundation is linked) or the process will abort if that is not the case. In the vast majority of cases, you don’t need to worry about this, since both root objects NSObject and NSProxy implement this method.

§Examples

Cast an NSString back and forth from NSObject.

use objc2::rc::Retained;
use objc2_foundation::{NSObject, NSString};

let obj: Retained<NSObject> = NSString::new().into_super();
let string = obj.downcast_ref::<NSString>().unwrap();
// Or with `downcast`, if we do not need the object afterwards
let string = obj.downcast::<NSString>().unwrap();

Try (and fail) to cast an NSObject to an NSString.

use objc2_foundation::{NSObject, NSString};

let obj = NSObject::new();
assert!(obj.downcast_ref::<NSString>().is_none());

Try to cast to an array of strings.

use objc2_foundation::{NSArray, NSObject, NSString};

let arr = NSArray::from_retained_slice(&[NSObject::new()]);
// This is invalid and doesn't type check.
let arr = arr.downcast_ref::<NSArray<NSString>>();

This fails to compile, since it would require enumerating over the array to ensure that each element is of the desired type, which is a performance pitfall.

Downcast when processing each element instead.

use objc2_foundation::{NSArray, NSObject, NSString};

let arr = NSArray::from_retained_slice(&[NSObject::new()]);

for elem in arr {
    if let Some(data) = elem.downcast_ref::<NSString>() {
        // handle `data`
    }
}

Trait Implementations§

Source§

impl AsRef<AVAssetReaderOutput> for AVAssetReaderVideoCompositionOutput

Source§

fn as_ref(&self) -> &AVAssetReaderOutput

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

impl AsRef<AVAssetReaderVideoCompositionOutput> for AVAssetReaderVideoCompositionOutput

Source§

fn as_ref(&self) -> &Self

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

impl AsRef<AnyObject> for AVAssetReaderVideoCompositionOutput

Source§

fn as_ref(&self) -> &AnyObject

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

impl AsRef<NSObject> for AVAssetReaderVideoCompositionOutput

Source§

fn as_ref(&self) -> &NSObject

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

impl Borrow<AVAssetReaderOutput> for AVAssetReaderVideoCompositionOutput

Source§

fn borrow(&self) -> &AVAssetReaderOutput

Immutably borrows from an owned value. Read more
Source§

impl Borrow<AnyObject> for AVAssetReaderVideoCompositionOutput

Source§

fn borrow(&self) -> &AnyObject

Immutably borrows from an owned value. Read more
Source§

impl Borrow<NSObject> for AVAssetReaderVideoCompositionOutput

Source§

fn borrow(&self) -> &NSObject

Immutably borrows from an owned value. Read more
Source§

impl ClassType for AVAssetReaderVideoCompositionOutput

Source§

const NAME: &'static str = "AVAssetReaderVideoCompositionOutput"

The name of the Objective-C class that this type represents. Read more
Source§

type Super = AVAssetReaderOutput

The superclass of this class. Read more
Source§

type ThreadKind = <<AVAssetReaderVideoCompositionOutput as ClassType>::Super as ClassType>::ThreadKind

Whether the type can be used from any thread, or from only the main thread. Read more
Source§

fn class() -> &'static AnyClass

Get a reference to the Objective-C class that this type represents. Read more
Source§

fn as_super(&self) -> &Self::Super

Get an immutable reference to the superclass.
Source§

impl Debug for AVAssetReaderVideoCompositionOutput

Source§

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

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

impl Deref for AVAssetReaderVideoCompositionOutput

Source§

type Target = AVAssetReaderOutput

The resulting type after dereferencing.
Source§

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

Dereferences the value.
Source§

impl Hash for AVAssetReaderVideoCompositionOutput

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 AVAssetReaderVideoCompositionOutput

Source§

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

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

impl NSObjectProtocol for AVAssetReaderVideoCompositionOutput

Source§

fn isEqual(&self, other: Option<&AnyObject>) -> bool
where Self: Sized + Message,

Check whether the object is equal to an arbitrary other object. Read more
Source§

fn hash(&self) -> usize
where Self: Sized + Message,

An integer that can be used as a table address in a hash table structure. Read more
Source§

fn isKindOfClass(&self, cls: &AnyClass) -> bool
where Self: Sized + Message,

Check if the object is an instance of the class, or one of its subclasses. Read more
Source§

fn is_kind_of<T>(&self) -> bool
where T: ClassType, Self: Sized + Message,

👎Deprecated: use isKindOfClass directly, or cast your objects with AnyObject::downcast_ref
Check if the object is an instance of the class type, or one of its subclasses. Read more
Source§

fn isMemberOfClass(&self, cls: &AnyClass) -> bool
where Self: Sized + Message,

Check if the object is an instance of a specific class, without checking subclasses. Read more
Source§

fn respondsToSelector(&self, aSelector: Sel) -> bool
where Self: Sized + Message,

Check whether the object implements or inherits a method with the given selector. Read more
Source§

fn conformsToProtocol(&self, aProtocol: &AnyProtocol) -> bool
where Self: Sized + Message,

Check whether the object conforms to a given protocol. Read more
Source§

fn description(&self) -> Retained<NSObject>
where Self: Sized + Message,

A textual representation of the object. Read more
Source§

fn debugDescription(&self) -> Retained<NSObject>
where Self: Sized + Message,

A textual representation of the object to use when debugging. Read more
Source§

fn isProxy(&self) -> bool
where Self: Sized + Message,

Check whether the receiver is a subclass of the NSProxy root class instead of the usual NSObject. Read more
Source§

fn retainCount(&self) -> usize
where Self: Sized + Message,

The reference count of the object. Read more
Source§

impl PartialEq for AVAssetReaderVideoCompositionOutput

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 AVAssetReaderVideoCompositionOutput

Source§

const ENCODING_REF: Encoding = <AVAssetReaderOutput as ::objc2::RefEncode>::ENCODING_REF

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

impl DowncastTarget for AVAssetReaderVideoCompositionOutput

Source§

impl Eq for AVAssetReaderVideoCompositionOutput

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<'a, T> AnyThread for T
where T: ClassType<ThreadKind = dyn AnyThread + 'a> + ?Sized,

Source§

fn alloc() -> Allocated<Self>
where Self: Sized + ClassType,

Allocate a new instance of the class. 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,