Skip to content

Commit 9a731a3

Browse files
authored
[Fix]Initial CallSetttings and external audio output (#819)
1 parent 47f388d commit 9a731a3

File tree

2 files changed

+26
-9
lines changed

2 files changed

+26
-9
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
88
- `CallViewController` was updated to accept the `video` flag when starting a call. [#811](https://github.com/GetStream/stream-video-swift/pull/811)
99
- `team` property when creating calls through `CallViewModel` and/or `CallViewController` [#817](https://github.com/GetStream/stream-video-swift/pull/817)
1010

11+
### 🔄 Changed
12+
- When joining a Call, if the user has an external audio device connected, we will ignore the remote `CallSettings.speakerOn = true`. [#819](https://github.com/GetStream/stream-video-swift/pull/819)
13+
1114
### 🐞 Fixed
1215
- Fix a retain cycle that was causing StreamVideo to leak in projects using NoiseCancellation. [#814](https://github.com/GetStream/stream-video-swift/pull/814)
1316
- Fix occasional crash caused inside `MicrophoneChecker`. [#813](https://github.com/GetStream/stream-video-swift/pull/813)

Sources/StreamVideo/WebRTC/v2/WebRTCAuthenticator.swift

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,30 @@ struct WebRTCAuthenticator: WebRTCAuthenticating {
7474
)
7575
)
7676

77-
/// Always apply either the provided callSettings or the ones from the dashboard.
78-
if let callSettings = await coordinator.stateAdapter.initialCallSettings {
79-
await coordinator.stateAdapter.set(
80-
callSettings: callSettings
81-
)
82-
} else {
83-
await coordinator.stateAdapter.set(
84-
callSettings: .init(response.call.settings)
85-
)
77+
/// Sets the initial call settings for the coordinator's state adapter.
78+
///
79+
/// - First, retrieves the initial call settings, if any, that may have been
80+
/// stored previously on the coordinator.
81+
/// - Then, constructs new call settings based on the remote values received
82+
/// from the backend.
83+
/// - If there are no locally stored settings, defaults to the remote settings.
84+
/// - If the current audio route is external (e.g., Bluetooth, AirPlay),
85+
/// and the settings indicate that the speaker should be on, updates
86+
/// the settings to turn the speaker off. This prevents external
87+
/// devices from mistakenly having the speaker route enabled.
88+
/// - Finally, applies the determined call settings to the state adapter.
89+
let initialCallSettings = await coordinator.stateAdapter.initialCallSettings
90+
let remoteCallSettings = CallSettings(response.call.settings)
91+
var callSettings = initialCallSettings ?? remoteCallSettings
92+
if
93+
coordinator.stateAdapter.audioSession.currentRoute.isExternal,
94+
callSettings.speakerOn
95+
{
96+
callSettings = callSettings.withUpdatedSpeakerState(false)
8697
}
98+
await coordinator.stateAdapter.set(
99+
callSettings: callSettings
100+
)
87101

88102
await coordinator.stateAdapter.set(
89103
videoOptions: .init(preferredCameraPosition: {

0 commit comments

Comments
 (0)