Skip to content

fix(coordinator): apply a playback-policy change to a live stream#23

Merged
ntt0601zcoder merged 1 commit into
mainfrom
fix/media-playback-auth
Jun 15, 2026
Merged

fix(coordinator): apply a playback-policy change to a live stream#23
ntt0601zcoder merged 1 commit into
mainfrom
fix/media-playback-auth

Conversation

@ntt0601zcoder

Copy link
Copy Markdown
Owner

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.

updateLocked refreshes the publisher's in-memory policy mirror (streamState.playbackPolicy) via UpdateProtocols, 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

  • Add StreamDiff.PlaybackPolicyChanged (computed from old.PlaybackPolicy != new.PlaybackPolicy).
  • Route it through the existing UpdateProtocols call. 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 sets PlaybackPolicyChanged and nothing else.
  • TestComputeDiff_PlaybackPolicyUnchanged — equal codes ⇒ no change.
  • go build, go vet, golangci-lint (0 issues), coordinator go test -race all green.

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.
@ntt0601zcoder ntt0601zcoder merged commit 2dd2860 into main Jun 15, 2026
4 checks passed
@ntt0601zcoder ntt0601zcoder deleted the fix/media-playback-auth branch June 15, 2026 04:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant