use std::io;
use thiserror::Error;
#[cfg(all(target_os = "windows", feature = "dxgi-capture"))]
use crate::elements::DxgiCaptureSourceError;
#[cfg(all(target_os = "windows", feature = "mf-capture"))]
use crate::elements::MfCaptureSourceError;
#[cfg(feature = "ort")]
use crate::elements::OrtDetectorError;
#[cfg(all(target_os = "linux", feature = "pipewire-audio-capture"))]
use crate::elements::PipeWireAudioCaptureSourceError;
#[cfg(all(target_os = "linux", feature = "pipewire-audio-renderer"))]
use crate::elements::PipeWireAudioRendererError;
#[cfg(all(target_os = "linux", feature = "pipewire-screen-capture"))]
use crate::elements::PipeWireScreenCaptureSourceError;
use crate::elements::RtspSinkError;
#[cfg(all(target_os = "linux", feature = "v4l2-capture"))]
use crate::elements::V4l2CaptureSourceError;
#[cfg(all(target_os = "windows", feature = "wasapi-capture"))]
use crate::elements::WasapiCaptureSourceError;
#[cfg(all(target_os = "windows", feature = "wasapi-renderer"))]
use crate::elements::WasapiRendererError;
#[cfg(feature = "webrtc")]
use crate::elements::WebRtcError;
#[cfg(all(target_os = "windows", feature = "wgc-capture"))]
use crate::elements::WgcCaptureSourceError;
#[cfg(feature = "cuda")]
use crate::elements::{
CudaConverterError, CudaDecoderError, CudaDownloadError, CudaEncoderError, CudaRendererError,
CudaScalerError, CudaUploadError, CudaVideoCompositorError,
};
#[cfg(all(target_os = "windows", feature = "d3d11"))]
use crate::elements::{
D3d11ChromaKeyError, D3d11DecoderError, D3d11DownloadError, D3d11RendererError,
D3d11ScalerError, D3d11TextLayerError, D3d11UploadError, D3d11VideoCompositorError,
D3d11VideoEncoderError,
};
#[cfg(all(target_os = "windows", feature = "d3d12"))]
use crate::elements::{
D3d12DecoderError, D3d12DownloadError, D3d12RendererError, D3d12ScalerError, D3d12UploadError,
};
use crate::{
control::{PrerollError, SeekError},
elements::{
AppSourceError, AudioMixerError, AudioResamplerError, AudioVolumeError, FileDemuxError,
FileMuxerError, HlsMuxerError, PacerError, RtspSourceError, SwAudioEncoderError,
SwChromaKeyError, SwDecoderError, SwEncoderError, SwScalerError, SwVideoCompositorError,
TestAudioSourceError, TestVideoSourceError, VideoSynchronizerError,
},
graph::GraphError,
log::LogInitError,
queue::QueueError,
};
#[derive(Debug, Error)]
#[error("failed to spawn {thread} thread: {source}")]
pub struct ThreadSpawnError {
thread: String,
#[source]
source: io::Error,
}
impl ThreadSpawnError {
pub(crate) fn new(thread: impl Into<String>, source: io::Error) -> Self {
Self {
thread: thread.into(),
source,
}
}
pub fn thread(&self) -> &str {
&self.thread
}
}
#[cfg(all(target_os = "windows", feature = "d3d11"))]
#[derive(Debug, Error)]
#[error("FFmpeg could not allocate a D3D11 texture buffer wrapper")]
pub struct D3d11FrameWrapError;
#[cfg(all(target_os = "windows", feature = "d3d11"))]
#[derive(Debug, Clone, Error)]
pub enum D3d11SharedDeviceError {
#[error(
"the D3D11 device was created with D3D11_CREATE_DEVICE_SINGLETHREADED and cannot be shared across a pipeline's threads"
)]
SingleThreaded,
#[error("the D3D11 runtime did not enable multithread protection on the shared context")]
ProtectionRefused,
#[error("windows error: {0}")]
Windows(#[from] windows::core::Error),
}
#[derive(Debug, Error)]
pub enum Error {
#[error(transparent)]
PrerollError(#[from] PrerollError),
#[error(transparent)]
SeekError(#[from] SeekError),
#[error(transparent)]
ThreadSpawnError(#[from] ThreadSpawnError),
#[cfg(all(target_os = "windows", feature = "d3d11"))]
#[error(transparent)]
D3d11FrameWrapError(#[from] D3d11FrameWrapError),
#[cfg(all(target_os = "windows", feature = "d3d11"))]
#[error(transparent)]
D3d11SharedDeviceError(#[from] D3d11SharedDeviceError),
#[error(transparent)]
FileDemuxError(#[from] FileDemuxError),
#[error(transparent)]
AppSourceError(#[from] AppSourceError),
#[error(transparent)]
RtspSourceError(#[from] RtspSourceError),
#[error(transparent)]
TestVideoSourceError(#[from] TestVideoSourceError),
#[error(transparent)]
TestAudioSourceError(#[from] TestAudioSourceError),
#[error(transparent)]
SwDecoderError(#[from] SwDecoderError),
#[cfg(feature = "cuda")]
#[error(transparent)]
CudaDecoderError(#[from] CudaDecoderError),
#[cfg(feature = "cuda")]
#[error(transparent)]
CudaRendererError(#[from] CudaRendererError),
#[cfg(feature = "cuda")]
#[error(transparent)]
CudaUploadError(#[from] CudaUploadError),
#[cfg(feature = "cuda")]
#[error(transparent)]
CudaDownloadError(#[from] CudaDownloadError),
#[cfg(feature = "cuda")]
#[error(transparent)]
CudaScalerError(#[from] CudaScalerError),
#[cfg(feature = "cuda")]
#[error(transparent)]
CudaConverterError(#[from] CudaConverterError),
#[cfg(feature = "cuda")]
#[error(transparent)]
CudaVideoCompositorError(#[from] CudaVideoCompositorError),
#[cfg(feature = "cuda")]
#[error(transparent)]
CudaEncoderError(#[from] CudaEncoderError),
#[error(transparent)]
SwEncoderError(#[from] SwEncoderError),
#[error(transparent)]
PacerError(#[from] PacerError),
#[error(transparent)]
VideoSynchronizerError(#[from] VideoSynchronizerError),
#[error(transparent)]
SwAudioEncoderError(#[from] SwAudioEncoderError),
#[error(transparent)]
AudioResamplerError(#[from] AudioResamplerError),
#[error(transparent)]
AudioVolumeError(#[from] AudioVolumeError),
#[error(transparent)]
SwScalerError(#[from] SwScalerError),
#[error(transparent)]
SwChromaKeyError(#[from] SwChromaKeyError),
#[error(transparent)]
QueueError(#[from] QueueError),
#[error(transparent)]
PipelineBridgeError(#[from] crate::elements::PipelineBridgeError),
#[error(transparent)]
GraphError(#[from] GraphError),
#[error(transparent)]
LogInitError(#[from] LogInitError),
#[error(transparent)]
AudioMixerError(#[from] AudioMixerError),
#[error(transparent)]
SwVideoCompositorError(#[from] SwVideoCompositorError),
#[error(transparent)]
FileMuxerError(#[from] FileMuxerError),
#[error(transparent)]
HlsMuxerError(#[from] HlsMuxerError),
#[error(transparent)]
RtspSinkError(#[from] RtspSinkError),
#[cfg(all(target_os = "windows", feature = "d3d12"))]
#[error(transparent)]
D3d12RendererError(#[from] D3d12RendererError),
#[cfg(all(target_os = "windows", feature = "d3d12"))]
#[error(transparent)]
D3d12DecoderError(#[from] D3d12DecoderError),
#[cfg(all(target_os = "windows", feature = "d3d12"))]
#[error(transparent)]
D3d12UploadError(#[from] D3d12UploadError),
#[cfg(all(target_os = "windows", feature = "d3d12"))]
#[error(transparent)]
D3d12DownloadError(#[from] D3d12DownloadError),
#[cfg(all(target_os = "windows", feature = "d3d12"))]
#[error(transparent)]
D3d12ScalerError(#[from] D3d12ScalerError),
#[cfg(all(target_os = "windows", feature = "d3d11"))]
#[error(transparent)]
D3d11DecoderError(#[from] D3d11DecoderError),
#[cfg(all(target_os = "windows", feature = "d3d11"))]
#[error(transparent)]
D3d11UploadError(#[from] D3d11UploadError),
#[cfg(all(target_os = "windows", feature = "d3d11"))]
#[error(transparent)]
D3d11DownloadError(#[from] D3d11DownloadError),
#[cfg(all(target_os = "windows", feature = "d3d11"))]
#[error(transparent)]
D3d11ScalerError(#[from] D3d11ScalerError),
#[cfg(all(target_os = "windows", feature = "d3d11"))]
#[error(transparent)]
D3d11ChromaKeyError(#[from] D3d11ChromaKeyError),
#[cfg(all(target_os = "windows", feature = "d3d11"))]
#[error(transparent)]
D3d11VideoEncoderError(#[from] D3d11VideoEncoderError),
#[cfg(all(target_os = "windows", feature = "d3d11"))]
#[error(transparent)]
D3d11RendererError(#[from] D3d11RendererError),
#[cfg(all(target_os = "windows", feature = "d3d11"))]
#[error(transparent)]
D3d11VideoCompositorError(#[from] D3d11VideoCompositorError),
#[cfg(all(target_os = "windows", feature = "d3d11"))]
#[error(transparent)]
D3d11TextLayerError(#[from] D3d11TextLayerError),
#[cfg(all(target_os = "windows", feature = "dxgi-capture"))]
#[error(transparent)]
DxgiCaptureSourceError(#[from] DxgiCaptureSourceError),
#[cfg(all(target_os = "windows", feature = "wgc-capture"))]
#[error(transparent)]
WgcCaptureSourceError(#[from] WgcCaptureSourceError),
#[cfg(all(target_os = "linux", feature = "pipewire-audio-capture"))]
#[error(transparent)]
PipeWireAudioCaptureSourceError(#[from] PipeWireAudioCaptureSourceError),
#[cfg(all(target_os = "linux", feature = "pipewire-audio-renderer"))]
#[error(transparent)]
PipeWireAudioRendererError(#[from] PipeWireAudioRendererError),
#[cfg(all(target_os = "linux", feature = "pipewire-screen-capture"))]
#[error(transparent)]
PipeWireScreenCaptureSourceError(#[from] PipeWireScreenCaptureSourceError),
#[cfg(all(target_os = "windows", feature = "mf-capture"))]
#[error(transparent)]
MfCaptureSourceError(#[from] MfCaptureSourceError),
#[cfg(all(target_os = "linux", feature = "v4l2-capture"))]
#[error(transparent)]
V4l2CaptureSourceError(#[from] V4l2CaptureSourceError),
#[cfg(all(target_os = "windows", feature = "wasapi-capture"))]
#[error(transparent)]
WasapiCaptureSourceError(#[from] WasapiCaptureSourceError),
#[cfg(all(target_os = "windows", feature = "wasapi-renderer"))]
#[error(transparent)]
WasapiRendererError(#[from] WasapiRendererError),
#[cfg(feature = "ort")]
#[error(transparent)]
OrtDetectorError(#[from] OrtDetectorError),
#[cfg(feature = "webrtc")]
#[error(transparent)]
WebRtcError(#[from] WebRtcError),
#[error("ffmpeg error: {0}")]
Ffmpeg(#[from] ffmpeg_next::Error),
#[error("{0}")]
Other(String),
}
pub type Result<T> = std::result::Result<T, Error>;