mirror of
https://github.com/storytold/deckcraft.git
synced 2026-10-24 18:46:57 -06:00
- crates/media: probe (duration, rate/channels, size/fps; WMA/WMV recognised), audio decode to f32 PCM (MP3, AAC M4A/ADTS, ALAC, WAV, AIFF, CAF, FLAC, Vorbis via symphonia; Opus with our decoder in Ogg/WebM/MKV), video decode (MP4/MOV/WebM/MKV) with YUV->RGBA, poster frames, trim/fade/volume, Player mixer + per-voice clock (device-clocked or wall-clocked), VideoFeed. - Codec crates ported from FilmCraft: bitstream, h264, hevc, vp9, av1, isobmff, matroska, ogg, opus. - insert.audio/insert.video probe and store duration/size and a poster frame; unplayable media is embedded with a warning. New media.play/pause/toggle/stop/seek/info/posterFrame. - UI: MediaHost (cpal output injected by the desktop app), control bar under media, video frames on canvas and in the show; autoplay, click to play, loop, rewind, across slides, hide, full screen. - Tests with in-code WAV/AIFF and CC0 self-generated fixtures (make.sh, ATTRIBUTION.md rows). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
54 lines
1.6 KiB
Rust
54 lines
1.6 KiB
Rust
use std::fmt;
|
|
use std::io;
|
|
|
|
/// Errors produced by the demuxer.
|
|
#[derive(Debug)]
|
|
pub enum Error {
|
|
/// Underlying I/O failure.
|
|
Io(io::Error),
|
|
/// Structurally invalid data that could not be recovered from.
|
|
Invalid(String),
|
|
/// Valid but unsupported feature (e.g. zlib-compressed or encrypted tracks when reading data).
|
|
Unsupported(String),
|
|
/// Not an EBML file, or an EBML file whose DocType is not `matroska`/`webm`.
|
|
NotMatroska(String),
|
|
/// A track index was out of range.
|
|
NoSuchTrack(usize),
|
|
/// A sample index was out of range.
|
|
NoSuchSample(usize),
|
|
}
|
|
|
|
impl fmt::Display for Error {
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
match self {
|
|
Error::Io(e) => write!(f, "I/O error: {e}"),
|
|
Error::Invalid(s) => write!(f, "invalid data: {s}"),
|
|
Error::Unsupported(s) => write!(f, "unsupported: {s}"),
|
|
Error::NotMatroska(s) => write!(f, "not a Matroska/WebM file: {s}"),
|
|
Error::NoSuchTrack(i) => write!(f, "track index {i} out of range"),
|
|
Error::NoSuchSample(i) => write!(f, "sample index {i} out of range"),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl std::error::Error for Error {
|
|
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
|
|
match self {
|
|
Error::Io(e) => Some(e),
|
|
_ => None,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl From<io::Error> for Error {
|
|
fn from(e: io::Error) -> Self {
|
|
Error::Io(e)
|
|
}
|
|
}
|
|
|
|
pub type Result<T> = std::result::Result<T, Error>;
|
|
|
|
pub(crate) fn invalid<T>(msg: impl Into<String>) -> Result<T> {
|
|
Err(Error::Invalid(msg.into()))
|
|
}
|