Skip to main content

Crate oxideav_source

Crate oxideav_source 

Source
Expand description

Source registry shim — oxideav_core::SourceRegistry plus the built-in file://, mem://, data:, and concat: drivers and a prefetching BufferedSource wrapper.

SourceRegistry, the typed source traits (BytesSource, PacketSource, FrameSource), and the SourceOutput enum live in oxideav-core. This crate retains the concrete drivers and the BufferedSource helper that oxideav-http and the player rely on; it also exposes a with_defaults free function that pre-populates a registry with the bundled drivers, matching the historical surface.

let reg = oxideav_source::with_defaults();
let _input = reg.open("/tmp/video.mp4").unwrap();

§Schemes

  • file://<path> and bare paths — local filesystem. Default opener is unscoped; install a FileScope via FileScope::register_into to restrict by directory allow-list.
  • mem://<id> — process-global in-memory buffer; register a payload with mem::put.
  • data:[<mediatype>][;base64],<bytes> — RFC 2397 inline byte literals; payload is decoded directly from the URI with no filesystem access.
  • concat:<a>|<b>|… — concatenate several file:// segments into one seekable byte stream (de-facto concat: shape; no on-wire spec).
  • slice:<offset>+<length>!<inner-uri> — URI-level windowed view over an inner file:// / mem:// / data: / slice: source. Pipelines can address a byte-range sub-stream without first materialising the inner source.

Re-exports§

pub use data::open_data;
pub use data::parse as parse_data_uri;
pub use data::DataUri;
pub use mem::open_mem;

Modules§

data
Built-in data: driver — inline byte literals embedded in the URI.
mem
Built-in mem:// driver — in-memory synthetic byte buffers.

Structs§

BufferedSource
Buffered, prefetching wrapper around any ReadSeek.
BufferedSourceBuilder
Builder for BufferedSource. Exposes every prefetch tunable for callers whose source has a non-default latency or transfer profile; callers that just want a sensible buffer can stay on BufferedSource::new.
FileScope
Configurable allow-list for file:// opens.
SourceRegistry
Registry mapping URI schemes to opener functions. Each scheme picks one of three opener kinds (bytes / packets / frames) at registration time; callers see the choice via the SourceOutput variant returned from open.
SubSource
Windowed view over an inner BytesSource.

Enums§

SourceOutput
What a SourceRegistry::open call returns. The variant is decided at driver-registration time, so callers can match on the shape and branch the pipeline accordingly.

Constants§

DEFAULT_BLOCK
Default worker block size in bytes (block_size).
DEFAULT_LOOKBACK_DEN
Default lookback fraction denominator. See DEFAULT_LOOKBACK_NUM.
DEFAULT_LOOKBACK_NUM
Default lookback fraction numerator. The ring keeps the most recent capacity * LOOKBACK_NUM / LOOKBACK_DEN bytes behind the reader so a short back-seek hits the ring instead of restarting prefetch. The default 1/8 (~12.5 %) matches the historical hardcoded value.
DEFAULT_PREFETCH_TIMEOUT
Default reader-side prefetch wait timeout. A read that has to wait for the worker longer than this surfaces io::ErrorKind::TimedOut instead of hanging forever; useful when the inner source has stalled (e.g. a frozen HTTP connection).

Traits§

BytesSource
A seekable byte stream (Read + Seek + Send). Replaces the historical Box<dyn ReadSeek> opener-return type with a name that mirrors the other source-shape traits in this module. Blanket-implemented for every type that satisfies the bounds, so existing readers (files, Cursor<Vec<u8>>, HTTP-over-Range adapters) work unchanged.
FrameSource
A producer of already-decoded Frames.
PacketSource
A producer of already-demuxed Packets.
ReadSeek
Convenience trait bundle for seekable readers.

Functions§

open_concat
Open a concat:<a>|<b>|… URI as a single BytesSource that reads the segments back-to-back. Each segment may be a bare path, a file:// URL, a mem://<id> reference, a data: literal, or a slice: URI.
open_file
Open a local file as a Box<dyn BytesSource>. Accepts:
open_file_scoped
Free-function opener compatible with SourceRegistry::register_bytes. Looks up the active scope and delegates. If no scope is installed, every call errors — install via FileScope::register_into first.
open_slice
Open a slice:<offset>+<length>!<inner-uri> URI.
register
Install the bundled source drivers (file://, bare paths, mem://, data:, concat:, slice:) into the given runtime context. Idempotent — replacing any prior registration of those schemes.
stream_len
Probe the total length of a seekable source non-destructively: remembers the current position, seeks to End(0), and restores the position before returning. Useful in any code path that wants the inner length once and doesn’t care about reading the bytes.
with_defaults
Build a SourceRegistry pre-populated with the built-in file, mem, data, concat, and slice drivers. Bare paths (without a scheme) dispatch to the file driver via the registry’s fall-back behaviour.