Add optional quality field to first_frame beacon#38
Open
stevenlyons wants to merge 2 commits into
Open
Conversation
Captures the initial rendition at first-frame time across all integrations, giving a complete quality picture from the start of playback — not just from the first ABR switch. - plinth-core: FirstFrame event becomes a struct variant carrying Option<QualityLevel>; first_frame beacon copies quality when present - plinth-js: PlayerEvent type updated to include optional quality - plinth-hlsjs: reads hls.levels[hls.currentLevel] at first frame - plinth-shaka: reads active variant track via getVariantTracks() - plinth-dashjs: uses lastRepresentation cached by quality_change handler - plinth-avplayer: reads presentationSize + access log indicatedBitrate - plinth-media3: reads player.videoFormat at onRenderedFirstFrame Quality is omitted (key absent) when the integration cannot determine the rendition (e.g. no access log entry yet, currentLevel=-1, no format). Also fixes a pre-existing bug: seekStart was serialized as "seek_start" in Swift but Rust expects "seek"; corrected encoding and updated tests.
Hls.js: LEVEL_SWITCHED fires for the initial level immediately after
first_frame, emitting a redundant quality_change at identical quality.
Fix: track lastQualityBitrate; skip LEVEL_SWITCHED if bitrate matches
what was captured at first_frame. Set lastQualityBitrate in onPlaying
alongside the first_frame emission. Two new tests cover this.
dash.js: QUALITY_CHANGE_REQUESTED fires after first_frame in practice,
so lastRepresentation was null when onPlaying ran. Fix: call
getCurrentRepresentationForType('video') directly at first_frame time
(always reflects the current rendition). Set lastQualityIndex from the
result so subsequent QUALITY_CHANGE_REQUESTED for the same index is
deduped. Tests 5 and 5a updated; new test 5b covers dedup after capture.
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.
Summary
QualityLeveltype; no beacon schema changes beyond making the field available onfirst_frameChanges
crates/plinth-core:FirstFrameevent becomes a struct variant carryingOption<QualityLevel>; beacon copies quality when present; 3 new core testspackages/web/plinth-js:PlayerEventtype updated with optionalqualityonfirst_framepackages/web/plinth-hlsjs: readshls.levels[hls.currentLevel]at first frame; falls back to no quality whencurrentLevel=-1packages/web/plinth-shaka: reads active variant viagetVariantTracks()using extractedqualityFromTrackhelperpackages/web/plinth-dashjs: useslastRepresentationcached by the quality-change handlerpackages/apple/plinth-avplayer: readspresentationSize+ access logindicatedBitratefromAVPlayerItempackages/android/plinth-media3: readsplayer.videoFormatinonRenderedFirstFramedocs/reference:beacon-payload.mdandbeacon-payload.schema.jsonupdated to document optional quality onfirst_frameseekStartwas serialized as"seek_start"in Swift but Rust expects"seek"Test plan
cargo test -p plinth-core— 143 tests pass, including 3 new first_frame quality testspnpm -r test— 38/38 hlsjs, 38/38 shaka, 35/35 dashjsswift test(frompackages/apple/plinth-apple/) — 21 tests pass./gradlew :plinth-media3:test— requires JDK+Android SDK; 5 new tests for first_frame quality{"type":"first_frame"}with noqualitykeyquality_changebeacons are not suppressed by the initial quality capture