diff --git a/Package.swift b/Package.swift index d01992404..21a503327 100644 --- a/Package.swift +++ b/Package.swift @@ -17,7 +17,7 @@ let package = Package( ) ], dependencies: [ - .package(name: "WebRTC", url: "https://github.com/webrtc-sdk/Specs.git", .exact("114.5735.02")), + .package(name: "WebRTC", url: "https://github.com/webrtc-sdk/Specs.git", .exact("114.5735.04")), .package(name: "SwiftProtobuf", url: "https://github.com/apple/swift-protobuf.git", .upToNextMajor(from: "1.21.0")), .package(name: "Promises", url: "https://github.com/google/promises.git", .upToNextMajor(from: "2.2.0")), .package(url: "https://github.com/apple/swift-log.git", .upToNextMajor(from: "1.5.2")) diff --git a/Sources/LiveKit/Core/Engine+WebRTC.swift b/Sources/LiveKit/Core/Engine+WebRTC.swift index f738e7cf8..8e809248b 100644 --- a/Sources/LiveKit/Core/Engine+WebRTC.swift +++ b/Sources/LiveKit/Core/Engine+WebRTC.swift @@ -79,6 +79,10 @@ internal extension Engine { static private let decoderFactory = VideoDecoderFactory() + static let audioProcessingModule: RTCDefaultAudioProcessingModule = { + RTCDefaultAudioProcessingModule() + }() + static let peerConnectionFactory: RTCPeerConnectionFactory = { logger.log("Initializing SSL...", type: Engine.self) @@ -94,7 +98,8 @@ internal extension Engine { return RTCPeerConnectionFactory(bypassVoiceProcessing: bypassVoiceProcessing, encoderFactory: encoderFactory, - decoderFactory: decoderFactory) + decoderFactory: decoderFactory, + audioProcessingModule: audioProcessingModule) }() // forbid direct access diff --git a/Sources/LiveKit/Core/Room.swift b/Sources/LiveKit/Core/Room.swift index 0030deb87..2c8464e32 100644 --- a/Sources/LiveKit/Core/Room.swift +++ b/Sources/LiveKit/Core/Room.swift @@ -442,3 +442,13 @@ extension Room { set { Engine.bypassVoiceProcessing = newValue } } } + +// MARK: - Audio Processing + +extension Room { + + @objc + public static var audioProcessingModule: RTCDefaultAudioProcessingModule { + Engine.audioProcessingModule + } +} diff --git a/Sources/LiveKit/Core/Transport.swift b/Sources/LiveKit/Core/Transport.swift index 397468914..25a13c9fc 100644 --- a/Sources/LiveKit/Core/Transport.swift +++ b/Sources/LiveKit/Core/Transport.swift @@ -297,7 +297,7 @@ extension Transport: RTCPeerConnectionDelegate { return } - log("didAdd track \(track.trackId)") + log("didAddTrack type: \(type(of: track)), id: \(track.trackId)") notify { $0.transport(self, didAddTrack: track, rtpReceiver: rtpReceiver, streams: mediaStreams) } } diff --git a/Sources/LiveKit/Track/AudioTrack.swift b/Sources/LiveKit/Track/AudioTrack.swift index 11047110b..c2d04196c 100644 --- a/Sources/LiveKit/Track/AudioTrack.swift +++ b/Sources/LiveKit/Track/AudioTrack.swift @@ -19,9 +19,4 @@ import WebRTC @objc public protocol AudioTrack where Self: Track { - -} - -extension AudioTrack { - } diff --git a/Sources/LiveKit/Track/Remote/RemoteAudioTrack.swift b/Sources/LiveKit/Track/Remote/RemoteAudioTrack.swift index 259c5f3a1..8cb4e5a32 100644 --- a/Sources/LiveKit/Track/Remote/RemoteAudioTrack.swift +++ b/Sources/LiveKit/Track/Remote/RemoteAudioTrack.swift @@ -60,4 +60,14 @@ public class RemoteAudioTrack: Track, RemoteTrack, AudioTrack { return didStop } } + + public func add(audioRenderer: RTCAudioRenderer) { + guard let audioTrack = mediaTrack as? RTCAudioTrack else { return } + audioTrack.add(audioRenderer) + } + + public func remove(audioRenderer: RTCAudioRenderer) { + guard let audioTrack = mediaTrack as? RTCAudioTrack else { return } + audioTrack.remove(audioRenderer) + } }