From 6d70ba0f6e8d1b0a4a35c8022e5a24afa2166426 Mon Sep 17 00:00:00 2001 From: Hiroshi Horie <548776+hiroshihorie@users.noreply.github.com> Date: Wed, 20 Mar 2024 12:37:00 +0900 Subject: [PATCH 1/3] impl --- .../contents.xcworkspacedata | 3 +++ .../xcshareddata/swiftpm/Package.resolved | 4 ++-- LiveKitExample.xcodeproj/project.pbxproj | 18 ++++++++++++++++++ Shared/Controllers/AppContext.swift | 16 ++++++++++++++++ Shared/RoomView.swift | 3 +++ 5 files changed, 42 insertions(+), 2 deletions(-) diff --git a/LiveKitExample-dev.xcworkspace/contents.xcworkspacedata b/LiveKitExample-dev.xcworkspace/contents.xcworkspacedata index 88e966b..825b1e7 100644 --- a/LiveKitExample-dev.xcworkspace/contents.xcworkspacedata +++ b/LiveKitExample-dev.xcworkspace/contents.xcworkspacedata @@ -4,6 +4,9 @@ + + diff --git a/LiveKitExample-dev.xcworkspace/xcshareddata/swiftpm/Package.resolved b/LiveKitExample-dev.xcworkspace/xcshareddata/swiftpm/Package.resolved index 7c013b3..7916af5 100644 --- a/LiveKitExample-dev.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/LiveKitExample-dev.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -32,8 +32,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-crypto.git", "state" : { - "revision" : "cc76b894169a3c86b71bac10c78a4db6beb7a9ad", - "version" : "3.2.0" + "revision" : "f0525da24dc3c6cbb2b6b338b65042bc91cbc4bb", + "version" : "3.3.0" } }, { diff --git a/LiveKitExample.xcodeproj/project.pbxproj b/LiveKitExample.xcodeproj/project.pbxproj index 9602372..4d0631d 100644 --- a/LiveKitExample.xcodeproj/project.pbxproj +++ b/LiveKitExample.xcodeproj/project.pbxproj @@ -35,6 +35,7 @@ 6867533C27A65652003707B9 /* AppContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6867533A27A65652003707B9 /* AppContext.swift */; }; 687230F82B14AE0A0098CCE6 /* PublishOptionsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 687230F72B14AE0A0098CCE6 /* PublishOptionsView.swift */; }; 687230F92B14AE0A0098CCE6 /* PublishOptionsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 687230F72B14AE0A0098CCE6 /* PublishOptionsView.swift */; }; + 687B93942BA7307D00FDD013 /* LiveKitKrispNoiseFilter in Frameworks */ = {isa = PBXBuildFile; productRef = 687B93932BA7307D00FDD013 /* LiveKitKrispNoiseFilter */; }; 68816CC127B4D6BC00E24622 /* KeychainAccess in Frameworks */ = {isa = PBXBuildFile; productRef = 68816CC027B4D6BC00E24622 /* KeychainAccess */; }; 68816CC327B4D94200E24622 /* KeychainAccess in Frameworks */ = {isa = PBXBuildFile; productRef = 68816CC227B4D94200E24622 /* KeychainAccess */; }; 68816CC527B4DCD500E24622 /* SecureStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68816CC427B4DCD500E24622 /* SecureStore.swift */; }; @@ -62,6 +63,16 @@ /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ + 683522152BA705A100FD50A9 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; 68EA18EB27F2E91100F9AE48 /* Embed Foundation Extensions */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; @@ -121,6 +132,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 687B93942BA7307D00FDD013 /* LiveKitKrispNoiseFilter in Frameworks */, 68FBA43F2A38B49C0015853E /* LiveKit in Frameworks */, 680FE2F227A8EF7700B6F6DB /* SFSafeSymbols in Frameworks */, 68816CC127B4D6BC00E24622 /* KeychainAccess in Frameworks */, @@ -279,6 +291,7 @@ 68B38540271E780700711D5F /* Frameworks */, 68B38541271E780700711D5F /* Resources */, 68EA18EB27F2E91100F9AE48 /* Embed Foundation Extensions */, + 683522152BA705A100FD50A9 /* Embed Frameworks */, ); buildRules = ( ); @@ -290,6 +303,7 @@ 680FE2F127A8EF7700B6F6DB /* SFSafeSymbols */, 68816CC027B4D6BC00E24622 /* KeychainAccess */, 68FBA43E2A38B49C0015853E /* LiveKit */, + 687B93932BA7307D00FDD013 /* LiveKitKrispNoiseFilter */, ); productName = "Multiplatform-SwiftUI (iOS)"; productReference = 68B38543271E780700711D5F /* LiveKitExample.app */; @@ -862,6 +876,10 @@ isa = XCSwiftPackageProductDependency; productName = LiveKit; }; + 687B93932BA7307D00FDD013 /* LiveKitKrispNoiseFilter */ = { + isa = XCSwiftPackageProductDependency; + productName = LiveKitKrispNoiseFilter; + }; 68816CC027B4D6BC00E24622 /* KeychainAccess */ = { isa = XCSwiftPackageProductDependency; package = 68816CBF27B4D6BC00E24622 /* XCRemoteSwiftPackageReference "KeychainAccess" */; diff --git a/Shared/Controllers/AppContext.swift b/Shared/Controllers/AppContext.swift index 98e9788..e561434 100644 --- a/Shared/Controllers/AppContext.swift +++ b/Shared/Controllers/AppContext.swift @@ -18,6 +18,10 @@ import Combine import LiveKit import SwiftUI +#if os(iOS) + import LiveKitKrispNoiseFilter +#endif + // This class contains the logic to control behavior of the whole app. final class AppContext: ObservableObject { private let store: ValueStore @@ -64,6 +68,18 @@ final class AppContext: ObservableObject { didSet { AudioManager.shared.isSpeakerOutputPreferred = preferSpeakerOutput } } +#if os(iOS) + // Krisp noise filter example + private lazy var krispProcessor = try? LiveKitKrispNoiseFilter() + + @Published var isKrispEnabled: Bool = false { + didSet { + // Runtime toggling of audio processor + AudioManager.shared.capturePostProcessingDelegate = isKrispEnabled ? krispProcessor : nil + } + } + #endif + public init(store: ValueStore) { self.store = store diff --git a/Shared/RoomView.swift b/Shared/RoomView.swift index a1c0a76..1a896b1 100644 --- a/Shared/RoomView.swift +++ b/Shared/RoomView.swift @@ -578,6 +578,9 @@ struct RoomView: View { Toggle("Prefer speaker output", isOn: $appCtx.preferSpeakerOutput) Toggle("E2EE enabled", isOn: $roomCtx.isE2eeEnabled) + #if os(iOS) + Toggle("Krisp Audio Filter Enabled", isOn: $appCtx.isKrispEnabled) + #endif } } label: { From 6cccbf642c38f2876159cad334611e06a097e62e Mon Sep 17 00:00:00 2001 From: Hiroshi Horie <548776+hiroshihorie@users.noreply.github.com> Date: Sat, 13 Apr 2024 00:54:42 +0800 Subject: [PATCH 2/3] update --- .../contents.xcworkspacedata | 2 +- .../xcshareddata/swiftpm/Package.resolved | 8 +++---- Shared/Controllers/AppContext.swift | 22 +++++++++++-------- Shared/LiveKitExample.swift | 6 +++++ Shared/RoomView.swift | 2 +- 5 files changed, 25 insertions(+), 15 deletions(-) diff --git a/LiveKitExample-dev.xcworkspace/contents.xcworkspacedata b/LiveKitExample-dev.xcworkspace/contents.xcworkspacedata index 825b1e7..1902060 100644 --- a/LiveKitExample-dev.xcworkspace/contents.xcworkspacedata +++ b/LiveKitExample-dev.xcworkspace/contents.xcworkspacedata @@ -5,7 +5,7 @@ location = "group:../../livekit/client-sdk-swift"> + location = "group:../../livekit/swift-krisp-noise-filter"> diff --git a/LiveKitExample-dev.xcworkspace/xcshareddata/swiftpm/Package.resolved b/LiveKitExample-dev.xcworkspace/xcshareddata/swiftpm/Package.resolved index 7916af5..596c863 100644 --- a/LiveKitExample-dev.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/LiveKitExample-dev.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -32,8 +32,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-crypto.git", "state" : { - "revision" : "f0525da24dc3c6cbb2b6b338b65042bc91cbc4bb", - "version" : "3.3.0" + "revision" : "cc76b894169a3c86b71bac10c78a4db6beb7a9ad", + "version" : "3.2.0" } }, { @@ -68,8 +68,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-protobuf.git", "state" : { - "revision" : "65e8f29b2d63c4e38e736b25c27b83e012159be8", - "version" : "1.25.2" + "revision" : "9f0c76544701845ad98716f3f6a774a892152bcb", + "version" : "1.26.0" } }, { diff --git a/Shared/Controllers/AppContext.swift b/Shared/Controllers/AppContext.swift index e561434..0caa766 100644 --- a/Shared/Controllers/AppContext.swift +++ b/Shared/Controllers/AppContext.swift @@ -68,16 +68,16 @@ final class AppContext: ObservableObject { didSet { AudioManager.shared.isSpeakerOutputPreferred = preferSpeakerOutput } } -#if os(iOS) - // Krisp noise filter example - private lazy var krispProcessor = try? LiveKitKrispNoiseFilter() - - @Published var isKrispEnabled: Bool = false { - didSet { - // Runtime toggling of audio processor - AudioManager.shared.capturePostProcessingDelegate = isKrispEnabled ? krispProcessor : nil + #if os(iOS) + // Krisp noise filter example + lazy var krispProcessor = LiveKitKrispNoiseFilter() + + @Published var isKrispEnabled: Bool = false { + didSet { + // Runtime toggling of audio processor + krispProcessor.isEnabled = isKrispEnabled + } } - } #endif public init(store: ValueStore) { @@ -100,5 +100,9 @@ final class AppContext: ObservableObject { self.inputDevice = audioManager.inputDevice } } + + #if os(iOS) + AudioManager.shared.capturePostProcessingDelegate = krispProcessor + #endif } } diff --git a/Shared/LiveKitExample.swift b/Shared/LiveKitExample.swift index 8e76b00..e33ddca 100644 --- a/Shared/LiveKitExample.swift +++ b/Shared/LiveKitExample.swift @@ -76,6 +76,12 @@ struct RoomContextView: View { .environmentObject(roomCtx.room) .environment(\.colorScheme, .dark) .foregroundColor(Color.white) + .onAppear { + #if os(iOS) + // Attach RoomDelegate to KrispProcessor + roomCtx.room.add(delegate: appCtx.krispProcessor) + #endif + } .onDisappear { print("\(String(describing: type(of: self))) onDisappear") Task { diff --git a/Shared/RoomView.swift b/Shared/RoomView.swift index 1a896b1..eeb797c 100644 --- a/Shared/RoomView.swift +++ b/Shared/RoomView.swift @@ -579,7 +579,7 @@ struct RoomView: View { Toggle("E2EE enabled", isOn: $roomCtx.isE2eeEnabled) #if os(iOS) - Toggle("Krisp Audio Filter Enabled", isOn: $appCtx.isKrispEnabled) + Toggle("Krisp Audio Filter Enabled", isOn: $appCtx.isKrispEnabled) #endif } From 5e8cc3e4924b5686360703e10dfb798f0f10c5e2 Mon Sep 17 00:00:00 2001 From: Hiroshi Horie <548776+hiroshihorie@users.noreply.github.com> Date: Sun, 28 Jul 2024 14:14:07 +0800 Subject: [PATCH 3/3] Update package --- .../contents.xcworkspacedata | 3 --- .../xcshareddata/swiftpm/Package.resolved | 21 +++++++++++++------ LiveKitExample.xcodeproj/project.pbxproj | 9 ++++++++ .../xcshareddata/swiftpm/Package.resolved | 15 ++++++++++--- 4 files changed, 36 insertions(+), 12 deletions(-) diff --git a/LiveKitExample-dev.xcworkspace/contents.xcworkspacedata b/LiveKitExample-dev.xcworkspace/contents.xcworkspacedata index 1902060..88e966b 100644 --- a/LiveKitExample-dev.xcworkspace/contents.xcworkspacedata +++ b/LiveKitExample-dev.xcworkspace/contents.xcworkspacedata @@ -4,9 +4,6 @@ - - diff --git a/LiveKitExample-dev.xcworkspace/xcshareddata/swiftpm/Package.resolved b/LiveKitExample-dev.xcworkspace/xcshareddata/swiftpm/Package.resolved index 32b52b5..d45b628 100644 --- a/LiveKitExample-dev.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/LiveKitExample-dev.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -32,8 +32,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-crypto.git", "state" : { - "revision" : "33f65a3cbc52f8c19295723af9cbecc2195484e1", - "version" : "3.5.0" + "revision" : "46072478ca365fe48370993833cb22de9b41567f", + "version" : "3.5.2" } }, { @@ -54,6 +54,15 @@ "version" : "1.0.0" } }, + { + "identity" : "swift-krisp-noise-filter", + "kind" : "remoteSourceControl", + "location" : "https://github.com/livekit/swift-krisp-noise-filter", + "state" : { + "revision" : "5c4608111033f1ac13edf64a335a1b9902c5496e", + "version" : "0.0.3" + } + }, { "identity" : "swift-log", "kind" : "remoteSourceControl", @@ -68,8 +77,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-protobuf.git", "state" : { - "revision" : "9f0c76544701845ad98716f3f6a774a892152bcb", - "version" : "1.26.0" + "revision" : "e17d61f26df0f0e06f58f6977ba05a097a720106", + "version" : "1.27.1" } }, { @@ -77,8 +86,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/livekit/webrtc-xcframework.git", "state" : { - "revision" : "5640582dbac33b193608574d4aa2a8d5d825db74", - "version" : "125.6422.2" + "revision" : "c0395fecffce2bc694835501aec11b17d793afaf", + "version" : "125.6422.4" } } ], diff --git a/LiveKitExample.xcodeproj/project.pbxproj b/LiveKitExample.xcodeproj/project.pbxproj index 5c0c51c..0fca838 100644 --- a/LiveKitExample.xcodeproj/project.pbxproj +++ b/LiveKitExample.xcodeproj/project.pbxproj @@ -370,6 +370,7 @@ 680FE2F027A8EF7700B6F6DB /* XCRemoteSwiftPackageReference "SFSafeSymbols" */, 68816CBF27B4D6BC00E24622 /* XCRemoteSwiftPackageReference "KeychainAccess" */, 68FBA43D2A38B49C0015853E /* XCRemoteSwiftPackageReference "client-sdk-swift" */, + 68A4AEFC2C51E6A3001F3DA9 /* XCRemoteSwiftPackageReference "swift-krisp-noise-filter" */, ); productRefGroup = 68B38544271E780700711D5F /* Products */; projectDirPath = ""; @@ -853,6 +854,14 @@ minimumVersion = 4.2.2; }; }; + 68A4AEFC2C51E6A3001F3DA9 /* XCRemoteSwiftPackageReference "swift-krisp-noise-filter" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/livekit/swift-krisp-noise-filter"; + requirement = { + kind = exactVersion; + version = 0.0.3; + }; + }; 68FBA43D2A38B49C0015853E /* XCRemoteSwiftPackageReference "client-sdk-swift" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/livekit/client-sdk-swift"; diff --git a/LiveKitExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/LiveKitExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index eb5392e..4291ccd 100644 --- a/LiveKitExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/LiveKitExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "bf59b79f5d4ea0a54ef7e929b035c5821f5094ee990a7a369ad0cb3713f6c62d", + "originHash" : "d4d1ddd5dbcd10b536e607b5cee6e6e561f9e6b49a06ae90e7bc0ed8971f7540", "pins" : [ { "identity" : "client-sdk-swift", @@ -28,6 +28,15 @@ "version" : "5.3.0" } }, + { + "identity" : "swift-krisp-noise-filter", + "kind" : "remoteSourceControl", + "location" : "https://github.com/livekit/swift-krisp-noise-filter", + "state" : { + "revision" : "5c4608111033f1ac13edf64a335a1b9902c5496e", + "version" : "0.0.3" + } + }, { "identity" : "swift-log", "kind" : "remoteSourceControl", @@ -42,8 +51,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-protobuf.git", "state" : { - "revision" : "9f0c76544701845ad98716f3f6a774a892152bcb", - "version" : "1.26.0" + "revision" : "e17d61f26df0f0e06f58f6977ba05a097a720106", + "version" : "1.27.1" } }, {