Skip to content

Commit

Permalink
more av versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
yury committed Nov 19, 2024
1 parent 3df9dca commit e5b1a07
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 12 deletions.
8 changes: 4 additions & 4 deletions cidre/pomace/av/av.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static void av_initializer(void)

#if TARGET_OS_VISION
#else
AV_CAPTURE_METADATA_OUTPUT = [AVCaptureMetadataOutput class];
AV_CAPTURE_METADATA_OUTPUT = NSClassFromString(@"AVCaptureMetadataOutput");
AV_CAPTURE_DEVICE_DISCOVERY_SESSION = [AVCaptureDeviceDiscoverySession class];
AV_CAPTURE_AUDIO_DATA_OUTPUT = [AVCaptureAudioDataOutput class];
AV_CAPTURE_VIDEO_PREVIEW_LAYER = [AVCaptureVideoPreviewLayer class];
Expand All @@ -104,11 +104,11 @@ static void av_initializer(void)
#else
#if TARGET_OS_VISION
#else
AV_CAPTURE_DEVICE_ROTATION_COORDINATOR = [AVCaptureDeviceRotationCoordinator class];
AV_CAPTURE_DEVICE_ROTATION_COORDINATOR = NSClassFromString(@"AVCaptureDeviceRotationCoordinator");
#endif

AV_SAMPLE_BUFFER_VIDEO_RENDERER = [AVSampleBufferVideoRenderer class];
AV_AUDIO_APPLICATION = [AVAudioApplication class];
AV_SAMPLE_BUFFER_VIDEO_RENDERER = NSClassFromString(@"AVSampleBufferVideoRenderer");
AV_AUDIO_APPLICATION = NSClassFromString(@"AVAudioApplication");
#endif
} else {
#if TARGET_OS_WATCH
Expand Down
56 changes: 53 additions & 3 deletions cidre/src/av/audio/application.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{arc, av, blocks, define_cls, define_obj_type, ns, objc};
use crate::{api, arc, av, blocks, define_obj_type, ns, objc};

#[doc(alias = "AVAudioApplicationRecordPermission")]
#[derive(Debug, Eq, PartialEq, Copy, Clone)]
Expand Down Expand Up @@ -41,6 +41,14 @@ pub enum MicInjectionPermission {
impl ns::NotificationName {
#[doc(alias = "AVAudioApplicationInputMuteStateChangeNotification")]
#[inline]
#[api::available(
macos = 14.0,
ios = 17.0,
maccatalyst = 17.0,
tvos = 17.0,
visionos = 1.0,
watchos = 10.0
)]
pub fn audio_app_input_mute_state_change() -> &'static Self {
unsafe { AVAudioApplicationInputMuteStateChangeNotification }
}
Expand All @@ -52,18 +60,42 @@ define_obj_type!(
);

impl App {
define_cls!(AV_AUDIO_APPLICATION);
#[api::available(
macos = 14.0,
ios = 17.0,
maccatalyst = 17.0,
tvos = 17.0,
visionos = 1.0,
watchos = 10.0
)]
crate::define_cls!(AV_AUDIO_APPLICATION);

#[doc(alias = "AVAudioApplicationInputMuteStateChangeNotification")]
#[doc(alias = "AVAudioApplication.inputMuteStateChangeNotification")]
#[inline]
#[api::available(
macos = 14.0,
ios = 17.0,
maccatalyst = 17.0,
tvos = 17.0,
visionos = 1.0,
watchos = 10.0
)]
pub fn input_change_notification() -> &'static ns::NotificationName {
ns::NotificationName::audio_app_input_mute_state_change()
unsafe { AVAudioApplicationInputMuteStateChangeNotification }
}

#[doc(alias = "AVAudioApplicationMuteStateKey")]
#[doc(alias = "AVAudioApplication.muteStateKey")]
#[inline]
#[api::available(
macos = 14.0,
ios = 17.0,
maccatalyst = 17.0,
tvos = 17.0,
visionos = 1.0,
watchos = 10.0
)]
pub fn mute_state_key() -> &'static ns::String {
unsafe { AVAudioApplicationMuteStateKey }
}
Expand Down Expand Up @@ -141,8 +173,26 @@ impl App {
}

#[link(name = "AVFAudio", kind = "framework")]
#[api::weak]
extern "C" {
#[api::available(
macos = 14.0,
ios = 17.0,
maccatalyst = 17.0,
tvos = 17.0,
visionos = 1.0,
watchos = 10.0
)]
static AVAudioApplicationInputMuteStateChangeNotification: &'static ns::NotificationName;

#[api::available(
macos = 14.0,
ios = 17.0,
maccatalyst = 17.0,
tvos = 17.0,
visionos = 1.0,
watchos = 10.0
)]
static AVAudioApplicationMuteStateKey: &'static ns::String;
}

Expand Down
4 changes: 3 additions & 1 deletion cidre/src/av/capture/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2142,8 +2142,10 @@ impl arc::A<RotationCoordinator> {
}

impl RotationCoordinator {
define_cls!(AV_CAPTURE_DEVICE_ROTATION_COORDINATOR);
#[api::available(macos = 14.0, ios = 17.0, maccatalyst = 17.0, tvos = 17.0)]
crate::define_cls!(AV_CAPTURE_DEVICE_ROTATION_COORDINATOR);

#[api::available(macos = 14.0, ios = 17.0, maccatalyst = 17.0, tvos = 17.0)]
pub fn with_device_preview_layer(
device: &Device,
preview_layer: Option<&ca::Layer>,
Expand Down
5 changes: 3 additions & 2 deletions cidre/src/av/capture/metadata_output.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{arc, av, cg, define_obj_type, dispatch, ns, objc};
use crate::{api, arc, av, cg, define_obj_type, dispatch, ns, objc};

use super::Output;

Expand All @@ -24,7 +24,8 @@ define_obj_type!(
/// adding it as an output to an [`av::CaptureSession`] object.
#[doc(alias = "AVCaptureMetadataOutput")]
pub MetadataOutput(Output),
AV_CAPTURE_METADATA_OUTPUT
AV_CAPTURE_METADATA_OUTPUT,
#[api::available(macos = 13.0, ios = 6.0, maccatalyst = 14.0, tvos = 17.0)]
);

impl MetadataOutput {
Expand Down
9 changes: 7 additions & 2 deletions cidre/src/av/sample_buffer/video_renderer.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
use crate::{arc, av, define_obj_type, ns, objc};
use crate::{api, arc, av, define_obj_type, ns, objc};

define_obj_type!(pub VideoRenderer(ns::Id), AV_SAMPLE_BUFFER_VIDEO_RENDERER);
define_obj_type!(
#[doc(alias = "AVSampleBufferVideoRenderer")]
pub VideoRenderer(ns::Id),
AV_SAMPLE_BUFFER_VIDEO_RENDERER,
#[api::available(macos = 14.0, ios = 17.0, maccatalyst = 17.0, tvos = 17.0, visionos = 1.0)]
);

impl av::QueuedSampleBufRendering for VideoRenderer {}

Expand Down

0 comments on commit e5b1a07

Please sign in to comment.