use std::io;
use thiserror::Error;
pub type PackagerResult<T> = Result<T, PackagerError>;
#[derive(Debug, Error)]
pub enum PackagerError {
#[error("I/O error: {0}")]
Io(#[from] io::Error),
#[error("Invalid configuration: {0}")]
InvalidConfig(String),
#[error("Unsupported codec: {0}")]
UnsupportedCodec(String),
#[error("Invalid bitrate ladder: {0}")]
InvalidLadder(String),
#[error("Segment generation failed: {0}")]
SegmentFailed(String),
#[error("Manifest generation failed: {0}")]
ManifestFailed(String),
#[error("Encryption error: {0}")]
EncryptionError(String),
#[error("Invalid media source: {0}")]
InvalidSource(String),
#[error("Missing required parameter: {0}")]
MissingParameter(String),
#[error("Keyframe alignment failed: {0}")]
AlignmentFailed(String),
#[error("DRM preparation failed: {0}")]
DrmFailed(String),
#[error("Cloud upload failed: {0}")]
UploadFailed(String),
#[error("Packaging error: {0}")]
PackagingError(String),
#[error("Core error: {0}")]
Core(#[from] oximedia_core::OxiError),
#[error("JSON error: {0}")]
Json(#[from] serde_json::Error),
#[error("XML error: {0}")]
Xml(#[from] quick_xml::Error),
#[error("Time error: {0}")]
Time(String),
}
impl PackagerError {
pub fn invalid_config(msg: impl Into<String>) -> Self {
Self::InvalidConfig(msg.into())
}
pub fn unsupported_codec(msg: impl Into<String>) -> Self {
Self::UnsupportedCodec(msg.into())
}
pub fn segment_failed(msg: impl Into<String>) -> Self {
Self::SegmentFailed(msg.into())
}
pub fn manifest_failed(msg: impl Into<String>) -> Self {
Self::ManifestFailed(msg.into())
}
}