objc2-replay-kit 0.3.2

Bindings to the ReplayKit 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-app-kit")]
#[cfg(target_os = "macos")]
use objc2_app_kit::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
use objc2_foundation::*;

use crate::*;

extern_class!(
    /// Controller object that allows clients to present the macOS broadcast picker and returns the RPBroadcastController object that controls broadcast functionality.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/replaykit/rpbroadcastactivitycontroller?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct RPBroadcastActivityController;
);

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

impl RPBroadcastActivityController {
    extern_methods!(
        #[cfg(all(
            feature = "block2",
            feature = "objc2-app-kit",
            feature = "objc2-core-foundation"
        ))]
        #[cfg(target_os = "macos")]
        /// Shows the broadcast picker at specified origin point from specified application window. Loads a RPBroadcastActivityController instance and returns it in the handler block. Calling this will present a macOS picker with a list of available broadcast services for the user to select and return the the RPBroadcastActivityController object. Note, the origin point represent the top left hand corner position of the picker that will be displayed. Upon completion of the picker, the picker object will be automatically dismissed and the delegate's broadcastActivityController:didFinishWithBroadcastController:error: will be called.
        ///
        /// Parameter `point`: origin point where (0,0) is the bottom left of the specified application window
        ///
        /// Parameter `window`: application window presenting the picker. nil specifies the picker is presented from the application main window.
        ///
        /// Parameter `preferredExtension`: The extension bundle identifier for the preferred broadcast extension service. nil specifies all extensions will be shown.
        ///
        /// The handler will be called after the user us finished with the picker and has finish setting up the broadcast extension, which will provide an instance of RPBroadcastAcvityController and an error if one occured.
        #[unsafe(method(showBroadcastPickerAtPoint:fromWindow:preferredExtensionIdentifier:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn showBroadcastPickerAtPoint_fromWindow_preferredExtensionIdentifier_completionHandler(
            point: CGPoint,
            window: Option<&NSWindow>,
            preferred_extension: Option<&NSString>,
            handler: &block2::DynBlock<dyn Fn(*mut RPBroadcastActivityController, *mut NSError)>,
        );

        /// Delegate that is notified when the activity view controller is complete.
        #[unsafe(method(delegate))]
        #[unsafe(method_family = none)]
        pub unsafe fn delegate(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn RPBroadcastActivityControllerDelegate>>>;

        /// Setter for [`delegate`][Self::delegate].
        ///
        /// This is a [weak property][objc2::topics::weak_property].
        #[unsafe(method(setDelegate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDelegate(
            &self,
            delegate: Option<&ProtocolObject<dyn RPBroadcastActivityControllerDelegate>>,
        );
    );
}

/// Methods declared on superclass `NSObject`.
impl RPBroadcastActivityController {
    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>;
    );
}

extern_protocol!(
    /// RPBroadcastActivityControllerDelegate is used to notify the caller when the user has finshed with the RPBroadcastActivityController's picker.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/replaykit/rpbroadcastactivitycontrollerdelegate?language=objc)
    pub unsafe trait RPBroadcastActivityControllerDelegate: NSObjectProtocol {
        #[unsafe(method(broadcastActivityController:didFinishWithBroadcastController:error:))]
        #[unsafe(method_family = none)]
        unsafe fn broadcastActivityController_didFinishWithBroadcastController_error(
            &self,
            broadcast_activity_controller: &RPBroadcastActivityController,
            broadcast_controller: Option<&RPBroadcastController>,
            error: Option<&NSError>,
        );
    }
);

extern_class!(
    /// Available once a user has successfully initiated a broadcast using an RPBroadcastActivityViewController. Can be used to start, pause and stop a broadcast.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/replaykit/rpbroadcastcontroller?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct RPBroadcastController;
);

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

impl RPBroadcastController {
    extern_methods!(
        #[unsafe(method(isBroadcasting))]
        #[unsafe(method_family = none)]
        pub unsafe fn isBroadcasting(&self) -> bool;

        #[unsafe(method(isPaused))]
        #[unsafe(method_family = none)]
        pub unsafe fn isPaused(&self) -> bool;

        #[unsafe(method(broadcastURL))]
        #[unsafe(method_family = none)]
        pub unsafe fn broadcastURL(&self) -> Retained<NSURL>;

        #[unsafe(method(serviceInfo))]
        #[unsafe(method_family = none)]
        pub unsafe fn serviceInfo(&self) -> Option<Retained<NSDictionary<NSString, NSObject>>>;

        #[unsafe(method(delegate))]
        #[unsafe(method_family = none)]
        pub unsafe fn delegate(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn RPBroadcastControllerDelegate>>>;

        /// Setter for [`delegate`][Self::delegate].
        ///
        /// This is a [weak property][objc2::topics::weak_property].
        #[unsafe(method(setDelegate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDelegate(
            &self,
            delegate: Option<&ProtocolObject<dyn RPBroadcastControllerDelegate>>,
        );

        #[deprecated = "No longer supported"]
        #[unsafe(method(broadcastExtensionBundleID))]
        #[unsafe(method_family = none)]
        pub unsafe fn broadcastExtensionBundleID(&self) -> Option<Retained<NSString>>;

        #[cfg(feature = "block2")]
        #[unsafe(method(startBroadcastWithHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn startBroadcastWithHandler(
            &self,
            handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
        );

        #[unsafe(method(pauseBroadcast))]
        #[unsafe(method_family = none)]
        pub unsafe fn pauseBroadcast(&self);

        #[unsafe(method(resumeBroadcast))]
        #[unsafe(method_family = none)]
        pub unsafe fn resumeBroadcast(&self);

        #[cfg(feature = "block2")]
        #[unsafe(method(finishBroadcastWithHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn finishBroadcastWithHandler(
            &self,
            handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
        );
    );
}

/// Methods declared on superclass `NSObject`.
impl RPBroadcastController {
    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>;
    );
}

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/replaykit/rpbroadcastcontrollerdelegate?language=objc)
    pub unsafe trait RPBroadcastControllerDelegate: NSObjectProtocol {
        #[optional]
        #[unsafe(method(broadcastController:didFinishWithError:))]
        #[unsafe(method_family = none)]
        unsafe fn broadcastController_didFinishWithError(
            &self,
            broadcast_controller: &RPBroadcastController,
            error: Option<&NSError>,
        );

        /// # Safety
        ///
        /// `service_info` generic must implement NSCoding.
        #[optional]
        #[unsafe(method(broadcastController:didUpdateServiceInfo:))]
        #[unsafe(method_family = none)]
        unsafe fn broadcastController_didUpdateServiceInfo(
            &self,
            broadcast_controller: &RPBroadcastController,
            service_info: &NSDictionary<NSString, NSObject>,
        );

        #[optional]
        #[unsafe(method(broadcastController:didUpdateBroadcastURL:))]
        #[unsafe(method_family = none)]
        unsafe fn broadcastController_didUpdateBroadcastURL(
            &self,
            broadcast_controller: &RPBroadcastController,
            broadcast_url: &NSURL,
        );
    }
);