pub enum RenderSource {
Image(DecodedImageData),
Wav(WavData),
TestPattern,
Unsupported {
path: PathBuf,
},
}Expand description
A resolved and decoded media source used by the render pipeline.
Cheaply cloneable via Arc.
Variants§
Image(DecodedImageData)
A decoded still image (PNG or JPEG) in RGBA8.
Wav(WavData)
Decoded WAV audio.
TestPattern
Deterministic test pattern (SMPTE colour bars / 1 kHz sine).
Unsupported
Source file exists but its format is not supported.
Implementations§
Source§impl RenderSource
impl RenderSource
Sourcepub fn from_path(path: &Path) -> EditResult<Arc<Self>>
pub fn from_path(path: &Path) -> EditResult<Arc<Self>>
Resolve a file-system path to a RenderSource.
Recognised extensions (case-insensitive): .png, .jpg/.jpeg,
.wav. Everything else becomes RenderSource::Unsupported.
Returns an Arc so callers can share the decoded data cheaply.
Sourcepub fn sample_video(&self, _source_pts: i64, width: u32, height: u32) -> Vec<u8> ⓘ
pub fn sample_video(&self, _source_pts: i64, width: u32, height: u32) -> Vec<u8> ⓘ
Produce an RGBA8 video frame of size width × height at source_pts.
- For
RenderSource::Imagethe image is scaled (nearest-neighbour) to fill the requested dimensions. - For
RenderSource::TestPatterna deterministic SMPTE colour bar pattern is generated. - All other variants return a black frame.
The returned buffer is width * height * 4 bytes.
Sourcepub fn sample_audio(
&self,
source_pts: i64,
num_samples: usize,
channels: u16,
sample_rate: u32,
) -> Vec<f32>
pub fn sample_audio( &self, source_pts: i64, num_samples: usize, channels: u16, sample_rate: u32, ) -> Vec<f32>
Produce interleaved f32 audio samples for num_samples stereo frames
starting at source_pts.
- For
RenderSource::Wavthe decoded samples are sliced/zero-padded at the requested offset. Channel count mismatches are handled by up-mixing mono→stereo or truncating to the requested channel count. - For
RenderSource::TestPatterna 1 kHz sine wave is generated. - All other variants return silence.
num_samples is per-channel frame count. The returned buffer has
num_samples * channels elements.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RenderSource
impl RefUnwindSafe for RenderSource
impl Send for RenderSource
impl Sync for RenderSource
impl Unpin for RenderSource
impl UnsafeUnpin for RenderSource
impl UnwindSafe for RenderSource
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