forge
Explore
Log in

Don't you dare go Hollow

edith

Clone
★ 0

0 watching0 forksRust18.3 MiBa2ebaacTahinli3 months ago107 commits

lib.rs79 lines, 2.5 KiBHistoryRawDownload
1//! Video engine: demux -> decode -> pixel convert. No UI dependencies.
2
3pub mod ao;
4pub mod audio;
5pub mod clock;
6pub mod color;
7pub mod convert;
8pub mod decode;
9pub mod demux;
10pub mod edith;
11pub mod eq;
12pub mod export;
13pub mod hw;
14pub mod mux;
15pub mod playback;
16pub mod project;
17pub mod scale;
18pub mod waveform;
19
20pub use audio::{
21 AacPacket, AacTrackParams, AudioChunk, AudioMeta, AudioProbe, AudioSession, StreamInfo,
22};
23pub use clock::PlaybackClock;
24pub use decode::{DecodeSession, Frame};
25pub use demux::{Codec, VideoMeta};
26pub use export::ExportHandle;
27pub use mux::{AudioParams, Mp4Muxer, VideoParams};
28pub use playback::PlaybackSession;
29pub use project::{Clip, Project};
30
31/// Whether a path names a standalone audio file -- a source with no picture,
32/// which belongs on the audio lane and nowhere else. Extension only, lowercased:
33/// the decoder is what really decides, but a front-end has to know which lane a
34/// dropped file may land on *before* anything is opened, and so does
35/// [`PlaybackSession::import`](playback::PlaybackSession::import).
36///
37/// Exactly the containers the engine's audio path reads (`audio::AudioSession`):
38/// no opus, ac3 or dts, for which no pure-Rust decoder exists -- those are
39/// refused by the same door that refuses a `.txt`, which is the honest answer.
40pub fn is_audio(path: &std::path::Path) -> bool {
41 path.extension().and_then(|e| e.to_str()).is_some_and(|e| {
42 matches!(
43 e.to_ascii_lowercase().as_str(),
44 "mp3" | "wav" | "flac" | "ogg" | "oga" | "m4a" | "aac"
45 )
46 })
47}
48
49/// Boxed error; the engine has few failure modes and every one of them is fatal
50/// to the session, so a message is all a caller can act on.
51pub type Error = Box<dyn std::error::Error + Send + Sync>;
52pub type Result<T> = std::result::Result<T, Error>;
53
54#[cfg(test)]
55mod tests {
56 use std::path::Path;
57
58 #[test]
59 fn is_audio_admits_the_containers_the_decoder_reads() {
60 for name in [
61 "song.mp3", "a.WAV", "b.flac", "c.ogg", "d.oga", "e.m4a", "f.aac",
62 ] {
63 assert!(super::is_audio(Path::new(name)), "{name}");
64 }
65 // Video, projects, the formats with no pure-Rust decoder, and a file
66 // with no extension at all: all of them go elsewhere.
67 for name in [
68 "clip.mp4",
69 "take.MP4",
70 "cut.edith",
71 "x.opus",
72 "y.ac3",
73 "notes",
74 "mp3",
75 ] {
76 assert!(!super::is_audio(Path::new(name)), "{name}");
77 }
78 }
79}