Skip to main content

VideoPlayer

Struct VideoPlayer 

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

Stateful local video player composed from VideoDemuxer and VideoDecoder.

open decodes through the first display-order frame, so current_frame is immediately available on success. Timing controls do not create a second decoder or runtime owner; all hardware work remains inside the supplied Runtime-owned decoder session.

Implementations§

Source§

impl VideoPlayer

Source

pub fn open( runtime: &Runtime, path: impl AsRef<Path>, config: VideoPlayerConfig, ) -> Result<Self>

Open a local source and present its first display-order frame.

§Errors

Returns an error for invalid pacing, demux/decode failure, unsupported codec/device capabilities, or a source with no displayable frame.

Source

pub fn new_native( runtime: &Runtime, path: impl AsRef<Path>, config: VideoPlayerConfig, ) -> Result<Self>

Open a player whose frames retain the decoder’s native Vulkan images.

This route does not read decoded pixels back to the host. Frames returned by current_frame retain their decoder slots; GPU consumers must register completion with VideoFrame::mark_consumed. Converted presentation textures use the configured bounded history; decoder slots themselves are never cached. A backward cache miss rebuilds a preceding window once, so subsequent reverse steps reuse GPU textures.

A native frame is not a render crate::Texture. A renderer must explicitly convert or sample its planes before displaying it.

§Errors

Returns the same stream and device errors as open.

Source

pub fn advance(&mut self) -> Result<bool>

Present exactly one next display-order frame, independent of play/pause state.

Returns false only after a non-looping source is exhausted.

Source

pub fn step_backward(&mut self) -> Result<()>

Present the preceding display-order frame.

Retained history is presented without decoding. If the requested frame has already been evicted, the player seeks through a bounded preceding presentation window and deterministically rebuilds through the target.

Source

pub fn step_frames(&mut self, delta: i32) -> Result<()>

Move by a signed number of display-order frames.

Positive movement stops successfully at the end of a non-looping stream. Negative movement saturates at the first indexed display frame. A zero delta is a no-op.

Source

pub fn tick(&mut self, elapsed: Duration) -> Result<u32>

Advance according to elapsed wall-clock time while playing.

Returns the number of frames presented. Paused players do not accumulate elapsed time, preventing a burst of implicit skipping after resume.

Source

pub fn seek(&mut self, timestamp: u64) -> Result<()>

Seek to a presentation timestamp in the selected track time base.

The demuxer rewinds to the preceding keyframe; the player then decodes forward until it reaches the first frame at or after timestamp.

Source

pub fn seek_at_or_before(&mut self, timestamp: u64) -> Result<()>

Present the most recent indexed frame at or before a track timestamp.

This is the seek policy for an external audio clock: choosing the first frame after the requested time would display future video early. A timestamp before the first frame selects that first frame. Unindexed streams can only be rewound to zero.

Source

pub fn seek_frame(&mut self, index: u64) -> Result<()>

Seek to an exact zero-based display-order frame.

A retained target is presented without decoding. Otherwise the player seeks to a bounded preceding presentation window and rebuilds decoder state through the requested frame.

Source

pub fn reset(&mut self) -> Result<()>

Rewind and present the first frame.

Source

pub fn flush(&mut self) -> Result<usize>

End the current decode sequence and discard delayed frames.

Playback becomes done until seek or reset establishes a new random-access boundary.

Source

pub fn close(&mut self)

Explicitly release decoder and demuxer state. A second close is harmless.

Source

pub fn play(&mut self) -> Result<()>

Resume time-paced playback.

Source

pub fn pause(&mut self) -> Result<()>

Pause time-paced playback and discard fractional accumulated time.

Source

pub fn toggle_play(&mut self) -> Result<()>

Toggle time-paced playback.

Source

pub fn set_looping(&mut self, looping: bool) -> Result<()>

Change end-of-stream looping policy.

Source

pub fn current_frame(&self) -> Result<&VideoFrame>

Borrow the currently presented frame.

Source

pub fn current_frame_texture(&mut self) -> Result<Texture>

Convert the currently presented frame into a Texture for rendering.

Native decoded frames convert on-device through the decoder’s native-plane-to-RGBA path. The presented frame is then re-seated on the texture: its timing, extent, and color metadata remain observable through current_frame while the decoder slot is released for the next decode. A texture-backed frame returns its backing directly, so repeated calls for the same presented frame are free. Host-planar playback has no texture path.

§Errors

Returns an error after close, when no frame is presented, for a non-native frame without a texture backing, or when the conversion submission fails.

Source

pub fn next_presentation_boundary(&self) -> Result<Option<Duration>>

Timestamp at which the next display frame may replace the current one.

Indexed containers use the next frame’s PTS, which respects variable frame rate and gaps. Sequential sources use the current frame’s declared end; an unknown duration cannot be paced by an external clock. None means the indexed stream has no further display frame.

Source

pub fn current_frame_index(&self) -> Result<u64>

Return the absolute zero-based display index in the selected track.

Source

pub fn info(&self) -> Option<VideoContainerInfo>

Return selected stream metadata while open.

Source

pub fn stats(&self) -> Option<VideoPlayerStats>

Return a snapshot of playback counters while open.

Source

pub fn is_playing(&self) -> bool

Return whether time-paced playback is enabled.

Source

pub fn is_done(&self) -> bool

Return whether a non-looping stream has presented its final frame.

Source

pub const fn is_open(&self) -> bool

Return whether the player still owns its sessions.

Auto Trait Implementations§

§

impl !RefUnwindSafe for VideoPlayer

§

impl !Send for VideoPlayer

§

impl !Sync for VideoPlayer

§

impl !UnwindSafe for VideoPlayer

§

impl Forget for VideoPlayer

§

impl Freeze for VideoPlayer
where I32NotAllOnes: Freeze, *const u8 is !null: Freeze, PhantomData<Sample>: Freeze, PhantomData<usize>: Freeze, PhantomData<u8>: Freeze, *const RcInner<RefCell<RuntimeState>> is !null: Freeze, PhantomData<RcInner<RefCell<RuntimeState>>>: Freeze, *const ArcInner<DecodeSession> is !null: Freeze, PhantomData<ArcInner<DecodeSession>>: Freeze, PhantomData<RecordedDecodeStep>: Freeze, PhantomData<Option<Event>>: Freeze, PhantomData<Option<VideoHostPlanes>>: Freeze, *const H264SequenceParameterSet is !null: Freeze, PhantomData<H264SequenceParameterSet>: Freeze, *const H264PictureParameterSet is !null: Freeze, PhantomData<H264PictureParameterSet>: Freeze, *const H265VideoParameterSet is !null: Freeze, PhantomData<H265VideoParameterSet>: Freeze, *const H265SequenceParameterSet is !null: Freeze, PhantomData<H265SequenceParameterSet>: Freeze, *const H265PictureParameterSet is !null: Freeze, PhantomData<H265PictureParameterSet>: Freeze, *const Av1Parser is !null: Freeze, PhantomData<Av1Parser>: Freeze, *const Av1SequenceHeader is !null: Freeze, PhantomData<Av1SequenceHeader>: Freeze, *const LeafNode<(u64, u64), VideoFrame> is !null: Freeze, PhantomData<(Owned, LeafOrInternal)>: Freeze, PhantomData<Box<((u64, u64), VideoFrame)>>: Freeze, *const RcInner<StorageInner> is !null: Freeze, PhantomData<RcInner<StorageInner>>: Freeze, *const RcInner<MatrixSemantic> is !null: Freeze, PhantomData<RcInner<MatrixSemantic>>: Freeze, PhantomData<Rc<()>>: Freeze, *const RcInner<ImageSemantic> is !null: Freeze, PhantomData<RcInner<ImageSemantic>>: Freeze, *const RcInner<NativeRgbaImage> is !null: Freeze, PhantomData<RcInner<NativeRgbaImage>>: Freeze, *const RcInner<RefCell<RendererState>> is !null: Freeze, PhantomData<RcInner<RefCell<RendererState>>>: Freeze, *const RcInner<TextureSemantic> is !null: Freeze, PhantomData<RcInner<TextureSemantic>>: Freeze, *const ArcInner<Device> is !null: Freeze, PhantomData<ArcInner<Device>>: Freeze, *const ArcInner<RetirementCompletion> is !null: Freeze, PhantomData<ArcInner<RetirementCompletion>>: Freeze, *const ArcInner<WorkerControl> is !null: Freeze, PhantomData<ArcInner<WorkerControl>>: Freeze, *const ArcInner<TimestampPairInner> is !null: Freeze, PhantomData<ArcInner<TimestampPairInner>>: Freeze, *const ArcInner<Mutex<Vec<Arc<DecodeStatus>>>> is !null: Freeze, PhantomData<ArcInner<Mutex<Vec<Arc<DecodeStatus>>>>>: Freeze, *const ArcInner<Mutex<Vec<Arc<EncodeReceipt>>>> is !null: Freeze, PhantomData<ArcInner<Mutex<Vec<Arc<EncodeReceipt>>>>>: Freeze, *const ArcInner<NativeDecodedFrameLease> is !null: Freeze, PhantomData<ArcInner<NativeDecodedFrameLease>>: Freeze, *const RcInner<Vec<Matrix>> is !null: Freeze, PhantomData<RcInner<Vec<Matrix>>>: Freeze, *const ArcInner<Vec<u8>> is !null: Freeze, PhantomData<ArcInner<Vec<u8>>>: Freeze, *const ArcInner<Vec<u16>> is !null: Freeze, PhantomData<ArcInner<Vec<u16>>>: Freeze, PhantomData<VideoFrame>: Freeze, PhantomData<CachedPresentation>: Freeze, PhantomData<DisplayTimestamp>: Freeze,

§

impl Move for VideoPlayer

§

impl Unpin for VideoPlayer
where I32NotAllOnes: Unpin, *const u8 is !null: Unpin, Rc<RefCell<RuntimeState>>: Unpin, Arc<DecodeSession>: Unpin, Arc<Device>: Unpin, Box<H264SequenceParameterSet>: Unpin, Box<H264PictureParameterSet>: Unpin, Box<H264SliceHeader>: Unpin, Box<H265SequenceParameterSet>: Unpin, Box<H265PictureParameterSet>: Unpin, Box<H265SliceHeader>: Unpin, Box<Av1Picture>: Unpin, Box<Vp9Picture>: Unpin, Arc<DecodedPlaneCopy>: Unpin, Rc<Vec<Matrix>>: Unpin, Arc<RetirementCompletion>: Unpin, Arc<WorkerControl>: Unpin, Arc<TimestampPairInner>: Unpin, Arc<Mutex<Vec<Arc<DecodeStatus>>>>: Unpin, Arc<Mutex<Vec<Arc<EncodeReceipt>>>>: Unpin, Arc<Vec<u8>>: Unpin, Arc<Vec<u16>>: Unpin, Box<H265VideoParameterSet>: Unpin, Box<Av1Parser>: Unpin, Box<Av1SequenceHeader>: Unpin, *const LeafNode<(u64, u64), VideoFrame> is !null: Unpin, Box<((u64, u64), VideoFrame)>: Unpin, Rc<StorageInner>: Unpin, Rc<MatrixSemantic>: Unpin, Rc<()>: Unpin, Rc<ImageSemantic>: Unpin, Rc<NativeRgbaImage>: Unpin, Rc<RefCell<RendererState>>: Unpin, Rc<TextureSemantic>: Unpin, Arc<NativeDecodedFrameLease>: Unpin,

§

impl UnsafeUnpin for VideoPlayer
where I32NotAllOnes: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<Sample>: UnsafeUnpin, PhantomData<usize>: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, *const RcInner<RefCell<RuntimeState>> is !null: UnsafeUnpin, PhantomData<RcInner<RefCell<RuntimeState>>>: UnsafeUnpin, *const ArcInner<DecodeSession> is !null: UnsafeUnpin, PhantomData<ArcInner<DecodeSession>>: UnsafeUnpin, PhantomData<RecordedDecodeStep>: UnsafeUnpin, PhantomData<Option<Event>>: UnsafeUnpin, PhantomData<Option<VideoHostPlanes>>: UnsafeUnpin, *const H264SequenceParameterSet is !null: UnsafeUnpin, PhantomData<H264SequenceParameterSet>: UnsafeUnpin, *const H264PictureParameterSet is !null: UnsafeUnpin, PhantomData<H264PictureParameterSet>: UnsafeUnpin, *const H265VideoParameterSet is !null: UnsafeUnpin, PhantomData<H265VideoParameterSet>: UnsafeUnpin, *const H265SequenceParameterSet is !null: UnsafeUnpin, PhantomData<H265SequenceParameterSet>: UnsafeUnpin, *const H265PictureParameterSet is !null: UnsafeUnpin, PhantomData<H265PictureParameterSet>: UnsafeUnpin, *const Av1Parser is !null: UnsafeUnpin, PhantomData<Av1Parser>: UnsafeUnpin, *const Av1SequenceHeader is !null: UnsafeUnpin, PhantomData<Av1SequenceHeader>: UnsafeUnpin, *const LeafNode<(u64, u64), VideoFrame> is !null: UnsafeUnpin, PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin, PhantomData<Box<((u64, u64), VideoFrame)>>: UnsafeUnpin, *const RcInner<StorageInner> is !null: UnsafeUnpin, PhantomData<RcInner<StorageInner>>: UnsafeUnpin, *const RcInner<MatrixSemantic> is !null: UnsafeUnpin, PhantomData<RcInner<MatrixSemantic>>: UnsafeUnpin, PhantomData<Rc<()>>: UnsafeUnpin, *const RcInner<ImageSemantic> is !null: UnsafeUnpin, PhantomData<RcInner<ImageSemantic>>: UnsafeUnpin, *const RcInner<NativeRgbaImage> is !null: UnsafeUnpin, PhantomData<RcInner<NativeRgbaImage>>: UnsafeUnpin, *const RcInner<RefCell<RendererState>> is !null: UnsafeUnpin, PhantomData<RcInner<RefCell<RendererState>>>: UnsafeUnpin, *const RcInner<TextureSemantic> is !null: UnsafeUnpin, PhantomData<RcInner<TextureSemantic>>: UnsafeUnpin, *const ArcInner<Device> is !null: UnsafeUnpin, PhantomData<ArcInner<Device>>: UnsafeUnpin, *const ArcInner<RetirementCompletion> is !null: UnsafeUnpin, PhantomData<ArcInner<RetirementCompletion>>: UnsafeUnpin, *const ArcInner<WorkerControl> is !null: UnsafeUnpin, PhantomData<ArcInner<WorkerControl>>: UnsafeUnpin, *const ArcInner<TimestampPairInner> is !null: UnsafeUnpin, PhantomData<ArcInner<TimestampPairInner>>: UnsafeUnpin, *const ArcInner<Mutex<Vec<Arc<DecodeStatus>>>> is !null: UnsafeUnpin, PhantomData<ArcInner<Mutex<Vec<Arc<DecodeStatus>>>>>: UnsafeUnpin, *const ArcInner<Mutex<Vec<Arc<EncodeReceipt>>>> is !null: UnsafeUnpin, PhantomData<ArcInner<Mutex<Vec<Arc<EncodeReceipt>>>>>: UnsafeUnpin, *const ArcInner<NativeDecodedFrameLease> is !null: UnsafeUnpin, PhantomData<ArcInner<NativeDecodedFrameLease>>: UnsafeUnpin, *const RcInner<Vec<Matrix>> is !null: UnsafeUnpin, PhantomData<RcInner<Vec<Matrix>>>: UnsafeUnpin, *const ArcInner<Vec<u8>> is !null: UnsafeUnpin, PhantomData<ArcInner<Vec<u8>>>: UnsafeUnpin, *const ArcInner<Vec<u16>> is !null: UnsafeUnpin, PhantomData<ArcInner<Vec<u16>>>: UnsafeUnpin, PhantomData<VideoFrame>: UnsafeUnpin, PhantomData<CachedPresentation>: UnsafeUnpin, PhantomData<DisplayTimestamp>: 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

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<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

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.