Files
proton-stream/crates/pstr-stream/src/lib.rs
nvrl 1c9e5872fe perf(android,ios): no block read-ahead under mpv on the phones either
B8 turned the block layer's read-ahead off under mpv on the desktop:
12 blocks cost 5.5 s to the first frame and 3.6 s to resume a seek,
against 2.5 s and 1.5 s with none. The mobile bridge, which iOS links
too, built its StreamSource from StreamConfig::default() and kept the
12 blocks. The value is now pstr_stream::MPV_READAHEAD_BLOCKS, passed by
every player (B74).
2026-11-28 18:27:55 +01:00

43 lines
2.0 KiB
Rust

//! Seekable, cached byte streams over Proton Drive revisions.
//!
//! The engine (memory ring, disk cache, read-ahead that yields to seeks, the
//! LRU of open streams) lives in `proton-media-rs`'s `stream` module, shared
//! with the other Proton apps. This crate pins it to Proton node UIDs and adds
//! the one piece that knows about this app's shares: [`LibraryOpener`].
//!
//! A Proton file's content blocks each decrypt on their own, so seeking costs
//! one block fetch, not a re-stream. Never assume a 4 MiB block: the sizes come
//! from the revision.
#![forbid(unsafe_code)]
pub mod ordered;
pub mod reader;
pub use proton_media_rs::stream::{
BlockSource, COPY_BLOCKS_IN_FLIGHT, DEFAULT_READAHEAD_BLOCKS, DEFAULT_RING_BYTES, FileBlocks,
MemoryBlocks, RevisionBlocks, RingStats, SharedBlocks, StreamConfig, StreamStats,
};
pub use proton_media_rs::{BlockMap, DiskCacheConfig, DiskStats, Error, Result};
/// Re-exported because every caller of this crate names one, and taking a
/// dependency on the whole SDK for a newtype is not a reasonable price for that.
pub use proton_sdk::ids::NodeUid;
pub use reader::LibraryOpener;
/// What a share's file is opened as: one revision, readable at any offset.
pub type VideoStream = proton_media_rs::stream::RangeStream<NodeUid>;
/// Opens and caches [`VideoStream`]s.
pub type StreamSource = proton_media_rs::stream::StreamSource<NodeUid>;
/// How many blocks the stream layer reads ahead when mpv is the reader:
/// **none**.
///
/// [`DEFAULT_READAHEAD_BLOCKS`] suits a reader with no read-ahead of its own.
/// mpv's demuxer cache already runs seconds ahead of the picture, so a second
/// speculative layer under it adds no buffer and takes bandwidth from the reads
/// mpv is waiting on. Every player (desktop, Android, iOS) passes this to
/// [`StreamConfig::with_readahead`]. Measured in `docs/BUGS.md` B8.
pub const MPV_READAHEAD_BLOCKS: usize = 0;
/// How a [`StreamSource`] turns a node into blocks.
pub use proton_media_rs::stream::RevisionOpener;