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 objc2_foundation::*;

use crate::*;

/// These constants are returned by the AVCaptionConversionValidator status property to indicate the progress of a validation operation.
///
///
/// Indicates that the validation operation has not yet been initiated.
///
/// Indicates that the validation operation is currently in progress.
///
/// Indicates that the validation operation has been completed.
///
/// Indicates that the validation operation was stopped prior to completion.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcaptionconversionvalidatorstatus?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct AVCaptionConversionValidatorStatus(pub NSInteger);
impl AVCaptionConversionValidatorStatus {
    #[doc(alias = "AVCaptionConversionValidatorStatusUnknown")]
    pub const Unknown: Self = Self(0);
    #[doc(alias = "AVCaptionConversionValidatorStatusValidating")]
    pub const Validating: Self = Self(1);
    #[doc(alias = "AVCaptionConversionValidatorStatusCompleted")]
    pub const Completed: Self = Self(2);
    #[doc(alias = "AVCaptionConversionValidatorStatusStopped")]
    pub const Stopped: Self = Self(3);
}

unsafe impl Encode for AVCaptionConversionValidatorStatus {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for AVCaptionConversionValidatorStatus {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    /// Performs a validation of captions for a conversion operation and warns about problems that are encountered.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcaptionconversionvalidator?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct AVCaptionConversionValidator;
);

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

impl AVCaptionConversionValidator {
    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>;

        #[cfg(all(
            feature = "AVCaption",
            feature = "AVCaptionSettings",
            feature = "objc2-core-media"
        ))]
        /// Returns an instance of AVCaptionConversionValidator that can validate an array of captions for a specific conversion operation and warn about problems that are encountered.
        ///
        /// Parameter `captions`: The array of captions to be validated.
        ///
        /// Parameter `timeRange`: The timeRange of the media timeline into which the specified captions must be integrated. See the timeRange property for further details.
        ///
        /// Parameter `conversionSettings`: Describes the conversion operation for which the captions are to be validated.
        ///
        /// Returns: A new instance of AVCaptionConversionValidator configured to perform the specified validation.
        ///
        /// This method throws an exception if the conversion setting's AVCaptionMediaTypeKey is not equal to AVMediaTypeClosedCaption, or if its AVCaptionMediaSubTypeKey is not equal to kCMClosedCaptionFormatType_CEA608.
        ///
        /// # Safety
        ///
        /// `conversion_settings` generic should be of the correct type.
        #[unsafe(method(captionConversionValidatorWithCaptions:timeRange:conversionSettings:))]
        #[unsafe(method_family = none)]
        pub unsafe fn captionConversionValidatorWithCaptions_timeRange_conversionSettings(
            captions: &NSArray<AVCaption>,
            time_range: CMTimeRange,
            conversion_settings: &NSDictionary<AVCaptionSettingsKey, AnyObject>,
        ) -> Retained<Self>;

        #[cfg(all(
            feature = "AVCaption",
            feature = "AVCaptionSettings",
            feature = "objc2-core-media"
        ))]
        /// Returns an instance of AVCaptionConversionValidator that can validate an array of captions for a specific conversion operation and warn about problems that are encountered.
        ///
        /// Parameter `captions`: The array of captions for which the validation is requested.
        ///
        /// Parameter `timeRange`: The timeRange of the media timeline into which the specified captions must be integrated. See the timeRange property for further details.
        ///
        /// Parameter `conversionSettings`: Describes the conversion operation for which the captions are to be validated.
        ///
        /// Returns: A new instance of AVCaptionConversionValidator configured to perform the specified validation.
        ///
        /// # Safety
        ///
        /// `conversion_settings` generic should be of the correct type.
        #[unsafe(method(initWithCaptions:timeRange:conversionSettings:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithCaptions_timeRange_conversionSettings(
            this: Allocated<Self>,
            captions: &NSArray<AVCaption>,
            time_range: CMTimeRange,
            conversion_settings: &NSDictionary<AVCaptionSettingsKey, AnyObject>,
        ) -> Retained<Self>;

        /// Indicates the status of the validation.
        #[unsafe(method(status))]
        #[unsafe(method_family = none)]
        pub unsafe fn status(&self) -> AVCaptionConversionValidatorStatus;

        #[cfg(feature = "AVCaption")]
        /// The array of captions to be validated for the specified conversion operation.
        #[unsafe(method(captions))]
        #[unsafe(method_family = none)]
        pub unsafe fn captions(&self) -> Retained<NSArray<AVCaption>>;

        #[cfg(feature = "objc2-core-media")]
        /// The timeRange of the media timeline into which the specified captions must be integrated.
        ///
        /// The start of this timeRange may be less than the start of the timeRange of the initial caption in the captions array, if the captions are to appear only after the start of accompanying video or audio. If no definite duration for the media timeline is known, the timeRange can have a duration of kCMTimePositiveInfinity. However, in order to perform a comprehensive validation of a conversion to closed captions, setting the duration of the timeRange to the duration of accompanying video media is recommended.
        #[unsafe(method(timeRange))]
        #[unsafe(method_family = none)]
        pub unsafe fn timeRange(&self) -> CMTimeRange;

        #[cfg(feature = "block2")]
        /// Initiates the specified validation and changes the value of status to AVCaptionConversionValidatorStatusValidating.
        ///
        /// Parameter `handler`: Specifies a block to be executed in order to warn you of a specific problem.
        ///
        /// It is an error to invoke this method when the value of status is greater than AVCaptionConversionValidatorStatusUnknown.
        /// If you wish to stop a validation operation in progress before it has been completed, send the message stopValidating to the receiver.
        /// When the validation is complete and all warnings have been reported, the block will be executed once with a value of nil for its warning parameter. When this occurs, the value of status will have been changed to AVCaptionConversionValidatorStatusCompleted.
        ///
        /// # Safety
        ///
        /// `handler` block must be sendable.
        #[unsafe(method(validateCaptionConversionWithWarningHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn validateCaptionConversionWithWarningHandler(
            &self,
            handler: &block2::DynBlock<dyn Fn(*mut AVCaptionConversionWarning)>,
        );

        /// Stops validation and changes the value of status to AVCaptionConversionValidatorStatusStopped.
        ///
        /// You can call this method at any time, even within your warning handler.
        #[unsafe(method(stopValidating))]
        #[unsafe(method_family = none)]
        pub unsafe fn stopValidating(&self);

        /// Provides the collection of warnings for problems that have been encountered. While the value of status is AVCaptionConversionValidatorStatusValidating, the count of warnings may increase.
        #[unsafe(method(warnings))]
        #[unsafe(method_family = none)]
        pub unsafe fn warnings(&self) -> Retained<NSArray<AVCaptionConversionWarning>>;
    );
}

/// The type of a caption conversion warning.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcaptionconversionwarningtype?language=objc)
// NS_TYPED_ENUM
pub type AVCaptionConversionWarningType = NSString;

extern "C" {
    /// Indicates that one or more captions in the validator's captions array exceed the capacity for media data of the media type and subtype specified by the conversion settings.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcaptionconversionwarningtypeexcessmediadata?language=objc)
    pub static AVCaptionConversionWarningTypeExcessMediaData:
        &'static AVCaptionConversionWarningType;
}

extern_class!(
    /// Reports a specific problem encountered during the validation of a caption conversion.
    ///
    /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcaptionconversionwarning?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct AVCaptionConversionWarning;
);

unsafe impl Send for AVCaptionConversionWarning {}

unsafe impl Sync for AVCaptionConversionWarning {}

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

impl AVCaptionConversionWarning {
    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>;

        /// Indicates the type of warning provided by the receiver.
        #[unsafe(method(warningType))]
        #[unsafe(method_family = none)]
        pub unsafe fn warningType(&self) -> Retained<AVCaptionConversionWarningType>;

        /// Indicates the range of captions in the validator's captions array for which the specified warning has been issued.
        ///
        /// Only captions with the same start time and duration will be referenced. If captions with different start times and durations exhibit similar problems, a separate instance of AVCaptionConversionWarning will be used to indicate each problematic case. If the referenced captions have multiple problems, a separate instance of AVCaptionConversionWarning will be issued to indicate each problem.
        #[unsafe(method(rangeOfCaptions))]
        #[unsafe(method_family = none)]
        pub unsafe fn rangeOfCaptions(&self) -> NSRange;

        /// Indicates an adjustment to the indicated captions that can be applied in order to correct the problem.
        ///
        /// If the value of adjustment is not nil and the conversion operation is performed without correcting the problem, the adjustment will be applied during conversion. If the value of adjustment is nil and the conversion operation is performed without correcting the problem, the indicated captions will be omitted from the output media data.
        #[unsafe(method(adjustment))]
        #[unsafe(method_family = none)]
        pub unsafe fn adjustment(&self) -> Option<Retained<AVCaptionConversionAdjustment>>;
    );
}

/// The type of a caption conversion adjustment.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcaptionconversionadjustmenttype?language=objc)
// NS_TYPED_ENUM
pub type AVCaptionConversionAdjustmentType = NSString;

extern "C" {
    /// Indicates a timing adjustment.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcaptionconversionadjustmenttypetimerange?language=objc)
    pub static AVCaptionConversionAdjustmentTypeTimeRange:
        &'static AVCaptionConversionAdjustmentType;
}

extern_class!(
    /// Describes an adjustment that can be performed in order to correct a problem encountered during the validation of a caption conversion.
    ///
    /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcaptionconversionadjustment?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct AVCaptionConversionAdjustment;
);

unsafe impl Send for AVCaptionConversionAdjustment {}

unsafe impl Sync for AVCaptionConversionAdjustment {}

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

impl AVCaptionConversionAdjustment {
    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>;

        /// Indicates the type of adjustment described by the receiver.
        #[unsafe(method(adjustmentType))]
        #[unsafe(method_family = none)]
        pub unsafe fn adjustmentType(&self) -> Retained<AVCaptionConversionAdjustmentType>;
    );
}

extern_class!(
    /// Describes an adjustment to the timeRange of one or more captions.
    ///
    /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcaptionconversiontimerangeadjustment?language=objc)
    #[unsafe(super(AVCaptionConversionAdjustment, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct AVCaptionConversionTimeRangeAdjustment;
);

unsafe impl Send for AVCaptionConversionTimeRangeAdjustment {}

unsafe impl Sync for AVCaptionConversionTimeRangeAdjustment {}

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

impl AVCaptionConversionTimeRangeAdjustment {
    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>;

        #[cfg(feature = "objc2-core-media")]
        /// Indicates the amount by which the timeRange.start of the captions must be adjusted in order to correct a problem.
        ///
        /// The value may any numeric value, positive, negative, or zero.
        #[unsafe(method(startTimeOffset))]
        #[unsafe(method_family = none)]
        pub unsafe fn startTimeOffset(&self) -> CMTime;

        #[cfg(feature = "objc2-core-media")]
        /// Indicates the amount by which the timeRange.duration of the captions must be adjusted in order to correct a problem.
        ///
        /// The value may any numeric value, positive, negative, or zero.
        #[unsafe(method(durationOffset))]
        #[unsafe(method_family = none)]
        pub unsafe fn durationOffset(&self) -> CMTime;
    );
}