Add LocalTrackPublication.set(videoPublishOptions:) to update encodings without republishing - #1096
Open
tarsyang wants to merge 1 commit into
Open
Conversation
tarsyang
requested review from
hiroshihorie,
pblazej and
xianshijing-lk
as code owners
August 20, 2026 17:44
… updates Publish options are currently fixed at publish time: set(source:enabled:) returns the existing publication (unmute) without applying the new captureOptions/publishOptions, so the only way to change encoding parameters (e.g. lowering maxBitrate under thermal pressure) is a full unpublish + republish, which drops frames and churns subscribers. The SDK already re-applies encodings live when capture dimensions change (recomputeSenderParameters). This exposes that path as a public API: set(videoPublishOptions:) stores the new options on the track, re-computes encodings for the current dimensions, applies them to the RTP sender, and reports the updated layers to the server. The encoding layer structure is fixed at publish time: options that would produce a different layer count or rid set (e.g. toggling simulcast) throw .invalidState.
tarsyang
force-pushed
the
feat/publication-set-video-publish-options
branch
from
August 20, 2026 17:49
a43bd1a to
70880ec
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Publish options are fixed at publish time.
LocalParticipant.set(source:enabled:)returns the existingpublication (unmute path) without applying newly passed
publishOptions, so the only way to change encoding parameters of apublished video track (e.g. lowering
maxBitratewhile the device isunder thermal pressure, then restoring it) is a full unpublish +
republish. That drops frames, churns the subscriber side, and re-runs
capture setup.
The SDK already updates sender encodings live when capture dimensions
change (
recomputeSenderParameters()), so the machinery exists; it hasno public entry point.
API
on
LocalTrackPublication:current capture dimensions, applies them to the RTP sender, and
reports the updated layers to the server (
sendUpdateVideoLayers),same as the dimensions-change path.
would produce a different layer count or
ridset (e.g. togglingsimulcast) throw
.invalidState. Without the guard such optionswould deactivate every non-matching layer in
recomputeSenderParameters()'s rid-matched merge..invalidStatewhen the publication is not a local videotrack, the participant or room is no longer available, the RTP sender
is not available, or capture dimensions are not resolved yet.
isActive,scaleResolutionDownBy,maxBitrate,maxFps) are re-applied;codec preferences, scalability mode, and
degradationPreferenceremain as published (documented on the API).
Testing
SetVideoPublishOptionsTests(locallivekit-server --dev):maxBitrateof a published non-simulcast camera-source track changesfrom 1.7 Mbps to 1.2 Mbps on the live sender without republishing
(same publication sid, still a single publication), and toggling
simulcast is rejected with
.invalidState.