objc2_av_foundation/generated/AVPlayerItemProtectedContentAdditions.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::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10/// Possible status values resulting from a call to requestContentAuthorizationAsynchronouslyWithTimeoutInterval:CompletionHandler:.
11///
12///
13///
14///
15///
16///
17///
18///
19/// Even if authorization is completed by the user, there is no guarantee that the content will then be authorized. The caller should re-check
20/// whether the content is authorized before proceeding.
21///
22/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcontentauthorizationstatus?language=objc)
23// NS_ENUM
24#[repr(transparent)]
25#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
26pub struct AVContentAuthorizationStatus(pub NSInteger);
27impl AVContentAuthorizationStatus {
28 #[doc(alias = "AVContentAuthorizationUnknown")]
29 pub const Unknown: Self = Self(0);
30 #[doc(alias = "AVContentAuthorizationCompleted")]
31 pub const Completed: Self = Self(1);
32 #[doc(alias = "AVContentAuthorizationCancelled")]
33 pub const Cancelled: Self = Self(2);
34 #[doc(alias = "AVContentAuthorizationTimedOut")]
35 pub const TimedOut: Self = Self(3);
36 #[doc(alias = "AVContentAuthorizationBusy")]
37 pub const Busy: Self = Self(4);
38 #[doc(alias = "AVContentAuthorizationNotAvailable")]
39 pub const NotAvailable: Self = Self(5);
40 #[doc(alias = "AVContentAuthorizationNotPossible")]
41 pub const NotPossible: Self = Self(6);
42}
43
44unsafe impl Encode for AVContentAuthorizationStatus {
45 const ENCODING: Encoding = NSInteger::ENCODING;
46}
47
48unsafe impl RefEncode for AVContentAuthorizationStatus {
49 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
50}
51
52/// AVPlayerItemProtectedContent.
53///
54/// Methods supporting protected content.
55#[cfg(feature = "AVPlayerItem")]
56impl AVPlayerItem {
57 extern_methods!(
58 /// Indicates whether or not authorization is required to play the content.
59 ///
60 /// This property reports whether or not authorization is required for the receiver's content to be played. If it does not require authorization, then none of the other
61 /// methods or properties in the AVPlayerItemProtectedContent category apply (though they will return sensible values where possible). This value is NOT key-value observable.
62 #[unsafe(method(isAuthorizationRequiredForPlayback))]
63 #[unsafe(method_family = none)]
64 pub unsafe fn isAuthorizationRequiredForPlayback(&self) -> bool;
65
66 /// Indicates whether the calling application can be used to play the content.
67 ///
68 /// This property reports whether or not the calling application is authorized to play the content associated with the receiver. Note that application authorization
69 /// is independent of content authorization (see contentAuthorizedForPlayback) and that both must be granted in order for an application to be allowed to play protected content.
70 /// Also, unlike content authorization, application authorization is not dependent on user credentials (i.e. if applicationAuthorizedForPlayback is NO, there are no means to obtain authorization).
71 /// This value is NOT key-value observable.
72 #[unsafe(method(isApplicationAuthorizedForPlayback))]
73 #[unsafe(method_family = none)]
74 pub unsafe fn isApplicationAuthorizedForPlayback(&self) -> bool;
75
76 /// Indicates whether the content has been authorized by the user (e.g. by authorizing the content's associated account in iTunes).
77 ///
78 /// This property reports whether or not the user has provided the necessary credentials to the system in order for the content to be decrypted for playback.
79 /// Note that content authorization is independent of application authorization (see applicationAuthorizedForPlayback) and that both must be
80 /// granted in order for an application to be allowed to play protected content. This value is NOT key-value observable.
81 #[unsafe(method(isContentAuthorizedForPlayback))]
82 #[unsafe(method_family = none)]
83 pub unsafe fn isContentAuthorizedForPlayback(&self) -> bool;
84
85 #[cfg(feature = "block2")]
86 /// Causes appropriate action to be taken to allow the user to authorize the content for playback.
87 ///
88 /// Calling this method will present the user with the opportunity to authorize the content (e.g. by launching iTunes and prompting the user to enter their Apple ID and password).
89 /// When the user has taken action (or the timeout has elapsted), the completion handler will be invoked. The status of the authorization attempt can be determined by checking
90 /// the value of the contentAuthorizationRequestStatus property. Note that even if the status indicates a completed authorization, the content may still not be authorized
91 /// (e.g. if the user authorizes an Apple ID other than that associated with the content). The contentAuthorizedForPlayback property should be re-checked to verify whether
92 /// the content has actually been authorized before continuing. It is not necessary to call this method if the value of contentAuthorizedForPlayback is already true.
93 ///
94 ///
95 /// Parameter `timeoutInterval`: The maximum amount of time to wait for the user to authorize the content in seconds before calling the handler block with a timeout result.
96 ///
97 /// Parameter `handler`: Block to be called upon completion.
98 ///
99 /// # Safety
100 ///
101 /// `handler` block must be sendable.
102 #[unsafe(method(requestContentAuthorizationAsynchronouslyWithTimeoutInterval:completionHandler:))]
103 #[unsafe(method_family = none)]
104 pub unsafe fn requestContentAuthorizationAsynchronouslyWithTimeoutInterval_completionHandler(
105 &self,
106 timeout_interval: NSTimeInterval,
107 handler: &block2::DynBlock<dyn Fn()>,
108 );
109
110 /// Causes the currently outstanding content authorization request to be cancelled.
111 ///
112 /// Calling this method while a content authorization request is pending will cause that request to be cancelled and its completion handler to be invoked
113 /// with a status of AVContentAuthorizationCancelled. This call does not block.
114 #[unsafe(method(cancelContentAuthorizationRequest))]
115 #[unsafe(method_family = none)]
116 pub unsafe fn cancelContentAuthorizationRequest(&self);
117
118 /// Indicates the status of the most recent call to requestContentAuthorizationAsynchronouslyWithTimeoutInterval:CompletionHandler:
119 ///
120 /// This property reports the authorization status as determined by the most recent call to requestContentAuthorizationAsynchronouslyWithTimeoutInterval:CompletionHandler:.
121 /// The value will be AVContentAuthorizationUnknown before the first call and between the time a request call is made and just prior to the completion handler being executed
122 /// (i.e. it is safe to query this property from the completion handler). This value is NOT key-value observable.
123 #[unsafe(method(contentAuthorizationRequestStatus))]
124 #[unsafe(method_family = none)]
125 pub unsafe fn contentAuthorizationRequestStatus(&self) -> AVContentAuthorizationStatus;
126 );
127}