Skip to main content

RgbaSink

Struct RgbaSink 

Source
pub struct RgbaSink {
    pub last_frame: Arc<Mutex<Option<RgbaFrame>>>,
}
Expand description

Reference FrameSink implementation that stores the latest frame in a shared Arc<Mutex<Option<RgbaFrame>>>.

Clone frame_handle to share access with a rendering thread:

let sink   = RgbaSink::new();
let handle = sink.frame_handle();
player.set_sink(Box::new(sink));

// In the render loop (any thread):
if let Some(frame) = handle.lock().unwrap().as_ref() {
    upload_to_gpu(&frame.data, frame.width, frame.height);
}

Only the latest frame is stored — not a queue. Renderers typically only need the current frame, not a backlog.

Fields§

§last_frame: Arc<Mutex<Option<RgbaFrame>>>

Shared storage for the most recently received RGBA frame.

Implementations§

Source§

impl RgbaSink

Source

pub fn new() -> Self

Create a new RgbaSink with an empty frame store.

Source

pub fn frame_handle(&self) -> Arc<Mutex<Option<RgbaFrame>>>

Clone the Arc for sharing with the rendering thread.

Trait Implementations§

Source§

impl Default for RgbaSink

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl FrameSink for RgbaSink

Source§

fn push_frame(&mut self, rgba: &[u8], width: u32, height: u32, pts: Duration)

Receive a video frame at its presentation time. Read more
Source§

fn flush(&mut self)

Called when playback ends (EOF or PlayerHandle::stop). Default: no-op. 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.