1use std::io;
12
13use thiserror::Error;
14
15#[cfg(all(target_os = "windows", feature = "dxgi-capture"))]
16use crate::elements::DxgiCaptureSourceError;
17#[cfg(all(target_os = "windows", feature = "mf-capture"))]
18use crate::elements::MfCaptureSourceError;
19#[cfg(feature = "ort")]
20use crate::elements::OrtDetectorError;
21#[cfg(all(target_os = "linux", feature = "pipewire-audio-capture"))]
22use crate::elements::PipeWireAudioCaptureSourceError;
23#[cfg(all(target_os = "linux", feature = "pipewire-audio-renderer"))]
24use crate::elements::PipeWireAudioRendererError;
25#[cfg(all(target_os = "linux", feature = "pipewire-screen-capture"))]
26use crate::elements::PipeWireScreenCaptureSourceError;
27use crate::elements::RtspSinkError;
28#[cfg(all(target_os = "linux", feature = "v4l2-capture"))]
29use crate::elements::V4l2CaptureSourceError;
30#[cfg(all(target_os = "windows", feature = "wasapi-capture"))]
31use crate::elements::WasapiCaptureSourceError;
32#[cfg(all(target_os = "windows", feature = "wasapi-renderer"))]
33use crate::elements::WasapiRendererError;
34#[cfg(feature = "webrtc")]
35use crate::elements::WebRtcError;
36#[cfg(all(target_os = "windows", feature = "wgc-capture"))]
37use crate::elements::WgcCaptureSourceError;
38#[cfg(feature = "cuda")]
39use crate::elements::{
40 CudaConverterError, CudaDecoderError, CudaDownloadError, CudaEncoderError, CudaRendererError,
41 CudaScalerError, CudaUploadError, CudaVideoCompositorError,
42};
43#[cfg(all(target_os = "windows", feature = "d3d11"))]
44use crate::elements::{
45 D3d11ChromaKeyError, D3d11DecoderError, D3d11DownloadError, D3d11RendererError,
46 D3d11ScalerError, D3d11TextLayerError, D3d11UploadError, D3d11VideoCompositorError,
47 D3d11VideoEncoderError,
48};
49#[cfg(all(target_os = "windows", feature = "d3d12"))]
50use crate::elements::{
51 D3d12DecoderError, D3d12DownloadError, D3d12RendererError, D3d12ScalerError, D3d12UploadError,
52};
53use crate::{
54 control::{PrerollError, SeekError},
55 elements::{
56 AppSourceError, AudioMixerError, AudioResamplerError, AudioVolumeError, FileDemuxError,
57 FileMuxerError, HlsMuxerError, PacerError, RtspSourceError, SwAudioEncoderError,
58 SwChromaKeyError, SwDecoderError, SwEncoderError, SwScalerError, SwVideoCompositorError,
59 TestAudioSourceError, TestVideoSourceError, VideoSynchronizerError,
60 },
61 graph::GraphError,
62 log::LogInitError,
63 queue::QueueError,
64};
65
66#[derive(Debug, Error)]
72#[error("failed to spawn {thread} thread: {source}")]
73pub struct ThreadSpawnError {
74 thread: String,
75 #[source]
76 source: io::Error,
77}
78
79impl ThreadSpawnError {
80 pub(crate) fn new(thread: impl Into<String>, source: io::Error) -> Self {
81 Self {
82 thread: thread.into(),
83 source,
84 }
85 }
86
87 pub fn thread(&self) -> &str {
89 &self.thread
90 }
91}
92
93#[cfg(all(target_os = "windows", feature = "d3d11"))]
96#[derive(Debug, Error)]
97#[error("FFmpeg could not allocate a D3D11 texture buffer wrapper")]
98pub struct D3d11FrameWrapError;
99
100#[cfg(all(target_os = "windows", feature = "d3d11"))]
109#[derive(Debug, Clone, Error)]
110pub enum D3d11SharedDeviceError {
111 #[error(
115 "the D3D11 device was created with D3D11_CREATE_DEVICE_SINGLETHREADED and cannot be shared across a pipeline's threads"
116 )]
117 SingleThreaded,
118
119 #[error("the D3D11 runtime did not enable multithread protection on the shared context")]
122 ProtectionRefused,
123
124 #[error("windows error: {0}")]
127 Windows(#[from] windows::core::Error),
128}
129
130#[derive(Debug, Error)]
140pub enum Error {
141 #[error(transparent)]
143 PrerollError(#[from] PrerollError),
144
145 #[error(transparent)]
147 SeekError(#[from] SeekError),
148
149 #[error(transparent)]
151 ThreadSpawnError(#[from] ThreadSpawnError),
152
153 #[cfg(all(target_os = "windows", feature = "d3d11"))]
155 #[error(transparent)]
156 D3d11FrameWrapError(#[from] D3d11FrameWrapError),
157
158 #[cfg(all(target_os = "windows", feature = "d3d11"))]
160 #[error(transparent)]
161 D3d11SharedDeviceError(#[from] D3d11SharedDeviceError),
162
163 #[error(transparent)]
165 FileDemuxError(#[from] FileDemuxError),
166
167 #[error(transparent)]
169 AppSourceError(#[from] AppSourceError),
170
171 #[error(transparent)]
173 RtspSourceError(#[from] RtspSourceError),
174
175 #[error(transparent)]
177 TestVideoSourceError(#[from] TestVideoSourceError),
178
179 #[error(transparent)]
181 TestAudioSourceError(#[from] TestAudioSourceError),
182
183 #[error(transparent)]
185 SwDecoderError(#[from] SwDecoderError),
186
187 #[cfg(feature = "cuda")]
189 #[error(transparent)]
190 CudaDecoderError(#[from] CudaDecoderError),
191
192 #[cfg(feature = "cuda")]
194 #[error(transparent)]
195 CudaRendererError(#[from] CudaRendererError),
196
197 #[cfg(feature = "cuda")]
199 #[error(transparent)]
200 CudaUploadError(#[from] CudaUploadError),
201
202 #[cfg(feature = "cuda")]
204 #[error(transparent)]
205 CudaDownloadError(#[from] CudaDownloadError),
206
207 #[cfg(feature = "cuda")]
209 #[error(transparent)]
210 CudaScalerError(#[from] CudaScalerError),
211
212 #[cfg(feature = "cuda")]
214 #[error(transparent)]
215 CudaConverterError(#[from] CudaConverterError),
216
217 #[cfg(feature = "cuda")]
219 #[error(transparent)]
220 CudaVideoCompositorError(#[from] CudaVideoCompositorError),
221
222 #[cfg(feature = "cuda")]
224 #[error(transparent)]
225 CudaEncoderError(#[from] CudaEncoderError),
226
227 #[error(transparent)]
229 SwEncoderError(#[from] SwEncoderError),
230
231 #[error(transparent)]
233 PacerError(#[from] PacerError),
234
235 #[error(transparent)]
237 VideoSynchronizerError(#[from] VideoSynchronizerError),
238
239 #[error(transparent)]
241 SwAudioEncoderError(#[from] SwAudioEncoderError),
242
243 #[error(transparent)]
245 AudioResamplerError(#[from] AudioResamplerError),
246
247 #[error(transparent)]
249 AudioVolumeError(#[from] AudioVolumeError),
250
251 #[error(transparent)]
253 SwScalerError(#[from] SwScalerError),
254
255 #[error(transparent)]
257 SwChromaKeyError(#[from] SwChromaKeyError),
258
259 #[error(transparent)]
261 QueueError(#[from] QueueError),
262
263 #[error(transparent)]
265 PipelineBridgeError(#[from] crate::elements::PipelineBridgeError),
266
267 #[error(transparent)]
269 GraphError(#[from] GraphError),
270
271 #[error(transparent)]
273 LogInitError(#[from] LogInitError),
274
275 #[error(transparent)]
277 AudioMixerError(#[from] AudioMixerError),
278
279 #[error(transparent)]
281 SwVideoCompositorError(#[from] SwVideoCompositorError),
282
283 #[error(transparent)]
285 FileMuxerError(#[from] FileMuxerError),
286
287 #[error(transparent)]
289 HlsMuxerError(#[from] HlsMuxerError),
290
291 #[error(transparent)]
293 RtspSinkError(#[from] RtspSinkError),
294
295 #[cfg(all(target_os = "windows", feature = "d3d12"))]
297 #[error(transparent)]
298 D3d12RendererError(#[from] D3d12RendererError),
299
300 #[cfg(all(target_os = "windows", feature = "d3d12"))]
302 #[error(transparent)]
303 D3d12DecoderError(#[from] D3d12DecoderError),
304
305 #[cfg(all(target_os = "windows", feature = "d3d12"))]
307 #[error(transparent)]
308 D3d12UploadError(#[from] D3d12UploadError),
309
310 #[cfg(all(target_os = "windows", feature = "d3d12"))]
312 #[error(transparent)]
313 D3d12DownloadError(#[from] D3d12DownloadError),
314
315 #[cfg(all(target_os = "windows", feature = "d3d12"))]
317 #[error(transparent)]
318 D3d12ScalerError(#[from] D3d12ScalerError),
319
320 #[cfg(all(target_os = "windows", feature = "d3d11"))]
322 #[error(transparent)]
323 D3d11DecoderError(#[from] D3d11DecoderError),
324
325 #[cfg(all(target_os = "windows", feature = "d3d11"))]
327 #[error(transparent)]
328 D3d11UploadError(#[from] D3d11UploadError),
329
330 #[cfg(all(target_os = "windows", feature = "d3d11"))]
332 #[error(transparent)]
333 D3d11DownloadError(#[from] D3d11DownloadError),
334
335 #[cfg(all(target_os = "windows", feature = "d3d11"))]
337 #[error(transparent)]
338 D3d11ScalerError(#[from] D3d11ScalerError),
339
340 #[cfg(all(target_os = "windows", feature = "d3d11"))]
342 #[error(transparent)]
343 D3d11ChromaKeyError(#[from] D3d11ChromaKeyError),
344
345 #[cfg(all(target_os = "windows", feature = "d3d11"))]
347 #[error(transparent)]
348 D3d11VideoEncoderError(#[from] D3d11VideoEncoderError),
349
350 #[cfg(all(target_os = "windows", feature = "d3d11"))]
352 #[error(transparent)]
353 D3d11RendererError(#[from] D3d11RendererError),
354
355 #[cfg(all(target_os = "windows", feature = "d3d11"))]
357 #[error(transparent)]
358 D3d11VideoCompositorError(#[from] D3d11VideoCompositorError),
359
360 #[cfg(all(target_os = "windows", feature = "d3d11"))]
362 #[error(transparent)]
363 D3d11TextLayerError(#[from] D3d11TextLayerError),
364
365 #[cfg(all(target_os = "windows", feature = "dxgi-capture"))]
367 #[error(transparent)]
368 DxgiCaptureSourceError(#[from] DxgiCaptureSourceError),
369
370 #[cfg(all(target_os = "windows", feature = "wgc-capture"))]
372 #[error(transparent)]
373 WgcCaptureSourceError(#[from] WgcCaptureSourceError),
374
375 #[cfg(all(target_os = "linux", feature = "pipewire-audio-capture"))]
377 #[error(transparent)]
378 PipeWireAudioCaptureSourceError(#[from] PipeWireAudioCaptureSourceError),
379
380 #[cfg(all(target_os = "linux", feature = "pipewire-audio-renderer"))]
382 #[error(transparent)]
383 PipeWireAudioRendererError(#[from] PipeWireAudioRendererError),
384
385 #[cfg(all(target_os = "linux", feature = "pipewire-screen-capture"))]
387 #[error(transparent)]
388 PipeWireScreenCaptureSourceError(#[from] PipeWireScreenCaptureSourceError),
389
390 #[cfg(all(target_os = "windows", feature = "mf-capture"))]
392 #[error(transparent)]
393 MfCaptureSourceError(#[from] MfCaptureSourceError),
394
395 #[cfg(all(target_os = "linux", feature = "v4l2-capture"))]
397 #[error(transparent)]
398 V4l2CaptureSourceError(#[from] V4l2CaptureSourceError),
399
400 #[cfg(all(target_os = "windows", feature = "wasapi-capture"))]
402 #[error(transparent)]
403 WasapiCaptureSourceError(#[from] WasapiCaptureSourceError),
404
405 #[cfg(all(target_os = "windows", feature = "wasapi-renderer"))]
407 #[error(transparent)]
408 WasapiRendererError(#[from] WasapiRendererError),
409
410 #[cfg(feature = "ort")]
412 #[error(transparent)]
413 OrtDetectorError(#[from] OrtDetectorError),
414
415 #[cfg(feature = "webrtc")]
417 #[error(transparent)]
418 WebRtcError(#[from] WebRtcError),
419
420 #[error("ffmpeg error: {0}")]
422 Ffmpeg(#[from] ffmpeg_next::Error),
423
424 #[error("{0}")]
426 Other(String),
427}
428
429pub type Result<T> = std::result::Result<T, Error>;