objc2_av_foundation/generated/
AVCaptureAudioDataOutput.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
14extern_class!(
15    /// AVCaptureAudioDataOutput is a concrete subclass of AVCaptureOutput that can be used to process uncompressed or compressed samples from the audio being captured.
16    ///
17    ///
18    /// Instances of AVCaptureAudioDataOutput produce audio sample buffers suitable for processing using other media APIs. Applications can access the sample buffers with the captureOutput:didOutputSampleBuffer:fromConnection: delegate method.
19    ///
20    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcaptureaudiodataoutput?language=objc)
21    #[unsafe(super(AVCaptureOutput, NSObject))]
22    #[derive(Debug, PartialEq, Eq, Hash)]
23    #[cfg(feature = "AVCaptureOutputBase")]
24    pub struct AVCaptureAudioDataOutput;
25);
26
27#[cfg(feature = "AVCaptureOutputBase")]
28extern_conformance!(
29    unsafe impl NSObjectProtocol for AVCaptureAudioDataOutput {}
30);
31
32#[cfg(feature = "AVCaptureOutputBase")]
33impl AVCaptureAudioDataOutput {
34    extern_methods!(
35        #[unsafe(method(init))]
36        #[unsafe(method_family = init)]
37        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
38
39        #[unsafe(method(new))]
40        #[unsafe(method_family = new)]
41        pub unsafe fn new() -> Retained<Self>;
42
43        #[cfg(feature = "dispatch2")]
44        /// Sets the receiver's delegate that will accept captured buffers and dispatch queue on which the delegate will be called.
45        ///
46        ///
47        /// Parameter `sampleBufferDelegate`: An object conforming to the AVCaptureAudioDataOutputSampleBufferDelegate protocol that will receive sample buffers after they are captured.
48        ///
49        /// Parameter `sampleBufferCallbackQueue`: A dispatch queue on which all sample buffer delegate methods will be called.
50        ///
51        ///
52        /// When a new audio sample buffer is captured it will be vended to the sample buffer delegate using the captureOutput:didOutputSampleBuffer:fromConnection: delegate method. All delegate methods will be called on the specified dispatch queue. If the queue is blocked when new samples are captured, those samples will be automatically dropped when they become sufficiently late. This allows clients to process existing samples on the same queue without having to manage the potential memory usage increases that would otherwise occur when that processing is unable to keep up with the rate of incoming samples.
53        ///
54        /// Clients that need to minimize the chances of samples being dropped should specify a queue on which a sufficiently small amount of processing is being done outside of receiving sample buffers. However, if such clients migrate extra processing to another queue, they are responsible for ensuring that memory usage does not grow without bound from samples that have not been processed.
55        ///
56        /// A serial dispatch queue must be used to guarantee that audio samples will be delivered in order. The sampleBufferCallbackQueue parameter may not be NULL, except when setting sampleBufferDelegate to nil otherwise -setSampleBufferDelegate:queue: throws an NSInvalidArgumentException.
57        #[unsafe(method(setSampleBufferDelegate:queue:))]
58        #[unsafe(method_family = none)]
59        pub unsafe fn setSampleBufferDelegate_queue(
60            &self,
61            sample_buffer_delegate: Option<
62                &ProtocolObject<dyn AVCaptureAudioDataOutputSampleBufferDelegate>,
63            >,
64            sample_buffer_callback_queue: Option<&DispatchQueue>,
65        );
66
67        /// The receiver's delegate.
68        ///
69        ///
70        /// The value of this property is an object conforming to the AVCaptureAudioDataOutputSampleBufferDelegate protocol that will receive sample buffers after they are captured. The delegate is set using the setSampleBufferDelegate:queue: method.
71        #[unsafe(method(sampleBufferDelegate))]
72        #[unsafe(method_family = none)]
73        pub unsafe fn sampleBufferDelegate(
74            &self,
75        ) -> Option<Retained<ProtocolObject<dyn AVCaptureAudioDataOutputSampleBufferDelegate>>>;
76
77        #[cfg(feature = "dispatch2")]
78        /// The dispatch queue on which all sample buffer delegate methods will be called.
79        ///
80        ///
81        /// The value of this property is a dispatch_queue_t. The queue is set using the setSampleBufferDelegate:queue: method.
82        #[unsafe(method(sampleBufferCallbackQueue))]
83        #[unsafe(method_family = none)]
84        pub unsafe fn sampleBufferCallbackQueue(&self) -> Option<Retained<DispatchQueue>>;
85
86        /// Specifies the settings used to decode or re-encode audio before it is output by the receiver.
87        ///
88        ///
89        /// The value of this property is an NSDictionary containing values for audio settings keys defined in AVAudioSettings.h. When audioSettings is set to nil, the AVCaptureAudioDataOutput vends samples in their device native format.
90        #[unsafe(method(audioSettings))]
91        #[unsafe(method_family = none)]
92        pub unsafe fn audioSettings(&self) -> Retained<NSDictionary<NSString, AnyObject>>;
93
94        /// Setter for [`audioSettings`][Self::audioSettings].
95        #[unsafe(method(setAudioSettings:))]
96        #[unsafe(method_family = none)]
97        pub unsafe fn setAudioSettings(
98            &self,
99            audio_settings: Option<&NSDictionary<NSString, AnyObject>>,
100        );
101
102        #[cfg(feature = "AVMediaFormat")]
103        /// Specifies the recommended settings for use with an AVAssetWriterInput.
104        ///
105        ///
106        /// Parameter `outputFileType`: Specifies the UTI of the file type to be written (see AVMediaFormat.h for a list of file format UTIs).
107        ///
108        /// Returns: A fully populated dictionary of keys and values that are compatible with AVAssetWriter.
109        ///
110        ///
111        /// The value of this property is an NSDictionary containing values for compression settings keys defined in AVAudioSettings.h. This dictionary is suitable for use as the "outputSettings" parameter when creating an AVAssetWriterInput, such as,
112        ///
113        /// [AVAssetWriterInput assetWriterInputWithMediaType:AVMediaTypeAudio outputSettings:outputSettings sourceFormatHint:hint];
114        ///
115        /// The dictionary returned contains all necessary keys and values needed by AVAssetWriter (see AVAssetWriterInput.h, -initWithMediaType:outputSettings: for a more in depth discussion). For QuickTime movie and ISO files, the recommended audio settings will always produce output comparable to that of AVCaptureMovieFileOutput.
116        ///
117        /// Note that the dictionary of settings is dependent on the current configuration of the receiver's AVCaptureSession and its inputs. The settings dictionary may change if the session's configuration changes. As such, you should configure your session first, then query the recommended audio settings.
118        #[unsafe(method(recommendedAudioSettingsForAssetWriterWithOutputFileType:))]
119        #[unsafe(method_family = none)]
120        pub unsafe fn recommendedAudioSettingsForAssetWriterWithOutputFileType(
121            &self,
122            output_file_type: &AVFileType,
123        ) -> Option<Retained<NSDictionary<NSString, AnyObject>>>;
124    );
125}
126
127extern_protocol!(
128    /// Defines an interface for delegates of AVCaptureAudioDataOutput to receive captured audio sample buffers.
129    ///
130    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcaptureaudiodataoutputsamplebufferdelegate?language=objc)
131    pub unsafe trait AVCaptureAudioDataOutputSampleBufferDelegate: NSObjectProtocol {
132        #[cfg(all(
133            feature = "AVCaptureOutputBase",
134            feature = "AVCaptureSession",
135            feature = "objc2-core-media"
136        ))]
137        /// Called whenever an AVCaptureAudioDataOutput instance outputs a new audio sample buffer.
138        ///
139        ///
140        /// Parameter `output`: The AVCaptureAudioDataOutput instance that output the samples.
141        ///
142        /// Parameter `sampleBuffer`: A CMSampleBuffer object containing the audio samples and additional information about them, such as their format and presentation time.
143        ///
144        /// Parameter `connection`: The AVCaptureConnection from which the audio was received.
145        ///
146        ///
147        /// Delegates receive this message whenever the output captures and outputs new audio samples, decoding or re-encoding as specified by the audioSettings property. Delegates can use the provided sample buffer in conjunction with other APIs for further processing. This method will be called on the dispatch queue specified by the output's sampleBufferCallbackQueue property. This method is called periodically, so it must be efficient to prevent capture performance problems, including dropped audio samples.
148        ///
149        /// Clients that need to reference the CMSampleBuffer object outside of the scope of this method must CFRetain it and then CFRelease it when they are finished with it.
150        #[optional]
151        #[unsafe(method(captureOutput:didOutputSampleBuffer:fromConnection:))]
152        #[unsafe(method_family = none)]
153        unsafe fn captureOutput_didOutputSampleBuffer_fromConnection(
154            &self,
155            output: &AVCaptureOutput,
156            sample_buffer: &CMSampleBuffer,
157            connection: &AVCaptureConnection,
158        );
159    }
160);