diff --git a/ios/RCTWebRTC/Utils/AudioDeviceModule/AudioDeviceModule.swift b/ios/RCTWebRTC/Utils/AudioDeviceModule/AudioDeviceModule.swift index 908f2c2f0..312d4110c 100644 --- a/ios/RCTWebRTC/Utils/AudioDeviceModule/AudioDeviceModule.swift +++ b/ios/RCTWebRTC/Utils/AudioDeviceModule/AudioDeviceModule.swift @@ -345,6 +345,30 @@ import WebRTC source.refreshStereoPlayoutState() } + /// Gates whether the internal `AVAudioEngine` may start/stop for input and output. + /// + /// This flag has the highest priority over any API that may start the engine + /// (e.g., enabling the mic, ``startLocalRecording()``, or starting playback). + /// + /// - Behavior: + /// - When set to a disabled availability, the engine will stop if running, + /// and it will not start, even if recording or playback is requested. + /// - When set back to enabled, the engine will start as soon as possible + /// if recording and/or playback had been previously requested while disabled + /// (i.e., pending requests are honored once availability allows). + /// + /// This is useful when you need to set up connections without touching the audio + /// device yet (e.g., CallKit flows), or to guarantee the engine remains off + /// regardless of subscription/publication requests. + public func setEngineAvailability(_ availability: RTCAudioEngineAvailability) -> Int { + source.setEngineAvailability(availability) + } + + /// The current engine availability for input and output. + public var engineAvailability: RTCAudioEngineAvailability { + source.engineAvailability + } + // MARK: - RTCAudioDeviceModuleDelegate /// Receives speech activity notifications emitted by WebRTC VAD. diff --git a/ios/RCTWebRTC/Utils/AudioDeviceModule/RTCAudioDeviceModuleControlling.swift b/ios/RCTWebRTC/Utils/AudioDeviceModule/RTCAudioDeviceModuleControlling.swift index fefd1671b..55b31662d 100644 --- a/ios/RCTWebRTC/Utils/AudioDeviceModule/RTCAudioDeviceModuleControlling.swift +++ b/ios/RCTWebRTC/Utils/AudioDeviceModule/RTCAudioDeviceModuleControlling.swift @@ -31,6 +31,16 @@ protocol RTCAudioDeviceModuleControlling: AnyObject { func refreshStereoPlayoutState() func setMuteMode(_ mode: RTCAudioEngineMuteMode) -> Int func setRecordingAlwaysPreparedMode(_ alwaysPreparedRecording: Bool) -> Int + func setEngineAvailability(_ availability: RTCAudioEngineAvailability) -> Int + var engineAvailability: RTCAudioEngineAvailability { get } +} + +extension RTCAudioEngineAvailability { + /// Engine may activate for both input and output (the WebRTC default). + public static let `default` = RTCAudioEngineAvailability(isInputAvailable: true, isOutputAvailable: true) + /// Engine start/stop is gated off for both input and output (e.g. before CallKit + /// activates the AVAudioSession). + public static let none = RTCAudioEngineAvailability(isInputAvailable: false, isOutputAvailable: false) } extension RTCAudioDeviceModule: RTCAudioDeviceModuleControlling { diff --git a/ios/RCTWebRTC/WebRTCModule+RTCAudioDeviceModule.m b/ios/RCTWebRTC/WebRTCModule+RTCAudioDeviceModule.m index 72c15764e..fb4b96a14 100644 --- a/ios/RCTWebRTC/WebRTCModule+RTCAudioDeviceModule.m +++ b/ios/RCTWebRTC/WebRTCModule+RTCAudioDeviceModule.m @@ -203,11 +203,6 @@ - (void)handleADMResult:(NSInteger)result reject:reject]; } -// TODO: `getEngineAvailability` / `setEngineAvailability` were dropped because the -// Stream WebRTC SDK does not expose `RTCAudioEngineAvailability` / `-setEngineAvailability:`. -// The closest equivalent is `RTCAudioEngineState` via `engineState`, but the -// semantics differ and the JS API isn't consumed anywhere yet. - // TODO: Observer delegate "resolve" methods were skipped because our current // `AudioDeviceModuleObserver` does not expose async JS-driven resolution hooks; // the Swift `AudioDeviceModule` wrapper always returns success immediately. diff --git a/package-lock.json b/package-lock.json index c9fc560c8..728d2a452 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@stream-io/react-native-webrtc", - "version": "145.0.0", + "version": "145.1.0-alpha.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@stream-io/react-native-webrtc", - "version": "145.0.0", + "version": "145.1.0-alpha.1", "license": "MIT", "dependencies": { "base64-js": "1.5.1", diff --git a/package.json b/package.json index 48481aa74..04927cfb1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@stream-io/react-native-webrtc", - "version": "145.0.0", + "version": "145.1.0-alpha.1", "repository": { "type": "git", "url": "git+https://github.com/GetStream/react-native-webrtc.git" diff --git a/stream-react-native-webrtc.podspec b/stream-react-native-webrtc.podspec index 351c91b6c..a7dc25749 100644 --- a/stream-react-native-webrtc.podspec +++ b/stream-react-native-webrtc.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.swift_version = '5.0' s.dependency 'React-Core' # WebRTC version from https://github.com/GetStream/stream-video-swift-webrtc releases - s.dependency 'StreamWebRTC', '= 145.10.0' + s.dependency 'StreamWebRTC', '= 145.11.0' # Swift/Objective-C compatibility #https://blog.cocoapods.org/CocoaPods-1.5.0/ s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES'