diff --git a/Sources/LiveKit/Core/RTC.swift b/Sources/LiveKit/Core/RTC.swift index 055c5b1ec..2c5d5ca77 100644 --- a/Sources/LiveKit/Core/RTC.swift +++ b/Sources/LiveKit/Core/RTC.swift @@ -50,7 +50,18 @@ private class VideoEncoderFactorySimulcast: LKRTCVideoEncoderFactorySimulcast { } class RTC { - static var bypassVoiceProcessing: Bool = false + private static var _bypassVoiceProcessing: Bool = false + private static var _peerConnectionFactoryInitialized = false + + static var bypassVoiceProcessing: Bool { + get { _bypassVoiceProcessing } + set { + if _peerConnectionFactoryInitialized { + logger.log("Warning: Setting bypassVoiceProcessing after PeerConnectionFactory initialization has no effect. Set it at application launch.", .warning, type: Room.self) + } + _bypassVoiceProcessing = newValue + } + } static let h264BaselineLevel5CodecInfo: LKRTCVideoCodecInfo = { // this should never happen @@ -89,6 +100,7 @@ class RTC { logger.log("Initializing PeerConnectionFactory...", type: Room.self) + _peerConnectionFactoryInitialized = true return LKRTCPeerConnectionFactory(bypassVoiceProcessing: bypassVoiceProcessing, encoderFactory: encoderFactory, decoderFactory: decoderFactory, diff --git a/Sources/LiveKit/Core/Room.swift b/Sources/LiveKit/Core/Room.swift index 93d1764d0..2db5e5977 100644 --- a/Sources/LiveKit/Core/Room.swift +++ b/Sources/LiveKit/Core/Room.swift @@ -515,6 +515,7 @@ extension Room: AppStateDelegate { public extension Room { /// Set this to true to bypass initialization of voice processing. /// Must be set before RTCPeerConnectionFactory gets initialized. + /// The most reliable place to set this is in your application's initialization process. @objc static var bypassVoiceProcessing: Bool { get { RTC.bypassVoiceProcessing }