Skip to main content

oxideav_mpegts/
error.rs

1//! Error type for the demuxer surface.
2
3use thiserror::Error;
4
5/// Errors raised by the MPEG-TS parsers.
6#[derive(Debug, Error)]
7pub enum TsError {
8    /// The slice handed to a parser is shorter than the spec-fixed
9    /// record size.
10    #[error("truncated: {what} (have {have} bytes, need {need})")]
11    Truncated {
12        what: &'static str,
13        have: usize,
14        need: usize,
15    },
16    /// A 188-byte TS packet's first byte is not the spec-defined sync
17    /// byte (`0x47`).
18    #[error("bad TS sync byte: 0x{0:02X} (want 0x47)")]
19    BadSyncByte(u8),
20    /// A PSI section header reported a length that exceeds the data
21    /// the caller supplied.
22    #[error("PSI section length {claimed} > available {have}")]
23    SectionLengthOverrun { claimed: usize, have: usize },
24    /// A PSI section's CRC-32/MPEG-2 trailer didn't match the body.
25    #[error("PSI CRC mismatch: header CRC=0x{header:08X} computed=0x{computed:08X}")]
26    PsiCrcMismatch { header: u32, computed: u32 },
27    /// PES packet start code was not `00 00 01`.
28    #[error("bad PES start code: {0:02X?}")]
29    BadPesStartCode([u8; 3]),
30    /// Catch-all for spec-permitted but currently unsupported values
31    /// (e.g. a TS_program_map_section variant we haven't wired).
32    #[error("{0}")]
33    Unsupported(&'static str),
34}