Skip to main content

moq_video/
error.rs

1/// Errors returned by `moq-video`.
2#[derive(Debug, thiserror::Error)]
3#[non_exhaustive]
4pub enum Error {
5	/// No encoder matching the requested codec / hardware preference could be
6	/// opened (none compiled in, or none available on this machine).
7	#[error("no usable video encoder found (tried: {0})")]
8	NoEncoder(String),
9
10	/// No decoder matching the requested codec / hardware preference could be
11	/// opened (none compiled in, or none available on this machine).
12	#[error("no usable video decoder found (tried: {0})")]
13	NoDecoder(String),
14
15	/// `Kind::Named` asked for an encoder this build does not have for that
16	/// codec: a name that is not a backend, one whose feature is off, or one
17	/// that does not encode the codec requested.
18	#[error("no encoder named {name} for {codec:?} (this build has: {available})")]
19	UnknownEncoder {
20		/// The name that was asked for.
21		name: String,
22		/// The codec it was asked for.
23		codec: crate::encode::Codec,
24		/// The encoders this build does have for that codec.
25		available: String,
26	},
27
28	/// `Kind::Named` asked for a decoder this build does not have for that
29	/// codec: a name that is not a backend, one whose feature is off, or one
30	/// that does not decode the codec requested.
31	#[error("no decoder named {name} for {codec:?} (this build has: {available})")]
32	UnknownDecoder {
33		/// The name that was asked for.
34		name: String,
35		/// The codec it was asked for.
36		codec: crate::decode::Codec,
37		/// The decoders this build does have for that codec.
38		available: String,
39	},
40
41	/// A track's codec is not supported by the native decoders.
42	#[error("unsupported codec for native decode: {0}")]
43	UnsupportedCodec(String),
44
45	/// The codec session is over: its worker thread stopped, or a cancelled
46	/// call left it out of step with the stream it was decoding.
47	///
48	/// Distinct from [`Codec`](Self::Codec), which describes the bytes of one
49	/// picture and which a caller can reasonably skip past. Nothing about this
50	/// one improves by reading on: the session that would have decoded the next
51	/// picture no longer exists, and only a new encoder or decoder recovers it.
52	#[error("codec session ended: {0}")]
53	CodecGone(String),
54
55	/// The requested capture source or enumeration has no implementation on this
56	/// platform (the message names what is missing).
57	#[error("not supported on this platform: {0}")]
58	Unsupported(String),
59
60	/// The operating system denied access to a capture source.
61	#[error("capture permission denied: {0}")]
62	PermissionDenied(String),
63
64	/// A requested capture source does not exist or disappeared while capturing.
65	#[error("capture source unavailable: {0}")]
66	SourceUnavailable(String),
67
68	/// The configured framerate is outside the supported range.
69	#[error("invalid framerate: {0} (must be between 1 and 1,000,000)")]
70	InvalidFramerate(u32),
71
72	/// This encoder can't change its bitrate once open, so it can't follow a
73	/// congestion-control estimate. Encoding continues at the configured rate.
74	#[error("encoder {0} cannot change bitrate while running")]
75	BitrateUnsupported(&'static str),
76
77	/// GPU rendering failure: building the pipeline, importing a frame's surface
78	/// as a texture, or the device itself.
79	#[error("render: {0}")]
80	Render(#[source] anyhow::Error),
81
82	/// Capture / encode / codec failure (the message carries the detail).
83	#[error(transparent)]
84	Codec(#[from] anyhow::Error),
85
86	/// moq-mux muxer/catalog error.
87	#[error(transparent)]
88	Mux(#[from] moq_mux::Error),
89
90	/// moq-net transport error.
91	#[error(transparent)]
92	Net(#[from] moq_net::Error),
93
94	/// Timestamp overflow converting to the moq microsecond timescale.
95	#[error(transparent)]
96	TimeOverflow(#[from] moq_net::TimeOverflow),
97}