1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
//! I/O layer for the OxiMedia multimedia framework.
//!
//! `oximedia-io` provides the full I/O stack used by OxiMedia's demuxers,
//! muxers, and codec pipeline: async media sources, magic-byte format
//! detection, bit-level reading, checksumming, buffered and memory-mapped
//! file I/O, and composable I/O pipeline stages.
//!
//! # Format detection
//!
//! [`format_detector::FormatDetector`] identifies over 45 media formats by
//! inspecting the leading bytes of a buffer (magic numbers). Detected
//! categories include video containers (MP4, MKV, AVI, MOV, WebM, MXF, Ogg,
//! TS, M2TS, FLV), audio formats (FLAC, WAV, MP3, AAC, Opus, Vorbis, AIFF,
//! AU, CAF), still-image formats (JPEG, PNG, GIF, WebP, BMP, TIFF, HEIC,
//! AVIF, DPX, EXR, DNG, JPEG-XL), subtitle formats (SRT, VTT, ASS), and
//! archive formats (ZIP, TAR, GZ, BZ2, XZ, Zstandard).
//!
//! ```
//! use oximedia_io::format_detector::FormatDetector;
//!
//! let mp4_header = b"\x00\x00\x00\x1cftyp";
//! let result = FormatDetector::detect(mp4_header);
//! println!("format: {:?}", result.format);
//! println!("mime: {}", result.mime_type);
//! ```
//!
//! # Media sources
//!
//! The [`source`] module provides the [`MediaSource`] async trait along with
//! two built-in implementations:
//!
//! - [`FileSource`] — Tokio async file reader (non-WASM targets only)
//! - [`MemorySource`] — zero-copy in-memory reader backed by `bytes::Bytes`
//!
//! ```no_run
//! use oximedia_io::source::{FileSource, MediaSource};
//!
//! #[tokio::main]
//! async fn main() -> oximedia_core::OxiResult<()> {
//! let mut source = FileSource::open("video.webm").await?;
//! let mut buf = [0u8; 4096];
//! let n = source.read(&mut buf).await?;
//! println!("read {n} bytes");
//! Ok(())
//! }
//! ```
//!
//! # Bit-level reading
//!
//! [`BitReader`] (re-exported from the [`bits`] module) reads individual bits
//! and multi-bit values from a byte slice in MSB-first order — the standard
//! ordering used by H.264, HEVC, AV1, VP9, and most other video codecs.
//! Exp-Golomb coded integers (unsigned `ue(v)` and signed `se(v)`) are
//! supported via [`bits::BitReader::read_exp_golomb`] /
//! [`bits::BitReader::read_signed_exp_golomb`].
//!
//! ```
//! use oximedia_io::bits::BitReader;
//!
//! // Parse a tiny AVC-style bitfield: profile_idc (8) | constraint byte (6 flags + 2 reserved) | level_idc (8)
//! let sps_bytes = [0x64u8, 0x00, 0x1f];
//! let mut r = BitReader::new(&sps_bytes);
//! let profile_idc = r.read_bits(8).unwrap(); // 100 — High Profile
//! let _constraint = r.read_bits(8).unwrap(); // constraint_set0..5_flag + reserved_zero_2bits
//! let level_idc = r.read_bits(8).unwrap(); // 31 — Level 3.1
//! assert_eq!(profile_idc, 100);
//! assert_eq!(level_idc, 31);
//! ```
//!
//! # MXF probing
//!
//! [`mxf_probe`] provides a lightweight parser for MXF (Material Exchange
//! Format) containers. It detects the Header Partition Pack, identifies the
//! SMPTE Operational Pattern (OP1a, OPAtom, etc.), and enumerates essence
//! tracks (video, audio, data) without parsing the full KLV body.
//!
//! # Other utilities
//!
//! | Module | Capability |
//! |--------|------------|
//! | [`aligned_io`] | Memory-aligned I/O for DMA-friendly transfers |
//! | [`async_io`] | Async I/O abstractions |
//! | [`buffer_pool`] | Pooled byte buffers to reduce allocations |
//! | [`buffered_io`] | Read-ahead buffering with configurable window |
//! | [`buffered_reader`] | Buffered synchronous reader |
//! | [`checksum`] | CRC32, CRC64, SHA-256, BLAKE3 checksums |
//! | [`chunked_writer`] | Write large outputs in fixed-size chunks |
//! | [`compression`] | Compress / decompress (zstd, LZ4, gzip, bzip2) |
//! | [`content_detect`] | Text encoding and binary-vs-text detection |
//! | [`copy_engine`] | High-throughput async file copy |
//! | [`file_metadata`] | Extended file metadata (size, timestamps) |
//! | [`file_watch`] | File system event watching |
//! | [`io_pipeline`] | Composable I/O pipeline stages |
//! | [`io_stats`] | Throughput and latency statistics |
//! | [`mmap`] | Memory-mapped zero-copy file access |
//! | [`progress_reader`] | Async reader with progress callback |
//! | [`rate_limiter`] | Bandwidth-limited I/O |
//! | [`retrying_source`] | Automatic retry on transient I/O errors |
//! | [`ring_buffer`] | Lock-free ring buffer for streaming pipelines |
//! | [`scatter_gather`] | Vectorized scatter-gather I/O |
//! | [`seekable`] | Seekable source utilities |
//! | [`splice_pipe`] | Zero-copy splice between descriptors (Linux) |
//! | [`temp_files`] | Secure temporary file management |
//! | [`verify_io`] | Read-back verification for write integrity |
//! | [`write_journal`] | Journaled writes for crash-safe I/O |
// Re-export commonly used types
pub use BitReader;
pub use FileSource;
pub use ;