Skip to main content

VideoPlaybackPipeline

Struct VideoPlaybackPipeline 

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

Asynchronous multi-threaded (native) / deterministic pumpable (wasm32) structured video playback pipeline.

Implementations§

Source§

impl VideoPlaybackPipeline

Multi-threaded (native) / deterministic pumpable (wasm32) structured video playback pipeline implementation.

Source

pub fn from_mp4_bytes(bytes: Vec<u8>) -> Result<Self, String>

Opens an MP4 byte stream using the pure-Rust SoftwareVideoDecoder fallback and bounded queue/pool capacities.

§Arguments
  • Vec<u8> - Complete MP4 container bytes.
§Returns
  • Result<Self, String> - Initialized video playback pipeline or parse/config error.
Source

pub fn from_mp4_with_backend( bytes: Vec<u8>, decoder: Box<dyn VideoDecoderBackend>, queue_capacity: usize, pool_capacity: usize, ) -> Result<Self, String>

Opens an MP4 byte stream using a custom hardware or software VideoDecoderBackend.

§Arguments
  • Vec<u8> - Complete MP4 container bytes.
  • Box<dyn VideoDecoderBackend> - Hardware zero-copy or software decoder backend.
  • usize - Bounded PTS frame queue capacity.
  • usize - Bounded CPU RGBA8 frame pool capacity.
§Returns
  • Result<Self, String> - Initialized video playback pipeline or error.
Source

pub fn demuxer(&self) -> &Mp4Demuxer

Returns a reference to the parsed MP4 demuxer.

§Arguments
  • &Self - Pipeline reference.
§Returns
  • &Mp4Demuxer - Demuxer reference.
Source

pub fn frame_pool(&self) -> &VideoFramePool

Returns a reference to the bounded CPU video frame pool.

§Arguments
  • &Self - Pipeline reference.
§Returns
  • &VideoFramePool - Frame pool reference.
Source

pub fn scheduler(&self) -> &AvSyncScheduler

Returns a reference to the active A/V synchronization scheduler.

§Arguments
  • &Self - Pipeline reference.
§Returns
  • &AvSyncScheduler - Scheduler reference.
Source

pub fn scheduler_mut(&mut self) -> &mut AvSyncScheduler

Returns a mutable reference to the A/V synchronization scheduler.

§Arguments
  • &Self - Mutable pipeline.
§Returns
  • &mut AvSyncScheduler - Mutable scheduler reference.
Source

pub const fn backend_kind(&self) -> HardwareDecoderKind

Returns the active decoder backend kind (VideoToolbox, MediaCodec, Vaapi, Dxva, WebCodecs, or SoftwareFallback).

§Arguments
  • &Self - Pipeline reference.
§Returns
  • HardwareDecoderKind - Active backend kind.
Source

pub const fn color_info(&self) -> VideoColorInfo

Returns preserved color primaries, transfer curve, matrix, range, and HDR metadata.

§Arguments
  • &Self - Pipeline reference.
§Returns
  • VideoColorInfo - Track color and HDR metadata.
Source

pub const fn playback_state(&self) -> PlaybackState

Returns the active transport playback state.

§Arguments
  • &Self - Pipeline reference.
§Returns
  • PlaybackState - Current playback state.
Source

pub fn current_frame(&self) -> Option<&DecodedVideoFrame>

Returns the currently displayed decoded frame, if any.

§Arguments
  • &Self - Pipeline reference.
§Returns
  • Option<&DecodedVideoFrame> - Active frame reference.
Source

pub const fn active_generation(&self) -> u64

Returns the active seek generation counter.

§Arguments
  • &Self - Pipeline reference.
§Returns
  • u64 - Active generation counter.
Source

pub fn play(&mut self)

Resumes background decoding and playback.

§Arguments
  • &Self - Mutable pipeline.
Source

pub fn pause(&mut self)

Pauses playback and suspends background worker decoding until resumed.

§Arguments
  • &Self - Mutable pipeline.
Source

pub fn seek_us(&mut self, target_pts_us: i64) -> u64

Executes a generation-tagged seek: drains stale frames, rewinds demuxer to the preceding keyframe, flushes decoder, and prerolls to target_pts_us.

§Arguments
  • &Self - Mutable pipeline.
  • i64 - Target presentation timestamp in microseconds.
§Returns
  • u64 - Newly incremented generation identifier.
Source

pub fn wait_until_queued(&mut self, min_frames: usize, timeout_ms: u64) -> usize

Waits on native targets (or pumps on wasm32) until at least min_frames frames of the active generation are queued or EOS/timeout occurs.

§Arguments
  • &Self - Mutable pipeline.
  • usize - Minimum queued frames desired.
  • u64 - Maximum wait timeout in milliseconds.
§Returns
  • usize - Number of queued frames currently ready.
Source

pub fn pump_decode_once(&mut self) -> bool

Synchronously pumps one decode step on WebAssembly targets (returns false on native where the background thread runs continuously).

§Arguments
  • &Self - Mutable pipeline.
§Returns
  • bool - true if a packet was decoded on this pump call.
Source

pub fn present_vsync( &mut self, audio_master_pts_us: Option<i64>, vsync_dt_us: u64, ) -> VideoPresentOutcome

Evaluates one display VSync tick against the A/V sync scheduler, moving a due frame into current_frame() with zero pixel copies and recycling the previous CPU frame.

§Arguments
  • &Self - Mutable pipeline.
  • Option<i64> - Optional hardware audio master timestamp in microseconds (None uses monotonic vsync_dt_us).
  • u64 - Elapsed display VSync interval in microseconds (e.g. 6_944 at 144Hz or 16_667 at 60Hz).
§Returns
  • VideoPresentOutcome - Whether a new frame replaced current_frame(), held current frame, buffered, or ended.
Source

pub fn queued_frame_count(&self) -> usize

Returns the number of decoded frames currently buffered in the PTS queue.

§Arguments
  • &Self - Pipeline reference.
§Returns
  • usize - Queued frame count.
Source

pub fn reached_eos(&self) -> bool

Returns true when the decoder worker has reached end-of-stream for the active generation.

§Arguments
  • &Self - Pipeline reference.
§Returns
  • bool - true when end-of-stream has been reached.
Source

pub fn packets_decoded(&self) -> u64

Returns total packets decoded by the pipeline worker across playback and seeks.

§Arguments
  • &Self - Pipeline reference.
§Returns
  • u64 - Total packets decoded.
Source

pub fn seek_preroll_frames_discarded(&self) -> u64

Returns total preroll frames decoded and discarded while advancing from a keyframe to a seek target PTS.

§Arguments
  • &Self - Pipeline reference.
§Returns
  • u64 - Preroll frames discarded during seek catch-up.
Source

pub fn last_error(&self) -> Option<String>

Returns the last worker decode error, if any occurred.

§Arguments
  • &Self - Pipeline reference.
§Returns
  • Option<String> - Error message when present.

Trait Implementations§

Source§

impl Debug for VideoPlaybackPipeline

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the struct fields as a debug struct, skipping excluded fields.

§Arguments
  • &mut ::std::fmt::Formatter<'_> - The formatter to write the representation into.
§Returns
  • ::std::fmt::Result - Success or failure of the formatting operation.
Source§

impl Drop for VideoPlaybackPipeline

Clean shutdown and background thread join on Drop for VideoPlaybackPipeline.

Source§

fn drop(&mut self)

Signals the background decode worker to exit, recycles buffered CPU frames, and joins the worker thread cleanly.

§Arguments
  • &Self - Mutable pipeline being dropped.
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§

§

impl !RefUnwindSafe for VideoPlaybackPipeline

§

impl !UnwindSafe for VideoPlaybackPipeline

§

impl Forget for VideoPlaybackPipeline

§

impl Freeze for VideoPlaybackPipeline
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze, PhantomData<String>: Freeze, PhantomData<Mp4Sample>: Freeze, *const ArcInner<Mutex<VideoFramePoolState>> is !null: Freeze, PhantomData<ArcInner<Mutex<VideoFramePoolState>>>: Freeze, *const ArcInner<(Mutex<VideoWorkerShared>, Condvar)> is !null: Freeze, PhantomData<ArcInner<(Mutex<VideoWorkerShared>, Condvar)>>: Freeze, *const ArcInner<Inner> is !null: Freeze, PhantomData<ArcInner<Inner>>: Freeze, *const ArcInner<Packet<'static, ()>> is !null: Freeze, PhantomData<ArcInner<Packet<'static, ()>>>: Freeze,

§

impl Move for VideoPlaybackPipeline

§

impl Send for VideoPlaybackPipeline
where RawVecInner: Send, Arc<Mutex<VideoFramePoolState>>: Send, Arc<(Mutex<VideoWorkerShared>, Condvar)>: Send, JoinHandle<()>: Send,

§

impl Sync for VideoPlaybackPipeline
where RawVecInner: Sync, Arc<Mutex<VideoFramePoolState>>: Sync, Arc<(Mutex<VideoWorkerShared>, Condvar)>: Sync, JoinHandle<()>: Sync,

§

impl Unpin for VideoPlaybackPipeline
where *const u8 is !null: Unpin, Arc<Mutex<VideoFramePoolState>>: Unpin, Arc<(Mutex<VideoWorkerShared>, Condvar)>: Unpin, Arc<Inner, System>: Unpin, Arc<Packet<'static, ()>>: Unpin,

§

impl UnsafeUnpin for VideoPlaybackPipeline
where *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, PhantomData<String>: UnsafeUnpin, PhantomData<Mp4Sample>: UnsafeUnpin, *const ArcInner<Mutex<VideoFramePoolState>> is !null: UnsafeUnpin, PhantomData<ArcInner<Mutex<VideoFramePoolState>>>: UnsafeUnpin, *const ArcInner<(Mutex<VideoWorkerShared>, Condvar)> is !null: UnsafeUnpin, PhantomData<ArcInner<(Mutex<VideoWorkerShared>, Condvar)>>: UnsafeUnpin, *const ArcInner<Inner> is !null: UnsafeUnpin, PhantomData<ArcInner<Inner>>: UnsafeUnpin, *const ArcInner<Packet<'static, ()>> is !null: UnsafeUnpin, PhantomData<ArcInner<Packet<'static, ()>>>: UnsafeUnpin,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.