Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Multiplatform/Controllers/AppContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
}
}
}
Expand Down Expand Up @@ -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()
Expand Down
15 changes: 4 additions & 11 deletions Multiplatform/Controllers/RoomContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<Void, Error>?

Expand Down Expand Up @@ -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))
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion Multiplatform/Views/AudioControlsPanel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
36 changes: 16 additions & 20 deletions Multiplatform/Views/RoomView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -385,34 +385,30 @@ 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: {
Image(systemSymbol: .rectangleFillOnRectangleFill)
.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
Expand Down
8 changes: 5 additions & 3 deletions Multiplatform/Views/ScreenShareSourcePickerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand All @@ -76,7 +79,6 @@ final class ScreenShareSourcePickerCtrl: ObservableObject {

typealias OnPickScreenShareSource = (MacOSScreenCaptureSource) -> Void

@available(macOS 12.3, *)
struct ScreenShareSourcePickerView: View {
enum Mode {
case display
Expand Down
Loading