fix(mac): resolve camera type deprecation

This commit is contained in:
Peter Steinberger
2026-01-03 01:21:30 +01:00
parent 5684e2d658
commit 75a9cd83a0
3 changed files with 24 additions and 253 deletions

View File

@@ -217,11 +217,13 @@ actor CameraCaptureService {
}
private nonisolated static func availableCameras() -> [AVCaptureDevice] {
let types: [AVCaptureDevice.DeviceType] = [
var types: [AVCaptureDevice.DeviceType] = [
.builtInWideAngleCamera,
.externalUnknown,
.continuityCamera,
]
if let external = externalDeviceType() {
types.append(external)
}
let session = AVCaptureDevice.DiscoverySession(
deviceTypes: types,
mediaType: .video,
@@ -229,6 +231,14 @@ actor CameraCaptureService {
return session.devices
}
private nonisolated static func externalDeviceType() -> AVCaptureDevice.DeviceType? {
if #available(macOS 14.0, *) {
return .external
}
// Use raw value to avoid deprecated symbol in the SDK.
return AVCaptureDevice.DeviceType(rawValue: "AVCaptureDeviceTypeExternalUnknown")
}
private nonisolated static func pickCamera(
facing: CameraFacing,
deviceId: String?) -> AVCaptureDevice?