Skip to content

Commit 99757b6

Browse files
authored
[Fix]CallSettings during reconnection (#808)
1 parent 10f9d21 commit 99757b6

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
55
# Upcoming
66

77
### 🐞 Fixed
8+
- Fix an issue that was causing CallSettings misalignment during reconnection [#810](https://github.com/GetStream/stream-video-swift/pull/810)
89
- Synchronize CallKit audioSession with the audioSession in the app. [#807](https://github.com/GetStream/stream-video-swift/pull/807)
910

1011
# [1.22.1](https://github.com/GetStream/stream-video-swift/releases/tag/1.22.1)

Sources/StreamVideo/WebRTC/v2/WebRTCStateAdapter.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,10 @@ actor WebRTCStateAdapter: ObservableObject, StreamAudioSessionAdapterDelegate {
340340
audioTracks = [:]
341341
videoTracks = [:]
342342
screenShareTracks = [:]
343+
344+
/// We set the initialCallSettings to the last activated CallSettings, in order to maintain the state
345+
/// during reconnects.
346+
initialCallSettings = callSettings
343347
}
344348

345349
/// Restores screen sharing if an active session exists.

StreamVideoTests/WebRTC/v2/WebRTCStateAdapter_Tests.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,30 @@ final class WebRTCStateAdapter_Tests: XCTestCase, @unchecked Sendable {
516516
await assertEqualAsync(await subject.participantPins, pins)
517517
}
518518

519+
func test_cleanUpForReconnection_setsInitialCallSettingsToCallSettings() async throws {
520+
let sfuStack = MockSFUStack()
521+
let ownCapabilities = Set([OwnCapability.blockUsers])
522+
let pins = [PinInfo(isLocal: true, pinnedAt: .init())]
523+
let userId = String.unique
524+
let currentParticipant = await CallParticipant.dummy(id: subject.sessionID)
525+
let participants = [
526+
userId: CallParticipant.dummy(id: userId),
527+
currentParticipant.sessionId: currentParticipant
528+
]
529+
try await prepare(
530+
sfuStack: sfuStack,
531+
ownCapabilities: ownCapabilities,
532+
participants: participants,
533+
participantPins: pins
534+
)
535+
await subject.set(callSettings: .init(cameraPosition: .back))
536+
537+
let sessionId = await subject.sessionID
538+
await subject.cleanUpForReconnection()
539+
540+
await assertEqualAsync(await subject.callSettings.cameraPosition, .back)
541+
}
542+
519543
// MARK: - didAddTrack
520544

521545
func test_didAddTrack_videoOfExistingParticipant_shouldAddTrack() async throws {

0 commit comments

Comments
 (0)