Skip to main content

FrameStore

Struct FrameStore 

Source
pub struct FrameStore<T> { /* private fields */ }
Expand description

Timestamped video frames and explicitly registered, time-independent images.

Implementations§

Source§

impl<T> FrameStore<T>

Source

pub fn sized(size: fn(&T) -> u64, video_byte_budget: u64) -> Self

A store that measures each value with size and keeps at most video_byte_budget bytes.

The budget counts every retained generation once, retired entries and images included. Eviction releases only cache ownership; submitted work owns its GPU resources.

A newly inserted frame may exceed the budget alone so it can be presented, in which case no other unpinned generation is kept. A pinned working set may not (Self::pin).

Source

pub fn set_video_byte_budget(&mut self, bytes: u64)

Changes the byte budget, evicting oldest generations at once to fit.

Source

pub fn pin(&mut self, keys: impl IntoIterator<Item = (String, i64)>)

Pins the working set of the frame being made: the frames at keys (source and time), the frames after them the keys hold, and each source’s image, which answers a time with no exact frame. Replaces earlier pins.

Until Self::unpin, the budget never evicts a pinned generation, and an upload or alias that would push the pinned set over budget is refused. A one-frame working set may exceed the budget, as any newest upload may.

Source

pub fn unpin(&mut self)

Drops the pins, leaving every generation to the budget again.

Source

pub const fn last_working_set_bytes(&self) -> u64

Bytes of the working set the last Self::unpin released: what one output frame needed, which a host lowering the budget under memory pressure keeps room for.

Source

pub fn insert( &mut self, key: (String, i64), value: T, ) -> Result<u64, WorkingSetOverBudget>

Stores a frame at key and returns its new generation. A frame already at key is retired with the frame after it the key held, and older unpinned generations are evicted to fit the budget.

§Errors

Refuses a frame at a pinned key that would push the working set over budget, keeping the store unchanged.

Source

pub fn insert_following( &mut self, key: (String, i64), value: T, times: FramePair, ) -> Result<Option<u64>, WorkingSetOverBudget>

Stores the frame after the one at key, with both frames’ presentation times, and returns its new generation; None, storing nothing, when key holds no frame. The frame is pinned with its key and dropped when the key’s frame is replaced or dropped.

§Errors

Refuses a frame at a pinned key that would push the working set over budget, keeping the store unchanged.

Source

pub fn alias_following( &mut self, existing: (&(String, i64), KeptFrame), requested: (String, i64), times: FramePair, ) -> Result<bool, WorkingSetOverBudget>

Makes the frame after the one at requested the frame existing holds as kept, sharing its generation and bytes. Returns false, changing nothing, when either key holds no such frame.

§Errors

Refuses a frame at a pinned key that would push the working set over budget, keeping the store unchanged.

Source

pub fn set_last(&mut self, key: (String, i64)) -> bool

Records that no frame follows the one at key: it is its source’s last, or the host cannot name the next. Returns false, changing nothing, when key holds no frame.

Source

pub fn follows(&self, source: &str, time: i64) -> bool

Whether key holds the frame after its own, or the record that there is none.

Source

pub fn kept_at( &self, source: &str, pts: i64, ) -> Option<((String, i64), KeptFrame)>

A key of source that keeps the frame presented at pts ticks and which of its two frames that is. Only keys holding the frame after their own are looked at.

Source

pub fn alias_kept( &mut self, existing: (&(String, i64), KeptFrame), requested: (String, i64), ) -> Result<bool, WorkingSetOverBudget>

Makes requested answer with the frame existing holds as kept, as Self::alias does for a presented frame.

§Errors

As Self::alias.

Source

pub fn alias( &mut self, existing: &(String, i64), requested: (String, i64), ) -> Result<bool, WorkingSetOverBudget>

Makes requested answer with the frame at existing, sharing its generation and bytes. Returns false when existing holds no frame.

§Errors

Refuses an alias into a pinned key that would push the working set over budget, keeping the store unchanged.

Source

pub fn insert_image( &mut self, source: String, value: T, ) -> Result<u64, WorkingSetOverBudget>

Stores source’s time-independent image and returns its new generation; the image answers every time with no exact frame.

§Errors

Refuses a pinned source’s image that would push the working set over budget, keeping the store unchanged.

Source

pub fn holds_image(&self, source: &str, generation: u64) -> bool

Whether source’s image is still the upload generation names. The store evicts images on its own, so a host checks before relying on an earlier upload.

Source

pub fn get(&self, source: &str, time: i64) -> Option<&T>

The frame stored at source and time, else the source’s image.

Source

pub fn generation(&self, source: &str, time: i64) -> Option<u64>

The upload generation get would answer from. A store never reuses generations.

Source

pub fn remove(&mut self, source: &str, time: i64) -> bool

Drops the frame at source and time; returns whether there was one.

Source

pub fn len(&self) -> usize

Generations held, retired ones included.

Source

pub fn is_empty(&self) -> bool

Whether nothing is held.

Source

pub fn retired_len(&self) -> usize

Retired entries held for release.

Source

pub fn retained_bytes(&self, bytes: impl Fn(&T) -> u64) -> u64

Bytes every generation holds, measured by bytes, each counted once.

Source

pub fn release_generation(&mut self, generation: u64) -> bool

Drops every frame, alias, image, and retired entry of generation. Returns whether anything was dropped.

Source

pub fn clear(&mut self)

Drops everything.

Source

pub fn retain_values(&mut self, keep: impl Fn(&T) -> bool)

Invalidates derived values everywhere, including aliases and retirees.

Source

pub fn retain_entries(&mut self, keep: impl Fn(&str, &T) -> bool)

Keeps only the frames and images keep accepts, given their source. Retired entries stay.

Source

pub fn retain_sources(&mut self, keep: impl Fn(&str) -> bool)

Keeps only the frames and images of sources keep accepts. Retired entries stay until released or evicted.

Source

pub fn release_source(&mut self, source: &str) -> bool

Drops one source’s frames and image after its media changed. Retired entries stay until released.

Source

pub fn trim_before(&mut self, source: &str, before: i64)

Drops source’s frames before before, a time on that source’s own timeline.

Trait Implementations§

Source§

impl<T> Default for FrameStore<T>

Source§

fn default() -> Self

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

impl<T: StoredFrame> FrameProvider for FrameStore<T>

Source§

fn source_key( &self, source: &SourceId, time: MediaTime, ) -> Option<RenderCacheKey>

Keyed by source and upload generation, since an upload’s picture never changes.

Source§

fn texture_for( &self, source: &SourceId, time: MediaTime, ) -> Option<SourceView<'_>>

Returns a texture for source at the requested source timestamp. Read more
Source§

fn following_for(&self, source: &SourceId, time: MediaTime) -> Following<'_>

Returns the frame after the one Self::texture_for presents at time, for a clip or media node that mixes the two. Asked only once that frame is there. With the default (Following::Last) the presented frame is drawn alone.
Source§

fn pending_source_work( &self, source: &SourceId, time: MediaTime, ) -> Option<&PendingSourceWork>

Returns presentation work that has not yet been submitted for this physical source texture. The default covers already-ready textures.
Source§

fn text(&self, _key: u64) -> Option<TextTexture<'_>>

Returns the prepared text crate::text_key names. With the default (none), a frame showing text fails with RenderError::MissingText.
Source§

fn layout(&self, _key: u128) -> Option<Arc<PreparedLayout>>

Returns the prepared layout crate::layout_key names. With the default (none), a frame showing a layout fails with RenderError::MissingText.

Auto Trait Implementations§

§

impl<T> Forget for FrameStore<T>

§

impl<T> Freeze for FrameStore<T>
where *const u8 is !null: Freeze, PhantomData<((String, i64), Entry<T>)>: Freeze, PhantomData<((String, i64), Followed<T>)>: Freeze, PhantomData<(String, Entry<T>)>: Freeze, PhantomData<(u64, Entry<T>)>: Freeze, PhantomData<((String, i64), ())>: Freeze,

§

impl<T> Move for FrameStore<T>

§

impl<T> RefUnwindSafe for FrameStore<T>

§

impl<T> Send for FrameStore<T>
where RawTable<((String, i64), Entry<T>)>: Send, RawTable<((String, i64), Followed<T>)>: Send, RawTable<(String, Entry<T>)>: Send, RawTable<(u64, Entry<T>)>: Send, RawTable<((String, i64), ())>: Send,

§

impl<T> Sync for FrameStore<T>
where RawTable<((String, i64), Entry<T>)>: Sync, RawTable<((String, i64), Followed<T>)>: Sync, RawTable<(String, Entry<T>)>: Sync, RawTable<(u64, Entry<T>)>: Sync, RawTable<((String, i64), ())>: Sync,

§

impl<T> Unpin for FrameStore<T>
where *const u8 is !null: Unpin, Arc<T>: Unpin,

§

impl<T> UnsafeUnpin for FrameStore<T>
where *const u8 is !null: UnsafeUnpin, PhantomData<((String, i64), Entry<T>)>: UnsafeUnpin, PhantomData<((String, i64), Followed<T>)>: UnsafeUnpin, PhantomData<(String, Entry<T>)>: UnsafeUnpin, PhantomData<(u64, Entry<T>)>: UnsafeUnpin, PhantomData<((String, i64), ())>: UnsafeUnpin,

§

impl<T> UnwindSafe for FrameStore<T>
where HashMap<(String, i64), Entry<T>>: UnwindSafe, HashMap<(String, i64), Followed<T>>: UnwindSafe, HashMap<String, Entry<T>>: UnwindSafe, HashMap<u64, Entry<T>>: UnwindSafe, NonNull<u8>: UnwindSafe, RawVecInner: UnwindSafe,

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<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,