oximedia_core/lib.rs
1//! Core types and traits for `OxiMedia`.
2//!
3//! `oximedia-core` provides the foundational types and traits used throughout
4//! the `OxiMedia` multimedia framework. This includes:
5//!
6//! - **Types**: Rational numbers, timestamps, pixel/sample formats, codec IDs
7//! - **Traits**: Decoder and demuxer interfaces
8//! - **Error handling**: Unified error type with patent violation detection
9//! - **Memory management**: Buffer pools for zero-copy operations
10//! - **HDR support**: HDR metadata, transfer functions, color primaries, and conversions
11//!
12//! # Green List Only
13//!
14//! `OxiMedia` only supports patent-free codecs:
15//!
16//! | Video | Audio | Subtitle |
17//! |-------|-------|----------|
18//! | AV1 | Opus | `WebVTT` |
19//! | VP9 | Vorbis| ASS/SSA |
20//! | VP8 | FLAC | SRT |
21//! | Theora| PCM | |
22//!
23//! Attempting to use patent-encumbered codecs (H.264, H.265, AAC, etc.)
24//! will result in a [`PatentViolation`](error::OxiError::PatentViolation) error.
25//!
26//! # Example
27//!
28//! ```
29//! use oximedia_core::types::{Rational, Timestamp, PixelFormat, CodecId};
30//! use oximedia_core::error::OxiResult;
31//!
32//! fn example() -> OxiResult<()> {
33//! // Create a timestamp at 1 second with millisecond precision
34//! let ts = Timestamp::new(1000, Rational::new(1, 1000));
35//! assert!((ts.to_seconds() - 1.0).abs() < f64::EPSILON);
36//!
37//! // Check codec properties
38//! let codec = CodecId::Av1;
39//! assert!(codec.is_video());
40//!
41//! // Check pixel format properties
42//! let format = PixelFormat::Yuv420p;
43//! assert!(format.is_planar());
44//! assert_eq!(format.plane_count(), 3);
45//!
46//! Ok(())
47//! }
48//! ```
49
50#![warn(missing_docs)]
51
52pub mod alloc;
53pub mod bitrate;
54pub mod buffer_pool;
55pub mod channel_layout;
56pub mod codec_info;
57pub mod codec_matrix;
58pub mod codec_negotiation;
59pub mod codec_params;
60pub mod color_metadata;
61pub mod convert;
62pub mod downmix;
63pub mod error;
64pub mod error_context;
65pub mod event_queue;
66pub mod event_stream;
67pub mod fourcc;
68pub mod frame_info;
69pub mod frame_pool;
70pub mod frame_sharing;
71pub mod hdr;
72pub mod media_clock;
73pub mod media_props;
74pub mod media_segment;
75pub mod media_time;
76pub mod memory;
77pub mod pixel_format;
78pub mod pixel_format_color;
79pub mod rational;
80pub mod resource_handle;
81pub mod ring_buffer;
82pub mod sample_conv;
83pub mod sample_format;
84pub mod sync;
85pub mod timestamp_arith;
86pub mod traits;
87pub mod type_registry;
88pub mod types;
89pub mod version;
90pub mod work_queue;
91pub mod work_steal;
92
93#[cfg(target_arch = "wasm32")]
94pub mod wasm;
95
96// Re-export commonly used items at crate root
97pub use error::{OxiError, OxiResult};
98pub use types::{CodecId, MediaType, PixelFormat, Rational, SampleFormat, Timestamp};
99
100/// Initialises the OxiMedia WASM module.
101///
102/// Sets up panic hooks for better error messages in the browser console.
103/// Called from `oximedia-wasm` init function.
104#[cfg(all(target_arch = "wasm32", feature = "wasm"))]
105pub fn wasm_init() {
106 console_error_panic_hook::set_once();
107}