objc2_shazam_kit/generated/SHSignatureGenerator.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-av-foundation")]
7use objc2_av_foundation::*;
8#[cfg(feature = "objc2-avf-audio")]
9use objc2_avf_audio::*;
10use objc2_foundation::*;
11
12use crate::*;
13
14extern_class!(
15 /// An object for converting audio data into a signature.
16 ///
17 /// Create both reference and query signatures using this class.
18 ///
19 /// See also [Apple's documentation](https://developer.apple.com/documentation/shazamkit/shsignaturegenerator?language=objc)
20 #[unsafe(super(NSObject))]
21 #[derive(Debug, PartialEq, Eq, Hash)]
22 pub struct SHSignatureGenerator;
23);
24
25extern_conformance!(
26 unsafe impl NSObjectProtocol for SHSignatureGenerator {}
27);
28
29impl SHSignatureGenerator {
30 extern_methods!(
31 #[cfg(all(
32 feature = "SHSignature",
33 feature = "block2",
34 feature = "objc2-av-foundation"
35 ))]
36 /// Creates a signature with the asset you specify.
37 ///
38 /// > Important:
39 /// > You can call this method from synchronous code using a completion handler, as shown on this page, or you can call it as an asynchronous method that has the following declaration:
40 /// >
41 /// > ```swift
42 /// > class func signature(from asset: AVAsset) async throws -> SHSignature
43 /// > ```
44 /// >
45 /// > For information about concurrency and asynchronous code in Swift, see
46 /// <doc
47 /// ://com.apple.documentation/documentation/swift/calling-objective-c-apis-asynchronously>.
48 ///
49 /// The asset you specify can be any type of media that contains audio tracks. If the asset has multiple tracks, the system mixes them into one ``SHSignature``.
50 ///
51 /// - Parameters:
52 /// - asset: An asset that contains the audio to convert.
53 /// - completionHandler: The system calls this completion block after creating the signature, or an error if the system couldn't create it.
54 ///
55 /// This block takes the following parameters:
56 ///
57 /// - term `signature`: A new signature instance.
58 /// - term error: An error object if a problem occurs when creating thesignature; otherwise, `nil`.
59 #[unsafe(method(generateSignatureFromAsset:completionHandler:))]
60 #[unsafe(method_family = none)]
61 pub unsafe fn generateSignatureFromAsset_completionHandler(
62 asset: &AVAsset,
63 completion_handler: &block2::DynBlock<dyn Fn(*mut SHSignature, *mut NSError)>,
64 );
65
66 #[cfg(feature = "objc2-avf-audio")]
67 /// Adds audio to the generator.
68 ///
69 /// Using noncontiguous audio may result in a lower-quality signature.
70 ///
71 /// The audio must be PCM at one of these rates:
72 ///
73 /// - `48000` hertz
74 /// - `44100` hertz
75 /// - `32000` hertz
76 /// - `16000` hertz
77 ///
78 /// - Parameters:
79 /// - buffer: The audio data to append to the signature generator.
80 /// - time: The time position of the start of the audio buffer in the full audio you use to generate the signature.
81 /// - error: The error that occurs; otherwise, `nil`.
82 #[unsafe(method(appendBuffer:atTime:error:_))]
83 #[unsafe(method_family = none)]
84 pub unsafe fn appendBuffer_atTime_error(
85 &self,
86 buffer: &AVAudioPCMBuffer,
87 time: Option<&AVAudioTime>,
88 ) -> Result<(), Retained<NSError>>;
89
90 #[cfg(feature = "SHSignature")]
91 /// Converts the audio buffer into a signature.
92 ///
93 /// - Returns: A signature that ShazamKit generates from the audio buffer.
94 #[unsafe(method(signature))]
95 #[unsafe(method_family = none)]
96 pub unsafe fn signature(&self) -> Retained<SHSignature>;
97 );
98}
99
100/// Methods declared on superclass `NSObject`.
101impl SHSignatureGenerator {
102 extern_methods!(
103 #[unsafe(method(init))]
104 #[unsafe(method_family = init)]
105 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
106
107 #[unsafe(method(new))]
108 #[unsafe(method_family = new)]
109 pub unsafe fn new() -> Retained<Self>;
110 );
111}