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/// Methods supporting protected content.
54#[cfg(feature = "AVPlayerItem")]
55impl AVPlayerItem {
56 extern_methods!(
57 /// Indicates whether or not authorization is required to play the content.
58 ///
59 /// 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
60 /// methods or properties in the AVPlayerItemProtectedContent category apply (though they will return sensible values where possible). This value is NOT key-value observable.
61 #[unsafe(method(isAuthorizationRequiredForPlayback))]
62 #[unsafe(method_family = none)]
63 pub unsafe fn isAuthorizationRequiredForPlayback(&self) -> bool;
64
65 /// Indicates whether the calling application can be used to play the content.
66 ///
67 /// This property reports whether or not the calling application is authorized to play the content associated with the receiver. Note that application authorization
68 /// 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.
69 /// 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).
70 /// This value is NOT key-value observable.
71 #[unsafe(method(isApplicationAuthorizedForPlayback))]
72 #[unsafe(method_family = none)]
73 pub unsafe fn isApplicationAuthorizedForPlayback(&self) -> bool;
74
75 /// Indicates whether the content has been authorized by the user (e.g. by authorizing the content's associated account in iTunes).
76 ///
77 /// 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.
78 /// Note that content authorization is independent of application authorization (see applicationAuthorizedForPlayback) and that both must be
79 /// granted in order for an application to be allowed to play protected content. This value is NOT key-value observable.
80 #[unsafe(method(isContentAuthorizedForPlayback))]
81 #[unsafe(method_family = none)]
82 pub unsafe fn isContentAuthorizedForPlayback(&self) -> bool;
83
84 #[cfg(feature = "block2")]
85 /// Causes appropriate action to be taken to allow the user to authorize the content for playback.
86 ///
87 /// 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).
88 /// 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
89 /// the value of the contentAuthorizationRequestStatus property. Note that even if the status indicates a completed authorization, the content may still not be authorized
90 /// (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
91 /// the content has actually been authorized before continuing. It is not necessary to call this method if the value of contentAuthorizedForPlayback is already true.
92 ///
93 ///
94 /// Parameter `timoutInterval`: 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.
95 ///
96 /// Parameter `handler`: Block to be called upon completion.
97 #[unsafe(method(requestContentAuthorizationAsynchronouslyWithTimeoutInterval:completionHandler:))]
98 #[unsafe(method_family = none)]
99 pub unsafe fn requestContentAuthorizationAsynchronouslyWithTimeoutInterval_completionHandler(
100 &self,
101 timeout_interval: NSTimeInterval,
102 handler: &block2::Block<dyn Fn()>,
103 );
104
105 /// Causes the currently outstanding content authorization request to be cancelled.
106 ///
107 /// Calling this method while a content authorization request is pending will cause that request to be cancelled and its completion handler to be invoked
108 /// with a status of AVContentAuthorizationCancelled. This call does not block.
109 #[unsafe(method(cancelContentAuthorizationRequest))]
110 #[unsafe(method_family = none)]
111 pub unsafe fn cancelContentAuthorizationRequest(&self);
112
113 /// Indicates the status of the most recent call to requestContentAuthorizationAsynchronouslyWithTimeoutInterval:CompletionHandler:
114 ///
115 /// This property reports the authorization status as determined by the most recent call to requestContentAuthorizationAsynchronouslyWithTimeoutInterval:CompletionHandler:.
116 /// 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
117 /// (i.e. it is safe to query this property from the completion handler). This value is NOT key-value observable.
118 #[unsafe(method(contentAuthorizationRequestStatus))]
119 #[unsafe(method_family = none)]
120 pub unsafe fn contentAuthorizationRequestStatus(&self) -> AVContentAuthorizationStatus;
121 );
122}