Files
craft-libs/crates/aaf/src/lib.rs
T
Dylan M. TaylorandNetterSilver 4f096b64d6 craft-aaf: AAF and OMF readers and writers over one composition model (from FilmCraft) (#918)
* craft-audio: integer PCM of WAV and AIFF files bit for bit, and minimal files around it

wav_pcm and aiff_pcm (feature decode-native) return a file's integer PCM as stored
(RawPcm: little-endian interleaved bytes, 8-bit unsigned, with channels, rate and
bits), built on the existing WAV and AIFF chunk parsers. pcm_wav_file,
pcm_wav_header, pcm_aiff_file and pcm_aiff_header (feature pcm-encode) write the
44-byte canonical WAVE header and the plain AIFF header around such bytes.

For essence embedded in AAF and OMF files, which is moved bit for bit and whose
descriptors hold a bare header as a summary. The writers are FilmCraft's
(filmcraft-interchange wav.rs); the readers replace its second WAV/AIFF parser
with this crate's.

* craft-timeline: exact media time, reports, media paths, ALE and CMX 3600 EDL

New crate for editorial timeline interchange (#782), moved from FilmCraft at
4bec22bd:

- time: filmcraft-time whole (Tick, FrameRate, TimeRange, SMPTE timecode,
  feet+frames, typed-timecode parsing) with its tests.
- report: Report / Level / ReportEntry.
- path: file URL and path conversion, relative references joined to a folder.
- rate: timebase+ntsc and floating rates to exact rates, MAX_RATE.
- ale: AleDoc, parse, write, standard heading and columns.
- edl: the parser (events, lines, timecode fields, M2, AUD, comment extensions),
  the frame-rate guess, and the line layout of the writer, on frame counts.
- Format, detect_text, decode_text.

Each format module gives the document as the format writes it. Mapping onto an
application's timeline stays in the application.

* craft-timeline: strip a UTF-8 byte order mark when parsing ALE files

An ALE saved with a BOM was refused as "not an ALE file": the mark made the
first line something other than "Heading".

Ported from storytold/filmcraft#4531.

* craft-aaf: AAF (Edit Protocol) and OMF 2.0 readers and writers over one composition model

New crate (#782), moved from FilmCraft's filmcraft-interchange at 4bec22bd:
the mob-style model types of comp.rs, aaf/{ids,store,read,write}.rs and
omf/{bento,read,write}.rs, with their structural and hostile-input tests
rebuilt on model documents instead of FilmCraft projects.

The container is craft-cfb, time and reports are craft-timeline's, and the
WAVE/AIFF wrappers of embedded PCM are craft-audio's. The writer's identity
(company, product, version, AAF product id) is passed in instead of being
FilmCraft's. The private tags and properties FilmCraft wrote keep their names
so existing files read back.

The mapping between the model and an application's project stays in the
application.

---------

Co-authored-by: NetterSilver <133535268+Silvertree2010@users.noreply.github.com>
2026-11-11 18:52:44 -05:00

61 lines
2.5 KiB
Rust

#![cfg_attr(not(test), deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable))]
//! AAF and OMF: the two mob-based editorial interchange formats, read and written through one
//! composition model.
//!
//! - [`model`]: a [`model::Document`] of compositions (tracks of fillers, source clips and
//! overlapping transitions, with clip gain and markers) and the media sources they reference,
//! with exact times ([`craft_timeline::time::Tick`]).
//! - [`aaf`]: Advanced Authoring Format, Edit Protocol, in structured storage (`craft-cfb`).
//! - [`omf`]: OMF Interchange 2.0 in a Bento container; sound only.
//!
//! Both read into and write from the same model, so an application maps its timeline onto the
//! model once. Audio essence can be embedded: the model carries it as PCM, and the WAVE / AIFF
//! wrappers the formats use are craft-audio's.
//!
//! Clean-room: written from the public specifications only (AMWA *AAF Object Specification* v1.1,
//! *AAF Low-Level Container Specification* v1.0.1, *AAF Edit Protocol* v1.0, SMPTE RP 224 / RP 210
//! labels; Avid *OMF Interchange Specification* 2.0, Apple *Bento Specification* 1.0d5). No file
//! I/O: documents are bytes and media references are strings.
//!
//! Input is untrusted: a damaged or crafted file gives an [`Error`] or a [`Report`] entry, never
//! a panic, a hang or an allocation sized by a count in the file.
pub mod aaf;
pub mod model;
pub mod omf;
mod pcm;
#[cfg(test)]
mod roundtrip_tests;
#[cfg(test)]
mod testdoc;
pub use craft_timeline::report::Report;
/// Error from a reader or writer. Unsupported *features* never error; they go in the [`Report`].
#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
pub enum Error {
/// The bytes are not a readable document of the format.
#[error("{format} parse error: {message}")]
Parse { format: &'static str, message: String },
/// The document has no composition.
#[error("the document contains no timeline")]
Empty,
/// The document could not be written.
#[error("{0}")]
Other(String),
}
pub type Result<T> = std::result::Result<T, Error>;
/// Who a written file says made it (the AAF `Identification` object, the OMF `IDNT` object).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct Identity<'a> {
pub company: &'a str,
pub product: &'a str,
/// The product's version, as text.
pub version: &'a str,
pub platform: &'a str,
/// AAF `ProductID`: an AUID naming the product.
pub product_id: [u8; 16],
}