Skip to main content

Module range_source

Module range_source 

Source
Expand description

HTTP Range-backed seekable byte source.

Used for YouTube Music (and any other URL where the server returns Accept-Ranges: bytes). Unlike crate::stream_buffer::StreamBuffer, this never downloads the file linearly — every miss in the rolling window cache becomes a Range: bytes=N-M request. Symphonia can seek freely: to the end (Matroska Cues), to scrub targets, anywhere.

Architecture:

  • One rolling 512 KiB window, anchored at chunk_start.
  • seek() is a constant-time pointer move.
  • read() fetches a fresh window only when pos falls outside the currently-cached window. Sequential playback stays inside the window 90%+ of the time.
  • HTTP calls happen via reqwest::blocking inside whatever thread is calling Read::read — callers MUST already be on a blocking-friendly thread (spawn_blocking or similar).

byte_len() is determined once upfront from Content-Range of the initial probe fetch. If the server doesn’t include it, we fall back to a HEAD request. If both fail, this source can’t be constructed.

Structs§

RangeStreamSource