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 the lifetime of their textures, and lend them as SourceViews. The pure model and evaluator crates never observe this platform-specific type. Textures must store 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 texture is the frame presented at time: the one whose presentation interval contains it, the last frame whose timestamp is at or before time plus the stream’s presentation slack, as alpha2_media::Decoder::seek resolves a time. Before the stream’s first frame that frame is shown; past the last, the last. A host that looks frames up by the requested time stores each under every time it was asked for.

None means the frame has not arrived yet; real-time runners may hold their previous output while deterministic 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: the host’s promise that the texture’s pixels depend on nothing the key leaves out: the source’s content, the frame, and how it was decoded, converted, and presented. Pictures drawn from keyed sources can be kept and reused (see alpha2_render::Renderer::set_result_cache_budget); the default, no key, keeps nothing drawn from the source.

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 text crate::text_key names, a caption or a text generator prepared by the host’s crate::TextTextures. The default holds none: a frame that shows text then fails with RenderError::MissingText.

Source

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

Returns the layout crate::layout_key names, resolved and drawn by the host’s crate::TextTextures, whose texts Self::text lends. The default holds none: a frame that shows a layout then fails with RenderError::MissingText.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§