fix(coordinator): apply a playback-policy change to a live stream#23
Merged
Conversation
A change to only Stream.PlaybackPolicy was not propagated to the running publisher. updateLocked called UpdateProtocols — which refreshes the in-memory policy binding (streamState.playbackPolicy) — only when protocols or push changed, so a policy-only edit left the live stream serving with its stale binding. The new media-auth policy then took effect only after the next stream restart, so an operator who bound a running stream to a policy saw playback stay open. Detect the change via diff.PlaybackPolicyChanged and route it through UpdateProtocols, which is a no-op for unchanged protocols/push but refreshes the binding under the publisher lock. Viewers are not interrupted; the new policy applies on the next authorization check.
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.
Problem
Binding a running stream to a media-auth policy (setting
playback_policy) did not take effect until the stream was restarted — playback stayed open with the stream's previous binding.updateLockedrefreshes the publisher's in-memory policy mirror (streamState.playbackPolicy) viaUpdateProtocols, but only called it when protocols or push changed. A policy-only edit matched neither condition, so the live authorizer kept resolving the stale (empty → public) binding even though the store held the new policy.Fix
StreamDiff.PlaybackPolicyChanged(computed fromold.PlaybackPolicy != new.PlaybackPolicy).UpdateProtocolscall. That call is a no-op for unchanged protocols/push (no goroutine is stopped/started) but refreshes the in-memory binding under the publisher lock.Viewers are not interrupted — no segmenter/transcoder/buffer restart. The new policy applies on the next authorization check (per HLS/DASH segment request; at next connect for RTMP/SRT/RTSP).
Tests
TestComputeDiff_PlaybackPolicyOnly— a policy-only change setsPlaybackPolicyChangedand nothing else.TestComputeDiff_PlaybackPolicyUnchanged— equal codes ⇒ no change.go build,go vet,golangci-lint(0 issues), coordinatorgo test -raceall green.