@stream-io/video-react-native-sdk 1.41.0 → 1.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +40 -0
- package/android/src/main/java/com/streamvideo/reactnative/audio/AudioDeviceManager.kt +79 -54
- package/android/src/main/java/com/streamvideo/reactnative/audio/utils/AudioManagerUtil.kt +6 -2
- package/android/src/main/java/com/streamvideo/reactnative/callmanager/StreamInCallManagerModule.kt +3 -3
- package/dist/commonjs/components/Call/RingingCallContent/OutgoingCall.js.map +1 -1
- package/dist/commonjs/components/Participant/FloatingParticipantView/index.js.map +1 -1
- package/dist/commonjs/contexts/ThemeContext.js +10 -0
- package/dist/commonjs/contexts/ThemeContext.js.map +1 -1
- package/dist/commonjs/hooks/index.js +11 -0
- package/dist/commonjs/hooks/index.js.map +1 -1
- package/dist/commonjs/hooks/push/useCallingExpWithCallingStateEffect.js +73 -0
- package/dist/commonjs/hooks/push/useCallingExpWithCallingStateEffect.js.map +1 -1
- package/dist/commonjs/hooks/useAudioDeviceStatus.js +76 -0
- package/dist/commonjs/hooks/useAudioDeviceStatus.js.map +1 -0
- package/dist/commonjs/hooks/useScreenShareButton.js.map +1 -1
- package/dist/commonjs/modules/call-manager/CallManager.js +94 -47
- package/dist/commonjs/modules/call-manager/CallManager.js.map +1 -1
- package/dist/commonjs/providers/NoiseCancellation/lib.js.map +1 -1
- package/dist/commonjs/providers/StreamCall/AudioInterruptionTracer.js.map +1 -1
- package/dist/commonjs/utils/internal/callingx/callingx.js +0 -7
- package/dist/commonjs/utils/internal/callingx/callingx.js.map +1 -1
- package/dist/commonjs/utils/push/setupCallingExpEvents.js +0 -2
- package/dist/commonjs/utils/push/setupCallingExpEvents.js.map +1 -1
- package/dist/commonjs/version.js +1 -1
- package/dist/module/components/Call/RingingCallContent/OutgoingCall.js.map +1 -1
- package/dist/module/components/Participant/FloatingParticipantView/index.js.map +1 -1
- package/dist/module/contexts/ThemeContext.js +10 -0
- package/dist/module/contexts/ThemeContext.js.map +1 -1
- package/dist/module/hooks/index.js +1 -0
- package/dist/module/hooks/index.js.map +1 -1
- package/dist/module/hooks/push/useCallingExpWithCallingStateEffect.js +73 -0
- package/dist/module/hooks/push/useCallingExpWithCallingStateEffect.js.map +1 -1
- package/dist/module/hooks/useAudioDeviceStatus.js +71 -0
- package/dist/module/hooks/useAudioDeviceStatus.js.map +1 -0
- package/dist/module/hooks/useScreenShareButton.js.map +1 -1
- package/dist/module/modules/call-manager/CallManager.js +94 -47
- package/dist/module/modules/call-manager/CallManager.js.map +1 -1
- package/dist/module/providers/NoiseCancellation/lib.js.map +1 -1
- package/dist/module/providers/StreamCall/AudioInterruptionTracer.js.map +1 -1
- package/dist/module/utils/internal/callingx/callingx.js +0 -7
- package/dist/module/utils/internal/callingx/callingx.js.map +1 -1
- package/dist/module/utils/push/setupCallingExpEvents.js +0 -2
- package/dist/module/utils/push/setupCallingExpEvents.js.map +1 -1
- package/dist/module/version.js +1 -1
- package/dist/typescript/components/Participant/FloatingParticipantView/index.d.ts.map +1 -1
- package/dist/typescript/contexts/ThemeContext.d.ts +10 -1
- package/dist/typescript/contexts/ThemeContext.d.ts.map +1 -1
- package/dist/typescript/hooks/index.d.ts +1 -0
- package/dist/typescript/hooks/index.d.ts.map +1 -1
- package/dist/typescript/hooks/push/useCallingExpWithCallingStateEffect.d.ts.map +1 -1
- package/dist/typescript/hooks/useAudioDeviceStatus.d.ts +21 -0
- package/dist/typescript/hooks/useAudioDeviceStatus.d.ts.map +1 -0
- package/dist/typescript/hooks/useScreenShareButton.d.ts +2 -1
- package/dist/typescript/hooks/useScreenShareButton.d.ts.map +1 -1
- package/dist/typescript/modules/call-manager/CallManager.d.ts +25 -11
- package/dist/typescript/modules/call-manager/CallManager.d.ts.map +1 -1
- package/dist/typescript/modules/call-manager/types.d.ts +29 -3
- package/dist/typescript/modules/call-manager/types.d.ts.map +1 -1
- package/dist/typescript/providers/NoiseCancellation/lib.d.ts.map +1 -1
- package/dist/typescript/providers/StreamCall/AudioInterruptionTracer.d.ts.map +1 -1
- package/dist/typescript/utils/StreamVideoRN/types.d.ts.map +1 -1
- package/dist/typescript/utils/internal/callingx/callingx.d.ts.map +1 -1
- package/dist/typescript/utils/push/setupCallingExpEvents.d.ts.map +1 -1
- package/dist/typescript/version.d.ts +1 -1
- package/expo-config-plugin/dist/index.js +2 -0
- package/expo-config-plugin/dist/withAndroidMessagingService.js +313 -0
- package/expo-config-plugin/dist/withIosScreenCapture/addBroadcastExtensionXcodeTarget.js +84 -2
- package/expo-config-plugin/dist/withIosScreenCapture/withPlistUpdates.js +3 -6
- package/expo-config-plugin/dist/withIosScreenCapture/withTarget.js +6 -4
- package/expo-config-plugin/static/AudioUploader.swift +230 -0
- package/expo-config-plugin/static/SampleHandler.swift +67 -14
- package/ios/StreamInCallManager.m +7 -0
- package/ios/StreamInCallManager.swift +258 -15
- package/ios/StreamVideoReactNative.m +15 -5
- package/package.json +27 -25
- package/src/components/Call/RingingCallContent/OutgoingCall.tsx +1 -2
- package/src/components/Participant/FloatingParticipantView/index.tsx +1 -4
- package/src/contexts/ThemeContext.tsx +10 -1
- package/src/hooks/index.ts +1 -0
- package/src/hooks/push/useCallingExpWithCallingStateEffect.ts +95 -0
- package/src/hooks/useAudioDeviceStatus.ts +90 -0
- package/src/hooks/useScreenShareButton.ts +2 -1
- package/src/modules/call-manager/CallManager.ts +123 -66
- package/src/modules/call-manager/native-module.d.ts +14 -7
- package/src/modules/call-manager/types.ts +30 -3
- package/src/providers/NoiseCancellation/lib.ts +1 -2
- package/src/providers/StreamCall/AudioInterruptionTracer.tsx +1 -2
- package/src/utils/StreamVideoRN/types.ts +1 -3
- package/src/utils/internal/callingx/callingx.ts +0 -8
- package/src/utils/push/setupCallingExpEvents.ts +0 -2
- package/src/version.ts +1 -1
- package/dist/commonjs/utils/internal/callingx/audioSessionPromise.js +0 -68
- package/dist/commonjs/utils/internal/callingx/audioSessionPromise.js.map +0 -1
- package/dist/module/utils/internal/callingx/audioSessionPromise.js +0 -63
- package/dist/module/utils/internal/callingx/audioSessionPromise.js.map +0 -1
- package/dist/typescript/utils/internal/callingx/audioSessionPromise.d.ts +0 -16
- package/dist/typescript/utils/internal/callingx/audioSessionPromise.d.ts.map +0 -1
- package/src/utils/internal/callingx/audioSessionPromise.ts +0 -65
|
@@ -17,6 +17,20 @@ enum DefaultAudioDevice {
|
|
|
17
17
|
case earpiece
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
/// An explicit output route chosen via the device picker.
|
|
21
|
+
///
|
|
22
|
+
/// `nil` (no explicit pick) means the call uses the category-driven default
|
|
23
|
+
/// (`.defaultToSpeaker` when the default device is the speaker), which keeps the
|
|
24
|
+
/// default route headphone-aware. Once the user picks a device we drive the route
|
|
25
|
+
/// explicitly instead — `.defaultToSpeaker` is dropped so `overrideOutputAudioPort(.none)`
|
|
26
|
+
/// can reach the earpiece (with `.defaultToSpeaker` present it resolves to the speaker).
|
|
27
|
+
private enum OutputRouting {
|
|
28
|
+
case speaker
|
|
29
|
+
/// Built-in earpiece (the built-in mic uid), wired headset, or Bluetooth — all
|
|
30
|
+
/// reached via `overrideOutputAudioPort(.none)` + `setPreferredInput(port)`.
|
|
31
|
+
case input(uid: String)
|
|
32
|
+
}
|
|
33
|
+
|
|
20
34
|
private enum Constants {
|
|
21
35
|
/// Debounce interval for refreshing stereo playout state after audio route changes.
|
|
22
36
|
///
|
|
@@ -32,6 +46,14 @@ private enum Constants {
|
|
|
32
46
|
|
|
33
47
|
private enum StreamInCallManagerEvents {
|
|
34
48
|
static let audioInterruption = "StreamInCallManagerAudioInterruption"
|
|
49
|
+
static let audioDeviceChanged = "onAudioDeviceChanged"
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/// Stable device-id scheme for the JS layer. The built-in speaker is synthetic; every
|
|
53
|
+
/// other device is keyed by its `AVAudioSessionPortDescription.uid` (the
|
|
54
|
+
/// built-in earpiece is the built-in mic input routed with `.none`).
|
|
55
|
+
private enum AudioDeviceId {
|
|
56
|
+
static let speaker = "speaker"
|
|
35
57
|
}
|
|
36
58
|
|
|
37
59
|
@objc(StreamInCallManager)
|
|
@@ -42,6 +64,9 @@ class StreamInCallManager: RCTEventEmitter {
|
|
|
42
64
|
private var audioManagerActivated = false
|
|
43
65
|
private var callAudioRole: CallAudioRole = .communicator
|
|
44
66
|
private var defaultAudioDevice: DefaultAudioDevice = .speaker
|
|
67
|
+
/// The user's explicit output pick, or `nil` to use the category default.
|
|
68
|
+
/// Re-applied on every engine rebuild so the pick survives interruptions.
|
|
69
|
+
private var selectedOutput: OutputRouting?
|
|
45
70
|
private var enableStereo: Bool = false
|
|
46
71
|
private var previousVolume: Float = 0.75
|
|
47
72
|
|
|
@@ -101,7 +126,7 @@ class StreamInCallManager: RCTEventEmitter {
|
|
|
101
126
|
}
|
|
102
127
|
|
|
103
128
|
/// Builds the audio config for the current role/device and sets it as WebRTC's default.
|
|
104
|
-
private func makeAudioConfiguration() -> RTCAudioSessionConfiguration {
|
|
129
|
+
private func makeAudioConfiguration(for routing: OutputRouting?) -> RTCAudioSessionConfiguration {
|
|
105
130
|
let category: AVAudioSession.Category
|
|
106
131
|
let mode: AVAudioSession.Mode
|
|
107
132
|
let options: AVAudioSession.CategoryOptions
|
|
@@ -127,7 +152,7 @@ class StreamInCallManager: RCTEventEmitter {
|
|
|
127
152
|
// only exists under .playAndRecord.
|
|
128
153
|
category = .playback
|
|
129
154
|
mode = .spokenAudio
|
|
130
|
-
options = []
|
|
155
|
+
options = [.mixWithOthers]
|
|
131
156
|
} else {
|
|
132
157
|
// XCode 16 and older don't expose .allowBluetoothHFP
|
|
133
158
|
// https://forums.swift.org/t/xcode-26-avaudiosession-categoryoptions-allowbluetooth-deprecated/80956
|
|
@@ -138,7 +163,14 @@ class StreamInCallManager: RCTEventEmitter {
|
|
|
138
163
|
#endif
|
|
139
164
|
category = .playAndRecord
|
|
140
165
|
mode = .voiceChat
|
|
141
|
-
|
|
166
|
+
|
|
167
|
+
var mustSetDefaultToSpeaker = defaultAudioDevice == .speaker
|
|
168
|
+
if case .input(let uid) = routing, isBuiltInMicUid(uid) {
|
|
169
|
+
// the selected output is a built-in mic
|
|
170
|
+
// then we always can't use defaultToSpeaker
|
|
171
|
+
mustSetDefaultToSpeaker = false
|
|
172
|
+
}
|
|
173
|
+
options = mustSetDefaultToSpeaker ? [bluetoothOption, .defaultToSpeaker, .mixWithOthers] : [bluetoothOption, .mixWithOthers]
|
|
142
174
|
}
|
|
143
175
|
|
|
144
176
|
let rtcConfig = RTCAudioSessionConfiguration.webRTC()
|
|
@@ -162,16 +194,21 @@ class StreamInCallManager: RCTEventEmitter {
|
|
|
162
194
|
func setup() {
|
|
163
195
|
audioSessionQueue.async { [self] in
|
|
164
196
|
let adm = getAudioDeviceModule()
|
|
197
|
+
selectedOutput = nil
|
|
198
|
+
|
|
199
|
+
// This path (no CallKit) owns audio-session activation itself, so the
|
|
200
|
+
// engine must be allowed to start. Restores availability in case a
|
|
201
|
+
// prior CallKit call had gated it off.
|
|
202
|
+
_ = adm.setEngineAvailability(.default)
|
|
165
203
|
|
|
166
204
|
// Stereo is listener-only and applies live. Cleared by stop()'s reset().
|
|
167
205
|
if callAudioRole == .listener && enableStereo {
|
|
168
206
|
adm.setStereoPlayoutPreference(true)
|
|
169
207
|
}
|
|
170
208
|
|
|
171
|
-
let rtcConfig = makeAudioConfiguration()
|
|
209
|
+
let rtcConfig = makeAudioConfiguration(for: selectedOutput)
|
|
172
210
|
log("Setup with category: \(rtcConfig.category), mode: \(rtcConfig.mode), options: \(rtcConfig.categoryOptions)")
|
|
173
211
|
|
|
174
|
-
// Set category only — the sink owns setActive().
|
|
175
212
|
let session = RTCAudioSession.sharedInstance()
|
|
176
213
|
session.lockForConfiguration()
|
|
177
214
|
defer { session.unlockForConfiguration() }
|
|
@@ -223,13 +260,16 @@ class StreamInCallManager: RCTEventEmitter {
|
|
|
223
260
|
return
|
|
224
261
|
}
|
|
225
262
|
|
|
226
|
-
let rtcConfig = makeAudioConfiguration()
|
|
263
|
+
let rtcConfig = makeAudioConfiguration(for: selectedOutput)
|
|
227
264
|
let session = RTCAudioSession.sharedInstance()
|
|
228
265
|
session.lockForConfiguration()
|
|
229
266
|
defer { session.unlockForConfiguration() }
|
|
230
267
|
do {
|
|
231
|
-
try session.setConfiguration(rtcConfig)
|
|
232
|
-
|
|
268
|
+
try session.setConfiguration(rtcConfig, active: true)
|
|
269
|
+
// Re-apply the explicit pick (if any) so it survives the engine rebuild.
|
|
270
|
+
if let selectedOutput {
|
|
271
|
+
try applyOutputRouting(selectedOutput)
|
|
272
|
+
}
|
|
233
273
|
log("engineWillEnable: applied category=\(rtcConfig.category) mode=\(rtcConfig.mode) activated=true")
|
|
234
274
|
} catch {
|
|
235
275
|
log("engineWillEnable error: \(String(describing: error))")
|
|
@@ -252,6 +292,21 @@ class StreamInCallManager: RCTEventEmitter {
|
|
|
252
292
|
}
|
|
253
293
|
}
|
|
254
294
|
|
|
295
|
+
private func clearOutputRouting() {
|
|
296
|
+
if Self.callingxOwnsSession() {
|
|
297
|
+
return
|
|
298
|
+
}
|
|
299
|
+
let session = RTCAudioSession.sharedInstance()
|
|
300
|
+
session.lockForConfiguration()
|
|
301
|
+
defer { session.unlockForConfiguration() }
|
|
302
|
+
do {
|
|
303
|
+
try session.overrideOutputAudioPort(.none)
|
|
304
|
+
try AVAudioSession.sharedInstance().setPreferredInput(nil)
|
|
305
|
+
} catch {
|
|
306
|
+
log("clearOutputRouting error: \(String(describing: error))")
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
255
310
|
/// Runtime KVC lookup of `CallingxSessionOwnership.callingxOwnsSession`.
|
|
256
311
|
/// `@stream-io/react-native-callingx` is an optional peer dep, so a direct
|
|
257
312
|
/// Swift `import` is not safe
|
|
@@ -303,6 +358,7 @@ class StreamInCallManager: RCTEventEmitter {
|
|
|
303
358
|
}
|
|
304
359
|
let adm = getAudioDeviceModule()
|
|
305
360
|
adm.reset()
|
|
361
|
+
clearOutputRouting()
|
|
306
362
|
// Deactivate directly: the .didDisableAudioEngine sink is async and we cancel it below.
|
|
307
363
|
applyConfigForEngineDisable()
|
|
308
364
|
// Tear down the engine-observer subscription so a re-setup wires a fresh one.
|
|
@@ -313,6 +369,7 @@ class StreamInCallManager: RCTEventEmitter {
|
|
|
313
369
|
stereoRefreshWorkItem = nil
|
|
314
370
|
callAudioRole = .communicator
|
|
315
371
|
defaultAudioDevice = .speaker
|
|
372
|
+
selectedOutput = nil
|
|
316
373
|
enableStereo = false
|
|
317
374
|
audioManagerActivated = false
|
|
318
375
|
}
|
|
@@ -345,18 +402,21 @@ class StreamInCallManager: RCTEventEmitter {
|
|
|
345
402
|
|
|
346
403
|
@objc(setForceSpeakerphoneOn:)
|
|
347
404
|
func setForceSpeakerphoneOn(enable: Bool) {
|
|
348
|
-
audioSessionQueue.async { [
|
|
405
|
+
audioSessionQueue.async { [self] in
|
|
349
406
|
let session = RTCAudioSession.sharedInstance()
|
|
350
407
|
session.lockForConfiguration()
|
|
351
408
|
defer {
|
|
352
409
|
session.unlockForConfiguration()
|
|
353
410
|
}
|
|
354
|
-
let avAudioSession = AVAudioSession.sharedInstance()
|
|
355
411
|
do {
|
|
356
|
-
|
|
357
|
-
|
|
412
|
+
if enable {
|
|
413
|
+
try applyOutputRouting(.speaker)
|
|
414
|
+
} else {
|
|
415
|
+
try session.overrideOutputAudioPort(.none)
|
|
416
|
+
try AVAudioSession.sharedInstance().setPreferredInput(nil)
|
|
417
|
+
}
|
|
358
418
|
} catch {
|
|
359
|
-
self
|
|
419
|
+
self.log("Error setting speakerphone: \(error)")
|
|
360
420
|
}
|
|
361
421
|
}
|
|
362
422
|
}
|
|
@@ -367,6 +427,174 @@ class StreamInCallManager: RCTEventEmitter {
|
|
|
367
427
|
log("iOS does not support setMicrophoneMute()")
|
|
368
428
|
}
|
|
369
429
|
|
|
430
|
+
// MARK: - Audio Device Picker
|
|
431
|
+
|
|
432
|
+
@objc(getAudioDeviceStatus:reject:)
|
|
433
|
+
func getAudioDeviceStatus(resolve: @escaping RCTPromiseResolveBlock,
|
|
434
|
+
reject: @escaping RCTPromiseRejectBlock) {
|
|
435
|
+
audioSessionQueue.async { [weak self] in
|
|
436
|
+
guard let self else {
|
|
437
|
+
resolve(["devices": [], "currentEndpointType": "Unknown"])
|
|
438
|
+
return
|
|
439
|
+
}
|
|
440
|
+
resolve(self.buildAudioDevicesState())
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
/// Switches the audio output to the device with the given id.
|
|
445
|
+
@objc(chooseAudioDeviceEndpoint:)
|
|
446
|
+
func chooseAudioDeviceEndpoint(id: String) {
|
|
447
|
+
audioSessionQueue.async { [self] in
|
|
448
|
+
guard callAudioRole == .communicator else {
|
|
449
|
+
log("chooseAudioDeviceEndpoint ignored: only supported in communicator role")
|
|
450
|
+
return
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
let routing: OutputRouting = id == AudioDeviceId.speaker ? .speaker : .input(uid: id)
|
|
454
|
+
|
|
455
|
+
let session = RTCAudioSession.sharedInstance()
|
|
456
|
+
session.lockForConfiguration()
|
|
457
|
+
defer { session.unlockForConfiguration() }
|
|
458
|
+
do {
|
|
459
|
+
// Reconfigure first so the live category matches the pick (e.g. the earpiece
|
|
460
|
+
// drops `.defaultToSpeaker`, otherwise overrideOutputAudioPort(.none) would
|
|
461
|
+
// resolve back to the speaker). Then drive the route.
|
|
462
|
+
try session.setConfiguration(makeAudioConfiguration(for: routing))
|
|
463
|
+
try applyOutputRouting(routing)
|
|
464
|
+
selectedOutput = routing
|
|
465
|
+
} catch {
|
|
466
|
+
// a failure leaves the previous route intact.
|
|
467
|
+
log("chooseAudioDeviceEndpoint error: \(String(describing: error))")
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
/// Re-applies the current output pick (`selectedOutput`) — category untouched, no setActive.
|
|
473
|
+
/// Called on interruption-end (via callingx's interruption event, forwarded from JS) to
|
|
474
|
+
/// restore a Bluetooth/wired route
|
|
475
|
+
@objc(reapplyAudioRoute)
|
|
476
|
+
func reapplyAudioRoute() {
|
|
477
|
+
audioSessionQueue.async { [self] in
|
|
478
|
+
guard callAudioRole == .communicator, let routing = selectedOutput else { return }
|
|
479
|
+
let session = RTCAudioSession.sharedInstance()
|
|
480
|
+
session.lockForConfiguration()
|
|
481
|
+
defer { session.unlockForConfiguration() }
|
|
482
|
+
do {
|
|
483
|
+
try applyOutputRouting(routing)
|
|
484
|
+
} catch {
|
|
485
|
+
log("reapplyAudioRoute error: \(String(describing: error))")
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
/// Whether `uid` is the built-in microphone (i.e. an earpiece pick, in our id scheme).
|
|
491
|
+
private func isBuiltInMicUid(_ uid: String) -> Bool {
|
|
492
|
+
AVAudioSession.sharedInstance().availableInputs?
|
|
493
|
+
.contains { $0.uid == uid && $0.portType == .builtInMic } ?? false
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/// Drives the audio route. Throws if a session command fails, so callers can gate
|
|
497
|
+
/// committed state (e.g. `selectedOutput`) on the route actually being applied.
|
|
498
|
+
private func applyOutputRouting(_ routing: OutputRouting) throws {
|
|
499
|
+
let rtcSession = RTCAudioSession.sharedInstance()
|
|
500
|
+
let availableInputs = AVAudioSession.sharedInstance().availableInputs
|
|
501
|
+
switch routing {
|
|
502
|
+
case .speaker:
|
|
503
|
+
if let builtInMic = availableInputs?.first(where: { $0.portType == .builtInMic }) {
|
|
504
|
+
try rtcSession.setPreferredInput(builtInMic)
|
|
505
|
+
}
|
|
506
|
+
try rtcSession.overrideOutputAudioPort(.speaker)
|
|
507
|
+
case .input(let uid):
|
|
508
|
+
try rtcSession.overrideOutputAudioPort(.none)
|
|
509
|
+
if let port = availableInputs?.first(where: { $0.uid == uid }) {
|
|
510
|
+
try rtcSession.setPreferredInput(port)
|
|
511
|
+
} else {
|
|
512
|
+
log("applyOutputRouting: no input found for id \(uid)")
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
/// Canonical endpoint-type string shared with the JS layer.M ust match with the Android implementation.
|
|
518
|
+
private func endpointType(for portType: AVAudioSession.Port) -> String {
|
|
519
|
+
switch portType {
|
|
520
|
+
case .builtInSpeaker: return "Speaker"
|
|
521
|
+
case .builtInMic, .builtInReceiver: return "Earpiece"
|
|
522
|
+
case .headphones, .headsetMic: return "Wired Headset"
|
|
523
|
+
case .bluetoothA2DP, .bluetoothHFP, .bluetoothLE, .carAudio: return "Bluetooth Device"
|
|
524
|
+
default: return "Unknown"
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
private func hasExternalAudioDevice(_ session: AVAudioSession) -> Bool {
|
|
529
|
+
let external: Set<AVAudioSession.Port> = [
|
|
530
|
+
.headphones, .headsetMic, .bluetoothHFP, .bluetoothA2DP, .bluetoothLE, .carAudio,
|
|
531
|
+
]
|
|
532
|
+
if session.availableInputs?.contains(where: { external.contains($0.portType) }) == true {
|
|
533
|
+
return true
|
|
534
|
+
}
|
|
535
|
+
return session.currentRoute.outputs.contains { external.contains($0.portType) }
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
private func buildAudioDevicesState() -> [String: Any] {
|
|
539
|
+
let session = AVAudioSession.sharedInstance()
|
|
540
|
+
let inputs = session.availableInputs ?? []
|
|
541
|
+
let hasExternal = hasExternalAudioDevice(session)
|
|
542
|
+
|
|
543
|
+
var devices: [[String: String]] = [
|
|
544
|
+
["id": AudioDeviceId.speaker, "name": "Speaker", "type": "Speaker"]
|
|
545
|
+
]
|
|
546
|
+
for port in inputs {
|
|
547
|
+
let isBuiltInMic = port.portType == .builtInMic
|
|
548
|
+
// Hide the earpiece when a wired/BT device is present — it can't be routed to
|
|
549
|
+
// while one is connected, so listing it would be a dead, duplicate option.
|
|
550
|
+
if isBuiltInMic && hasExternal { continue }
|
|
551
|
+
devices.append([
|
|
552
|
+
"id": port.uid,
|
|
553
|
+
"name": isBuiltInMic ? "Earpiece" : port.portName,
|
|
554
|
+
"type": endpointType(for: port.portType),
|
|
555
|
+
])
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
let output = session.currentRoute.outputs.first
|
|
559
|
+
let currentEndpointType = output.map { endpointType(for: $0.portType) } ?? "Unknown"
|
|
560
|
+
|
|
561
|
+
// Output-only routes (e.g. wired headphones without a mic) never appear in
|
|
562
|
+
// availableInputs. Add the active output when no listed device already represents
|
|
563
|
+
// its endpoint type, so it stays visible and selectable in the picker.
|
|
564
|
+
if let output,
|
|
565
|
+
output.portType != .builtInSpeaker,
|
|
566
|
+
!devices.contains(where: { $0["type"] == currentEndpointType }) {
|
|
567
|
+
devices.append([
|
|
568
|
+
"id": output.uid,
|
|
569
|
+
"name": output.portName,
|
|
570
|
+
"type": currentEndpointType,
|
|
571
|
+
])
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
let selectedDeviceId: String?
|
|
575
|
+
if output?.portType == .builtInSpeaker {
|
|
576
|
+
selectedDeviceId = AudioDeviceId.speaker
|
|
577
|
+
} else if let inputUid = session.currentRoute.inputs.first?.uid,
|
|
578
|
+
devices.contains(where: { $0["id"] == inputUid }) {
|
|
579
|
+
// The active input maps to a listed device (earpiece / wired / BT).
|
|
580
|
+
selectedDeviceId = inputUid
|
|
581
|
+
} else {
|
|
582
|
+
// Output is on a device whose active input differs from a listed one — e.g. BT is
|
|
583
|
+
// the output while the input stayed built-in mic. Match by the output's endpoint
|
|
584
|
+
// type so the picker highlights the actual output (not the earpiece).
|
|
585
|
+
selectedDeviceId = devices.first(where: { $0["type"] == currentEndpointType })?["id"]
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
var result: [String: Any] = [
|
|
589
|
+
"devices": devices,
|
|
590
|
+
"currentEndpointType": currentEndpointType,
|
|
591
|
+
]
|
|
592
|
+
if let selectedDeviceId {
|
|
593
|
+
result["selectedDeviceId"] = selectedDeviceId
|
|
594
|
+
}
|
|
595
|
+
return result
|
|
596
|
+
}
|
|
597
|
+
|
|
370
598
|
@objc
|
|
371
599
|
func logAudioState() {
|
|
372
600
|
log(getAudioStateLog())
|
|
@@ -580,7 +808,19 @@ class StreamInCallManager: RCTEventEmitter {
|
|
|
580
808
|
}
|
|
581
809
|
|
|
582
810
|
logAudioState()
|
|
583
|
-
|
|
811
|
+
|
|
812
|
+
// Notify JS of the updated device list / selection.
|
|
813
|
+
audioSessionQueue.async { [weak self] in
|
|
814
|
+
guard let self,
|
|
815
|
+
self.audioManagerActivated,
|
|
816
|
+
self.callAudioRole == .communicator,
|
|
817
|
+
!Self.callingxOwnsSession() else { return }
|
|
818
|
+
self.sendEvent(
|
|
819
|
+
withName: StreamInCallManagerEvents.audioDeviceChanged,
|
|
820
|
+
body: self.buildAudioDevicesState()
|
|
821
|
+
)
|
|
822
|
+
}
|
|
823
|
+
|
|
584
824
|
// Route changes can arrive on arbitrary queues; ensure UI-safe work on main
|
|
585
825
|
DispatchQueue.main.async { [weak self] in
|
|
586
826
|
self?.updateProximityMonitoring()
|
|
@@ -616,7 +856,10 @@ class StreamInCallManager: RCTEventEmitter {
|
|
|
616
856
|
// MARK: - RCTEventEmitter
|
|
617
857
|
|
|
618
858
|
override func supportedEvents() -> [String]! {
|
|
619
|
-
return [
|
|
859
|
+
return [
|
|
860
|
+
StreamInCallManagerEvents.audioInterruption,
|
|
861
|
+
StreamInCallManagerEvents.audioDeviceChanged,
|
|
862
|
+
]
|
|
620
863
|
}
|
|
621
864
|
|
|
622
865
|
// MARK: - Helper Methods
|
|
@@ -51,6 +51,7 @@ void broadcastNotificationCallback(CFNotificationCenterRef center,
|
|
|
51
51
|
bool hasListeners;
|
|
52
52
|
CFNotificationCenterRef _notificationCenter;
|
|
53
53
|
AVAudioPlayer *_busyTonePlayer; // Instance variable
|
|
54
|
+
ScreenAudioCapture *_screenAudioCapture; // Broadcast screen-share audio receiver
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
RCT_EXPORT_MODULE();
|
|
@@ -647,19 +648,25 @@ RCT_EXPORT_METHOD(startScreenShareAudioMixing:(RCTPromiseResolveBlock)resolve
|
|
|
647
648
|
if (apmId && [apmId isKindOfClass:[RTCDefaultAudioProcessingModule class]]) {
|
|
648
649
|
RTCDefaultAudioProcessingModule *apm = (RTCDefaultAudioProcessingModule *)apmId;
|
|
649
650
|
apm.capturePostProcessingDelegate = mixer;
|
|
650
|
-
NSLog(@"[SSAMixer] Set capturePostProcessingDelegate on APM");
|
|
651
651
|
} else {
|
|
652
|
-
NSLog(@"[
|
|
652
|
+
NSLog(@"[SSAudio][Native] WARNING: No RTCDefaultAudioProcessingModule available, screen-share audio mixing will not work");
|
|
653
653
|
}
|
|
654
654
|
|
|
655
655
|
[mixer startMixing];
|
|
656
656
|
|
|
657
|
-
// Wire audio buffer handler on the active capturer → mixer.enqueue
|
|
658
657
|
InAppScreenCapturer *capturer = options.activeInAppScreenCapturer;
|
|
659
658
|
if (capturer) {
|
|
660
659
|
capturer.audioBufferHandler = ^(CMSampleBufferRef sampleBuffer) {
|
|
661
660
|
[mixer enqueue:sampleBuffer];
|
|
662
661
|
};
|
|
662
|
+
} else {
|
|
663
|
+
if (!_screenAudioCapture) {
|
|
664
|
+
_screenAudioCapture = [ScreenAudioCapture new];
|
|
665
|
+
}
|
|
666
|
+
_screenAudioCapture.onAudioBuffer = ^(AVAudioPCMBuffer *pcmBuffer) {
|
|
667
|
+
[mixer enqueuePCM:pcmBuffer];
|
|
668
|
+
};
|
|
669
|
+
[_screenAudioCapture start];
|
|
663
670
|
}
|
|
664
671
|
|
|
665
672
|
resolve(nil);
|
|
@@ -671,12 +678,16 @@ RCT_EXPORT_METHOD(stopScreenShareAudioMixing:(RCTPromiseResolveBlock)resolve
|
|
|
671
678
|
WebRTCModule *webrtcModule = [self.moduleRegistry moduleForName:"WebRTCModule"];
|
|
672
679
|
WebRTCModuleOptions *options = [WebRTCModuleOptions sharedInstance];
|
|
673
680
|
|
|
674
|
-
// Stop feeding audio to the mixer
|
|
675
681
|
InAppScreenCapturer *capturer = options.activeInAppScreenCapturer;
|
|
676
682
|
if (capturer) {
|
|
677
683
|
capturer.audioBufferHandler = nil;
|
|
678
684
|
}
|
|
679
685
|
|
|
686
|
+
if (_screenAudioCapture) {
|
|
687
|
+
_screenAudioCapture.onAudioBuffer = nil;
|
|
688
|
+
[_screenAudioCapture stop];
|
|
689
|
+
}
|
|
690
|
+
|
|
680
691
|
// Stop mixing
|
|
681
692
|
ScreenShareAudioMixer *mixer = webrtcModule.audioDeviceModule.screenShareAudioMixer;
|
|
682
693
|
[mixer stopMixing];
|
|
@@ -686,7 +697,6 @@ RCT_EXPORT_METHOD(stopScreenShareAudioMixing:(RCTPromiseResolveBlock)resolve
|
|
|
686
697
|
if (apmId && [apmId isKindOfClass:[RTCDefaultAudioProcessingModule class]]) {
|
|
687
698
|
RTCDefaultAudioProcessingModule *apm = (RTCDefaultAudioProcessingModule *)apmId;
|
|
688
699
|
apm.capturePostProcessingDelegate = nil;
|
|
689
|
-
NSLog(@"[SSAMixer] Cleared capturePostProcessingDelegate on APM");
|
|
690
700
|
}
|
|
691
701
|
|
|
692
702
|
resolve(nil);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stream-io/video-react-native-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.43.0",
|
|
4
4
|
"description": "Stream Video SDK for React Native",
|
|
5
5
|
"author": "https://getstream.io",
|
|
6
6
|
"homepage": "https://getstream.io/video/docs/react-native/",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"build:expo-plugin": "rimraf expo-config-plugin/dist && tsc --project expo-config-plugin/tsconfig.json",
|
|
17
17
|
"build": "yarn copy-version && bob build && yarn build:expo-plugin",
|
|
18
18
|
"test:expo-plugin": "jest --config=expo-config-plugin/jest.config.js --coverage",
|
|
19
|
-
"test": "yarn copy-version && jest --coverage && yarn test:expo-plugin",
|
|
19
|
+
"test": "yarn copy-version && jest --coverage && yarn test:types && yarn test:expo-plugin",
|
|
20
20
|
"test:types": "yarn copy-version && tsc -p tsconfig.spec.json",
|
|
21
21
|
"copy-version": "echo \"export const version = '$npm_package_version';\" > ./src/version.ts"
|
|
22
22
|
},
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
"!**/.*"
|
|
53
53
|
],
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@stream-io/video-client": "1.
|
|
56
|
-
"@stream-io/video-react-bindings": "1.
|
|
55
|
+
"@stream-io/video-client": "1.57.0",
|
|
56
|
+
"@stream-io/video-react-bindings": "1.19.2",
|
|
57
57
|
"intl-pluralrules": "2.0.1",
|
|
58
58
|
"react-native-url-polyfill": "^3.0.0",
|
|
59
59
|
"rxjs": "~7.8.2",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"@react-native-firebase/messaging": ">=17.5.0",
|
|
66
66
|
"@stream-io/noise-cancellation-react-native": ">=0.1.0",
|
|
67
67
|
"@stream-io/react-native-callingx": ">=0.1.0",
|
|
68
|
-
"@stream-io/react-native-webrtc": "^145.
|
|
68
|
+
"@stream-io/react-native-webrtc": "^145.2.0",
|
|
69
69
|
"@stream-io/video-filters-react-native": ">=0.1.0",
|
|
70
70
|
"expo": ">=47.0.0",
|
|
71
71
|
"expo-notifications": "*",
|
|
@@ -106,37 +106,39 @@
|
|
|
106
106
|
},
|
|
107
107
|
"devDependencies": {
|
|
108
108
|
"@babel/core": "^7.29.7",
|
|
109
|
-
"@
|
|
110
|
-
"@
|
|
109
|
+
"@babel/preset-env": "^7.29.7",
|
|
110
|
+
"@babel/preset-typescript": "^7.29.7",
|
|
111
|
+
"@expo/config-plugins": "^57.0.6",
|
|
112
|
+
"@expo/config-types": "^57.0.2",
|
|
111
113
|
"@expo/plist": "^0.7.0",
|
|
112
114
|
"@react-native-community/netinfo": "12.0.1",
|
|
113
|
-
"@react-native-firebase/app": "^24.
|
|
114
|
-
"@react-native-firebase/messaging": "^24.
|
|
115
|
-
"@react-native/babel-preset": "0.
|
|
116
|
-
"@react-native/
|
|
117
|
-
"@
|
|
118
|
-
"@stream-io/react-native
|
|
119
|
-
"@stream-io/react-native-
|
|
115
|
+
"@react-native-firebase/app": "^24.1.1",
|
|
116
|
+
"@react-native-firebase/messaging": "^24.1.1",
|
|
117
|
+
"@react-native/babel-preset": "0.86.2",
|
|
118
|
+
"@react-native/jest-preset": "0.86.2",
|
|
119
|
+
"@react-native/metro-config": "0.86.2",
|
|
120
|
+
"@stream-io/noise-cancellation-react-native": "^0.10.0",
|
|
121
|
+
"@stream-io/react-native-callingx": "^0.9.0",
|
|
122
|
+
"@stream-io/react-native-webrtc": "145.2.0",
|
|
120
123
|
"@stream-io/typescript-config": "^0.0.0",
|
|
121
|
-
"@stream-io/video-filters-react-native": "^0.
|
|
124
|
+
"@stream-io/video-filters-react-native": "^0.15.0",
|
|
122
125
|
"@testing-library/jest-native": "^5.4.3",
|
|
123
126
|
"@testing-library/react-native": "13.3.3",
|
|
124
127
|
"@tsconfig/node18": "^18.2.6",
|
|
125
128
|
"@types/jest": "^29.5.14",
|
|
126
|
-
"@types/node": "^25.9.
|
|
127
|
-
"@types/react": "~19.2.
|
|
129
|
+
"@types/node": "^25.9.5",
|
|
130
|
+
"@types/react": "~19.2.18",
|
|
128
131
|
"@types/react-test-renderer": "^19.1.0",
|
|
129
|
-
"expo": "~
|
|
130
|
-
"expo-
|
|
131
|
-
"expo-notifications": "~56.0.16",
|
|
132
|
+
"expo": "~57.0.9",
|
|
133
|
+
"expo-notifications": "~57.0.8",
|
|
132
134
|
"jest": "^29.7.0",
|
|
133
135
|
"react": "19.2.3",
|
|
134
|
-
"react-native": "0.
|
|
135
|
-
"react-native-builder-bob": "^0.
|
|
136
|
-
"react-native-gesture-handler": "~2.
|
|
137
|
-
"react-native-reanimated": "4.3
|
|
136
|
+
"react-native": "0.86.2",
|
|
137
|
+
"react-native-builder-bob": "^0.43.0",
|
|
138
|
+
"react-native-gesture-handler": "~2.32.0",
|
|
139
|
+
"react-native-reanimated": "4.5.3",
|
|
138
140
|
"react-native-svg": "15.15.5",
|
|
139
|
-
"react-native-worklets": "0.
|
|
141
|
+
"react-native-worklets": "0.10.1",
|
|
140
142
|
"react-test-renderer": "19.2.3",
|
|
141
143
|
"rimraf": "^6.1.3",
|
|
142
144
|
"typescript": "^6.0.3"
|
|
@@ -109,8 +109,7 @@ const Background = () => {
|
|
|
109
109
|
const { useCameraState } = useCallStateHooks();
|
|
110
110
|
const { isMute, camera } = useCameraState();
|
|
111
111
|
const localVideoStream = camera.state.mediaStream as unknown as
|
|
112
|
-
|
|
|
113
|
-
| undefined;
|
|
112
|
+
MediaStream | undefined;
|
|
114
113
|
|
|
115
114
|
if (isMute || !localVideoStream) {
|
|
116
115
|
return (
|
|
@@ -25,10 +25,7 @@ import { useFloatingVideoDimensions } from './useFloatingVideoDimensions';
|
|
|
25
25
|
import { type StreamVideoParticipant } from '@stream-io/video-client';
|
|
26
26
|
|
|
27
27
|
export type FloatingParticipantViewAlignment =
|
|
28
|
-
| 'top-left'
|
|
29
|
-
| 'top-right'
|
|
30
|
-
| 'bottom-left'
|
|
31
|
-
| 'bottom-right';
|
|
28
|
+
'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
32
29
|
|
|
33
30
|
/**
|
|
34
31
|
* Props to be passed for the LocalVideoView component.
|
|
@@ -7,8 +7,17 @@ import React, {
|
|
|
7
7
|
|
|
8
8
|
import { defaultTheme, type Theme } from '../theme/theme';
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Recursively marks every property of `T` as optional.
|
|
12
|
+
*
|
|
13
|
+
* The `extends object` guard is required, not cosmetic: `Theme` carries a
|
|
14
|
+
* `[component: string]: any` index signature, which the mapped type inherits.
|
|
15
|
+
* Without the guard that index signature becomes `DeepPartial<any>`, an
|
|
16
|
+
* all-object type that no primitive leaf can satisfy, and every theme override
|
|
17
|
+
* fails to typecheck. Guarding short-circuits `any` back to `any`.
|
|
18
|
+
*/
|
|
10
19
|
export type DeepPartial<T> = {
|
|
11
|
-
[P in keyof T]?: DeepPartial<T[P]
|
|
20
|
+
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
12
21
|
};
|
|
13
22
|
|
|
14
23
|
export type StreamThemeInputValue = {
|
package/src/hooks/index.ts
CHANGED