pub struct FrameStore<T> { /* private fields */ }Expand description
Timestamped video frames and explicitly registered, time-independent images.
Implementations§
Source§impl<T> FrameStore<T>
impl<T> FrameStore<T>
Sourcepub fn sized(size: fn(&T) -> u64, video_byte_budget: u64) -> Self
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).
Sourcepub fn set_video_byte_budget(&mut self, bytes: u64)
pub fn set_video_byte_budget(&mut self, bytes: u64)
Changes the byte budget, evicting oldest generations at once to fit.
Sourcepub fn pin(&mut self, keys: impl IntoIterator<Item = (String, i64)>)
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.
Sourcepub const fn last_working_set_bytes(&self) -> u64
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.
Sourcepub fn insert(
&mut self,
key: (String, i64),
value: T,
) -> Result<u64, WorkingSetOverBudget>
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.
Sourcepub fn insert_following(
&mut self,
key: (String, i64),
value: T,
times: FramePair,
) -> Result<Option<u64>, WorkingSetOverBudget>
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.
Sourcepub fn alias_following(
&mut self,
existing: (&(String, i64), KeptFrame),
requested: (String, i64),
times: FramePair,
) -> Result<bool, WorkingSetOverBudget>
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.
Sourcepub fn set_last(&mut self, key: (String, i64)) -> bool
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.
Sourcepub fn follows(&self, source: &str, time: i64) -> bool
pub fn follows(&self, source: &str, time: i64) -> bool
Whether key holds the frame after its own, or the record that there is none.
Sourcepub fn kept_at(
&self,
source: &str,
pts: i64,
) -> Option<((String, i64), KeptFrame)>
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.
Sourcepub fn alias_kept(
&mut self,
existing: (&(String, i64), KeptFrame),
requested: (String, i64),
) -> Result<bool, WorkingSetOverBudget>
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.
Sourcepub fn alias(
&mut self,
existing: &(String, i64),
requested: (String, i64),
) -> Result<bool, WorkingSetOverBudget>
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.
Sourcepub fn insert_image(
&mut self,
source: String,
value: T,
) -> Result<u64, WorkingSetOverBudget>
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.
Sourcepub fn holds_image(&self, source: &str, generation: u64) -> bool
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.
Sourcepub fn get(&self, source: &str, time: i64) -> Option<&T>
pub fn get(&self, source: &str, time: i64) -> Option<&T>
The frame stored at source and time, else the source’s image.
Sourcepub fn generation(&self, source: &str, time: i64) -> Option<u64>
pub fn generation(&self, source: &str, time: i64) -> Option<u64>
The upload generation get would answer from. A store never reuses generations.
Sourcepub fn remove(&mut self, source: &str, time: i64) -> bool
pub fn remove(&mut self, source: &str, time: i64) -> bool
Drops the frame at source and time; returns whether there was one.
Sourcepub fn retired_len(&self) -> usize
pub fn retired_len(&self) -> usize
Retired entries held for release.
Sourcepub fn retained_bytes(&self, bytes: impl Fn(&T) -> u64) -> u64
pub fn retained_bytes(&self, bytes: impl Fn(&T) -> u64) -> u64
Bytes every generation holds, measured by bytes, each counted once.
Sourcepub fn release_generation(&mut self, generation: u64) -> bool
pub fn release_generation(&mut self, generation: u64) -> bool
Drops every frame, alias, image, and retired entry of generation. Returns whether
anything was dropped.
Sourcepub fn retain_values(&mut self, keep: impl Fn(&T) -> bool)
pub fn retain_values(&mut self, keep: impl Fn(&T) -> bool)
Invalidates derived values everywhere, including aliases and retirees.
Sourcepub fn retain_entries(&mut self, keep: impl Fn(&str, &T) -> bool)
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.
Sourcepub fn retain_sources(&mut self, keep: impl Fn(&str) -> bool)
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.
Sourcepub fn release_source(&mut self, source: &str) -> bool
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.
Sourcepub fn trim_before(&mut self, source: &str, before: i64)
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>
impl<T> Default for FrameStore<T>
Source§impl<T: StoredFrame> FrameProvider for FrameStore<T>
impl<T: StoredFrame> FrameProvider for FrameStore<T>
Source§fn source_key(
&self,
source: &SourceId,
time: MediaTime,
) -> Option<RenderCacheKey>
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<'_>>
fn texture_for( &self, source: &SourceId, time: MediaTime, ) -> Option<SourceView<'_>>
source at the requested source timestamp. Read moreSource§fn following_for(&self, source: &SourceId, time: MediaTime) -> Following<'_>
fn following_for(&self, source: &SourceId, time: MediaTime) -> Following<'_>
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>
fn pending_source_work( &self, source: &SourceId, time: MediaTime, ) -> Option<&PendingSourceWork>
Source§fn text(&self, _key: u64) -> Option<TextTexture<'_>>
fn text(&self, _key: u64) -> Option<TextTexture<'_>>
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>>
fn layout(&self, _key: u128) -> Option<Arc<PreparedLayout>>
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>
impl<T> Sync for FrameStore<T>
impl<T> Unpin for FrameStore<T>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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