Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix]Allow callSettings propagation to CallState #497

Merged
merged 4 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
13 changes: 10 additions & 3 deletions Sources/StreamVideoSwiftUI/CallViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,11 @@ open class CallViewModel: ObservableObject {
backstage: backstage
)
} else {
let call = streamVideo.call(callType: callType, callId: callId)
self.call = call
let call = streamVideo.call(
callType: callType,
callId: callId,
callSettings: callSettings
)
Task {
do {
let callData = try await call.create(
Expand Down Expand Up @@ -572,7 +575,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
Loading