Skip to content

Commit

Permalink
[Fix]Allow callSettings propagation to CallState (#497)
Browse files Browse the repository at this point in the history
  • Loading branch information
ipavlidakis authored Aug 29, 2024
1 parent a54a99f commit fbfa582
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### ✅ Added
- Participants (regular and anonymous) count, can be accessed - before or after joining a call - from the `Call.state.participantCount` & `Call.state.anonymousParticipantCount` respectively. [#496](https://github.com/GetStream/stream-video-swift/pull/496)
- You can now provide the `CallSettings` when you start a ringing call [#497](https://github.com/GetStream/stream-video-swift/pull/497)

# [1.0.9](https://github.com/GetStream/stream-video-swift/releases/tag/1.0.9)
_July 19, 2024_
Expand Down
11 changes: 10 additions & 1 deletion Sources/StreamVideo/Call.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public class Call: @unchecked Sendable, WSEventsSubscriber {
callType: String,
callId: String,
coordinatorClient: DefaultAPI,
callController: CallController
callController: CallController,
callSettings: CallSettings? = nil
) {
self.callId = callId
self.callType = callType
Expand All @@ -63,6 +64,14 @@ public class Call: @unchecked Sendable, WSEventsSubscriber {
initialSpeakerStatus: .enabled,
initialAudioOutputStatus: .enabled
)

/// If we received a non-nil initial callSettings, we updated them here.
if let callSettings {
Task { @MainActor [weak self] in
self?.state.update(callSettings: callSettings)
}
}

self.callController.call = self
// It's important to instantiate the stateMachine as soon as possible
// to ensure it's uniqueness.
Expand Down
8 changes: 6 additions & 2 deletions Sources/StreamVideo/StreamVideo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -215,18 +215,22 @@ public class StreamVideo: ObservableObject, @unchecked Sendable {
/// - Parameters:
/// - callType: the type of the call.
/// - callId: the id of the all.
/// - callSettings: the initial CallSettings to use. If `nil` is provided, the default CallSettings
/// will be used.
/// - Returns: `Call` object.
public func call(
callType: String,
callId: String
callId: String,
callSettings: CallSettings? = nil
) -> Call {
callCache.call(for: callCid(from: callId, callType: callType)) {
let callController = makeCallController(callType: callType, callId: callId)
let call = Call(
callType: callType,
callId: callId,
coordinatorClient: coordinatorClient,
callController: callController
callController: callController,
callSettings: callSettings
)
eventsMiddleware.add(subscriber: call)
return call
Expand Down
12 changes: 10 additions & 2 deletions Sources/StreamVideoSwiftUI/CallViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,11 @@ open class CallViewModel: ObservableObject {
backstage: backstage
)
} else {
let call = streamVideo.call(callType: callType, callId: callId)
let call = streamVideo.call(
callType: callType,
callId: callId,
callSettings: callSettings
)
self.call = call
Task {
do {
Expand Down Expand Up @@ -572,7 +576,11 @@ open class CallViewModel: ObservableObject {
enteringCallTask = Task {
do {
log.debug("Starting call")
let call = call ?? streamVideo.call(callType: callType, callId: callId)
let call = call ?? streamVideo.call(
callType: callType,
callId: callId,
callSettings: callSettings
)
var settingsRequest: CallSettingsRequest?
var limits: LimitsSettingsRequest?
if maxDuration != nil || maxParticipants != nil {
Expand Down
6 changes: 5 additions & 1 deletion StreamVideoTests/Mock/MockStreamVideo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ final class MockStreamVideo: StreamVideo, Mockable {
stubbedFunction[function] = value
}

override func call(callType: String, callId: String) -> Call {
override func call(
callType: String,
callId: String,
callSettings: CallSettings? = nil
) -> Call {
stubbedFunction[.call] as! Call
}

Expand Down

0 comments on commit fbfa582

Please sign in to comment.