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;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-core-media")]
7use objc2_core_media::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12/// AVContentKeySystem string constants
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    /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcontentkeysession?language=objc)
67    #[unsafe(super(NSObject))]
68    #[derive(Debug, PartialEq, Eq, Hash)]
69    pub struct AVContentKeySession;
70);
71
72unsafe impl Send for AVContentKeySession {}
73
74unsafe impl Sync for AVContentKeySession {}
75
76unsafe impl NSObjectProtocol for AVContentKeySession {}
77
78impl AVContentKeySession {
79    extern_methods!(
80        #[unsafe(method(init))]
81        #[unsafe(method_family = init)]
82        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
83
84        #[unsafe(method(new))]
85        #[unsafe(method_family = new)]
86        pub unsafe fn new() -> Retained<Self>;
87
88        /// Creates a new instance of AVContentKeySession to manage a collection of media content keys.
89        ///
90        /// Parameter `keySystem`: A valid key system for retrieving keys.
91        ///
92        /// Returns: A new AVContentKeySession.
93        ///
94        /// 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.
95        #[unsafe(method(contentKeySessionWithKeySystem:))]
96        #[unsafe(method_family = none)]
97        pub unsafe fn contentKeySessionWithKeySystem(
98            key_system: &AVContentKeySystem,
99        ) -> Retained<Self>;
100
101        /// Creates a new instance of AVContentKeySession to manage a collection of media content keys.
102        ///
103        /// Parameter `keySystem`: A valid key system for retrieving keys.
104        ///
105        /// Parameter `storageURL`: URL to a writable directory that the session will use to facilitate expired session reports after abnormal session termination.
106        ///
107        /// Returns: A new AVContentKeySession.
108        ///
109        /// 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.
110        #[unsafe(method(contentKeySessionWithKeySystem:storageDirectoryAtURL:))]
111        #[unsafe(method_family = none)]
112        pub unsafe fn contentKeySessionWithKeySystem_storageDirectoryAtURL(
113            key_system: &AVContentKeySystem,
114            storage_url: &NSURL,
115        ) -> Retained<Self>;
116
117        /// The receiver's delegate.
118        ///
119        /// The value of this property is an object conforming to the AVContentKeySessionDelegate protocol. The delegate is set using the setDelegate:queue: method.
120        #[unsafe(method(delegate))]
121        #[unsafe(method_family = none)]
122        pub unsafe fn delegate(
123            &self,
124        ) -> Option<Retained<ProtocolObject<dyn AVContentKeySessionDelegate>>>;
125
126        /// The storage URL provided when the AVContentKeySession was created. May be nil.
127        ///
128        /// URL to a writable directory; may be nil. The session will use this to facilitate expired session reports after abnormal session termination.
129        #[unsafe(method(storageURL))]
130        #[unsafe(method_family = none)]
131        pub unsafe fn storageURL(&self) -> Option<Retained<NSURL>>;
132
133        /// The key system used for retrieving keys
134        #[unsafe(method(keySystem))]
135        #[unsafe(method_family = none)]
136        pub unsafe fn keySystem(&self) -> Retained<AVContentKeySystem>;
137
138        /// Tells the receiver to treat the session as having been intentionally and normally expired.
139        ///
140        /// 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.
141        #[unsafe(method(expire))]
142        #[unsafe(method_family = none)]
143        pub unsafe fn expire(&self);
144
145        /// An opaque identifier for the current content protection session.
146        ///
147        /// 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.
148        #[unsafe(method(contentProtectionSessionIdentifier))]
149        #[unsafe(method_family = none)]
150        pub unsafe fn contentProtectionSessionIdentifier(&self) -> Option<Retained<NSData>>;
151
152        /// Informs the receiver that it should attempt to instantiate a content decryption key using the specified initialization data.
153        ///
154        /// 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.
155        ///
156        /// 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.
157        ///
158        /// Parameter `options`: Additional information necessary to obtain the key, or nil if none. See AVContentKeyRequest*Key below.
159        ///
160        /// 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.
161        #[unsafe(method(processContentKeyRequestWithIdentifier:initializationData:options:))]
162        #[unsafe(method_family = none)]
163        pub unsafe fn processContentKeyRequestWithIdentifier_initializationData_options(
164            &self,
165            identifier: Option<&AnyObject>,
166            initialization_data: Option<&NSData>,
167            options: Option<&NSDictionary<NSString, AnyObject>>,
168        );
169
170        /// Informs the receiver that the already provided response data for an earlier AVContentKeyRequest will imminently expire.
171        ///
172        /// 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:.
173        #[unsafe(method(renewExpiringResponseDataForContentKeyRequest:))]
174        #[unsafe(method_family = none)]
175        pub unsafe fn renewExpiringResponseDataForContentKeyRequest(
176            &self,
177            content_key_request: &AVContentKeyRequest,
178        );
179
180        #[cfg(feature = "block2")]
181        /// 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.
182        ///
183        /// Parameter `persistableContentKeyData`: Persistable content key data that was previously created using -[AVContentKeyRequest persistableContentKeyFromKeyVendorResponse:options:error:] or obtained via AVContentKeySessionDelegate callback -contentKeySession:didUpdatePersistableContentKey:forContentKeyIdentifier:.
184        ///
185        /// Parameter `handler`: Once the secure token is ready, this block will be called with the token or an error describing the failure.
186        #[unsafe(method(makeSecureTokenForExpirationDateOfPersistableContentKey:completionHandler:))]
187        #[unsafe(method_family = none)]
188        pub unsafe fn makeSecureTokenForExpirationDateOfPersistableContentKey_completionHandler(
189            &self,
190            persistable_content_key_data: &NSData,
191            handler: &block2::Block<dyn Fn(*mut NSData, *mut NSError)>,
192        );
193
194        #[cfg(feature = "block2")]
195        /// 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.
196        ///
197        /// Parameter `persistableContentKeyData`: Persistable content key data that was previously created using -[AVContentKeyRequest persistableContentKeyFromKeyVendorResponse:options:error:] or obtained via AVContentKeySessionDelegate callback -contentKeySession:didUpdatePersistableContentKey:forContentKeyIdentifier:.
198        ///
199        /// Parameter `options`: Additional information necessary to generate the server playback context, or nil if none. See AVContentKeySessionServerPlaybackContextOption for supported options.
200        ///
201        /// Parameter `handler`: Once the server playback context is ready, this block will be called with the data or an error describing the failure.
202        ///
203        /// Once invalidated, a persistable content key cannot be used to answer key requests during later playback sessions.
204        #[unsafe(method(invalidatePersistableContentKey:options:completionHandler:))]
205        #[unsafe(method_family = none)]
206        pub unsafe fn invalidatePersistableContentKey_options_completionHandler(
207            &self,
208            persistable_content_key_data: &NSData,
209            options: Option<
210                &NSDictionary<AVContentKeySessionServerPlaybackContextOption, AnyObject>,
211            >,
212            handler: &block2::Block<dyn Fn(*mut NSData, *mut NSError)>,
213        );
214
215        #[cfg(feature = "block2")]
216        /// 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.
217        ///
218        /// 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.
219        ///
220        /// Parameter `options`: Additional information necessary to generate the server playback context, or nil if none. See AVContentKeySessionServerPlaybackContextOption for supported options.
221        ///
222        /// Parameter `handler`: Once the server playback context is ready, this block will be called with the data or an error describing the failure.
223        ///
224        /// Once invalidated, persistable content keys cannot be used to answer key requests during later playback sessions.
225        #[unsafe(method(invalidateAllPersistableContentKeysForApp:options:completionHandler:))]
226        #[unsafe(method_family = none)]
227        pub unsafe fn invalidateAllPersistableContentKeysForApp_options_completionHandler(
228            &self,
229            app_identifier: &NSData,
230            options: Option<
231                &NSDictionary<AVContentKeySessionServerPlaybackContextOption, AnyObject>,
232            >,
233            handler: &block2::Block<dyn Fn(*mut NSData, *mut NSError)>,
234        );
235    );
236}
237
238/// AVContentKeyRecipients.
239impl AVContentKeySession {
240    extern_methods!(
241        /// Informs the receiver that the specified recipient will be used for the session.
242        ///
243        /// 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.
244        #[unsafe(method(addContentKeyRecipient:))]
245        #[unsafe(method_family = none)]
246        pub unsafe fn addContentKeyRecipient(
247            &self,
248            recipient: &ProtocolObject<dyn AVContentKeyRecipient>,
249        );
250
251        /// Informs the receiver that the specified recipient will no longer be used.
252        ///
253        /// 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.
254        #[unsafe(method(removeContentKeyRecipient:))]
255        #[unsafe(method_family = none)]
256        pub unsafe fn removeContentKeyRecipient(
257            &self,
258            recipient: &ProtocolObject<dyn AVContentKeyRecipient>,
259        );
260
261        /// The array of recipients of content keys currently associated with the AVContentKeySession.
262        #[unsafe(method(contentKeyRecipients))]
263        #[unsafe(method_family = none)]
264        pub unsafe fn contentKeyRecipients(
265            &self,
266        ) -> Retained<NSArray<ProtocolObject<dyn AVContentKeyRecipient>>>;
267    );
268}
269
270/// AVContentKeySessionPendingExpiredSessionReports.
271impl AVContentKeySession {
272    extern_methods!(
273        /// Provides "expired session reports" for prior AVContentKeySessions created with the specified app identifier that have expired either normally or abnormally.
274        ///
275        /// 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.
276        ///
277        /// Parameter `storageURL`: URL to a directory previously used with one or more instances of AVContentKeySession for the storage of expired session reports.
278        ///
279        /// 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.
280        ///
281        /// Note that no reports for sessions still in progress will be included.
282        #[unsafe(method(pendingExpiredSessionReportsWithAppIdentifier:storageDirectoryAtURL:))]
283        #[unsafe(method_family = none)]
284        pub unsafe fn pendingExpiredSessionReportsWithAppIdentifier_storageDirectoryAtURL(
285            app_identifier: &NSData,
286            storage_url: &NSURL,
287        ) -> Retained<NSArray<NSData>>;
288
289        /// 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:.
290        ///
291        /// Parameter `expiredSessionReports`: An array of expired session reports to be discarded.
292        ///
293        /// 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.
294        ///
295        /// Parameter `storageURL`: URL to a writable folder.
296        ///
297        /// 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.
298        #[unsafe(method(removePendingExpiredSessionReports:withAppIdentifier:storageDirectoryAtURL:))]
299        #[unsafe(method_family = none)]
300        pub unsafe fn removePendingExpiredSessionReports_withAppIdentifier_storageDirectoryAtURL(
301            expired_session_reports: &NSArray<NSData>,
302            app_identifier: &NSData,
303            storage_url: &NSURL,
304        );
305    );
306}
307
308/// AVContentKeyRequestRetryReason string constants
309///
310/// Used to specify a reason for asking the client to retry a content key request.
311///
312/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcontentkeyrequestretryreason?language=objc)
313// NS_TYPED_ENUM
314pub type AVContentKeyRequestRetryReason = NSString;
315
316extern "C" {
317    /// 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.
318    ///
319    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcontentkeyrequestretryreasontimedout?language=objc)
320    pub static AVContentKeyRequestRetryReasonTimedOut: &'static AVContentKeyRequestRetryReason;
321}
322
323extern "C" {
324    /// Indicates that the content key request should be retried because a key response with expired lease was set on the previous content key request.
325    ///
326    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcontentkeyrequestretryreasonreceivedresponsewithexpiredlease?language=objc)
327    pub static AVContentKeyRequestRetryReasonReceivedResponseWithExpiredLease:
328        &'static AVContentKeyRequestRetryReason;
329}
330
331extern "C" {
332    /// Indicates that the content key request should be retried because an obsolete key response was set on the previous content key request.
333    ///
334    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcontentkeyrequestretryreasonreceivedobsoletecontentkey?language=objc)
335    pub static AVContentKeyRequestRetryReasonReceivedObsoleteContentKey:
336        &'static AVContentKeyRequestRetryReason;
337}
338
339extern_protocol!(
340    /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcontentkeysessiondelegate?language=objc)
341    pub unsafe trait AVContentKeySessionDelegate: NSObjectProtocol {
342        #[unsafe(method(contentKeySession:didProvideContentKeyRequest:))]
343        #[unsafe(method_family = none)]
344        unsafe fn contentKeySession_didProvideContentKeyRequest(
345            &self,
346            session: &AVContentKeySession,
347            key_request: &AVContentKeyRequest,
348        );
349
350        #[optional]
351        #[unsafe(method(contentKeySession:didProvideRenewingContentKeyRequest:))]
352        #[unsafe(method_family = none)]
353        unsafe fn contentKeySession_didProvideRenewingContentKeyRequest(
354            &self,
355            session: &AVContentKeySession,
356            key_request: &AVContentKeyRequest,
357        );
358
359        #[optional]
360        #[unsafe(method(contentKeySession:didProvidePersistableContentKeyRequest:))]
361        #[unsafe(method_family = none)]
362        unsafe fn contentKeySession_didProvidePersistableContentKeyRequest(
363            &self,
364            session: &AVContentKeySession,
365            key_request: &AVPersistableContentKeyRequest,
366        );
367
368        #[optional]
369        #[unsafe(method(contentKeySession:didUpdatePersistableContentKey:forContentKeyIdentifier:))]
370        #[unsafe(method_family = none)]
371        unsafe fn contentKeySession_didUpdatePersistableContentKey_forContentKeyIdentifier(
372            &self,
373            session: &AVContentKeySession,
374            persistable_content_key: &NSData,
375            key_identifier: &AnyObject,
376        );
377
378        #[optional]
379        #[unsafe(method(contentKeySession:contentKeyRequest:didFailWithError:))]
380        #[unsafe(method_family = none)]
381        unsafe fn contentKeySession_contentKeyRequest_didFailWithError(
382            &self,
383            session: &AVContentKeySession,
384            key_request: &AVContentKeyRequest,
385            err: &NSError,
386        );
387
388        #[optional]
389        #[unsafe(method(contentKeySession:shouldRetryContentKeyRequest:reason:))]
390        #[unsafe(method_family = none)]
391        unsafe fn contentKeySession_shouldRetryContentKeyRequest_reason(
392            &self,
393            session: &AVContentKeySession,
394            key_request: &AVContentKeyRequest,
395            retry_reason: &AVContentKeyRequestRetryReason,
396        ) -> bool;
397
398        #[optional]
399        #[unsafe(method(contentKeySession:contentKeyRequestDidSucceed:))]
400        #[unsafe(method_family = none)]
401        unsafe fn contentKeySession_contentKeyRequestDidSucceed(
402            &self,
403            session: &AVContentKeySession,
404            key_request: &AVContentKeyRequest,
405        );
406
407        #[optional]
408        #[unsafe(method(contentKeySessionContentProtectionSessionIdentifierDidChange:))]
409        #[unsafe(method_family = none)]
410        unsafe fn contentKeySessionContentProtectionSessionIdentifierDidChange(
411            &self,
412            session: &AVContentKeySession,
413        );
414
415        #[optional]
416        #[unsafe(method(contentKeySessionDidGenerateExpiredSessionReport:))]
417        #[unsafe(method_family = none)]
418        unsafe fn contentKeySessionDidGenerateExpiredSessionReport(
419            &self,
420            session: &AVContentKeySession,
421        );
422
423        #[optional]
424        #[unsafe(method(contentKeySession:externalProtectionStatusDidChangeForContentKey:))]
425        #[unsafe(method_family = none)]
426        unsafe fn contentKeySession_externalProtectionStatusDidChangeForContentKey(
427            &self,
428            session: &AVContentKeySession,
429            content_key: &AVContentKey,
430        );
431
432        #[optional]
433        #[unsafe(method(contentKeySession:didProvideContentKeyRequests:forInitializationData:))]
434        #[unsafe(method_family = none)]
435        unsafe fn contentKeySession_didProvideContentKeyRequests_forInitializationData(
436            &self,
437            session: &AVContentKeySession,
438            key_requests: &NSArray<AVContentKeyRequest>,
439            initialization_data: Option<&NSData>,
440        );
441    }
442);
443
444/// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcontentkeyrequeststatus?language=objc)
445// NS_ENUM
446#[repr(transparent)]
447#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
448pub struct AVContentKeyRequestStatus(pub NSInteger);
449impl AVContentKeyRequestStatus {
450    #[doc(alias = "AVContentKeyRequestStatusRequestingResponse")]
451    pub const RequestingResponse: Self = Self(0);
452    #[doc(alias = "AVContentKeyRequestStatusReceivedResponse")]
453    pub const ReceivedResponse: Self = Self(1);
454    #[doc(alias = "AVContentKeyRequestStatusRenewed")]
455    pub const Renewed: Self = Self(2);
456    #[doc(alias = "AVContentKeyRequestStatusRetried")]
457    pub const Retried: Self = Self(3);
458    #[doc(alias = "AVContentKeyRequestStatusCancelled")]
459    pub const Cancelled: Self = Self(4);
460    #[doc(alias = "AVContentKeyRequestStatusFailed")]
461    pub const Failed: Self = Self(5);
462}
463
464unsafe impl Encode for AVContentKeyRequestStatus {
465    const ENCODING: Encoding = NSInteger::ENCODING;
466}
467
468unsafe impl RefEncode for AVContentKeyRequestStatus {
469    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
470}
471
472extern "C" {
473    /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcontentkeyrequestrequiresvalidationdatainsecuretokenkey?language=objc)
474    pub static AVContentKeyRequestRequiresValidationDataInSecureTokenKey: &'static NSString;
475}
476
477extern_class!(
478    /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
479    ///
480    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcontentkeyrequest?language=objc)
481    #[unsafe(super(NSObject))]
482    #[derive(Debug, PartialEq, Eq, Hash)]
483    pub struct AVContentKeyRequest;
484);
485
486unsafe impl Send for AVContentKeyRequest {}
487
488unsafe impl Sync for AVContentKeyRequest {}
489
490unsafe impl NSObjectProtocol for AVContentKeyRequest {}
491
492impl AVContentKeyRequest {
493    extern_methods!(
494        /// This describes the state of the AVContentKeyRequest, value is one of AVContentKeyRequestStatus.
495        #[unsafe(method(status))]
496        #[unsafe(method_family = none)]
497        pub unsafe fn status(&self) -> AVContentKeyRequestStatus;
498
499        /// If the receiver's status is AVContentKeyRequestStatusFailed, this describes the error that caused the failure.
500        ///
501        /// 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.
502        #[unsafe(method(error))]
503        #[unsafe(method_family = none)]
504        pub unsafe fn error(&self) -> Option<Retained<NSError>>;
505
506        #[unsafe(method(identifier))]
507        #[unsafe(method_family = none)]
508        pub unsafe fn identifier(&self) -> Option<Retained<AnyObject>>;
509
510        #[unsafe(method(initializationData))]
511        #[unsafe(method_family = none)]
512        pub unsafe fn initializationData(&self) -> Option<Retained<NSData>>;
513
514        #[unsafe(method(options))]
515        #[unsafe(method_family = none)]
516        pub unsafe fn options(&self) -> Retained<NSDictionary<NSString, AnyObject>>;
517
518        #[unsafe(method(canProvidePersistableContentKey))]
519        #[unsafe(method_family = none)]
520        pub unsafe fn canProvidePersistableContentKey(&self) -> bool;
521
522        #[unsafe(method(contentKeySpecifier))]
523        #[unsafe(method_family = none)]
524        pub unsafe fn contentKeySpecifier(&self) -> Retained<AVContentKeySpecifier>;
525
526        #[unsafe(method(contentKey))]
527        #[unsafe(method_family = none)]
528        pub unsafe fn contentKey(&self) -> Option<Retained<AVContentKey>>;
529
530        #[cfg(feature = "block2")]
531        /// Obtains a content key request data for a specific combination of application and content.
532        ///
533        /// Parameter `appIdentifier`: An opaque identifier for the application. The value of this identifier depends on the particular system used to provide the content key.
534        ///
535        /// 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.
536        ///
537        /// Parameter `options`: Additional information necessary to obtain the key, or nil if none. See AVContentKeyRequest*Key below.
538        ///
539        /// 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.
540        ///
541        /// If option AVContentKeyRequestProtocolVersionsKey is not specified the default protocol version of 1 is assumed.
542        #[unsafe(method(makeStreamingContentKeyRequestDataForApp:contentIdentifier:options:completionHandler:))]
543        #[unsafe(method_family = none)]
544        pub unsafe fn makeStreamingContentKeyRequestDataForApp_contentIdentifier_options_completionHandler(
545            &self,
546            app_identifier: &NSData,
547            content_identifier: Option<&NSData>,
548            options: Option<&NSDictionary<NSString, AnyObject>>,
549            handler: &block2::Block<dyn Fn(*mut NSData, *mut NSError)>,
550        );
551
552        /// Informs the receiver to process the specified content key response.
553        ///
554        /// Parameter `keyResponse`: An instance of AVContentKeyResponse carrying a response to a content key request.
555        ///
556        /// 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:.
557        #[unsafe(method(processContentKeyResponse:))]
558        #[unsafe(method_family = none)]
559        pub unsafe fn processContentKeyResponse(&self, key_response: &AVContentKeyResponse);
560
561        /// Informs the receiver that obtaining a content key response has failed, resulting in failure handling.
562        ///
563        /// Parameter `error`: An instance of NSError that describes the specific failure that occurred.
564        #[unsafe(method(processContentKeyResponseError:))]
565        #[unsafe(method_family = none)]
566        pub unsafe fn processContentKeyResponseError(&self, error: &NSError);
567
568        /// Informs the receiver to process a persistable content key request.
569        ///
570        /// 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:.
571        #[deprecated]
572        #[unsafe(method(respondByRequestingPersistableContentKeyRequest))]
573        #[unsafe(method_family = none)]
574        pub unsafe fn respondByRequestingPersistableContentKeyRequest(&self);
575
576        #[unsafe(method(respondByRequestingPersistableContentKeyRequestAndReturnError:_))]
577        #[unsafe(method_family = none)]
578        pub unsafe fn respondByRequestingPersistableContentKeyRequestAndReturnError(
579            &self,
580        ) -> Result<(), Retained<NSError>>;
581    );
582}
583
584/// Methods declared on superclass `NSObject`.
585impl AVContentKeyRequest {
586    extern_methods!(
587        #[unsafe(method(init))]
588        #[unsafe(method_family = init)]
589        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
590
591        #[unsafe(method(new))]
592        #[unsafe(method_family = new)]
593        pub unsafe fn new() -> Retained<Self>;
594    );
595}
596
597extern_class!(
598    /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
599    ///
600    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avpersistablecontentkeyrequest?language=objc)
601    #[unsafe(super(AVContentKeyRequest, NSObject))]
602    #[derive(Debug, PartialEq, Eq, Hash)]
603    pub struct AVPersistableContentKeyRequest;
604);
605
606unsafe impl Send for AVPersistableContentKeyRequest {}
607
608unsafe impl Sync for AVPersistableContentKeyRequest {}
609
610unsafe impl NSObjectProtocol for AVPersistableContentKeyRequest {}
611
612impl AVPersistableContentKeyRequest {
613    extern_methods!(
614        /// Obtains a persistable content key from a context.
615        ///
616        /// Parameter `keyVendorResponse`: The response returned from the key vendor as a result of a request generated from makeStreamingContentKeyRequestDataForApp:contentIdentifier:options:completionHandler:.
617        ///
618        /// Parameter `options`: Additional information necessary to obtain the persistable content key, or nil if none.
619        ///
620        /// Parameter `outError`: If obtaining the persistable content key fails, will be set to an instance of NSError describing the failure.
621        ///
622        /// Returns: The persistable content key data that may be stored offline to answer future loading requests of the same content key.
623        ///
624        /// 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:.
625        #[unsafe(method(persistableContentKeyFromKeyVendorResponse:options:error:_))]
626        #[unsafe(method_family = none)]
627        pub unsafe fn persistableContentKeyFromKeyVendorResponse_options_error(
628            &self,
629            key_vendor_response: &NSData,
630            options: Option<&NSDictionary<NSString, AnyObject>>,
631        ) -> Result<Retained<NSData>, Retained<NSError>>;
632    );
633}
634
635/// Methods declared on superclass `NSObject`.
636impl AVPersistableContentKeyRequest {
637    extern_methods!(
638        #[unsafe(method(init))]
639        #[unsafe(method_family = init)]
640        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
641
642        #[unsafe(method(new))]
643        #[unsafe(method_family = new)]
644        pub unsafe fn new() -> Retained<Self>;
645    );
646}
647
648/// AVContentKeyRequestRenewal.
649impl AVContentKeyRequest {
650    extern_methods!(
651        #[unsafe(method(renewsExpiringResponseData))]
652        #[unsafe(method_family = none)]
653        pub unsafe fn renewsExpiringResponseData(&self) -> bool;
654    );
655}
656
657extern_class!(
658    /// AVContentKeyResponse is used to represent the data returned from the key server when requesting a key for decrypting content.
659    ///
660    /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
661    ///
662    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcontentkeyresponse?language=objc)
663    #[unsafe(super(NSObject))]
664    #[derive(Debug, PartialEq, Eq, Hash)]
665    pub struct AVContentKeyResponse;
666);
667
668unsafe impl Send for AVContentKeyResponse {}
669
670unsafe impl Sync for AVContentKeyResponse {}
671
672unsafe impl NSObjectProtocol for AVContentKeyResponse {}
673
674impl AVContentKeyResponse {
675    extern_methods!(
676        /// Create an AVContentKeyResponse from the server response to a key request made when using FairPlayStreaming (FPS) as the method of key delivery.
677        ///
678        /// Parameter `keyResponseData`: The response from the FairPlayStreaming key server
679        ///
680        /// Returns: A new AVContentKeyResponse holding data from a FairPlayStreaming key server that is used to decrypt the content
681        ///
682        /// 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
683        #[unsafe(method(contentKeyResponseWithFairPlayStreamingKeyResponseData:))]
684        #[unsafe(method_family = none)]
685        pub unsafe fn contentKeyResponseWithFairPlayStreamingKeyResponseData(
686            key_response_data: &NSData,
687        ) -> Retained<Self>;
688
689        /// Create an AVContentKeyResponse from the key and IV when using AVContentKeySystemClearKey as the key system
690        ///
691        ///
692        /// Parameter `keyData`: The key used for decrypting content.
693        ///
694        /// Parameter `initializationVector`: The initialization vector used for decrypting content, or nil if initialization vector is available in the media to be decrypted
695        ///
696        /// Returns: A new AVContentKeyResponse holding Clear Key data.
697        ///
698        /// 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.
699        #[unsafe(method(contentKeyResponseWithClearKeyData:initializationVector:))]
700        #[unsafe(method_family = none)]
701        pub unsafe fn contentKeyResponseWithClearKeyData_initializationVector(
702            key_data: &NSData,
703            initialization_vector: Option<&NSData>,
704        ) -> Retained<Self>;
705
706        /// Create an AVContentKeyResponse from authorization token data when using AVContentKeySystemAuthorizationToken key system.
707        ///
708        /// Parameter `authorizationTokenData`: Data blob containing the authorization token.
709        ///
710        /// Returns: A new AVContentKeyResponse holding the authorization token data.
711        ///
712        /// 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.
713        #[unsafe(method(contentKeyResponseWithAuthorizationTokenData:))]
714        #[unsafe(method_family = none)]
715        pub unsafe fn contentKeyResponseWithAuthorizationTokenData(
716            authorization_token_data: &NSData,
717        ) -> Retained<Self>;
718    );
719}
720
721/// Methods declared on superclass `NSObject`.
722impl AVContentKeyResponse {
723    extern_methods!(
724        #[unsafe(method(init))]
725        #[unsafe(method_family = init)]
726        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
727
728        #[unsafe(method(new))]
729        #[unsafe(method_family = new)]
730        pub unsafe fn new() -> Retained<Self>;
731    );
732}
733
734extern "C" {
735    /// Specifies the versions of the content protection protocol supported by the application as an NSArray of one or more NSNumber objects.
736    ///
737    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcontentkeyrequestprotocolversionskey?language=objc)
738    pub static AVContentKeyRequestProtocolVersionsKey: &'static NSString;
739}
740
741extern_protocol!(
742    /// 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.
743    ///
744    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcontentkeyrecipient?language=objc)
745    pub unsafe trait AVContentKeyRecipient {
746        /// Informs the receiver that an AVContentKey has been obtained as the result of an invocation of -[AVContentKeyRequest processContentKeyResponse:].
747        ///
748        /// The recipient may employ the AVContentKey for use with objects that support manual attachment of keys, such as CMSampleBuffer via an invocation of AVSampleBufferAttachContentKey.
749        #[optional]
750        #[unsafe(method(contentKeySession:didProvideContentKey:))]
751        #[unsafe(method_family = none)]
752        unsafe fn contentKeySession_didProvideContentKey(
753            &self,
754            content_key_session: &AVContentKeySession,
755            content_key: &AVContentKey,
756        );
757
758        /// Indicates whether the receiver may require decryption keys for media data in order to enable processing.
759        ///
760        /// 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.
761        #[unsafe(method(mayRequireContentKeysForMediaDataProcessing))]
762        #[unsafe(method_family = none)]
763        unsafe fn mayRequireContentKeysForMediaDataProcessing(&self) -> bool;
764    }
765);
766
767extern_class!(
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/avcontentkeyspecifier?language=objc)
771    #[unsafe(super(NSObject))]
772    #[derive(Debug, PartialEq, Eq, Hash)]
773    pub struct AVContentKeySpecifier;
774);
775
776unsafe impl Send for AVContentKeySpecifier {}
777
778unsafe impl Sync for AVContentKeySpecifier {}
779
780unsafe impl NSObjectProtocol for AVContentKeySpecifier {}
781
782impl AVContentKeySpecifier {
783    extern_methods!(
784        /// Creates a new instance of AVContentKeySpecifier.
785        ///
786        /// Parameter `keySystem`: A valid key system for content keys.
787        ///
788        /// Parameter `contentKeyIdentifier`: Container and protocol-specific key identifier.
789        ///
790        /// Parameter `options`: Additional information necessary to obtain the key, can be empty if none needed.
791        ///
792        /// Returns: A new AVContentKeySpecifier
793        ///
794        /// This method returns an AVContentKeySpecifier instance that represents a content key in a specific content key system.
795        #[unsafe(method(contentKeySpecifierForKeySystem:identifier:options:))]
796        #[unsafe(method_family = none)]
797        pub unsafe fn contentKeySpecifierForKeySystem_identifier_options(
798            key_system: &AVContentKeySystem,
799            content_key_identifier: &AnyObject,
800            options: &NSDictionary<NSString, AnyObject>,
801        ) -> Retained<Self>;
802
803        /// Initialize an instance of AVContentKeySpecifier.
804        ///
805        /// Parameter `keySystem`: A valid key system for content keys.
806        ///
807        /// Parameter `contentKeyIdentifier`: Container and protocol-specific key identifier.
808        ///
809        /// Parameter `options`: Additional information necessary to obtain the key, can be empty if none needed.
810        ///
811        /// Returns: An instance of AVContentKeySpecifier
812        ///
813        /// This method returns an AVContentKeySpecifier instance that represents a content key in a specific content key system.
814        #[unsafe(method(initForKeySystem:identifier:options:))]
815        #[unsafe(method_family = init)]
816        pub unsafe fn initForKeySystem_identifier_options(
817            this: Allocated<Self>,
818            key_system: &AVContentKeySystem,
819            content_key_identifier: &AnyObject,
820            options: &NSDictionary<NSString, AnyObject>,
821        ) -> Retained<Self>;
822
823        /// A valid key system for content keys.
824        #[unsafe(method(keySystem))]
825        #[unsafe(method_family = none)]
826        pub unsafe fn keySystem(&self) -> Retained<AVContentKeySystem>;
827
828        /// Container and protocol-specific key identifier.
829        #[unsafe(method(identifier))]
830        #[unsafe(method_family = none)]
831        pub unsafe fn identifier(&self) -> Retained<AnyObject>;
832
833        #[unsafe(method(options))]
834        #[unsafe(method_family = none)]
835        pub unsafe fn options(&self) -> Retained<NSDictionary<NSString, AnyObject>>;
836    );
837}
838
839/// Methods declared on superclass `NSObject`.
840impl AVContentKeySpecifier {
841    extern_methods!(
842        #[unsafe(method(init))]
843        #[unsafe(method_family = init)]
844        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
845
846        #[unsafe(method(new))]
847        #[unsafe(method_family = new)]
848        pub unsafe fn new() -> Retained<Self>;
849    );
850}
851
852/// 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.
853///
854///
855/// Indicates that the current protection status has not yet been discovered for the attached display(s).
856///
857/// 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).
858///
859/// Indicates that sufficient protection with the attached display(s) has failed to be established, content protected by the associated AVContentKey will not be displayed.
860///
861/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avexternalcontentprotectionstatus?language=objc)
862// NS_ENUM
863#[repr(transparent)]
864#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
865pub struct AVExternalContentProtectionStatus(pub NSInteger);
866impl AVExternalContentProtectionStatus {
867    #[doc(alias = "AVExternalContentProtectionStatusPending")]
868    pub const Pending: Self = Self(0);
869    #[doc(alias = "AVExternalContentProtectionStatusSufficient")]
870    pub const Sufficient: Self = Self(1);
871    #[doc(alias = "AVExternalContentProtectionStatusInsufficient")]
872    pub const Insufficient: Self = Self(2);
873}
874
875unsafe impl Encode for AVExternalContentProtectionStatus {
876    const ENCODING: Encoding = NSInteger::ENCODING;
877}
878
879unsafe impl RefEncode for AVExternalContentProtectionStatus {
880    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
881}
882
883extern_class!(
884    /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
885    ///
886    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcontentkey?language=objc)
887    #[unsafe(super(NSObject))]
888    #[derive(Debug, PartialEq, Eq, Hash)]
889    pub struct AVContentKey;
890);
891
892unsafe impl Send for AVContentKey {}
893
894unsafe impl Sync for AVContentKey {}
895
896unsafe impl NSObjectProtocol for AVContentKey {}
897
898impl AVContentKey {
899    extern_methods!(
900        #[unsafe(method(contentKeySpecifier))]
901        #[unsafe(method_family = none)]
902        pub unsafe fn contentKeySpecifier(&self) -> Retained<AVContentKeySpecifier>;
903
904        /// The external protection status for the AVContentKey based on all attached displays.
905        ///
906        /// This property is not key-value observable, instead the contentKeySession:externalProtectionStatusDidChangeForContentKey: delegate method should be used.
907        #[unsafe(method(externalContentProtectionStatus))]
908        #[unsafe(method_family = none)]
909        pub unsafe fn externalContentProtectionStatus(&self) -> AVExternalContentProtectionStatus;
910
911        /// Revokes the decryption context of the content key, and removes it from its associated AVContentKeySession.
912        ///
913        /// Once revoked, the AVContentKey is no longer eligible to be used with any media.
914        /// 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.
915        /// 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.
916        #[unsafe(method(revoke))]
917        #[unsafe(method_family = none)]
918        pub unsafe fn revoke(&self);
919    );
920}
921
922/// Methods declared on superclass `NSObject`.
923impl AVContentKey {
924    extern_methods!(
925        #[unsafe(method(init))]
926        #[unsafe(method_family = init)]
927        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
928
929        #[unsafe(method(new))]
930        #[unsafe(method_family = new)]
931        pub unsafe fn new() -> Retained<Self>;
932    );
933}
934
935/// Attaches an AVContentKey to a CMSampleBuffer for the purpose of content decryption.
936///
937/// Parameter `sbuf`: The sample buffer to which the content key is to be attached.
938///
939/// Parameter `contentKey`: The content key to be attached.
940///
941/// 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.
942///
943/// 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.
944#[cfg(feature = "objc2-core-media")]
945#[inline]
946pub unsafe extern "C-unwind" fn AVSampleBufferAttachContentKey(
947    sbuf: &CMSampleBuffer,
948    content_key: &AVContentKey,
949    out_error: *mut *mut NSError,
950) -> bool {
951    extern "C-unwind" {
952        fn AVSampleBufferAttachContentKey(
953            sbuf: &CMSampleBuffer,
954            content_key: &AVContentKey,
955            out_error: *mut *mut NSError,
956        ) -> Bool;
957    }
958    unsafe { AVSampleBufferAttachContentKey(sbuf, content_key, out_error) }.as_bool()
959}