1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-core-media")]
use objc2_core_media::*;
use objc2_foundation::*;
use crate::*;
/// These constants are returned by the AVAssetReader status property to indicate whether it can successfully read samples from its asset.
///
///
/// Indicates that the status of the asset reader is not currently known.
///
/// Indicates that the asset reader is successfully reading samples from its asset.
///
/// Indicates that the asset reader has successfully read all of the samples in its time range.
///
/// Indicates that the asset reader can no longer read samples from its asset because of an error. The error is described by the value of the asset reader's error property.
///
/// Indicates that the asset reader can no longer read samples because reading was canceled with the cancelReading method.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avassetreaderstatus?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct AVAssetReaderStatus(pub NSInteger);
impl AVAssetReaderStatus {
#[doc(alias = "AVAssetReaderStatusUnknown")]
pub const Unknown: Self = Self(0);
#[doc(alias = "AVAssetReaderStatusReading")]
pub const Reading: Self = Self(1);
#[doc(alias = "AVAssetReaderStatusCompleted")]
pub const Completed: Self = Self(2);
#[doc(alias = "AVAssetReaderStatusFailed")]
pub const Failed: Self = Self(3);
#[doc(alias = "AVAssetReaderStatusCancelled")]
pub const Cancelled: Self = Self(4);
}
unsafe impl Encode for AVAssetReaderStatus {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for AVAssetReaderStatus {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_class!(
/// AVAssetReader provides services for obtaining media data from an asset.
///
///
/// Instances of AVAssetReader read media data from an instance of AVAsset, whether the asset is file-based or represents an assembly of media data from multiple sources, as is the case with AVComposition.
///
/// Clients of AVAssetReader can read data from specific tracks of an asset and in specific formats by adding concrete instances of AVAssetReaderOutput to an AVAssetReader instance.
///
/// AVAssetReaderTrackOutput, a concrete subclass of AVAssetReaderOutput, can either read the track's media samples in the format in which they are stored by the asset or convert the media samples to a different format.
///
/// AVAssetReaderAudioMixOutput mixes multiple audio tracks of the asset after reading them, while AVAssetReaderVideoCompositionOutput composites multiple video tracks after reading them.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avassetreader?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct AVAssetReader;
);
extern_conformance!(
unsafe impl NSObjectProtocol for AVAssetReader {}
);
impl AVAssetReader {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
#[cfg(feature = "AVAsset")]
/// Returns an instance of AVAssetReader for reading media data from the specified asset.
///
///
/// Parameter `asset`: The asset from which media data is to be read.
///
/// Parameter `outError`: On return, if initialization of the AVAssetReader fails, points to an NSError describing the nature of the failure.
///
/// Returns: An instance of AVAssetReader.
///
/// If the specified asset belongs to a mutable subclass of AVAsset, AVMutableComposition or AVMutableMovie, the results of any asset reading operation are undefined if you mutate the asset after invoking -startReading.
#[unsafe(method(assetReaderWithAsset:error:_))]
#[unsafe(method_family = none)]
pub unsafe fn assetReaderWithAsset_error(
asset: &AVAsset,
) -> Result<Retained<Self>, Retained<NSError>>;
#[cfg(feature = "AVAsset")]
/// Creates an instance of AVAssetReader for reading media data from the specified asset.
///
///
/// Parameter `asset`: The asset from which media data is to be read.
///
/// Parameter `outError`: On return, if initialization of the AVAssetReader fails, points to an NSError describing the nature of the failure.
///
/// Returns: An instance of AVAssetReader.
///
/// If the specified asset belongs to a mutable subclass of AVAsset, AVMutableComposition or AVMutableMovie, the results of any asset reading operation are undefined if you mutate the asset after invoking -startReading.
#[unsafe(method(initWithAsset:error:_))]
#[unsafe(method_family = init)]
pub unsafe fn initWithAsset_error(
this: Allocated<Self>,
asset: &AVAsset,
) -> Result<Retained<Self>, Retained<NSError>>;
#[cfg(feature = "AVAsset")]
/// The asset from which the receiver's outputs read sample buffers.
///
///
/// The value of this property is an AVAsset. Concrete instances of AVAssetReader that are created with specific AVAssetTrack instances must obtain those tracks from the asset returned by this property.
#[unsafe(method(asset))]
#[unsafe(method_family = none)]
pub unsafe fn asset(&self) -> Retained<AVAsset>;
/// The status of reading sample buffers from the receiver's asset.
///
///
/// The value of this property is an AVAssetReaderStatus that indicates whether reading is in progress, has completed successfully, has been canceled, or has failed. Clients of AVAssetReaderOutput objects should check the value of this property after -[AVAssetReaderOutput copyNextSampleBuffer] returns NULL to determine why no more samples could be read. This property is thread safe.
#[unsafe(method(status))]
#[unsafe(method_family = none)]
pub unsafe fn status(&self) -> AVAssetReaderStatus;
/// If the receiver's status is AVAssetReaderStatusFailed, this describes the error that caused the failure.
///
///
/// The value of this property is an NSError that describes what caused the receiver to no longer be able to read its asset. If the receiver's status is not AVAssetReaderStatusFailed, the value of this property is nil. This property is thread safe.
#[unsafe(method(error))]
#[unsafe(method_family = none)]
pub unsafe fn error(&self) -> Option<Retained<NSError>>;
#[cfg(feature = "objc2-core-media")]
/// Specifies a range of time that may limit the temporal portion of the receiver's asset from which media data will be read.
///
///
/// The intersection of the value of timeRange and CMTimeRangeMake(kCMTimeZero, asset.duration) will determine the time range of the asset from which media data will be read. The default value of timeRange is CMTimeRangeMake(kCMTimeZero, kCMTimePositiveInfinity).
///
/// This property throws an exception if a value is set after reading has started.
#[unsafe(method(timeRange))]
#[unsafe(method_family = none)]
pub unsafe fn timeRange(&self) -> CMTimeRange;
#[cfg(feature = "objc2-core-media")]
/// Setter for [`timeRange`][Self::timeRange].
#[unsafe(method(setTimeRange:))]
#[unsafe(method_family = none)]
pub unsafe fn setTimeRange(&self, time_range: CMTimeRange);
#[cfg(feature = "AVAssetReaderOutput")]
/// The outputs from which clients of receiver can read media data.
///
///
/// The value of this property is an NSArray containing concrete instances of AVAssetReaderOutput. Outputs can be added to the receiver using the addOutput: method.
#[unsafe(method(outputs))]
#[unsafe(method_family = none)]
pub unsafe fn outputs(&self) -> Retained<NSArray<AVAssetReaderOutput>>;
#[cfg(feature = "AVAssetReaderOutput")]
/// Tests whether an output can be added to the receiver.
///
///
/// Parameter `output`: The AVAssetReaderOutput object to be tested.
///
/// Returns: A BOOL indicating whether the output can be added to the receiver.
///
///
/// An output that reads from a track of an asset other than the asset used to initialize the receiver cannot be added.
#[unsafe(method(canAddOutput:))]
#[unsafe(method_family = none)]
pub unsafe fn canAddOutput(&self, output: &AVAssetReaderOutput) -> bool;
#[cfg(feature = "AVAssetReaderOutput")]
/// Adds an output to the receiver.
///
///
/// Parameter `output`: The AVAssetReaderOutput object to be added.
///
///
/// Outputs are created with a reference to one or more AVAssetTrack objects. These tracks must be owned by the asset returned by the receiver's asset property.
///
/// This method throws an exception if the output has already been added to an AVAssetReader or if reading has started (`status` has progressed beyond AVAssetReaderStatusUnknown).
#[unsafe(method(addOutput:))]
#[unsafe(method_family = none)]
pub unsafe fn addOutput(&self, output: &AVAssetReaderOutput);
/// Prepares the receiver for reading sample buffers from the asset.
///
///
/// Returns: A BOOL indicating whether reading could be started.
///
///
/// This method validates the entire collection of settings for outputs for tracks, for audio mixing, and for video composition and initiates reading from the receiver's asset.
///
/// If this method returns NO, clients can determine the nature of the failure by checking the value of the status and error properties.
///
/// This method throws an exception if reading has already started (`status` has progressed beyond AVAssetReaderStatusUnknown).
#[unsafe(method(startReading))]
#[unsafe(method_family = none)]
pub unsafe fn startReading(&self) -> bool;
/// Cancels any background work and prevents the receiver's outputs from reading more samples.
///
///
/// Clients that want to stop reading samples from the receiver before reaching the end of its time range should call this method to stop any background read ahead operations that the may have been in progress.
///
/// This method should not be called concurrently with any calls to -[AVAssetReaderOutput copyNextSampleBuffer].
#[unsafe(method(cancelReading))]
#[unsafe(method_family = none)]
pub unsafe fn cancelReading(&self);
);
}