#[cfg(not(all(
feature = "input-avfoundation",
any(target_os = "macos", target_os = "ios")
)))]
fn init_avfoundation(callback: impl Fn(bool) + Send + 'static) {
callback(true);
}
#[cfg(all(
feature = "input-avfoundation",
any(target_os = "macos", target_os = "ios")
))]
fn init_avfoundation(callback: impl Fn(bool) + Send + Sync + 'static) {
use nokhwa_bindings_macos::request_permission_with_callback;
request_permission_with_callback(callback);
}
#[cfg(not(all(
feature = "input-avfoundation",
any(target_os = "macos", target_os = "ios")
)))]
fn status_avfoundation() -> bool {
true
}
#[cfg(all(
feature = "input-avfoundation",
any(target_os = "macos", target_os = "ios")
))]
fn status_avfoundation() -> bool {
use nokhwa_bindings_macos::{current_authorization_status, AVAuthorizationStatus};
matches!(
current_authorization_status(),
AVAuthorizationStatus::Authorized
)
}
pub fn nokhwa_initialize(on_complete: impl Fn(bool) + Send + Sync + 'static) {
init_avfoundation(on_complete);
}
#[must_use]
pub fn nokhwa_check() -> bool {
status_avfoundation()
}