Repository navigation
Conversation
… key With QUMO_USAGE_URL and QUMO_AUTH_KEYS, qumo rtmp and qumo rtsp-push send each stream to the usage URL as a relay sends a publishing session: an open, usage every 30 s and a close, under the kid of the token that granted the push, with the media the ingest took in (ingest.media_bytes) and how long it kept the broadcast opted into each egress. The relay only sees the ingest's own session, so a stream pushed over RTMP or RTSP is billed to its publisher here. - ingest.PublishAuthorizer returns a Permission: the lapse, and the kid of the key that granted it. - Session counts the media pushed into it and its opt-in time (Usage). - The opt-in clock moved from the relay to internal/optin (optin.Clock), which both use. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KPWMJL7PH3rPhK5UTGavaB
…hare the whole-seconds rule TestRTMPServer_Meter flushed the meter once the broadcast was announced, but the stream's usage report opens after that, so the sink often got nothing. It now flushes until the open arrives. TestMeterStream runs its stream in a synctest bubble instead of sleeping for real time. The rule turning opt-in time into whole-second metrics was written in both auth and ingest; optin.AddSeconds is now the one copy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KPWMJNAzsnsiqRPREa2JqY
The opt-in clock now lives in internal/optin: NewClock takes no clock and its tests run in a synctest bubble, as in #613. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KPWMJNAzsnsiqRPREa2JqY
This branch has not been deployed
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.
Description
Step 3 of usage metering, stacked on #613 (which is stacked on #608). Merge those first; GitHub then retargets this PR to
main.A stream pushed over RTMP or RTSP reaches the relay over the ingest's own session, under the ingest's key, so the relay can't bill it to its publisher. With
QUMO_USAGE_URLandQUMO_AUTH_KEYS,qumo rtmpandqumo rtsp-pushnow report each stream themselves, under the kid of the token that granted the push. This is the rule used for all metering: usage goes to the kid of the tenant token the server itself verified.Each stream sends, through
internal/meter(#608):session_open;usagerecord every 30 s;session_close.The records carry:
ingest.media_bytes(usage.IngestMediaBytes): the media the ingest took in, the payload of every frame without the protocol around it;gateway.opt_in_seconds.abrand.hls: how long the ingest kept the broadcast opted into each egress on the publisher's behalf.Related Issue
Follows #608 and #613. Step 4 (hls) comes next.
Changes
ingest.PublishAuthorizerreturns aPermission: the lapse, as before, plus the kid of the key that granted the push. The verifying authorizer fills it fromauth.Grant.KeyID().ingest.Session:PushVideo,PushAudio,PushAudioFrames);Usage).meterStream:RTMPConfig.MeterandRTSPConfig.Meter.QUMO_USAGE_URLis read by the ingest commands and refused withoutQUMO_AUTH_KEYS.optin.Clock: the opt-in clock from feat(relay): report how long each publishing session kept broadcasts opted into HLS and ABR #613 moved frominternal/relaytointernal/optin; the relay and the ingest both use it.cli/rtmp.mdandcli/rtsp-push.md(a Usage section and theQUMO_USAGE_URLrow), and configuration (an opt-in through ingest is billed by the ingest, not by the relay). CHANGELOG (Added).RTSP pull (
qumo rtsp) presents no publisher token, so it reports nothing; the operator configures that stream.Testing
Session.Usagecounts the payload bytes of every push method and the opt-in time.meterStream: an open, then a close under the kid with the media bytes and the opt-in seconds; nothing without a meter or a kid.authorizeAnyandpublishAuthorizerreturn the kid of the credential that granted the push.-race.TestIngest_ReportsUsageruns ffmpeg → RTMP ingest with two tokens (broadcast and ABR opt-in) checked against a key set.session_closeis under the tenant's kid, carriesingest.media_bytes > 0, and carriesgateway.opt_in_seconds.abrbetween 2 and 6 after a 2.2 s opt-in.go test ./...passes; golangci-lint reports 0 issues; the wholeinternal/integrationsuite passes (176 s).Checklist
Generated by Claude Code