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	/// libav* (capture, scaling, or codec) failure.
6	///
7	/// Carries the formatted message rather than the typed `ffmpeg_next::Error`
8	/// on purpose: keeping ffmpeg out of the public surface means an
9	/// `ffmpeg-next` major bump isn't a breaking change for consumers.
10	#[error("ffmpeg: {0}")]
11	Ffmpeg(String),
12
13	/// No encoder matching the requested codec / hardware preference was
14	/// compiled into the linked ffmpeg.
15	#[error("no usable H.264 encoder found (tried: {0})")]
16	NoEncoder(String),
17
18	/// The requested input format (avfoundation / v4l2 / dshow) is not
19	/// available in the linked libavdevice.
20	#[error("capture backend {0:?} not available in this ffmpeg build")]
21	NoCaptureBackend(&'static str),
22
23	/// The opened capture device exposed no decodable video stream.
24	#[error("no video stream on capture device {0:?}")]
25	NoVideoStream(String),
26
27	/// The configured framerate was zero (would divide by zero / produce a
28	/// degenerate codec time base).
29	#[error("invalid framerate: {0} (must be non-zero)")]
30	InvalidFramerate(u32),
31
32	/// moq-mux codec/transport error (H.264 import, catalog).
33	#[error(transparent)]
34	Codec(#[from] anyhow::Error),
35
36	/// moq-net transport error.
37	#[error(transparent)]
38	Moq(#[from] moq_net::Error),
39
40	/// Timestamp overflow converting to the moq microsecond timescale.
41	#[error(transparent)]
42	TimeOverflow(#[from] moq_net::TimeOverflow),
43}
44
45// Manual (not `#[from]`) so the typed ffmpeg error stays out of the public
46// variant while `?` on ffmpeg results still converts automatically.
47impl From<ffmpeg_next::Error> for Error {
48	fn from(err: ffmpeg_next::Error) -> Self {
49		Self::Ffmpeg(err.to_string())
50	}
51}