-
Notifications
You must be signed in to change notification settings - Fork 100
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
Allowing subscription settings to update before fully subscribed #200
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,7 @@ public class RemoteTrackPublication: TrackPublication { | |
// MARK: - Private | ||
|
||
// user's preference to subscribe or not | ||
private var preferSubscribed: Bool? | ||
private var preferSubscribed: Bool | ||
private var metadataMuted: Bool = false | ||
|
||
// adaptiveStream | ||
|
@@ -47,6 +47,8 @@ public class RemoteTrackPublication: TrackPublication { | |
track: Track? = nil, | ||
participant: Participant) { | ||
|
||
preferSubscribed = participant.room.engine._state.connectOptions.autoSubscribe | ||
|
||
super.init(info: info, | ||
track: track, | ||
participant: participant) | ||
|
@@ -115,11 +117,24 @@ public class RemoteTrackPublication: TrackPublication { | |
public func set(preferredFPS newValue: UInt) -> Promise<Void> { | ||
// no-op if already the desired value | ||
let trackSettings = _state.trackSettings | ||
guard trackSettings.preferredFPS != newValue else { return Promise(()) } | ||
guard trackSettings.fps != newValue else { return Promise(()) } | ||
|
||
guard userCanModifyTrackSettings else { return Promise(TrackError.state(message: "adaptiveStream must be disabled and track must be subscribed")) } | ||
|
||
let settings = trackSettings.copyWith(preferredFPS: newValue) | ||
let settings = trackSettings.copyWith(fps: newValue) | ||
// attempt to set the new settings | ||
return send(trackSettings: settings) | ||
} | ||
|
||
@discardableResult | ||
public func set(preferredDimensions newValue: Dimensions) -> Promise<Void> { | ||
// no-op if already the desired value | ||
let trackSettings = _state.trackSettings | ||
guard trackSettings.dimensions != newValue else { return Promise(()) } | ||
|
||
guard userCanModifyTrackSettings else { return Promise(TrackError.state(message: "adaptiveStream must be disabled and track must be subscribed")) } | ||
|
||
let settings = trackSettings.copyWith(dimensions: newValue) | ||
// attempt to set the new settings | ||
return send(trackSettings: settings) | ||
} | ||
|
@@ -184,7 +199,15 @@ private extension RemoteTrackPublication { | |
|
||
var userCanModifyTrackSettings: Bool { | ||
// adaptiveStream must be disabled and must be subscribed | ||
!isAdaptiveStreamEnabled && subscribed | ||
if kind == .video && isAdaptiveStreamEnabled { | ||
log("Adaptive stream is enabled, cannot change video track settings", .warning) | ||
return false | ||
} | ||
if !(preferSubscribed || subscribed) { | ||
log("Cannot update track settings when not subscribed", .warning) | ||
return false | ||
} | ||
return true | ||
} | ||
Comment on lines
200
to
211
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @davidzhao Do you mean this whole check is not required anymore ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just mean the |
||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is no longer true. they should be able to change settings anytime