1use std::io;
12
13use thiserror::Error;
14
15#[cfg(all(target_os = "windows", feature = "dxgi-capture"))]
16use crate::elements::DxgiCaptureSourceError;
17#[cfg(feature = "ort")]
18use crate::elements::OrtDetectorError;
19#[cfg(all(target_os = "linux", feature = "pipewire-audio-capture"))]
20use crate::elements::PipeWireAudioCaptureSourceError;
21#[cfg(all(target_os = "linux", feature = "pipewire-audio-renderer"))]
22use crate::elements::PipeWireAudioRendererError;
23#[cfg(all(target_os = "linux", feature = "pipewire-screen-capture"))]
24use crate::elements::PipeWireScreenCaptureSourceError;
25use crate::elements::RtspSinkError;
26#[cfg(all(target_os = "windows", feature = "wasapi-capture"))]
27use crate::elements::WasapiCaptureSourceError;
28#[cfg(all(target_os = "windows", feature = "wasapi-renderer"))]
29use crate::elements::WasapiRendererError;
30#[cfg(feature = "webrtc")]
31use crate::elements::WebRtcError;
32#[cfg(feature = "cuda")]
33use crate::elements::{
34 CudaConverterError, CudaDecoderError, CudaDownloadError, CudaEncoderError, CudaRendererError,
35 CudaScalerError, CudaUploadError, CudaVideoCompositorError,
36};
37#[cfg(all(target_os = "windows", feature = "d3d11"))]
38use crate::elements::{
39 D3d11ChromaKeyError, D3d11DecoderError, D3d11DownloadError, D3d11NvencEncoderError,
40 D3d11RendererError, D3d11ScalerError, D3d11TextLayerError, D3d11UploadError,
41 D3d11VideoCompositorError,
42};
43#[cfg(all(target_os = "windows", feature = "d3d12"))]
44use crate::elements::{
45 D3d12DecoderError, D3d12DownloadError, D3d12RendererError, D3d12ScalerError, D3d12UploadError,
46};
47use crate::{
48 elements::{
49 AppSourceError, AudioMixerError, AudioResamplerError, AudioVolumeError, FileDemuxError,
50 HlsMuxerError, Mp4MuxerError, PacerError, RtspSourceError, SwAudioEncoderError,
51 SwChromaKeyError, SwDecoderError, SwEncoderError, SwScalerError, SwVideoCompositorError,
52 TestAudioSourceError, TestVideoSourceError, VideoSynchronizerError,
53 },
54 graph::GraphError,
55 log::LogInitError,
56 queue::QueueError,
57};
58
59#[derive(Debug, Error)]
65#[error("failed to spawn {thread} thread: {source}")]
66pub struct ThreadSpawnError {
67 thread: String,
68 #[source]
69 source: io::Error,
70}
71
72impl ThreadSpawnError {
73 pub(crate) fn new(thread: impl Into<String>, source: io::Error) -> Self {
74 Self {
75 thread: thread.into(),
76 source,
77 }
78 }
79
80 pub fn thread(&self) -> &str {
82 &self.thread
83 }
84}
85
86#[cfg(all(target_os = "windows", feature = "d3d11"))]
89#[derive(Debug, Error)]
90#[error("FFmpeg could not allocate a D3D11 texture buffer wrapper")]
91pub struct D3d11FrameWrapError;
92
93#[derive(Debug, Error)]
103pub enum Error {
104 #[error(transparent)]
106 ThreadSpawnError(#[from] ThreadSpawnError),
107
108 #[cfg(all(target_os = "windows", feature = "d3d11"))]
110 #[error(transparent)]
111 D3d11FrameWrapError(#[from] D3d11FrameWrapError),
112
113 #[error(transparent)]
115 FileDemuxError(#[from] FileDemuxError),
116
117 #[error(transparent)]
119 AppSourceError(#[from] AppSourceError),
120
121 #[error(transparent)]
123 RtspSourceError(#[from] RtspSourceError),
124
125 #[error(transparent)]
127 TestVideoSourceError(#[from] TestVideoSourceError),
128
129 #[error(transparent)]
131 TestAudioSourceError(#[from] TestAudioSourceError),
132
133 #[error(transparent)]
135 SwDecoderError(#[from] SwDecoderError),
136
137 #[cfg(feature = "cuda")]
139 #[error(transparent)]
140 CudaDecoderError(#[from] CudaDecoderError),
141
142 #[cfg(feature = "cuda")]
144 #[error(transparent)]
145 CudaRendererError(#[from] CudaRendererError),
146
147 #[cfg(feature = "cuda")]
149 #[error(transparent)]
150 CudaUploadError(#[from] CudaUploadError),
151
152 #[cfg(feature = "cuda")]
154 #[error(transparent)]
155 CudaDownloadError(#[from] CudaDownloadError),
156
157 #[cfg(feature = "cuda")]
159 #[error(transparent)]
160 CudaScalerError(#[from] CudaScalerError),
161
162 #[cfg(feature = "cuda")]
164 #[error(transparent)]
165 CudaConverterError(#[from] CudaConverterError),
166
167 #[cfg(feature = "cuda")]
169 #[error(transparent)]
170 CudaVideoCompositorError(#[from] CudaVideoCompositorError),
171
172 #[cfg(feature = "cuda")]
174 #[error(transparent)]
175 CudaEncoderError(#[from] CudaEncoderError),
176
177 #[error(transparent)]
179 SwEncoderError(#[from] SwEncoderError),
180
181 #[error(transparent)]
183 PacerError(#[from] PacerError),
184
185 #[error(transparent)]
187 VideoSynchronizerError(#[from] VideoSynchronizerError),
188
189 #[error(transparent)]
191 SwAudioEncoderError(#[from] SwAudioEncoderError),
192
193 #[error(transparent)]
195 AudioResamplerError(#[from] AudioResamplerError),
196
197 #[error(transparent)]
199 AudioVolumeError(#[from] AudioVolumeError),
200
201 #[error(transparent)]
203 SwScalerError(#[from] SwScalerError),
204
205 #[error(transparent)]
207 SwChromaKeyError(#[from] SwChromaKeyError),
208
209 #[error(transparent)]
211 QueueError(#[from] QueueError),
212
213 #[error(transparent)]
215 GraphError(#[from] GraphError),
216
217 #[error(transparent)]
219 LogInitError(#[from] LogInitError),
220
221 #[error(transparent)]
223 AudioMixerError(#[from] AudioMixerError),
224
225 #[error(transparent)]
227 SwVideoCompositorError(#[from] SwVideoCompositorError),
228
229 #[error(transparent)]
231 Mp4MuxerError(#[from] Mp4MuxerError),
232
233 #[error(transparent)]
235 HlsMuxerError(#[from] HlsMuxerError),
236
237 #[error(transparent)]
239 RtspSinkError(#[from] RtspSinkError),
240
241 #[cfg(all(target_os = "windows", feature = "d3d12"))]
243 #[error(transparent)]
244 D3d12RendererError(#[from] D3d12RendererError),
245
246 #[cfg(all(target_os = "windows", feature = "d3d12"))]
248 #[error(transparent)]
249 D3d12DecoderError(#[from] D3d12DecoderError),
250
251 #[cfg(all(target_os = "windows", feature = "d3d12"))]
253 #[error(transparent)]
254 D3d12UploadError(#[from] D3d12UploadError),
255
256 #[cfg(all(target_os = "windows", feature = "d3d12"))]
258 #[error(transparent)]
259 D3d12DownloadError(#[from] D3d12DownloadError),
260
261 #[cfg(all(target_os = "windows", feature = "d3d12"))]
263 #[error(transparent)]
264 D3d12ScalerError(#[from] D3d12ScalerError),
265
266 #[cfg(all(target_os = "windows", feature = "d3d11"))]
268 #[error(transparent)]
269 D3d11DecoderError(#[from] D3d11DecoderError),
270
271 #[cfg(all(target_os = "windows", feature = "d3d11"))]
273 #[error(transparent)]
274 D3d11UploadError(#[from] D3d11UploadError),
275
276 #[cfg(all(target_os = "windows", feature = "d3d11"))]
278 #[error(transparent)]
279 D3d11DownloadError(#[from] D3d11DownloadError),
280
281 #[cfg(all(target_os = "windows", feature = "d3d11"))]
283 #[error(transparent)]
284 D3d11ScalerError(#[from] D3d11ScalerError),
285
286 #[cfg(all(target_os = "windows", feature = "d3d11"))]
288 #[error(transparent)]
289 D3d11ChromaKeyError(#[from] D3d11ChromaKeyError),
290
291 #[cfg(all(target_os = "windows", feature = "d3d11"))]
293 #[error(transparent)]
294 D3d11NvencEncoderError(#[from] D3d11NvencEncoderError),
295
296 #[cfg(all(target_os = "windows", feature = "d3d11"))]
298 #[error(transparent)]
299 D3d11RendererError(#[from] D3d11RendererError),
300
301 #[cfg(all(target_os = "windows", feature = "d3d11"))]
303 #[error(transparent)]
304 D3d11VideoCompositorError(#[from] D3d11VideoCompositorError),
305
306 #[cfg(all(target_os = "windows", feature = "d3d11"))]
308 #[error(transparent)]
309 D3d11TextLayerError(#[from] D3d11TextLayerError),
310
311 #[cfg(all(target_os = "windows", feature = "dxgi-capture"))]
313 #[error(transparent)]
314 DxgiCaptureSourceError(#[from] DxgiCaptureSourceError),
315
316 #[cfg(all(target_os = "linux", feature = "pipewire-audio-capture"))]
318 #[error(transparent)]
319 PipeWireAudioCaptureSourceError(#[from] PipeWireAudioCaptureSourceError),
320
321 #[cfg(all(target_os = "linux", feature = "pipewire-audio-renderer"))]
323 #[error(transparent)]
324 PipeWireAudioRendererError(#[from] PipeWireAudioRendererError),
325
326 #[cfg(all(target_os = "linux", feature = "pipewire-screen-capture"))]
328 #[error(transparent)]
329 PipeWireScreenCaptureSourceError(#[from] PipeWireScreenCaptureSourceError),
330
331 #[cfg(all(target_os = "windows", feature = "wasapi-capture"))]
333 #[error(transparent)]
334 WasapiCaptureSourceError(#[from] WasapiCaptureSourceError),
335
336 #[cfg(all(target_os = "windows", feature = "wasapi-renderer"))]
338 #[error(transparent)]
339 WasapiRendererError(#[from] WasapiRendererError),
340
341 #[cfg(feature = "ort")]
343 #[error(transparent)]
344 OrtDetectorError(#[from] OrtDetectorError),
345
346 #[cfg(feature = "webrtc")]
348 #[error(transparent)]
349 WebRtcError(#[from] WebRtcError),
350
351 #[error("ffmpeg error: {0}")]
353 Ffmpeg(#[from] ffmpeg_next::Error),
354
355 #[error("{0}")]
357 Other(String),
358}
359
360pub type Result<T> = std::result::Result<T, Error>;