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-media")]
use objc2_core_media::*;
use objc2_foundation::*;

use crate::*;

mod private_NSExtensionContextRPBroadcastExtension {
    pub trait Sealed {}
}

/// Category "RPBroadcastExtension" on [`NSExtensionContext`].
///
/// Category which defines the method to call from on an extension context object when user interaction is complete during the broadcast setup flow.
#[doc(alias = "RPBroadcastExtension")]
pub unsafe trait NSExtensionContextRPBroadcastExtension:
    ClassType + Sized + private_NSExtensionContextRPBroadcastExtension::Sealed
{
    extern_methods!(
        #[cfg(all(feature = "block2", feature = "objc2-app-kit"))]
        #[cfg(target_os = "macos")]
        /// Load information about the broadcasting app.
        ///
        /// Parameter `handler`: block which will be supplied a bundleID, displayName and an optional appIcon.
        #[unsafe(method(loadBroadcastingApplicationInfoWithCompletion:))]
        #[unsafe(method_family = none)]
        unsafe fn loadBroadcastingApplicationInfoWithCompletion(
            &self,
            handler: &block2::DynBlock<dyn Fn(NonNull<NSString>, NonNull<NSString>, *mut NSImage)>,
        );

        /// # Safety
        ///
        /// `setup_info` generic must implement NSCoding.
        #[unsafe(method(completeRequestWithBroadcastURL:setupInfo:))]
        #[unsafe(method_family = none)]
        unsafe fn completeRequestWithBroadcastURL_setupInfo(
            &self,
            broadcast_url: &NSURL,
            setup_info: Option<&NSDictionary<NSString, NSObject>>,
        );
    );
}

impl private_NSExtensionContextRPBroadcastExtension::Sealed for NSExtensionContext {}
unsafe impl NSExtensionContextRPBroadcastExtension for NSExtensionContext {}

extern_class!(
    /// Base class for extensions that are responsible for handling video and audio data.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/replaykit/rpbroadcasthandler?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct RPBroadcastHandler;
);

extern_conformance!(
    unsafe impl NSExtensionRequestHandling for RPBroadcastHandler {}
);

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

impl RPBroadcastHandler {
    extern_methods!(
        /// Call this method, supplying it with a dictionary defined by the service, to populate the serviceInfo property on RPBroadcastController. This can be used to communicate viewing stats or messages back to the broadcasting app.
        ///
        /// Parameter `serviceInfo`: Dictionary that can be passed back to the broadcasting app that may contain information about the ongoing broadcast.
        ///
        /// # Safety
        ///
        /// `service_info` generic must implement NSCoding.
        #[unsafe(method(updateServiceInfo:))]
        #[unsafe(method_family = none)]
        pub unsafe fn updateServiceInfo(&self, service_info: &NSDictionary<NSString, NSObject>);

        /// Call this method, supplying it with a URL to update the broadcastURL property on RPBroadcastController.
        ///
        /// Parameter `broadcastURL`: URL of the resource where broadcast can be viewed which will be passed to the broadcasting app.
        #[unsafe(method(updateBroadcastURL:))]
        #[unsafe(method_family = none)]
        pub unsafe fn updateBroadcastURL(&self, broadcast_url: &NSURL);
    );
}

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

/// [Apple's documentation](https://developer.apple.com/documentation/replaykit/rpsamplebuffertype?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct RPSampleBufferType(pub NSInteger);
impl RPSampleBufferType {
    #[doc(alias = "RPSampleBufferTypeVideo")]
    pub const Video: Self = Self(1);
    #[doc(alias = "RPSampleBufferTypeAudioApp")]
    pub const AudioApp: Self = Self(2);
    #[doc(alias = "RPSampleBufferTypeAudioMic")]
    pub const AudioMic: Self = Self(3);
}

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

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

extern "C" {
    /// RPVideoSampleOrientationKey
    ///
    /// Use this key in conjunction with CMGetAttachment on CMSampleBufferRef to get the orientation for the sample. The orientation will follow the enum CGImagePropertyOrientation
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/replaykit/rpvideosampleorientationkey?language=objc)
    pub static RPVideoSampleOrientationKey: &'static NSString;
}

extern "C" {
    /// RPApplicationInfoBundleIdentifierKey
    ///
    /// Use this key to retrieve bundle identifier from dictionary provided by broadcastAnnotatedWithApplicationInfo
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/replaykit/rpapplicationinfobundleidentifierkey?language=objc)
    pub static RPApplicationInfoBundleIdentifierKey: &'static NSString;
}

extern_class!(
    /// Subclass this class to handle CMSampleBuffer objects as they are captured by ReplayKit. To enable this mode of handling, set the RPBroadcastProcessMode in the extension's info.plist to RPBroadcastProcessModeSampleBuffer.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/replaykit/rpbroadcastsamplehandler?language=objc)
    #[unsafe(super(RPBroadcastHandler, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct RPBroadcastSampleHandler;
);

extern_conformance!(
    unsafe impl NSExtensionRequestHandling for RPBroadcastSampleHandler {}
);

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

impl RPBroadcastSampleHandler {
    extern_methods!(
        /// Method is called when the RPBroadcastController startBroadcast method is called from the broadcasting application.
        ///
        /// Parameter `setupInfo`: Dictionary that can be supplied by the UI extension to the sample handler.
        ///
        /// # Safety
        ///
        /// `setup_info` generic should be of the correct type.
        #[unsafe(method(broadcastStartedWithSetupInfo:))]
        #[unsafe(method_family = none)]
        pub unsafe fn broadcastStartedWithSetupInfo(
            &self,
            setup_info: Option<&NSDictionary<NSString, NSObject>>,
        );

        /// Method is called when the RPBroadcastController pauseBroadcast method is called from the broadcasting application.
        #[unsafe(method(broadcastPaused))]
        #[unsafe(method_family = none)]
        pub unsafe fn broadcastPaused(&self);

        /// Method is called when the RPBroadcastController resumeBroadcast method is called from the broadcasting application.
        #[unsafe(method(broadcastResumed))]
        #[unsafe(method_family = none)]
        pub unsafe fn broadcastResumed(&self);

        /// Method is called when the RPBroadcastController finishBroadcast method is called from the broadcasting application.
        #[unsafe(method(broadcastFinished))]
        #[unsafe(method_family = none)]
        pub unsafe fn broadcastFinished(&self);

        /// Method is called when broadcast is started from Control Center and provides extension information about the first application opened or used during the broadcast.
        ///
        /// Parameter `applicationInfo`: Dictionary that contains information about the first application opened or used buring the broadcast.
        ///
        /// # Safety
        ///
        /// `application_info` generic should be of the correct type.
        #[unsafe(method(broadcastAnnotatedWithApplicationInfo:))]
        #[unsafe(method_family = none)]
        pub unsafe fn broadcastAnnotatedWithApplicationInfo(&self, application_info: &NSDictionary);

        #[cfg(feature = "objc2-core-media")]
        /// Method is called as video and audio data become available during a broadcast session and is delivered as CMSampleBuffer objects.
        ///
        /// Parameter `sampleBuffer`: CMSampleBuffer object which contains either video or audio data.
        ///
        /// Parameter `sampleBufferType`: Determine's the type of the sample buffer defined by the RPSampleBufferType enum.
        #[unsafe(method(processSampleBuffer:withType:))]
        #[unsafe(method_family = none)]
        pub unsafe fn processSampleBuffer_withType(
            &self,
            sample_buffer: &CMSampleBuffer,
            sample_buffer_type: RPSampleBufferType,
        );

        /// Method that should be called when broadcasting can not proceed due to an error. Calling this method will stop the broadcast and deliver the error back to the broadcasting app through RPBroadcastController's delegate.
        ///
        /// Parameter `error`: NSError object that will be passed back to the broadcasting app through RPBroadcastControllerDelegate's broadcastController:didFinishWithError: method.
        #[unsafe(method(finishBroadcastWithError:))]
        #[unsafe(method_family = none)]
        pub unsafe fn finishBroadcastWithError(&self, error: &NSError);
    );
}

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