fix(youtube): support SABR random access from player time#83
Open
Priveetee wants to merge 8 commits into
Open
Conversation
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
This PR adds an additional random-access option for YouTube SABR sessions.
The existing SABR flow is kept as-is. This adds another way to drive a SABR session when a caller already knows the current playback position: seed the YouTube player response with
startTimeSecs, then request media around a specificplayerTimeMs.The session still keeps the normal stateful SABR data: selected formats, active tracks, buffered ranges, playback cookie, SABR contexts and PO token state.
It also fixes SABR init retrieval for fresh sessions opened at a non-zero playback position by fetching init data before applying seek-state changes.
Why
PipePipe's SABR support already has the pieces needed for stateful playback, but consumers currently have no clean extractor-level primitive for "give me media around this playback time".
This gives PipePipe and downstream consumers another option for playback flows where starting from the beginning is not ideal or not enough.
It can be useful for:
Without a player-time entry point, downstream consumers may need to restart from the beginning, keep local workaround state, or accidentally depend on fallback playback surfaces instead of driving the SABR session directly.
This PR keeps that behavior inside PipePipeExtractor, where the YouTube SABR session state is already managed.
For TypeType, this is essential because TypeType uses a SABR-only YouTube playback contract and needs a reliable way to open or reuse a stateful SABR session around the current player position. The same primitive could be useful to PipePipe in the future for resume, seek, quality-switch and performance-sensitive playback paths.
Changes
YoutubeSabrProbe.fetchSabrInfo(..., startTimeSecs).startTimeSecsin the YouTube player request when provided.YoutubeSabrSession.fetchMediaAt(playerTimeMs, videoActive, audioActive, localization).YoutubeSabrSession.fetchMediaSegmentAt(...)for targeted player-time media requests.Validation
Extractor:
Player-time media probes:
Observed media around
321601ms:Both returned media ranges cover
321601ms.Downstream runtime validation also passed in TypeType, which uses SABR-only playback without HLS/DASH/progressive fallback:
Notes
This does not replace the existing SABR session flow.
It adds an optional player-time random-access path. Callers that do not need this behavior can continue using the current flow unchanged.