use crate::{arc, av, define_cls, define_obj_type, ns, objc};
define_obj_type!(
#[doc(alias = "AVAudioSessionLocation")]
pub Location(ns::String)
);
#[cfg(any(target_os = "ios", target_os = "watchos", target_os = "tvos"))]
impl Location {
pub fn upper() -> &'static Self {
unsafe { AVAudioSessionLocationUpper }
}
pub fn lower() -> &'static Self {
unsafe { AVAudioSessionLocationLower }
}
}
#[cfg(any(target_os = "ios", target_os = "watchos", target_os = "tvos"))]
unsafe extern "C" {
static AVAudioSessionLocationUpper: &'static Location;
static AVAudioSessionLocationLower: &'static Location;
}
define_obj_type!(
#[doc(alias = "AVAudioSessionOrientation")]
pub Orientation(ns::String)
);
#[cfg(any(target_os = "ios", target_os = "watchos", target_os = "tvos"))]
impl Orientation {
pub fn top() -> &'static Self {
unsafe { AVAudioSessionOrientationTop }
}
pub fn bottom() -> &'static Self {
unsafe { AVAudioSessionOrientationBottom }
}
pub fn front() -> &'static Self {
unsafe { AVAudioSessionOrientationFront }
}
pub fn back() -> &'static Self {
unsafe { AVAudioSessionOrientationBack }
}
pub fn left() -> &'static Self {
unsafe { AVAudioSessionOrientationLeft }
}
pub fn right() -> &'static Self {
unsafe { AVAudioSessionOrientationRight }
}
}
#[cfg(any(target_os = "ios", target_os = "watchos", target_os = "tvos"))]
unsafe extern "C" {
static AVAudioSessionOrientationTop: &'static Orientation;
static AVAudioSessionOrientationBottom: &'static Orientation;
static AVAudioSessionOrientationFront: &'static Orientation;
static AVAudioSessionOrientationBack: &'static Orientation;
static AVAudioSessionOrientationLeft: &'static Orientation;
static AVAudioSessionOrientationRight: &'static Orientation;
}
define_obj_type!(
#[doc(alias = "AVAudioSessionPolarPattern")]
pub PolarPattern(ns::String)
);
#[cfg(any(target_os = "ios", target_os = "watchos", target_os = "tvos"))]
impl PolarPattern {
pub fn omnidirectional() -> &'static Self {
unsafe { AVAudioSessionPolarPatternOmnidirectional }
}
pub fn cardioid() -> &'static Self {
unsafe { AVAudioSessionPolarPatternCardioid }
}
pub fn subcardioid() -> &'static Self {
unsafe { AVAudioSessionPolarPatternSubcardioid }
}
#[cfg(target_os = "ios")]
pub fn stereo() -> &'static Self {
unsafe { AVAudioSessionPolarPatternStereo }
}
}
#[cfg(any(target_os = "ios", target_os = "watchos", target_os = "tvos"))]
unsafe extern "C" {
static AVAudioSessionPolarPatternOmnidirectional: &'static PolarPattern;
static AVAudioSessionPolarPatternCardioid: &'static PolarPattern;
static AVAudioSessionPolarPatternSubcardioid: &'static PolarPattern;
#[cfg(target_os = "ios")]
static AVAudioSessionPolarPatternStereo: &'static PolarPattern;
}
define_obj_type!(
#[doc(alias = "AVAudioSessionChannelDescription")]
pub ChannelDesc(ns::Id)
);
impl ChannelDesc {
#[objc::msg_send(channelName)]
pub fn channel_name(&self) -> arc::R<ns::String>;
#[objc::msg_send(owningPortUID)]
pub fn owning_port_uid(&self) -> arc::R<ns::String>;
#[objc::msg_send(channelNumber)]
pub fn channel_number(&self) -> usize;
#[objc::msg_send(channelLabel)]
pub fn channel_label(&self) -> crate::cat::audio::ChannelLabel;
}
define_obj_type!(
#[doc(alias = "AVAudioSessionDataSourceDescription")]
pub DataSrcDesc(ns::Id)
);
impl DataSrcDesc {
#[objc::msg_send(dataSourceID)]
pub fn data_src_id(&self) -> arc::R<ns::String>;
#[objc::msg_send(dataSourceName)]
pub fn data_source_name(&self) -> arc::R<ns::String>;
#[objc::msg_send(location)]
pub fn location(&self) -> Option<arc::R<Location>>;
#[objc::msg_send(orientation)]
pub fn orientation(&self) -> Option<arc::R<Orientation>>;
#[objc::msg_send(supportedPolarPatterns)]
pub fn supported_polar_patterns(&self) -> Option<arc::R<ns::Array<PolarPattern>>>;
#[objc::msg_send(selectedPolarPattern)]
pub fn selected_polar_pattern(&self) -> Option<arc::R<PolarPattern>>;
#[objc::msg_send(preferredPolarPattern)]
pub fn preferred_polar_pattern(&self) -> Option<arc::R<PolarPattern>>;
#[objc::msg_send(setPreferredPolarPattern:error:)]
pub unsafe fn set_preferred_polar_pattern_err<'ear>(
&mut self,
val: Option<&PolarPattern>,
err: *mut Option<&'ear ns::Error>,
) -> bool;
pub fn set_preferred_polar_pattern<'ear>(&mut self, val: Option<&PolarPattern>) -> ns::Result {
ns::if_false(|err| unsafe { self.set_preferred_polar_pattern_err(val, err) })
}
}
define_obj_type!(
#[doc(alias = "AVAudioSessionCapability")]
pub Capability(ns::Id)
);
impl Capability {
#[objc::msg_send(isSupported)]
pub fn is_supported(&self) -> bool;
#[objc::msg_send(isEnabled)]
pub fn is_enabled(&self) -> bool;
}
define_obj_type!(
#[doc(alias = "AVAudioSessionPortExtensionBluetoothMicrophone")]
pub PortExtensionBluetoothMic(ns::Id)
);
impl PortExtensionBluetoothMic {
#[objc::msg_send(highQualityRecording)]
pub fn high_quality_recording(&self) -> arc::R<Capability>;
}
define_obj_type!(
#[doc(alias = "AVAudioSessionPortDescription")]
pub PortDesc(ns::Id)
);
impl PortDesc {
#[objc::msg_send(portType)]
pub fn port_type(&self) -> arc::R<av::AudioSessionPort>;
#[objc::msg_send(portName)]
pub fn port_name(&self) -> arc::R<ns::String>;
#[objc::msg_send(UID)]
pub fn uid(&self) -> arc::R<ns::String>;
#[objc::msg_send(hasHardwareVoiceCallProcessing)]
pub fn has_hw_voice_call_processing(&self) -> bool;
#[objc::msg_send(isSpatialAudioEnabled)]
pub fn is_spatial_audio_enabled(&self) -> bool;
#[objc::msg_send(channels)]
pub fn channels(&self) -> Option<arc::R<ns::Array<ChannelDesc>>>;
#[objc::msg_send(dataSources)]
pub fn data_srcs(&self) -> Option<arc::R<ns::Array<DataSrcDesc>>>;
#[objc::msg_send(selectedDataSource)]
pub fn selected_data_src(&self) -> Option<arc::R<DataSrcDesc>>;
#[objc::msg_send(preferredDataSource)]
pub fn preferred_data_src(&self) -> Option<arc::R<DataSrcDesc>>;
#[objc::msg_send(setPreferredDataSource:error:)]
pub unsafe fn set_preferred_data_src_err<'ear>(
&mut self,
val: Option<&DataSrcDesc>,
err: *mut Option<&'ear ns::Error>,
) -> bool;
pub fn set_preferred_data_src(&mut self, val: Option<&DataSrcDesc>) -> ns::Result {
ns::if_false(|err| unsafe { self.set_preferred_data_src_err(val, err) })
}
}
impl PortDesc {
#[objc::msg_send(bluetoothMicrophoneExtension)]
#[objc::available(
ios = 26.0,
maccatalyst = 26.0,
watchos = 26.0,
tvos = 26.0,
visionos = 26.0
)]
pub fn bluetooth_mic_extension(&self) -> Option<arc::R<PortExtensionBluetoothMic>>;
}
define_obj_type!(
#[doc(alias = "AVAudioSessionRouteDescription")]
pub RouteDesc(ns::Id)
);
impl RouteDesc {
define_cls!(AV_AUDIO_SESSION_ROUTE_DESCRIPTION);
#[objc::msg_send(inputs)]
pub fn inputs(&self) -> arc::R<ns::Array<PortDesc>>;
#[objc::msg_send(outputs)]
pub fn outputs(&self) -> arc::R<ns::Array<PortDesc>>;
}
#[link(name = "av", kind = "static")]
unsafe extern "C" {
static AV_AUDIO_SESSION_ROUTE_DESCRIPTION: &'static objc::Class<RouteDesc>;
}