pub struct Exporter { /* private fields */ }Expand description
Deterministic, retryable frame-sequence runner.
Implementations§
Source§impl Exporter
impl Exporter
Sourcepub const MISSING_FRAME_POLICY: MissingFramePolicy = MissingFramePolicy::Wait
pub const MISSING_FRAME_POLICY: MissingFramePolicy = MissingFramePolicy::Wait
The only policy an export can apply.
Export output must not depend on decode timing: a pipelined export and
a synchronous one are required to be byte-identical, which
scripts/test-host-cli-parity.mjs asserts. Repeating the previous
frame when a source is late would make the result a function of how
fast the host decoded, so this is a constant rather than a setting.
Player configures the same policy because a dropped real-time frame
has no such guarantee to break.
Sourcepub fn new(
snapshot: &EngineProject,
range: TimeRange,
frame_rate: FrameRate,
quality: QualityProfile,
codec: VideoCodec,
) -> Result<Self, EngineError>
pub fn new( snapshot: &EngineProject, range: TimeRange, frame_rate: FrameRate, quality: QualityProfile, codec: VideoCodec, ) -> Result<Self, EngineError>
Creates an exporter for frame intervals intersecting a half-open timeline range.
Everything an export can be refused for is refused here, before a
host opens an encoder: the output 4:2:0 frames are the project size at
quality, and they must be even in both dimensions. They are packed
for codec: YuvEncoding::export. Every later step takes this
snapshot (or a clone of it) and refuses any other with
EngineError::ExportProjectChanged, so an export renders one
project, at the size checked here.
§Errors
Returns an error for an empty range, invalid quality, timeline overflow,
or EngineError::OddExportDimensions.
Sourcepub const fn encoding(&self) -> YuvEncoding
pub const fn encoding(&self) -> YuvEncoding
How this export’s frames are packed into 4:2:0 YUV.
Sourcepub const fn effective_range(&self) -> TimeRange
pub const fn effective_range(&self) -> TimeRange
The timeline range this export covers: the requested range widened to
the frame grid, [floor(start), ceil(end)).
A video export renders whole frames, so its first frame can start up to one frame before the requested start. That frame’s start is the output’s zero, and a host places audio, and reports the export, from this range rather than from the request.
Sourcepub fn audio_window(
&self,
sample_rate: u32,
) -> Result<ExportAudioWindow, EngineError>
pub fn audio_window( &self, sample_rate: u32, ) -> Result<ExportAudioWindow, EngineError>
The samples this export’s audio covers at sample_rate: the
export_audio_window of Self::effective_range.
§Errors
Returns EngineError::OutOfRange when the range does not fit in
memory-addressable samples.
Sourcepub fn for_project(
project: &EngineProject,
quality: QualityProfile,
codec: VideoCodec,
) -> Result<Self, EngineError>
pub fn for_project( project: &EngineProject, quality: QualityProfile, codec: VideoCodec, ) -> Result<Self, EngineError>
Creates an exporter spanning everything a project shows, its clips
and caption cues (EngineProject::timeline_range), packed for
codec.
§Errors
Returns an error for an empty project or invalid schedule.
Sourcepub const fn missing_frame_policy(&self) -> MissingFramePolicy
pub const fn missing_frame_policy(&self) -> MissingFramePolicy
Returns the policy used when source frames are unavailable.
Sourcepub const fn progress(&self) -> ExportProgress
pub const fn progress(&self) -> ExportProgress
Returns current deterministic export progress.
Sourcepub fn render_size(
&self,
project: &EngineProject,
) -> Result<RenderSize, EngineError>
pub fn render_size( &self, project: &EngineProject, ) -> Result<RenderSize, EngineError>
The size frames of project render at: where a host prepares their
captions.
§Errors
Returns an error when the quality profile cannot size the project.
Sourcepub fn pending_time(&self) -> Option<MediaTime>
pub fn pending_time(&self) -> Option<MediaTime>
Returns the pending frame timestamp, or None after completion.
Sourcepub fn take_next(&mut self) -> Result<Option<(u64, MediaTime)>, EngineError>
pub fn take_next(&mut self) -> Result<Option<(u64, MediaTime)>, EngineError>
Takes the pending frame as supplied from elsewhere (a copy baked by
an earlier export of the same snapshot) and advances the cursor
exactly as a render does. Returns its index and time, or None after
completion.
§Errors
Returns EngineError::OutOfRange if the cursor would overflow.
Sourcepub const fn frame_rate(&self) -> FrameRate
pub const fn frame_rate(&self) -> FrameRate
The frame grid the export renders on.
Sourcepub fn upcoming_times(&self, frames: u32) -> Result<Vec<MediaTime>, EngineError>
pub fn upcoming_times(&self, frames: u32) -> Result<Vec<MediaTime>, EngineError>
The times of the pending frame and up to frames - 1 after it, in
order, as Self::take_next and the renders after it will reach
them: fewer near the end of the range, none after completion. The
cursor is not changed, and frames is clamped as in
Self::prefetch_needs.
§Errors
Returns EngineError::OutOfRange if a time overflows.
Sourcepub fn prefetch_needs(
&self,
project: &EngineProject,
frames: u32,
) -> Result<Vec<ExportFrameNeeds>, EngineError>
pub fn prefetch_needs( &self, project: &EngineProject, frames: u32, ) -> Result<Vec<ExportFrameNeeds>, EngineError>
Returns decode requirements for the pending frame and bounded lookahead.
The exporter cursor is not changed. frames is the total number of
scheduled frames requested, including the current frame, and is clamped
to 120 to keep one request bounded.
§Errors
Returns evaluation or timeline overflow errors, and
EngineError::ExportProjectChanged for another snapshot.
Sourcepub fn render_next(
&mut self,
project: &EngineProject,
renderer: &Renderer,
frames: &dyn FrameProvider,
) -> Result<ExportStep, EngineError>
pub fn render_next( &mut self, project: &EngineProject, renderer: &Renderer, frames: &dyn FrameProvider, ) -> Result<ExportStep, EngineError>
Attempts one frame without blocking on host decode.
Waiting does not change progress. A successful render advances the exact rational frame cursor once, so retries cannot skip timestamps.
§Errors
Returns timeline evaluation, quality, or rendering failures, and
EngineError::ExportProjectChanged for another snapshot.
Sourcepub fn render_next_timed(
&mut self,
project: &EngineProject,
renderer: &Renderer,
frames: &dyn FrameProvider,
timings: &mut ExportStepTimings,
) -> Result<ExportStep, EngineError>
pub fn render_next_timed( &mut self, project: &EngineProject, renderer: &Renderer, frames: &dyn FrameProvider, timings: &mut ExportStepTimings, ) -> Result<ExportStep, EngineError>
Attempts one frame and reports where the step spent its time.
This renders exactly what Exporter::render_next renders. A step
that only waits leaves timings holding the stages that ran.
§Errors
Returns timeline evaluation, quality, or rendering failures, and
EngineError::ExportProjectChanged for another snapshot.
Sourcepub fn render_next_texture(
&mut self,
project: &EngineProject,
renderer: &Renderer,
frames: &dyn FrameProvider,
) -> Result<ExportTextureStep, EngineError>
pub fn render_next_texture( &mut self, project: &EngineProject, renderer: &Renderer, frames: &dyn FrameProvider, ) -> Result<ExportTextureStep, EngineError>
Renders the next frame and hands its texture over, with no readback and no pack: for a host that moves the picture on by other means, such as presenting it to a canvas an encoder captures.
The cursor advances exactly as it does for Self::render_next.
§Errors
Returns an engine error when evaluation or rendering fails, and
EngineError::ExportProjectChanged for another snapshot.