objc2_av_foundation/generated/
AVContentKeySession.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5#[cfg(feature = "dispatch2")]
6use dispatch2::*;
7use objc2::__framework_prelude::*;
8#[cfg(feature = "objc2-core-media")]
9use objc2_core_media::*;
10use objc2_foundation::*;
11
12use crate::*;
13
14/// Used by AVContentKeySession to determine the method of key delivery
15///
16/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcontentkeysystem?language=objc)
17// NS_TYPED_ENUM
18pub type AVContentKeySystem = NSString;
19
20extern "C" {
21    /// Used to specify FairPlay Streaming (FPS) as the method of key delivery.
22    ///
23    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcontentkeysystemfairplaystreaming?language=objc)
24    pub static AVContentKeySystemFairPlayStreaming: &'static AVContentKeySystem;
25}
26
27extern "C" {
28    /// Used to specify clear key as the method of key delivery.
29    ///
30    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcontentkeysystemclearkey?language=objc)
31    pub static AVContentKeySystemClearKey: &'static AVContentKeySystem;
32}
33
34extern "C" {
35    /// Used to specify a token that could be used to authorize playback of associated content key recipients.
36    ///
37    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcontentkeysystemauthorizationtoken?language=objc)
38    pub static AVContentKeySystemAuthorizationToken: &'static AVContentKeySystem;
39}
40
41/// Options keys used to specify additional information for generating server playback context (SPC) in
42/// -[AVContentKeySession invalidatePersistableContentKey:options:completionHandler:] and
43/// -[AVContentKeySession invalidateAllPersistableContentKeysForApp:options:completionHandler:]
44///
45/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcontentkeysessionserverplaybackcontextoption?language=objc)
46// NS_TYPED_ENUM
47pub type AVContentKeySessionServerPlaybackContextOption = NSString;
48
49extern "C" {
50    /// Specifies the versions of the content protection protocol supported by the application; as an NSArray of one or more NSNumber objects. If this option is not set, an appropriate protocol version will be selected based on sideband information such as an associated HLS playlist. If such information is not available, a protocol version of 1 is assumed
51    ///
52    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcontentkeysessionserverplaybackcontextoptionprotocolversions?language=objc)
53    pub static AVContentKeySessionServerPlaybackContextOptionProtocolVersions:
54        &'static AVContentKeySessionServerPlaybackContextOption;
55}
56
57extern "C" {
58    /// Specifies a nonce as a 8-byte NSData object to be included in the secure server playback context (SPC) in order to prevent replay attacks. If not specified default server challenge of 0 is assumed.
59    ///
60    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcontentkeysessionserverplaybackcontextoptionserverchallenge?language=objc)
61    pub static AVContentKeySessionServerPlaybackContextOptionServerChallenge:
62        &'static AVContentKeySessionServerPlaybackContextOption;
63}
64
65extern_class!(
66    /// An AVContentKeySession is used to create and track decryption keys for media data. Objects conforming to the AVContentKeyRecipient protocol, such as AVURLAssets, can be added to an AVContentKeySession to employ the services of the AVContentKeySession in handling new key requests and to obtain access to the session's already existing keys.
67    ///
68    /// Its secondary purpose is to provide a report of expired sessions to assist a controlling entity that wishes to track the set of sessions that are still active. If initialized with a location at which to store them, AVContentKeySession maintains a global collection of pending "expired session reports", each associated with an identifier for the app that created the session. The contents of this identifier are specified by the controlling entity that provides media data or that grants permission for its use.
69    ///
70    /// Expired sessions are tracked as follows: a stream processing session is considered to be started after an instance of AVContentKeySession is created and the first object conforming to the AVContentKeyRecipient protocol is added to it. If an instance of AVContentKeySession that has reached this state does not receive an expire message before it's deallocated or the process in which it's running is terminated, an "expired session report" will subsequently be added to the pending list of expired session reports that indicates that the session expired abnormally. In contrast, for AVContentKeySessions that reach the state of having at least one object conforming to the AVContentKeyRecipient protocol added to them and later receive an expire message, "expired session reports" will be generated that indicate that the session expired normally.
71    ///
72    /// To obtain the collection of pending expired session reports in order to provide them to the controlling entity associated with a specific app identifier, use +pendingExpiredSessionReportsWithAppIdentifier:.
73    ///
74    /// After pending expired session reports have been sent to the controlling entity and their receipt has been acknowledged, they can be removed from the collection of pending expired session reports maintained by AVContentKeySession by using +removePendingExpiredSessionReports:withAppIdentifier:.
75    ///
76    /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
77    ///
78    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcontentkeysession?language=objc)
79    #[unsafe(super(NSObject))]
80    #[derive(Debug, PartialEq, Eq, Hash)]
81    pub struct AVContentKeySession;
82);
83
84unsafe impl Send for AVContentKeySession {}
85
86unsafe impl Sync for AVContentKeySession {}
87
88extern_conformance!(
89    unsafe impl NSObjectProtocol for AVContentKeySession {}
90);
91
92impl AVContentKeySession {
93    extern_methods!(
94        #[unsafe(method(init))]
95        #[unsafe(method_family = init)]
96        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
97
98        #[unsafe(method(new))]
99        #[unsafe(method_family = new)]
100        pub unsafe fn new() -> Retained<Self>;
101
102        /// Creates a new instance of AVContentKeySession to manage a collection of media content keys.
103        ///
104        /// This method returns an AVContentKeySession instance that is capable of managing collection of media content keys corresponding to the input keySystem. An NSInvalidArgumentException will be raised if the value of keySystem is unsupported.
105        ///
106        /// - Parameter keySystem: A valid key system for retrieving keys.
107        ///
108        /// - Returns: A new AVContentKeySession.
109        #[unsafe(method(contentKeySessionWithKeySystem:))]
110        #[unsafe(method_family = none)]
111        pub unsafe fn contentKeySessionWithKeySystem(
112            key_system: &AVContentKeySystem,
113        ) -> Retained<Self>;
114
115        /// Creates a new instance of AVContentKeySession to manage a collection of media content keys.
116        ///
117        /// This method returns an AVContentKeySession instance that is capable of managing collection of media content keys corresponding to the input keySystem. An NSInvalidArgumentException will be raised if the value of keySystem is unsupported.
118        ///
119        /// - Parameter keySystem: A valid key system for retrieving keys.
120        /// - Parameter storageURL: URL to a writable directory that the session will use to facilitate expired session reports after abnormal session termination.
121        ///
122        /// - Returns: A new AVContentKeySession.
123        #[unsafe(method(contentKeySessionWithKeySystem:storageDirectoryAtURL:))]
124        #[unsafe(method_family = none)]
125        pub unsafe fn contentKeySessionWithKeySystem_storageDirectoryAtURL(
126            key_system: &AVContentKeySystem,
127            storage_url: &NSURL,
128        ) -> Retained<Self>;
129
130        #[cfg(feature = "dispatch2")]
131        /// Sets the receiver's delegate. A delegate is required to handle content key initialization.
132        ///
133        /// - Parameter delegate: An object conforming to the AVContentKeySessionDelegate protocol.
134        /// - Parameter delegateQueue: A dispatch queue on which delegate methods will be invoked whenever processes requiring content keys are executed asynchronously. Passing a value of nil for the delegateQueue parameter along with a non-nil value for the delegate parameter will result in an invalid argument exception.
135        ///
136        /// # Safety
137        ///
138        /// `delegate_queue` possibly has additional threading requirements.
139        #[unsafe(method(setDelegate:queue:))]
140        #[unsafe(method_family = none)]
141        pub unsafe fn setDelegate_queue(
142            &self,
143            delegate: Option<&ProtocolObject<dyn AVContentKeySessionDelegate>>,
144            delegate_queue: Option<&DispatchQueue>,
145        );
146
147        /// The receiver's delegate.
148        ///
149        /// The value of this property is an object conforming to the AVContentKeySessionDelegate protocol. The delegate is set using the setDelegate:queue: method.
150        #[unsafe(method(delegate))]
151        #[unsafe(method_family = none)]
152        pub unsafe fn delegate(
153            &self,
154        ) -> Option<Retained<ProtocolObject<dyn AVContentKeySessionDelegate>>>;
155
156        #[cfg(feature = "dispatch2")]
157        /// The dispatch queue on which all delegate methods will be invoked whenever processes requiring content keys are executed asynchronously.
158        ///
159        /// The value of this property is a dispatch_queue_t. The queue is set using the setDelegate:queue: method.
160        #[unsafe(method(delegateQueue))]
161        #[unsafe(method_family = none)]
162        pub unsafe fn delegateQueue(&self) -> Option<Retained<DispatchQueue>>;
163
164        /// The storage URL provided when the AVContentKeySession was created. May be nil.
165        ///
166        /// URL to a writable directory; may be nil. The session will use this to facilitate expired session reports after abnormal session termination.
167        #[unsafe(method(storageURL))]
168        #[unsafe(method_family = none)]
169        pub unsafe fn storageURL(&self) -> Option<Retained<NSURL>>;
170
171        /// The key system used for retrieving keys
172        #[unsafe(method(keySystem))]
173        #[unsafe(method_family = none)]
174        pub unsafe fn keySystem(&self) -> Retained<AVContentKeySystem>;
175
176        /// Tells the receiver to treat the session as having been intentionally and normally expired.
177        ///
178        /// When an instance of AVContentKeySession receives an expire message, all of its associated objects conforming to the AVContentKeyRecipient protocol will become inoperable. Send this message only after you have finished operating on the media data.
179        #[unsafe(method(expire))]
180        #[unsafe(method_family = none)]
181        pub unsafe fn expire(&self);
182
183        /// An opaque identifier for the current content protection session.
184        ///
185        /// May be nil. Will call the delegate's contentKeySessionContentProtectionSessionIdentifierDidChange: when the identifier changes. The protection session ID is a unique string identifier generated by the AVContentKeySession that can be used by the application to identify content key session objects.
186        #[unsafe(method(contentProtectionSessionIdentifier))]
187        #[unsafe(method_family = none)]
188        pub unsafe fn contentProtectionSessionIdentifier(&self) -> Option<Retained<NSData>>;
189
190        /// Informs the receiver that it should attempt to instantiate a content decryption key using the specified initialization data.
191        ///
192        /// May be used to generate an AVContentKeyRequest from request initialization data already in hand, without awaiting such data during the processing of media data of an associated recipient.
193        ///
194        /// - Parameter identifier: Container- and protocol-specific identifier to be used to obtain a key response. Either identifier or initializationData must be non-nil. Both can be non-nil, if the content protection protocol requires both.
195        /// - Parameter initializationData: Container- and protocol-specific data to be used to obtain a key response. Either identifier or initializationData must be non-nil. Both can be non-nil, if the content protection protocol requires both.
196        /// - Parameter options: Additional information necessary to obtain the key, or nil if none. See AVContentKeyRequest*Key below.
197        ///
198        /// # Safety
199        ///
200        /// - `identifier` should be of the correct type.
201        /// - `options` generic should be of the correct type.
202        #[unsafe(method(processContentKeyRequestWithIdentifier:initializationData:options:))]
203        #[unsafe(method_family = none)]
204        pub unsafe fn processContentKeyRequestWithIdentifier_initializationData_options(
205            &self,
206            identifier: Option<&AnyObject>,
207            initialization_data: Option<&NSData>,
208            options: Option<&NSDictionary<NSString, AnyObject>>,
209        );
210
211        /// Informs the receiver that the already provided response data for an earlier AVContentKeyRequest will imminently expire.
212        ///
213        /// In response the receiver will invoke your delegate with a new content key request entreating it to renew the expiring response data, via -contentKeySession:didProvideRenewingContentKeyRequest:.
214        #[unsafe(method(renewExpiringResponseDataForContentKeyRequest:))]
215        #[unsafe(method_family = none)]
216        pub unsafe fn renewExpiringResponseDataForContentKeyRequest(
217            &self,
218            content_key_request: &AVContentKeyRequest,
219        );
220
221        #[cfg(feature = "block2")]
222        /// Creates a secure server playback context (SPC) that the client could send to the key server to obtain an expiration date for the provided persistable content key data.
223        ///
224        /// - Parameter persistableContentKeyData: Persistable content key data that was previously created using -[AVContentKeyRequest persistableContentKeyFromKeyVendorResponse:options:error:] or obtained via AVContentKeySessionDelegate callback -contentKeySession:didUpdatePersistableContentKey:forContentKeyIdentifier:.
225        /// - Parameter handler: Once the secure token is ready, this block will be called with the token or an error describing the failure.
226        ///
227        /// # Safety
228        ///
229        /// `handler` block must be sendable.
230        #[unsafe(method(makeSecureTokenForExpirationDateOfPersistableContentKey:completionHandler:))]
231        #[unsafe(method_family = none)]
232        pub unsafe fn makeSecureTokenForExpirationDateOfPersistableContentKey_completionHandler(
233            &self,
234            persistable_content_key_data: &NSData,
235            handler: &block2::DynBlock<dyn Fn(*mut NSData, *mut NSError)>,
236        );
237
238        #[cfg(feature = "block2")]
239        /// Invalidates the persistable content key and creates a secure server playback context (SPC) that the client could send to the key server to verify the outcome of invalidation request.
240        ///
241        /// Once invalidated, a persistable content key cannot be used to answer key requests during later playback sessions.
242        ///
243        /// - Parameter persistableContentKeyData: Persistable content key data that was previously created using -[AVContentKeyRequest persistableContentKeyFromKeyVendorResponse:options:error:] or obtained via AVContentKeySessionDelegate callback -contentKeySession:didUpdatePersistableContentKey:forContentKeyIdentifier:.
244        /// - Parameter options: Additional information necessary to generate the server playback context, or nil if none. See AVContentKeySessionServerPlaybackContextOption for supported options.
245        /// - Parameter handler: Once the server playback context is ready, this block will be called with the data or an error describing the failure.
246        ///
247        /// # Safety
248        ///
249        /// - `options` generic should be of the correct type.
250        /// - `handler` block must be sendable.
251        #[unsafe(method(invalidatePersistableContentKey:options:completionHandler:))]
252        #[unsafe(method_family = none)]
253        pub unsafe fn invalidatePersistableContentKey_options_completionHandler(
254            &self,
255            persistable_content_key_data: &NSData,
256            options: Option<
257                &NSDictionary<AVContentKeySessionServerPlaybackContextOption, AnyObject>,
258            >,
259            handler: &block2::DynBlock<dyn Fn(*mut NSData, *mut NSError)>,
260        );
261
262        #[cfg(feature = "block2")]
263        /// Invalidates all persistable content keys associated with the application and creates a secure server playback context (SPC) that the client could send to the key server to verify the outcome of invalidation request.
264        ///
265        /// Once invalidated, persistable content keys cannot be used to answer key requests during later playback sessions.
266        ///
267        /// - Parameter appIdentifier: An opaque identifier for the application. The contents of this identifier depend on the particular protocol in use by the entity that controls the use of the media data.
268        /// - Parameter options: Additional information necessary to generate the server playback context, or nil if none. See AVContentKeySessionServerPlaybackContextOption for supported options.
269        /// - Parameter handler: Once the server playback context is ready, this block will be called with the data or an error describing the failure.
270        ///
271        /// # Safety
272        ///
273        /// - `options` generic should be of the correct type.
274        /// - `handler` block must be sendable.
275        #[unsafe(method(invalidateAllPersistableContentKeysForApp:options:completionHandler:))]
276        #[unsafe(method_family = none)]
277        pub unsafe fn invalidateAllPersistableContentKeysForApp_options_completionHandler(
278            &self,
279            app_identifier: &NSData,
280            options: Option<
281                &NSDictionary<AVContentKeySessionServerPlaybackContextOption, AnyObject>,
282            >,
283            handler: &block2::DynBlock<dyn Fn(*mut NSData, *mut NSError)>,
284        );
285    );
286}
287
288/// AVContentKeyRecipients.
289impl AVContentKeySession {
290    extern_methods!(
291        /// Informs the receiver that the specified recipient will be used for the session.
292        ///
293        /// It is an error to add recipient to sessions that have received an expire message. It is also an error to add recipients after they have already begun to process media data (e.g. after an AVURLAsset has loaded the values of any of its keys). Such errors will result in NSInternalInconsistencyExceptions. Sending this message to an AVContentKeySession is atomic.
294        #[unsafe(method(addContentKeyRecipient:))]
295        #[unsafe(method_family = none)]
296        pub unsafe fn addContentKeyRecipient(
297            &self,
298            recipient: &ProtocolObject<dyn AVContentKeyRecipient>,
299        );
300
301        /// Informs the receiver that the specified recipient will no longer be used.
302        ///
303        /// After the specified recipient is removed from the receiver it will become inoperable. Remove the recipient only after you have finished operating on the media data associated with it. Sending this message to an AVContentKeySession is atomic.
304        #[unsafe(method(removeContentKeyRecipient:))]
305        #[unsafe(method_family = none)]
306        pub unsafe fn removeContentKeyRecipient(
307            &self,
308            recipient: &ProtocolObject<dyn AVContentKeyRecipient>,
309        );
310
311        /// The array of recipients of content keys currently associated with the AVContentKeySession.
312        #[unsafe(method(contentKeyRecipients))]
313        #[unsafe(method_family = none)]
314        pub unsafe fn contentKeyRecipients(
315            &self,
316        ) -> Retained<NSArray<ProtocolObject<dyn AVContentKeyRecipient>>>;
317    );
318}
319
320/// AVContentKeySessionPendingExpiredSessionReports.
321impl AVContentKeySession {
322    extern_methods!(
323        /// Provides "expired session reports" for prior AVContentKeySessions created with the specified app identifier that have expired either normally or abnormally.
324        ///
325        /// Note that no reports for sessions still in progress will be included.
326        ///
327        /// - Parameter appIdentifier: An opaque identifier for the application. The contents of this identifier depend on the particular protocol in use by the entity that controls the use of the media data.
328        /// - Parameter storageURL: URL to a directory previously used with one or more instances of AVContentKeySession for the storage of expired session reports.
329        ///
330        /// - Returns: An NSArray containing instances of NSData, each containing a pending expired session report as a property-list serialization of an NSDictionary object. The contents of expired session reports depend on the particular protocol in use by the entity that controls the use of the media data.
331        #[unsafe(method(pendingExpiredSessionReportsWithAppIdentifier:storageDirectoryAtURL:))]
332        #[unsafe(method_family = none)]
333        pub unsafe fn pendingExpiredSessionReportsWithAppIdentifier_storageDirectoryAtURL(
334            app_identifier: &NSData,
335            storage_url: &NSURL,
336        ) -> Retained<NSArray<NSData>>;
337
338        /// Removes expired session reports for prior AVContentKeySessions from storage. Once they have been removed, they will no longer be available via subsequent invocations of +pendingExpiredSessionReportsWithAppIdentifier:.
339        ///
340        /// This method is most suitable for use only after the specified expired session reports have been sent to the entity that controls the use of the media data and the entity has acknowledged their receipt.
341        ///
342        /// - Parameter expiredSessionReports: An array of expired session reports to be discarded.
343        /// - Parameter appIdentifier: An opaque identifier for the application. The contents of this identifier depend on the particular protocol in use by the entity that controls the use of the media data.
344        /// - Parameter storageURL: URL to a writable folder.
345        #[unsafe(method(removePendingExpiredSessionReports:withAppIdentifier:storageDirectoryAtURL:))]
346        #[unsafe(method_family = none)]
347        pub unsafe fn removePendingExpiredSessionReports_withAppIdentifier_storageDirectoryAtURL(
348            expired_session_reports: &NSArray<NSData>,
349            app_identifier: &NSData,
350            storage_url: &NSURL,
351        );
352    );
353}
354
355/// Used to specify a reason for asking the client to retry a content key request.
356///
357/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcontentkeyrequestretryreason?language=objc)
358// NS_TYPED_ENUM
359pub type AVContentKeyRequestRetryReason = NSString;
360
361extern "C" {
362    /// Indicates that the content key request should be retried because the key response was not set soon enough either due the initial request/response was taking too long, or a lease was expiring in the meantime.
363    ///
364    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcontentkeyrequestretryreasontimedout?language=objc)
365    pub static AVContentKeyRequestRetryReasonTimedOut: &'static AVContentKeyRequestRetryReason;
366}
367
368extern "C" {
369    /// Indicates that the content key request should be retried because a key response with expired lease was set on the previous content key request.
370    ///
371    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcontentkeyrequestretryreasonreceivedresponsewithexpiredlease?language=objc)
372    pub static AVContentKeyRequestRetryReasonReceivedResponseWithExpiredLease:
373        &'static AVContentKeyRequestRetryReason;
374}
375
376extern "C" {
377    /// Indicates that the content key request should be retried because an obsolete key response was set on the previous content key request.
378    ///
379    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcontentkeyrequestretryreasonreceivedobsoletecontentkey?language=objc)
380    pub static AVContentKeyRequestRetryReasonReceivedObsoleteContentKey:
381        &'static AVContentKeyRequestRetryReason;
382}
383
384extern_protocol!(
385    /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcontentkeysessiondelegate?language=objc)
386    pub unsafe trait AVContentKeySessionDelegate: NSObjectProtocol + Send + Sync {
387        #[unsafe(method(contentKeySession:didProvideContentKeyRequest:))]
388        #[unsafe(method_family = none)]
389        unsafe fn contentKeySession_didProvideContentKeyRequest(
390            &self,
391            session: &AVContentKeySession,
392            key_request: &AVContentKeyRequest,
393        );
394
395        #[optional]
396        #[unsafe(method(contentKeySession:didProvideRenewingContentKeyRequest:))]
397        #[unsafe(method_family = none)]
398        unsafe fn contentKeySession_didProvideRenewingContentKeyRequest(
399            &self,
400            session: &AVContentKeySession,
401            key_request: &AVContentKeyRequest,
402        );
403
404        #[optional]
405        #[unsafe(method(contentKeySession:didProvidePersistableContentKeyRequest:))]
406        #[unsafe(method_family = none)]
407        unsafe fn contentKeySession_didProvidePersistableContentKeyRequest(
408            &self,
409            session: &AVContentKeySession,
410            key_request: &AVPersistableContentKeyRequest,
411        );
412
413        /// # Safety
414        ///
415        /// `key_identifier` should be of the correct type.
416        #[optional]
417        #[unsafe(method(contentKeySession:didUpdatePersistableContentKey:forContentKeyIdentifier:))]
418        #[unsafe(method_family = none)]
419        unsafe fn contentKeySession_didUpdatePersistableContentKey_forContentKeyIdentifier(
420            &self,
421            session: &AVContentKeySession,
422            persistable_content_key: &NSData,
423            key_identifier: &AnyObject,
424        );
425
426        #[optional]
427        #[unsafe(method(contentKeySession:contentKeyRequest:didFailWithError:))]
428        #[unsafe(method_family = none)]
429        unsafe fn contentKeySession_contentKeyRequest_didFailWithError(
430            &self,
431            session: &AVContentKeySession,
432            key_request: &AVContentKeyRequest,
433            err: &NSError,
434        );
435
436        #[optional]
437        #[unsafe(method(contentKeySession:shouldRetryContentKeyRequest:reason:))]
438        #[unsafe(method_family = none)]
439        unsafe fn contentKeySession_shouldRetryContentKeyRequest_reason(
440            &self,
441            session: &AVContentKeySession,
442            key_request: &AVContentKeyRequest,
443            retry_reason: &AVContentKeyRequestRetryReason,
444        ) -> bool;
445
446        #[optional]
447        #[unsafe(method(contentKeySession:contentKeyRequestDidSucceed:))]
448        #[unsafe(method_family = none)]
449        unsafe fn contentKeySession_contentKeyRequestDidSucceed(
450            &self,
451            session: &AVContentKeySession,
452            key_request: &AVContentKeyRequest,
453        );
454
455        #[optional]
456        #[unsafe(method(contentKeySessionContentProtectionSessionIdentifierDidChange:))]
457        #[unsafe(method_family = none)]
458        unsafe fn contentKeySessionContentProtectionSessionIdentifierDidChange(
459            &self,
460            session: &AVContentKeySession,
461        );
462
463        #[optional]
464        #[unsafe(method(contentKeySessionDidGenerateExpiredSessionReport:))]
465        #[unsafe(method_family = none)]
466        unsafe fn contentKeySessionDidGenerateExpiredSessionReport(
467            &self,
468            session: &AVContentKeySession,
469        );
470
471        #[optional]
472        #[unsafe(method(contentKeySession:externalProtectionStatusDidChangeForContentKey:))]
473        #[unsafe(method_family = none)]
474        unsafe fn contentKeySession_externalProtectionStatusDidChangeForContentKey(
475            &self,
476            session: &AVContentKeySession,
477            content_key: &AVContentKey,
478        );
479
480        #[optional]
481        #[unsafe(method(contentKeySession:didProvideContentKeyRequests:forInitializationData:))]
482        #[unsafe(method_family = none)]
483        unsafe fn contentKeySession_didProvideContentKeyRequests_forInitializationData(
484            &self,
485            session: &AVContentKeySession,
486            key_requests: &NSArray<AVContentKeyRequest>,
487            initialization_data: Option<&NSData>,
488        );
489    }
490);
491
492/// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcontentkeyrequeststatus?language=objc)
493// NS_ENUM
494#[repr(transparent)]
495#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
496pub struct AVContentKeyRequestStatus(pub NSInteger);
497impl AVContentKeyRequestStatus {
498    /// Indicates that the request has just been created.
499    #[doc(alias = "AVContentKeyRequestStatusRequestingResponse")]
500    pub const RequestingResponse: Self = Self(0);
501    /// Indicates that a response to a key reequest was received and key is in use. This does not indicate that the key is valid.
502    #[doc(alias = "AVContentKeyRequestStatusReceivedResponse")]
503    pub const ReceivedResponse: Self = Self(1);
504    /// Indicates that the key request was renewed. This does not indicate that the key is valid.
505    #[doc(alias = "AVContentKeyRequestStatusRenewed")]
506    pub const Renewed: Self = Self(2);
507    /// Indicates that the key request was retried.
508    #[doc(alias = "AVContentKeyRequestStatusRetried")]
509    pub const Retried: Self = Self(3);
510    /// Indicates that the key request was cancelled.
511    #[doc(alias = "AVContentKeyRequestStatusCancelled")]
512    pub const Cancelled: Self = Self(4);
513    /// Indicates that the request has encountered an error. See also the error property.
514    #[doc(alias = "AVContentKeyRequestStatusFailed")]
515    pub const Failed: Self = Self(5);
516}
517
518unsafe impl Encode for AVContentKeyRequestStatus {
519    const ENCODING: Encoding = NSInteger::ENCODING;
520}
521
522unsafe impl RefEncode for AVContentKeyRequestStatus {
523    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
524}
525
526extern "C" {
527    /// Request secure token to have extended validation data. The value for the key should be previously created offline key using -[AVContentKeyRequest persistableContentKeyFromKeyVendorResponse:options:error:].
528    ///
529    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcontentkeyrequestrequiresvalidationdatainsecuretokenkey?language=objc)
530    pub static AVContentKeyRequestRequiresValidationDataInSecureTokenKey: &'static NSString;
531}
532
533extern_class!(
534    /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
535    ///
536    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcontentkeyrequest?language=objc)
537    #[unsafe(super(NSObject))]
538    #[derive(Debug, PartialEq, Eq, Hash)]
539    pub struct AVContentKeyRequest;
540);
541
542unsafe impl Send for AVContentKeyRequest {}
543
544unsafe impl Sync for AVContentKeyRequest {}
545
546extern_conformance!(
547    unsafe impl NSObjectProtocol for AVContentKeyRequest {}
548);
549
550impl AVContentKeyRequest {
551    extern_methods!(
552        /// This describes the state of the AVContentKeyRequest, value is one of AVContentKeyRequestStatus.
553        #[unsafe(method(status))]
554        #[unsafe(method_family = none)]
555        pub unsafe fn status(&self) -> AVContentKeyRequestStatus;
556
557        /// If the receiver's status is AVContentKeyRequestStatusFailed, this describes the error that caused the failure.
558        ///
559        /// The value of this property is an NSError that describes what caused the content key request to fail. If the receiver's status is not AVContentKeyRequestStatusFailed, the value of this property is nil.
560        #[unsafe(method(error))]
561        #[unsafe(method_family = none)]
562        pub unsafe fn error(&self) -> Option<Retained<NSError>>;
563
564        /// Container- and protocol-specific identifier for the content key.
565        ///
566        /// In order to use a key with an HTTP Live Streaming AVURLAsset, the identifier must be an NSURL that matches a key URI in the Media Playlist.
567        #[unsafe(method(identifier))]
568        #[unsafe(method_family = none)]
569        pub unsafe fn identifier(&self) -> Option<Retained<AnyObject>>;
570
571        /// This property is not atomic.
572        ///
573        /// # Safety
574        ///
575        /// This might not be thread-safe.
576        #[unsafe(method(initializationData))]
577        #[unsafe(method_family = none)]
578        pub unsafe fn initializationData(&self) -> Option<Retained<NSData>>;
579
580        /// Additional information specified while initiaing key loading using -processContentKeyRequestWithIdentifier:initializationData:options:.
581        #[unsafe(method(options))]
582        #[unsafe(method_family = none)]
583        pub unsafe fn options(&self) -> Retained<NSDictionary<NSString, AnyObject>>;
584
585        /// When the value of this property is YES, you can use the method -persistableContentKeyFromKeyVendorResponse:options:error: to create a persistable content key from the content key response.
586        ///
587        /// The value of this property will be YES only when the receiver is provided to your AVContentKeySession delegate via the method -contentKeySession:didProvidePersistableContentKeyRequest:. If you have an AVContentKeyRequest for which the value of canProvidePersistableContentKey is NO, but you wish to obtain a persistable content key, send the AVContentKeyRequest the message -respondByRequestingPersistableContentKeyRequest.
588        #[unsafe(method(canProvidePersistableContentKey))]
589        #[unsafe(method_family = none)]
590        pub unsafe fn canProvidePersistableContentKey(&self) -> bool;
591
592        /// Specifies the requested content key.
593        #[unsafe(method(contentKeySpecifier))]
594        #[unsafe(method_family = none)]
595        pub unsafe fn contentKeySpecifier(&self) -> Retained<AVContentKeySpecifier>;
596
597        /// Represents an AVContentKey that results from an invocation of -processContentKeyResponse:.
598        ///
599        /// Before the receiver achieves the status AVContentKeyRequestReceivedResponse, the value of this property will be nil. Once that status has been achieved, the value of this property becomes a non-nil AVContentKey that can be provided to content key recipients that apply content keys manually to objects that require them, such as CMSampleBuffers, or to initiate renewal. A non-nil value does not indicate that the content key is valid; authorization failures may yet be possible.
600        #[unsafe(method(contentKey))]
601        #[unsafe(method_family = none)]
602        pub unsafe fn contentKey(&self) -> Option<Retained<AVContentKey>>;
603
604        /// The AVContentKeyRecipient which initiated this request, if any.
605        ///
606        /// The originatingRecipient is an AVFoundation object responsible for initiating an AVContentKeyRequest.
607        /// For example, an AVURLAsset used for playback can trigger an AVContentKeyRequest.
608        ///
609        /// If an application triggers key loading directly, for example with
610        /// -[AVContentKeySession processContentKeyRequestWithIdentifier:initializationData:options:],
611        /// the value of originatingRecipient will be nil.
612        ///
613        /// The originatingRecipient of key requests from HLS interstitials will always be the corresponding
614        /// interstitial AVURLAsset. To receive key requests for DRM-protected interstitial content, applications
615        /// must ensure their AVContentKeySession is attached to these interstitial AVURLAssets.
616        ///
617        /// These interstitial AVURLAssets may be retrieved from the primary AVURLAsset via AVPlayerInterstitialEventMonitor.
618        #[unsafe(method(originatingRecipient))]
619        #[unsafe(method_family = none)]
620        pub unsafe fn originatingRecipient(
621            &self,
622        ) -> Option<Retained<ProtocolObject<dyn AVContentKeyRecipient>>>;
623
624        #[cfg(feature = "block2")]
625        /// Obtains a content key request data for a specific combination of application and content.
626        ///
627        /// If option AVContentKeyRequestProtocolVersionsKey is not specified the default protocol version of 1 is assumed.
628        ///
629        /// - Parameter appIdentifier: An opaque identifier for the application. The value of this identifier depends on the particular system used to provide the content key.
630        /// - Parameter contentIdentifier: An optional opaque identifier for the content. The value of this identifier depends on the particular system used to provide the content key.
631        /// - Parameter options: Additional information necessary to obtain the key, or nil if none. See AVContentKeyRequest*Key below.
632        /// - Parameter handler: Once the streaming content key request is prepared, this block will be called with the request data or an error describing the failure.
633        ///
634        /// # Safety
635        ///
636        /// - `options` generic should be of the correct type.
637        /// - `handler` block must be sendable.
638        #[unsafe(method(makeStreamingContentKeyRequestDataForApp:contentIdentifier:options:completionHandler:))]
639        #[unsafe(method_family = none)]
640        pub unsafe fn makeStreamingContentKeyRequestDataForApp_contentIdentifier_options_completionHandler(
641            &self,
642            app_identifier: &NSData,
643            content_identifier: Option<&NSData>,
644            options: Option<&NSDictionary<NSString, AnyObject>>,
645            handler: &block2::DynBlock<dyn Fn(*mut NSData, *mut NSError)>,
646        );
647
648        /// Informs the receiver to process the specified content key response.
649        ///
650        /// After you receive an AVContentKeyRequest via -contentKeySession:didProvideContentKeyRequest: and after you invoke -[AVContentKeyRequest makeStreamingContentKeyRequestDataForApp:contentIdentifier:options:completionHandler:] on that request, you must obtain a response to the request in accordance with the protocol in use by the entity that controls the use of the media data. This is the method you use to provide the content key response to make protected content available for processing. If obtaining the content key response fails, use -processContentKeyResponseError:.
651        ///
652        /// - Parameter keyResponse: An instance of AVContentKeyResponse carrying a response to a content key request.
653        #[unsafe(method(processContentKeyResponse:))]
654        #[unsafe(method_family = none)]
655        pub unsafe fn processContentKeyResponse(&self, key_response: &AVContentKeyResponse);
656
657        /// Informs the receiver that obtaining a content key response has failed, resulting in failure handling.
658        ///
659        /// - Parameter error: An instance of NSError that describes the specific failure that occurred.
660        #[unsafe(method(processContentKeyResponseError:))]
661        #[unsafe(method_family = none)]
662        pub unsafe fn processContentKeyResponseError(&self, error: &NSError);
663
664        /// Informs the receiver to process a persistable content key request.
665        ///
666        /// When you receive an AVContentKeyRequest via -contentKeySession:didProvideContentKeyRequest: and you want the resulting key response to produce a key that can persist across multiple playback sessions, you must invoke -respondByRequestingPersistableContentKeyRequest on that AVContentKeyRequest in order to signal that you want to process an AVPersistableContentKeyRequest instead. If the underlying protocol supports persistable content keys, in response your delegate will receive an AVPersistableContentKeyRequest via -contentKeySession:didProvidePersistableContentKeyRequest:. NSInternalInconsistencyException will be raised, if you are attempting to create and use a persistable key but your AVContentKeySession delegate does not respond to contentKeySession:didProvidePersistableContentKeyRequest:.
667        #[deprecated]
668        #[unsafe(method(respondByRequestingPersistableContentKeyRequest))]
669        #[unsafe(method_family = none)]
670        pub unsafe fn respondByRequestingPersistableContentKeyRequest(&self);
671
672        /// Informs the receiver to process a persistable content key request.
673        ///
674        /// When you receive an AVContentKeyRequest via -contentKeySession:didProvideContentKeyRequest: and you want the resulting key response to produce a key that can persist across multiple playback sessions, you must invoke -respondByRequestingPersistableContentKeyRequest on that AVContentKeyRequest in order to signal that you want to process an AVPersistableContentKeyRequest instead. If the underlying protocol supports persistable content keys, in response your delegate will receive an AVPersistableContentKeyRequest via -contentKeySession:didProvidePersistableContentKeyRequest:. NSInternalInconsistencyException will be raised, if you are attempting to create and use a persistable key but your AVContentKeySession delegate does not respond to contentKeySession:didProvidePersistableContentKeyRequest:.
675        ///
676        /// - Parameter outError: The error returned if a persistable content key request cannot be requested.
677        ///
678        /// - Returns: YES if sucessful. If NO, this request should be responded to via processContentKeyResponse: or processContentKeyResponseError:.
679        #[unsafe(method(respondByRequestingPersistableContentKeyRequestAndReturnError:_))]
680        #[unsafe(method_family = none)]
681        pub unsafe fn respondByRequestingPersistableContentKeyRequestAndReturnError(
682            &self,
683        ) -> Result<(), Retained<NSError>>;
684    );
685}
686
687/// Methods declared on superclass `NSObject`.
688impl AVContentKeyRequest {
689    extern_methods!(
690        #[unsafe(method(init))]
691        #[unsafe(method_family = init)]
692        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
693
694        #[unsafe(method(new))]
695        #[unsafe(method_family = new)]
696        pub unsafe fn new() -> Retained<Self>;
697    );
698}
699
700extern_class!(
701    /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
702    ///
703    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avpersistablecontentkeyrequest?language=objc)
704    #[unsafe(super(AVContentKeyRequest, NSObject))]
705    #[derive(Debug, PartialEq, Eq, Hash)]
706    pub struct AVPersistableContentKeyRequest;
707);
708
709unsafe impl Send for AVPersistableContentKeyRequest {}
710
711unsafe impl Sync for AVPersistableContentKeyRequest {}
712
713extern_conformance!(
714    unsafe impl NSObjectProtocol for AVPersistableContentKeyRequest {}
715);
716
717impl AVPersistableContentKeyRequest {
718    extern_methods!(
719        /// Obtains a persistable content key from a context.
720        ///
721        /// The data returned from this method may be used to immediately satisfy an AVPersistableContentKeyRequest, as well as any subsequent requests for the same key url using processContentKeyResponse: method. When you receive an AVContentKeyRequest via -contentKeySession:didProvideContentKeyRequest: and you want to use existing persistent content key from storage, you must invoke -respondByRequestingPersistableContentKeyRequest on that AVContentKeyRequest in order to signal that you want to process an AVPersistableContentKeyRequest instead. If the underlying protocol supports persistable content keys, in response your delegate will receive an AVPersistableContentKeyRequest via -contentKeySession:didProvidePersistableContentKeyRequest:. You can set the persistent key from storage on the AVPersistableContentKeyRequest using processContentKeyResponse:.
722        ///
723        /// - Parameter keyVendorResponse: The response returned from the key vendor as a result of a request generated from makeStreamingContentKeyRequestDataForApp:contentIdentifier:options:completionHandler:.
724        /// - Parameter options: Additional information necessary to obtain the persistable content key, or nil if none.
725        /// - Parameter outError: If obtaining the persistable content key fails, will be set to an instance of NSError describing the failure.
726        ///
727        /// - Returns: The persistable content key data that may be stored offline to answer future loading requests of the same content key.
728        ///
729        /// # Safety
730        ///
731        /// `options` generic should be of the correct type.
732        #[unsafe(method(persistableContentKeyFromKeyVendorResponse:options:error:_))]
733        #[unsafe(method_family = none)]
734        pub unsafe fn persistableContentKeyFromKeyVendorResponse_options_error(
735            &self,
736            key_vendor_response: &NSData,
737            options: Option<&NSDictionary<NSString, AnyObject>>,
738        ) -> Result<Retained<NSData>, Retained<NSError>>;
739    );
740}
741
742/// Methods declared on superclass `NSObject`.
743impl AVPersistableContentKeyRequest {
744    extern_methods!(
745        #[unsafe(method(init))]
746        #[unsafe(method_family = init)]
747        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
748
749        #[unsafe(method(new))]
750        #[unsafe(method_family = new)]
751        pub unsafe fn new() -> Retained<Self>;
752    );
753}
754
755/// AVContentKeyRequestRenewal.
756impl AVContentKeyRequest {
757    extern_methods!(
758        /// Indicates whether the receiver represents a request to renew previously provided response data that is expiring or has expired.
759        #[unsafe(method(renewsExpiringResponseData))]
760        #[unsafe(method_family = none)]
761        pub unsafe fn renewsExpiringResponseData(&self) -> bool;
762    );
763}
764
765extern_class!(
766    /// AVContentKeyResponse is used to represent the data returned from the key server when requesting a key for decrypting content.
767    ///
768    /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
769    ///
770    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcontentkeyresponse?language=objc)
771    #[unsafe(super(NSObject))]
772    #[derive(Debug, PartialEq, Eq, Hash)]
773    pub struct AVContentKeyResponse;
774);
775
776unsafe impl Send for AVContentKeyResponse {}
777
778unsafe impl Sync for AVContentKeyResponse {}
779
780extern_conformance!(
781    unsafe impl NSObjectProtocol for AVContentKeyResponse {}
782);
783
784impl AVContentKeyResponse {
785    extern_methods!(
786        /// Create an AVContentKeyResponse from the server response to a key request made when using FairPlayStreaming (FPS) as the method of key delivery.
787        ///
788        /// The object created by this method is typically used with an AVContentKeyRequest created by an AVContentKeySession using keySystem AVContentKeySystemFairPlayStreaming. It is passed to AVContentKeyRequest -processContentKeyResponse: in order to supply the decryptor with key data
789        ///
790        /// - Parameter keyResponseData: The response from the FairPlayStreaming key server
791        ///
792        /// - Returns: A new AVContentKeyResponse holding data from a FairPlayStreaming key server that is used to decrypt the content
793        #[unsafe(method(contentKeyResponseWithFairPlayStreamingKeyResponseData:))]
794        #[unsafe(method_family = none)]
795        pub unsafe fn contentKeyResponseWithFairPlayStreamingKeyResponseData(
796            key_response_data: &NSData,
797        ) -> Retained<Self>;
798
799        /// Create an AVContentKeyResponse from the key and IV when using AVContentKeySystemClearKey as the key system
800        ///
801        /// The object created by this method is typically used with an AVContentKeyRequest created by an AVContentKeySession using keySystem AVContentKeySystemClearKey. It is passed to AVContentKeyRequest -processContentKeyResponse: in order to supply the decryptor with key data.
802        ///
803        /// - Parameter keyData: The key used for decrypting content.
804        /// - Parameter initializationVector: The initialization vector used for decrypting content, or nil if initialization vector is available in the media to be decrypted
805        ///
806        /// - Returns: A new AVContentKeyResponse holding Clear Key data.
807        #[unsafe(method(contentKeyResponseWithClearKeyData:initializationVector:))]
808        #[unsafe(method_family = none)]
809        pub unsafe fn contentKeyResponseWithClearKeyData_initializationVector(
810            key_data: &NSData,
811            initialization_vector: Option<&NSData>,
812        ) -> Retained<Self>;
813
814        /// Create an AVContentKeyResponse from authorization token data when using AVContentKeySystemAuthorizationToken key system.
815        ///
816        /// The object created by this method is typically used with an AVContentKeyRequest created by an AVContentKeySession using keySystem AVContentKeySystemAuthorizationToken. It is passed to AVContentKeyRequest -processContentKeyResponse: in order to supply the authorization token data.
817        ///
818        /// - Parameter authorizationTokenData: Data blob containing the authorization token.
819        ///
820        /// - Returns: A new AVContentKeyResponse holding the authorization token data.
821        #[unsafe(method(contentKeyResponseWithAuthorizationTokenData:))]
822        #[unsafe(method_family = none)]
823        pub unsafe fn contentKeyResponseWithAuthorizationTokenData(
824            authorization_token_data: &NSData,
825        ) -> Retained<Self>;
826    );
827}
828
829/// Methods declared on superclass `NSObject`.
830impl AVContentKeyResponse {
831    extern_methods!(
832        #[unsafe(method(init))]
833        #[unsafe(method_family = init)]
834        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
835
836        #[unsafe(method(new))]
837        #[unsafe(method_family = new)]
838        pub unsafe fn new() -> Retained<Self>;
839    );
840}
841
842extern "C" {
843    /// Specifies the versions of the content protection protocol supported by the application as an NSArray of one or more NSNumber objects.
844    ///
845    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcontentkeyrequestprotocolversionskey?language=objc)
846    pub static AVContentKeyRequestProtocolVersionsKey: &'static NSString;
847}
848
849extern "C" {
850    /// Value is an Boolean indicating whether the user's deviceID contained in the SPC blob during FairPlay key exchange should be randomized using a system generated seed
851    ///
852    /// Content providers use the SPC to distinguish the playback device from other devices, typically to enforce per-screen business rule limits.
853    /// If the app developer, in cooperation with the content vendor, does not require to distinguish the playback device, they can further enhance user
854    /// privacy by making this identifier non-constant, using this option.
855    /// In either case, apps are not allowed to store or use the FairPlay anonymized device ID for anything other than to enforce business rule limits.
856    /// App developers must use the AppTrackingTransparency framework to disclose to users if the application or the related FairPlay Key Server collect
857    /// data about end users and share it with other companies for purposes of tracking across apps and web sites.
858    /// When true, the system generates a random seed with which the device id will be randomized. To override the seed used; use this property in conjunction with AVContentKeyRequestRandomDeviceIdentifierSeedKey
859    /// to provide a seed generated by your application.
860    ///
861    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcontentkeyrequestshouldrandomizedeviceidentifierkey?language=objc)
862    pub static AVContentKeyRequestShouldRandomizeDeviceIdentifierKey: &'static NSString;
863}
864
865extern "C" {
866    /// Value is an NSData containing a 16-byte seed to randomize the user's deviceID contained in the SPC blob during FairPlay key exchange
867    ///
868    /// This property must be used in conjunction with AVContentKeyRequestShouldRandomizeDeviceIdentifierKey. Use a RND function to generate a 16 byte seed.
869    /// This seed will be used to randomize the user's anonymized device ID if AVContentKeyRequestShouldRandomizeDeviceIdentifierKey is true.
870    /// Content providers use the SPC to distinguish the playback device from other devices, typically to enforce per-screen business rule limits.
871    /// If the app developer, in cooperation with the content vendor, does not require to distinguish the playback device, they can further enhance user
872    /// privacy by making this identifier non-constant, using this option.
873    /// In either case, apps are not allowed to store or use the FairPlay anonymized device ID for anything other than to enforce business rule limits.
874    /// App developers must use the AppTrackingTransparency framework to disclose to users if the application or the related FairPlay Key Server collect
875    /// data about end users and share it with other companies for purposes of tracking across apps and web sites.
876    ///
877    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcontentkeyrequestrandomdeviceidentifierseedkey?language=objc)
878    pub static AVContentKeyRequestRandomDeviceIdentifierSeedKey: &'static NSString;
879}
880
881extern_protocol!(
882    /// Classes of objects that may require decryption keys for media data in order to enable processing, such as parsing or playback, conform to this protocol.
883    ///
884    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcontentkeyrecipient?language=objc)
885    pub unsafe trait AVContentKeyRecipient {
886        /// Informs the receiver that an AVContentKey has been obtained as the result of an invocation of -[AVContentKeyRequest processContentKeyResponse:].
887        ///
888        /// The recipient may employ the AVContentKey for use with objects that support manual attachment of keys, such as CMSampleBuffer via an invocation of AVSampleBufferAttachContentKey.
889        #[optional]
890        #[unsafe(method(contentKeySession:didProvideContentKey:))]
891        #[unsafe(method_family = none)]
892        unsafe fn contentKeySession_didProvideContentKey(
893            &self,
894            content_key_session: &AVContentKeySession,
895            content_key: &AVContentKey,
896        );
897
898        /// Indicates whether the receiver may require decryption keys for media data in order to enable processing.
899        ///
900        /// When the value of mayRequireContentKeysForMediaDataProcessing is YES, adding the receiver to an AVContentKeySession allows it to employ the session's already existing keys and also enables the handling of new key requests by the AVContentKeySession's delegate.
901        #[unsafe(method(mayRequireContentKeysForMediaDataProcessing))]
902        #[unsafe(method_family = none)]
903        unsafe fn mayRequireContentKeysForMediaDataProcessing(&self) -> bool;
904    }
905);
906
907extern_class!(
908    /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
909    ///
910    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcontentkeyspecifier?language=objc)
911    #[unsafe(super(NSObject))]
912    #[derive(Debug, PartialEq, Eq, Hash)]
913    pub struct AVContentKeySpecifier;
914);
915
916unsafe impl Send for AVContentKeySpecifier {}
917
918unsafe impl Sync for AVContentKeySpecifier {}
919
920extern_conformance!(
921    unsafe impl NSObjectProtocol for AVContentKeySpecifier {}
922);
923
924impl AVContentKeySpecifier {
925    extern_methods!(
926        /// Creates a new instance of AVContentKeySpecifier.
927        ///
928        /// This method returns an AVContentKeySpecifier instance that represents a content key in a specific content key system.
929        ///
930        /// - Parameter keySystem: A valid key system for content keys.
931        /// - Parameter contentKeyIdentifier: Container and protocol-specific key identifier.
932        /// - Parameter options: Additional information necessary to obtain the key, can be empty if none needed.
933        ///
934        /// - Returns: A new AVContentKeySpecifier
935        ///
936        /// # Safety
937        ///
938        /// - `content_key_identifier` should be of the correct type.
939        /// - `options` generic should be of the correct type.
940        #[unsafe(method(contentKeySpecifierForKeySystem:identifier:options:))]
941        #[unsafe(method_family = none)]
942        pub unsafe fn contentKeySpecifierForKeySystem_identifier_options(
943            key_system: &AVContentKeySystem,
944            content_key_identifier: &AnyObject,
945            options: &NSDictionary<NSString, AnyObject>,
946        ) -> Retained<Self>;
947
948        /// Initialize an instance of AVContentKeySpecifier.
949        ///
950        /// This method returns an AVContentKeySpecifier instance that represents a content key in a specific content key system.
951        ///
952        /// - Parameter keySystem: A valid key system for content keys.
953        /// - Parameter contentKeyIdentifier: Container and protocol-specific key identifier.
954        /// - Parameter options: Additional information necessary to obtain the key, can be empty if none needed.
955        ///
956        /// - Returns: An instance of AVContentKeySpecifier
957        ///
958        /// # Safety
959        ///
960        /// - `content_key_identifier` should be of the correct type.
961        /// - `options` generic should be of the correct type.
962        #[unsafe(method(initForKeySystem:identifier:options:))]
963        #[unsafe(method_family = init)]
964        pub unsafe fn initForKeySystem_identifier_options(
965            this: Allocated<Self>,
966            key_system: &AVContentKeySystem,
967            content_key_identifier: &AnyObject,
968            options: &NSDictionary<NSString, AnyObject>,
969        ) -> Retained<Self>;
970
971        /// A valid key system for content keys.
972        #[unsafe(method(keySystem))]
973        #[unsafe(method_family = none)]
974        pub unsafe fn keySystem(&self) -> Retained<AVContentKeySystem>;
975
976        /// Container and protocol-specific key identifier.
977        #[unsafe(method(identifier))]
978        #[unsafe(method_family = none)]
979        pub unsafe fn identifier(&self) -> Retained<AnyObject>;
980
981        /// Additional information necessary to obtain the key, can be empty if none needed.
982        #[unsafe(method(options))]
983        #[unsafe(method_family = none)]
984        pub unsafe fn options(&self) -> Retained<NSDictionary<NSString, AnyObject>>;
985    );
986}
987
988/// Methods declared on superclass `NSObject`.
989impl AVContentKeySpecifier {
990    extern_methods!(
991        #[unsafe(method(init))]
992        #[unsafe(method_family = init)]
993        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
994
995        #[unsafe(method(new))]
996        #[unsafe(method_family = new)]
997        pub unsafe fn new() -> Retained<Self>;
998    );
999}
1000
1001/// The constants can be used to derive whether or not we have established sufficient protection to display content protected by this AVContentKey on some set of attached displays.
1002///
1003/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avexternalcontentprotectionstatus?language=objc)
1004// NS_ENUM
1005#[repr(transparent)]
1006#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
1007pub struct AVExternalContentProtectionStatus(pub NSInteger);
1008impl AVExternalContentProtectionStatus {
1009    /// Indicates that the current protection status has not yet been discovered for the attached display(s).
1010    #[doc(alias = "AVExternalContentProtectionStatusPending")]
1011    pub const Pending: Self = Self(0);
1012    /// Indicates that sufficient protection with the attached display(s) has been established, content protected by the associated AVContentKey will be eligible to be displayed on the display(s).
1013    #[doc(alias = "AVExternalContentProtectionStatusSufficient")]
1014    pub const Sufficient: Self = Self(1);
1015    /// Indicates that sufficient protection with the attached display(s) has failed to be established, content protected by the associated AVContentKey will not be displayed.
1016    #[doc(alias = "AVExternalContentProtectionStatusInsufficient")]
1017    pub const Insufficient: Self = Self(2);
1018}
1019
1020unsafe impl Encode for AVExternalContentProtectionStatus {
1021    const ENCODING: Encoding = NSInteger::ENCODING;
1022}
1023
1024unsafe impl RefEncode for AVExternalContentProtectionStatus {
1025    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
1026}
1027
1028extern_class!(
1029    /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
1030    ///
1031    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcontentkey?language=objc)
1032    #[unsafe(super(NSObject))]
1033    #[derive(Debug, PartialEq, Eq, Hash)]
1034    pub struct AVContentKey;
1035);
1036
1037unsafe impl Send for AVContentKey {}
1038
1039unsafe impl Sync for AVContentKey {}
1040
1041extern_conformance!(
1042    unsafe impl NSObjectProtocol for AVContentKey {}
1043);
1044
1045impl AVContentKey {
1046    extern_methods!(
1047        /// Specifies the content key.
1048        #[unsafe(method(contentKeySpecifier))]
1049        #[unsafe(method_family = none)]
1050        pub unsafe fn contentKeySpecifier(&self) -> Retained<AVContentKeySpecifier>;
1051
1052        /// The external protection status for the AVContentKey based on all attached displays.
1053        ///
1054        /// This property is not key-value observable, instead the contentKeySession:externalProtectionStatusDidChangeForContentKey: delegate method should be used.
1055        #[unsafe(method(externalContentProtectionStatus))]
1056        #[unsafe(method_family = none)]
1057        pub unsafe fn externalContentProtectionStatus(&self) -> AVExternalContentProtectionStatus;
1058
1059        /// Revokes the decryption context of the content key, and removes it from its associated AVContentKeySession.
1060        ///
1061        /// Once revoked, the AVContentKey is no longer eligible to be used with any media.
1062        /// If the key is required again, or if the key is requested to be loaded by the application, a new AVContentKeyRequest will be dispatched to the delegate.
1063        /// If there is media playback occurring which is dependent on the content key it will fail and may result in an error being generated with the playback halting.
1064        #[unsafe(method(revoke))]
1065        #[unsafe(method_family = none)]
1066        pub unsafe fn revoke(&self);
1067    );
1068}
1069
1070/// Methods declared on superclass `NSObject`.
1071impl AVContentKey {
1072    extern_methods!(
1073        #[unsafe(method(init))]
1074        #[unsafe(method_family = init)]
1075        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
1076
1077        #[unsafe(method(new))]
1078        #[unsafe(method_family = new)]
1079        pub unsafe fn new() -> Retained<Self>;
1080    );
1081}
1082
1083/// Attaches an AVContentKey to a CMSampleBuffer for the purpose of content decryption.
1084///
1085/// The client is expected to attach AVContentKeys to CMSampleBuffers that have been created by the client for enqueueing with AVSampleBufferDisplayLayer or AVSampleBufferAudioRenderer, for which the AVContentKeySpecifier matches indications of suitability that are available to the client according to the content key system that's in use.
1086///
1087/// - Parameter sbuf: The sample buffer to which the content key is to be attached.
1088/// - Parameter contentKey: The content key to be attached.
1089/// - Parameter outError: If the result is NO and errorOut is non-NULL, the location referenced by errorOut receives an instance of NSError that describes the reason for failure to attach the content key.
1090///
1091/// # Safety
1092///
1093/// `out_error` must be a valid pointer or null.
1094#[cfg(feature = "objc2-core-media")]
1095#[inline]
1096pub unsafe extern "C-unwind" fn AVSampleBufferAttachContentKey(
1097    sbuf: &CMSampleBuffer,
1098    content_key: &AVContentKey,
1099    out_error: *mut *mut NSError,
1100) -> bool {
1101    extern "C-unwind" {
1102        fn AVSampleBufferAttachContentKey(
1103            sbuf: &CMSampleBuffer,
1104            content_key: &AVContentKey,
1105            out_error: *mut *mut NSError,
1106        ) -> Bool;
1107    }
1108    unsafe { AVSampleBufferAttachContentKey(sbuf, content_key, out_error) }.as_bool()
1109}