Skip to main content

PlayerRunner

Struct PlayerRunner 

Source
pub struct PlayerRunner { /* private fields */ }
Expand description

Exclusive owner of the decode pipeline. Move to a background thread and call run.

Configure with set_sink, use_proxy_if_available, and set_hardware_accel before calling run.

Implementations§

Source§

impl PlayerRunner

Source

pub fn set_sink(&mut self, sink: Box<dyn FrameSink>)

Register the frame sink. Call before run.

Source

pub fn set_hardware_accel(&mut self, accel: HardwareAccel) -> &mut Self

Configure hardware acceleration. Call before run.

The setting takes effect at the start of run(). HardwareAccel::Auto (the default) probes available backends and falls back to software. HardwareAccel::None forces CPU-only decoding.

Source

pub fn active_source(&self) -> &Path

Returns the path currently being decoded (original or active proxy).

Source

pub fn with_frame_cache_budget(self, bytes: usize) -> Self

Enable an in-memory RGBA frame cache with the given byte budget.

When the budget is set, frames decoded during playback are stored and served on cache hit without re-decoding, enabling instant scrubbing. The cache is invalidated automatically whenever a seek targets a PTS outside the currently cached range.

Example: runner.with_frame_cache_budget(512 * 1024 * 1024) for 512 MB.

Source

pub fn duration(&self) -> Option<Duration>

Container-reported duration, or None for live / streaming sources.

Source

pub fn use_proxy_if_available(&mut self, proxy_dir: &Path) -> bool

Activate a lower-resolution proxy if one exists in proxy_dir.

Must be called before run. Returns true if a proxy was found and activated; false if no proxy exists or activation failed.

Proxy lookup order: halfquartereighth; first match wins.

Source

pub fn run(self) -> Result<(), PreviewError>

A/V sync presentation loop.

Blocks until a PlayerCommand::Stop is received, the end of file is reached, or an unrecoverable decode error occurs.

At the top of each frame, all pending commands are drained from the channel. Consecutive PlayerCommand::Seek commands are coalesced — only the last one executes.

Emits PlayerEvent::SeekCompleted after each successful seek, PlayerEvent::PositionUpdate after each presented video frame, PlayerEvent::Error on non-fatal decode errors, and PlayerEvent::Eof before returning.

§Errors

Returns PreviewError if a seek fails.

Trait Implementations§

Source§

impl Drop for PlayerRunner

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.