Skip to main content

FrameProvider

Trait FrameProvider 

Source
pub trait FrameProvider {
    // Required method
    fn texture_for(
        &self,
        source: &SourceId,
        time: MediaTime,
    ) -> Option<SourceView<'_>>;

    // Provided methods
    fn source_key(
        &self,
        _source: &SourceId,
        _time: MediaTime,
    ) -> Option<RenderCacheKey> { ... }
    fn pending_source_work(
        &self,
        _source: &SourceId,
        _time: MediaTime,
    ) -> Option<&PendingSourceWork> { ... }
    fn text(&self, _key: u64) -> Option<TextTexture<'_>> { ... }
    fn layout(&self, _key: u128) -> Option<Arc<PreparedLayout>> { ... }
}
Expand description

Supplies decoded source frames as GPU textures to the renderer.

Implementations own decode caches and texture lifetimes and lend textures as SourceViews. Textures must hold premultiplied, sRGB-encoded RGBA in a non-sRGB GPU format, as returned by Renderer::upload_rgba8 or Renderer::render_yuv420p.

Required Methods§

Source

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

Returns a texture for source at the requested source timestamp.

The frame presented at time, resolved as alpha2_media::Decoder::seek does (last timestamp at or before time plus the presentation slack, clamped to the stream).

None means the frame has not arrived; players may hold the previous output while exporters wait and retry.

Provided Methods§

Source

fn source_key( &self, _source: &SourceId, _time: MediaTime, ) -> Option<RenderCacheKey>

A key for the texture Self::texture_for returns, promising its pixels depend on nothing outside the key (content, frame, decode and conversion). Keyed sources let drawn results be reused (alpha2_render::Renderer::set_result_cache_budget); the default None disables reuse.

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.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§