objc2-av-foundation 0.3.2

Bindings to the AVFoundation framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-core-media")]
use objc2_core_media::*;

use crate::*;

extern_class!(
    /// An interface for generating a spatial audio timed metadata sample.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcapturespatialaudiometadatasamplegenerator?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct AVCaptureSpatialAudioMetadataSampleGenerator;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for AVCaptureSpatialAudioMetadataSampleGenerator {}
);

impl AVCaptureSpatialAudioMetadataSampleGenerator {
    extern_methods!(
        #[cfg(feature = "objc2-core-media")]
        /// Returns the format description of the sample buffer returned from the ``newTimedMetadataSampleBufferAndResetAnalyzer`` method.
        ///
        /// Use this format description when creating your ``AVAssetWriter`` track for spatial audio timed metadata.
        #[unsafe(method(timedMetadataSampleBufferFormatDescription))]
        #[unsafe(method_family = none)]
        pub unsafe fn timedMetadataSampleBufferFormatDescription(
            &self,
        ) -> Retained<CMFormatDescription>;

        #[cfg(feature = "objc2-core-media")]
        /// Analyzes the provided audio sample buffer for its contribution to the spatial audio timed metadata value.
        ///
        /// - Parameter sbuf: a sample buffer containing spatial audio.
        /// - Returns: `noErr` if the sample is successfully analyzed, otherwise a non-zero error code.
        ///
        /// You must call this method with each and every spatial audio buffer you provide to ``AVAssetWriter``, so it can be analyzed for the generation of a proper spatial audio timed metadata value.
        #[unsafe(method(analyzeAudioSample:))]
        #[unsafe(method_family = none)]
        pub unsafe fn analyzeAudioSample(&self, sbuf: &CMSampleBuffer) -> OSStatus;

        #[cfg(feature = "objc2-core-media")]
        /// Creates a sample buffer containing a spatial audio timed metadata sample computed from all analyzed audio buffers, and resets the analyzer to its initial state.
        ///
        /// - Returns: a ``CMSampleBufferRef`` containing the spatial audio timed metadata sample, or `NULL` if no value can be computed.
        ///
        /// Call this method after you pass the last audio sample buffer of your recording to ``analyzeAudioSample:``. Then pass the returned ``CMSampleBufferRef`` directly to your ``AVAssetWriterInput`` to add the sample to your recording's audio timed metadata track. Note that ``AVAssetWriter`` expects one and only one spatial audio metadata sample buffer to be present in the timed metadata track.
        ///
        /// - Note: Calling this method also resets the analyzer, making it ready for another run of audio sample buffers. Thus one generator can be re-used for multiple recordings.
        #[unsafe(method(newTimedMetadataSampleBufferAndResetAnalyzer))]
        #[unsafe(method_family = none)]
        pub unsafe fn newTimedMetadataSampleBufferAndResetAnalyzer(
            &self,
        ) -> Option<Retained<CMSampleBuffer>>;

        /// Calling this method resets the analyzer to its initial state so that a new run of audio sample buffers can be analyzed.
        ///
        /// Call this method if you need to abort generating the audio timed metadata buffer for audio already provided to ``analyzeAudioSample:``.
        #[unsafe(method(resetAnalyzer))]
        #[unsafe(method_family = none)]
        pub unsafe fn resetAnalyzer(&self);
    );
}

/// Methods declared on superclass `NSObject`.
impl AVCaptureSpatialAudioMetadataSampleGenerator {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}