Skip to main content

oxideav_source/
lib.rs

1//! Source registry shim — `oxideav_core::SourceRegistry` plus the
2//! built-in `file://` driver and a prefetching `BufferedSource`
3//! wrapper.
4//!
5//! `SourceRegistry`, the typed source traits ([`BytesSource`],
6//! [`PacketSource`], [`FrameSource`]), and the [`SourceOutput`] enum
7//! live in `oxideav-core`. This crate retains the concrete `file://`
8//! driver and the `BufferedSource` helper that `oxideav-http` and the
9//! player rely on; it also exposes a [`with_defaults`] free function
10//! that pre-populates a registry with the file driver, matching the
11//! historical surface.
12//!
13//! ```no_run
14//! let reg = oxideav_source::with_defaults();
15//! let _input = reg.open("/tmp/video.mp4").unwrap();
16//! ```
17
18pub use oxideav_core::{
19    BytesSource, FrameSource, PacketSource, ReadSeek, SourceOutput, SourceRegistry,
20};
21
22mod buffered;
23mod file;
24mod uri;
25
26pub use buffered::BufferedSource;
27pub use file::open_file;
28
29/// Build a [`SourceRegistry`] pre-populated with the built-in `file`
30/// driver. Bare paths (without a scheme) also dispatch to it via the
31/// registry's fall-back behaviour.
32pub fn with_defaults() -> SourceRegistry {
33    let mut r = SourceRegistry::new();
34    r.register_bytes("file", open_file);
35    r
36}
37
38/// Install the `file://` (and bare-path) source driver into the given
39/// runtime context. Idempotent — replacing a prior registration of the
40/// `file` scheme.
41pub fn register(ctx: &mut oxideav_core::RuntimeContext) {
42    ctx.sources.register_bytes("file", open_file);
43}
44
45oxideav_core::register!("source", register);