Repository navigation
feat(js)!: the browser publisher and player report stats and feedback #7222
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
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
975ceea
chore(quest): claim quest/m2/stats/js.md
kixelated 6687905
wip(js): publish stats and viewer feedback from the browser elements
kixelated 2d09aba
wip(js): feedback docs, demo, and tests
kixelated 4d6d15c
quest: finish browser stats and feedback reporters
kixelated ad4d86f
Merge origin/main into quest/m2/stats/js
kixelated 5daefb9
fix(watch): clock-lint the feedback tests and unblock the latency ledger
kixelated 00c53d5
Merge remote-tracking branch 'origin/main' into quest/m2/stats/js
kixelated d7e8ded
chore(js): refresh the public API reports for stats and feedback
kixelated 6b5d78e
fix(watch): feedback belongs to one catalog, without retaining depart…
kixelated 337d9fe
fix(watch): bound departed reporters' rendition IDs like a tally
kixelated 80faed9
Merge remote-tracking branch 'origin/main' into quest/m2/stats/js
kixelated c0f7260
refactor(watch): a feedback reporter adds what it counted since joining
kixelated 50b4bcf
refactor(watch)!: each <moq-watch> publishes its own feedback broadcast
kixelated 2219155
Merge origin/main into quest/m2/stats/js
kixelated f8ccc91
feat(watch): a refused feedback reporter takes over once the holder l…
kixelated 2e47321
fix(watch): report arrival at transport ingress and refuse malformed …
kixelated 6edf951
Merge origin/main into quest/m2/stats/js
kixelated 7a1c8d2
Merge branch 'base' into pr-7222
d209a98
fix(watch): follow base publication instance API
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| /** | ||
| * The track a media report rides on: a publisher's stats or a viewer's feedback. | ||
| * @module | ||
| */ | ||
|
|
||
| import * as Json from "@moq/json"; | ||
| import type * as Moq from "@moq/net"; | ||
| import type * as z from "@zod/mini"; | ||
|
|
||
| /** How often a reporter writes, in milliseconds: about once a second, as the hang draft asks. */ | ||
| export const INTERVAL = 1000; | ||
|
|
||
| /** The report track's priority: below every media track, so a report never delays the media it describes. */ | ||
| export const PRIORITY = -128; | ||
|
|
||
| // Deltas compress against the snapshot in their group, and a joiner asks for a fresh group once | ||
| // they outweigh eight snapshots. Matches the Rust CLI's report tracks. | ||
| const REFRESH = 8; | ||
|
|
||
| /** | ||
| * One compressed snapshot track, written only while someone subscribes, so an unobserved report | ||
| * never leaves the process. | ||
| */ | ||
| export class Writer<T> { | ||
| /** The report track. */ | ||
| readonly track: Moq.Track.Producer; | ||
|
|
||
| #producer: Json.Snapshot.Producer<T>; | ||
| #closed = false; | ||
|
|
||
| /** Create `name` on `broadcast`, validating each report against `schema` before it is written. */ | ||
| constructor(broadcast: Moq.Broadcast.Producer, name: string, schema?: z.ZodMiniType<T>) { | ||
| this.track = broadcast.createTrack(name, { priority: PRIORITY, compress: true, refresh: REFRESH }); | ||
| this.#producer = new Json.Snapshot.Producer<T>({ track: this.track, schema }); | ||
| } | ||
|
|
||
| /** Whether anyone subscribes now, which is when {@link update} writes. Observe `track.demand().wanted` to follow it. */ | ||
| get wanted(): boolean { | ||
| return this.track.demand().wanted.peek() !== undefined; | ||
| } | ||
|
|
||
| /** | ||
| * Publish `value` when someone subscribes; an unchanged value writes nothing. A track that refuses | ||
| * a write would refuse every later one, so it is aborted with the cause, which its subscribers read. | ||
| */ | ||
| update(value: T): void { | ||
| if (this.#closed || !this.wanted) return; | ||
| try { | ||
| this.#producer.update({ value }); | ||
| } catch (err) { | ||
| console.warn("a report track failed; closing it", err); | ||
| this.#closed = true; | ||
| this.track.abort(err instanceof Error ? err : new Error(String(err))); | ||
| } | ||
| } | ||
|
|
||
| /** End the track cleanly, keeping the last report for a late subscriber. Idempotent. */ | ||
| finish(): void { | ||
| if (this.#closed) return; | ||
| this.#closed = true; | ||
| this.#producer.finish(); | ||
| } | ||
| } |
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
Script executed:
Repository: moq-dev/moq
Length of output: 7235
Script executed:
Repository: moq-dev/moq
Length of output: 37204
Script executed:
Repository: moq-dev/moq
Length of output: 19785
Keep separate encoded-output and sent-media counters.
The callback can count a frame while
#liveis absent or while the frame is below#floor. The rendition stats contract reports media sent, butEncoderOutput.statsis documented as encoded-output totals. Moving the existing update afterlive.producer.encodewould fix the rendition value only by changing the publicStatscontract. Keep the encoded-output counter and update a separate sent-media counter after a successfullive.producer.encode; proxy that counter torendition.stats.