diff --git a/Multiplatform/Controllers/AppContext.swift b/Multiplatform/Controllers/AppContext.swift index 62bb471..ad5500b 100644 --- a/Multiplatform/Controllers/AppContext.swift +++ b/Multiplatform/Controllers/AppContext.swift @@ -90,13 +90,13 @@ final class AppContext: NSObject, ObservableObject { didSet { AudioManager.shared.isVoiceProcessingAGCEnabled = isVoiceProcessingAGCEnabled } } - @Published var isVoiceProcessingEnabled: Bool = true { + @Published var isPlatformVoiceProcessingAllowed: Bool = true { didSet { - guard oldValue != isVoiceProcessingEnabled else { return } + guard oldValue != isPlatformVoiceProcessingAllowed else { return } do { - try AudioManager.shared.setVoiceProcessingEnabled(isVoiceProcessingEnabled) + try AudioManager.shared.setPlatformVoiceProcessingAllowed(isPlatformVoiceProcessingAllowed) } catch { - print("Failed to set voice processing enabled: \(error)") + print("Failed to set platform voice processing allowed: \(error)") } } } @@ -223,7 +223,7 @@ final class AppContext: NSObject, ObservableObject { inputDevices = AudioManager.shared.inputDevices outputDevice = AudioManager.shared.outputDevice inputDevice = AudioManager.shared.inputDevice - isVoiceProcessingEnabled = AudioManager.shared.isVoiceProcessingEnabled + isPlatformVoiceProcessingAllowed = AudioManager.shared.isPlatformVoiceProcessingAllowed isVoiceProcessingAGCEnabled = AudioManager.shared.isVoiceProcessingAGCEnabled isRecordingAlwaysPreparedMode = AudioManager.shared.isRecordingAlwaysPreparedMode updateAudioDeviceSelections() diff --git a/Multiplatform/Controllers/RoomContext.swift b/Multiplatform/Controllers/RoomContext.swift index 35c2e48..4cbbf58 100644 --- a/Multiplatform/Controllers/RoomContext.swift +++ b/Multiplatform/Controllers/RoomContext.swift @@ -107,11 +107,7 @@ final class RoomContext: ObservableObject { } } - private lazy var backgroundBlurProcessor: (some VideoProcessor)? = if #available(iOS 15.0, *) { - BackgroundBlurVideoProcessor() - } else { - nil - } + private lazy var backgroundBlurProcessor = BackgroundBlurVideoProcessor() var _connectTask: Task? @@ -230,7 +226,6 @@ final class RoomContext: ObservableObject { #if os(macOS) weak var screenShareTrack: LocalTrackPublication? - @available(macOS 12.3, *) func setScreenShareMacOS(isEnabled: Bool, screenShareSource: sending MacOSScreenCaptureSource? = nil) async throws { if isEnabled, let screenShareSource { let track = await LocalVideoTrack.createMacOSScreenShareTrack(source: screenShareSource, options: ScreenShareCaptureOptions(appAudio: true)) @@ -248,11 +243,9 @@ final class RoomContext: ObservableObject { weak var arCameraTrack: LocalTrackPublication? func setARCamera(isEnabled: Bool) async throws { - if #available(visionOS 2.0, *) { - if isEnabled { - let track = LocalVideoTrack.createARCameraTrack() - arCameraTrack = try await room.localParticipant.publish(videoTrack: track) - } + if isEnabled { + let track = await LocalVideoTrack.createARCameraTrack() + arCameraTrack = try await room.localParticipant.publish(videoTrack: track) } if !isEnabled, let arCameraTrack { diff --git a/Multiplatform/Views/AudioControlsPanel.swift b/Multiplatform/Views/AudioControlsPanel.swift index d69d1f1..02e1073 100644 --- a/Multiplatform/Views/AudioControlsPanel.swift +++ b/Multiplatform/Views/AudioControlsPanel.swift @@ -83,7 +83,7 @@ struct AudioControlsPanel: View { } Section(header: Text("Voice Processing")) { - Toggle("Voice processing enabled", isOn: $appCtx.isVoiceProcessingEnabled) + Toggle("Platform voice processing allowed", isOn: $appCtx.isPlatformVoiceProcessingAllowed) Toggle("Bypass voice processing", isOn: $appCtx.isVoiceProcessingBypassed) Toggle("Auto gain control (AGC)", isOn: $appCtx.isVoiceProcessingAGCEnabled) } diff --git a/Multiplatform/Views/RoomView.swift b/Multiplatform/Views/RoomView.swift index 5f7ffea..5c2d945 100644 --- a/Multiplatform/Views/RoomView.swift +++ b/Multiplatform/Views/RoomView.swift @@ -385,17 +385,15 @@ struct RoomView: View { .disabled(isScreenSharePublishingBusy) #elseif os(macOS) Button(action: { - if #available(macOS 12.3, *) { - if isScreenShareEnabled { - // Turn off screen share - Task { - isScreenSharePublishingBusy = true - defer { Task { @MainActor in isScreenSharePublishingBusy = false } } - try? await roomCtx.setScreenShareMacOS(isEnabled: false) - } - } else { - screenPickerPresented = true + if isScreenShareEnabled { + // Turn off screen share + Task { + isScreenSharePublishingBusy = true + defer { Task { @MainActor in isScreenSharePublishingBusy = false } } + try? await roomCtx.setScreenShareMacOS(isEnabled: false) } + } else { + screenPickerPresented = true } }, label: { @@ -403,16 +401,14 @@ struct RoomView: View { .renderingMode(isScreenShareEnabled ? .original : .template) .foregroundColor(isScreenShareEnabled ? Color.green : Color.white) }).popover(isPresented: $screenPickerPresented) { - if #available(macOS 12.3, *) { - ScreenShareSourcePickerView { source in - Task { - isScreenSharePublishingBusy = true - defer { Task { @MainActor in isScreenSharePublishingBusy = false } } - try? await roomCtx.setScreenShareMacOS(isEnabled: true, screenShareSource: source) - } - screenPickerPresented = false - }.padding() - } + ScreenShareSourcePickerView { source in + Task { + isScreenSharePublishingBusy = true + defer { Task { @MainActor in isScreenSharePublishingBusy = false } } + try? await roomCtx.setScreenShareMacOS(isEnabled: true, screenShareSource: source) + } + screenPickerPresented = false + }.padding() } .disabled(isScreenSharePublishingBusy) #endif diff --git a/Multiplatform/Views/ScreenShareSourcePickerView.swift b/Multiplatform/Views/ScreenShareSourcePickerView.swift index 68e52c0..2a25e95 100644 --- a/Multiplatform/Views/ScreenShareSourcePickerView.swift +++ b/Multiplatform/Views/ScreenShareSourcePickerView.swift @@ -22,7 +22,6 @@ import SwiftUI #if os(macOS) @MainActor -@available(macOS 12.3, *) final class ScreenShareSourcePickerCtrl: ObservableObject { @Published var tracks = [LocalVideoTrack]() @Published var mode: ScreenShareSourcePickerView.Mode = .display { @@ -57,7 +56,11 @@ final class ScreenShareSourcePickerCtrl: ObservableObject { let sources = try await MacOSScreenCapturer.sources(for: mode == .display ? .display : .window) let options = ScreenShareCaptureOptions(dimensions: .h360_43, fps: 5) - let _newTracks = sources.map { LocalVideoTrack.createMacOSScreenShareTrack(source: $0, options: options) } + var tracks = [LocalVideoTrack]() + for source in sources { + await tracks.append(LocalVideoTrack.createMacOSScreenShareTrack(source: source, options: options)) + } + let _newTracks = tracks Task { @MainActor in self.tracks = _newTracks @@ -76,7 +79,6 @@ final class ScreenShareSourcePickerCtrl: ObservableObject { typealias OnPickScreenShareSource = (MacOSScreenCaptureSource) -> Void -@available(macOS 12.3, *) struct ScreenShareSourcePickerView: View { enum Mode { case display