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-foundation")]
use objc2_core_foundation::*;
#[cfg(feature = "objc2-core-video")]
use objc2_core_video::*;
use objc2_foundation::*;
#[cfg(feature = "objc2-quartz-core")]
#[cfg(not(target_os = "watchos"))]
use objc2_quartz_core::*;

use crate::*;

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerlayer?language=objc)
    #[unsafe(super(CALayer, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "objc2-quartz-core")]
    #[cfg(not(target_os = "watchos"))]
    pub struct AVPlayerLayer;
);

#[cfg(feature = "objc2-quartz-core")]
#[cfg(not(target_os = "watchos"))]
extern_conformance!(
    unsafe impl CAMediaTiming for AVPlayerLayer {}
);

#[cfg(feature = "objc2-quartz-core")]
#[cfg(not(target_os = "watchos"))]
extern_conformance!(
    unsafe impl NSCoding for AVPlayerLayer {}
);

#[cfg(feature = "objc2-quartz-core")]
#[cfg(not(target_os = "watchos"))]
extern_conformance!(
    unsafe impl NSObjectProtocol for AVPlayerLayer {}
);

#[cfg(feature = "objc2-quartz-core")]
#[cfg(not(target_os = "watchos"))]
extern_conformance!(
    unsafe impl NSSecureCoding for AVPlayerLayer {}
);

#[cfg(feature = "objc2-quartz-core")]
#[cfg(not(target_os = "watchos"))]
impl AVPlayerLayer {
    extern_methods!(
        #[cfg(feature = "AVPlayer")]
        /// Returns an instance of AVPlayerLayer to display the visual output of the specified AVPlayer.
        ///
        /// Returns: An instance of AVPlayerLayer.
        #[unsafe(method(playerLayerWithPlayer:))]
        #[unsafe(method_family = none)]
        pub unsafe fn playerLayerWithPlayer(player: Option<&AVPlayer>) -> Retained<AVPlayerLayer>;

        #[cfg(feature = "AVPlayer")]
        /// Indicates the instance of AVPlayer for which the AVPlayerLayer displays visual output
        #[unsafe(method(player))]
        #[unsafe(method_family = none)]
        pub unsafe fn player(&self, mtm: MainThreadMarker) -> Option<Retained<AVPlayer>>;

        #[cfg(feature = "AVPlayer")]
        /// Setter for [`player`][Self::player].
        #[unsafe(method(setPlayer:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPlayer(&self, player: Option<&AVPlayer>);

        #[cfg(feature = "AVAnimation")]
        /// A string defining how the video is displayed within an AVPlayerLayer bounds rect.
        ///
        /// Options are AVLayerVideoGravityResizeAspect, AVLayerVideoGravityResizeAspectFill
        /// and AVLayerVideoGravityResize. AVLayerVideoGravityResizeAspect is default.
        /// See
        /// <AVFoundation
        /// /AVAnimation.h> for a description of these options.
        #[unsafe(method(videoGravity))]
        #[unsafe(method_family = none)]
        pub unsafe fn videoGravity(&self) -> Retained<AVLayerVideoGravity>;

        #[cfg(feature = "AVAnimation")]
        /// Setter for [`videoGravity`][Self::videoGravity].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setVideoGravity:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setVideoGravity(&self, video_gravity: &AVLayerVideoGravity);

        /// Boolean indicating that the first video frame has been made ready for display for the current item of the associated AVPlayer.
        ///
        /// Use this property as an indicator of when best to show or animate-in an AVPlayerLayer into view.
        /// An AVPlayerLayer may be displayed, or made visible, while this property is NO, however the layer will not have any user-visible content until the value becomes YES. Note that if an animation is added to an AVPlayerLayer before it becomes readyForDisplay the video image displayed inside might not animate with the receiver.
        /// This property remains NO for an AVPlayer currentItem whose AVAsset contains no enabled video tracks.
        /// This property is key-value observable.
        #[unsafe(method(isReadyForDisplay))]
        #[unsafe(method_family = none)]
        pub unsafe fn isReadyForDisplay(&self) -> bool;

        #[cfg(feature = "objc2-core-foundation")]
        /// The current size and position of the video image as displayed within the receiver's bounds.
        #[unsafe(method(videoRect))]
        #[unsafe(method_family = none)]
        pub unsafe fn videoRect(&self) -> CGRect;

        /// The client requirements for the visual output displayed in AVPlayerLayer during playback.
        ///
        /// Pixel buffer attribute keys are defined in
        /// <CoreVideo
        /// /CVPixelBuffer.h>
        /// This property is key-value observable.
        #[unsafe(method(pixelBufferAttributes))]
        #[unsafe(method_family = none)]
        pub unsafe fn pixelBufferAttributes(
            &self,
        ) -> Option<Retained<NSDictionary<NSString, AnyObject>>>;

        /// Setter for [`pixelBufferAttributes`][Self::pixelBufferAttributes].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        ///
        /// # Safety
        ///
        /// `pixel_buffer_attributes` generic should be of the correct type.
        #[unsafe(method(setPixelBufferAttributes:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPixelBufferAttributes(
            &self,
            pixel_buffer_attributes: Option<&NSDictionary<NSString, AnyObject>>,
        );

        #[cfg(feature = "objc2-core-video")]
        /// Returns a retained reference to the pixel buffer currently displayed in this AVPlayerLayer. This will return NULL if the displayed pixel buffer is protected, no image is currently being displayed, if the current player's rate is non-zero or if the image is unavailable.
        ///
        /// This will only return the current image while the media is paused, otherwise this will return nil. Clients must release the pixel buffer after use.
        ///
        /// Do not write to the returned CVPixelBuffer's attachments or pixel data.
        #[unsafe(method(copyDisplayedPixelBuffer))]
        #[unsafe(method_family = copy)]
        pub unsafe fn copyDisplayedPixelBuffer(&self) -> Option<Retained<CVPixelBuffer>>;
    );
}

/// Methods declared on superclass `CALayer`.
#[cfg(feature = "objc2-quartz-core")]
#[cfg(not(target_os = "watchos"))]
impl AVPlayerLayer {
    extern_methods!(
        /// Layer creation and initialization. *
        #[unsafe(method(layer))]
        #[unsafe(method_family = none)]
        pub unsafe fn layer() -> Retained<Self>;

        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        /// # Safety
        ///
        /// `layer` should be of the correct type.
        #[unsafe(method(initWithLayer:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithLayer(this: Allocated<Self>, layer: &AnyObject) -> Retained<Self>;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "objc2-quartz-core")]
#[cfg(not(target_os = "watchos"))]
impl AVPlayerLayer {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}