Skip to main content

openipc_video/api/
error.rs

1use super::VideoCodec;
2
3/// Error produced while configuring or driving a video backend.
4#[derive(Debug, thiserror::Error)]
5pub enum VideoError {
6    /// Decoder options were internally inconsistent.
7    #[error("invalid decoder option: {0}")]
8    InvalidOption(&'static str),
9    /// Input did not contain a valid Annex-B NAL unit sequence.
10    #[error("invalid Annex-B access unit: {0}")]
11    InvalidAnnexB(&'static str),
12    /// A NAL unit cannot be represented by the target framing format.
13    #[error("NAL unit is too large: {0} bytes")]
14    NalUnitTooLarge(usize),
15    /// Codec configuration did not match the submitted stream.
16    #[error("decoder is configured for {configured}, but received {received}")]
17    CodecMismatch {
18        /// Active decoder codec.
19        configured: VideoCodec,
20        /// Submitted access-unit codec.
21        received: VideoCodec,
22    },
23    /// The current platform does not provide the requested decoder.
24    #[error("{codec} is not supported by the {backend} backend")]
25    UnsupportedCodec {
26        /// Requested codec.
27        codec: VideoCodec,
28        /// Backend identifier.
29        backend: &'static str,
30    },
31    /// The codec exists on this platform, but no hardware decoder is advertised.
32    #[error("no hardware {codec} decoder is available through {backend}")]
33    HardwareDecoderUnavailable {
34        /// Requested codec.
35        codec: VideoCodec,
36        /// Backend identifier.
37        backend: &'static str,
38    },
39    /// A native platform call returned an error status.
40    #[error("{api} failed with platform status {status}")]
41    Platform {
42        /// Native API that failed.
43        api: &'static str,
44        /// Native status code.
45        status: i32,
46    },
47    /// A backend operation failed with a platform-specific diagnostic.
48    #[error("{backend} {operation} failed: {message}")]
49    Backend {
50        /// Decoder backend identifier.
51        backend: &'static str,
52        /// Operation that failed.
53        operation: &'static str,
54        /// Native library diagnostic.
55        message: String,
56    },
57}