diff --git a/src/rtsp/adpcm.rs b/src/rtsp/adpcm.rs index c7d4bea..5eaefca 100644 --- a/src/rtsp/adpcm.rs +++ b/src/rtsp/adpcm.rs @@ -102,7 +102,7 @@ pub(crate) fn adpcm_to_pcm(bytes: &[u8]) -> Result, Error> { if bytes.len() < 4 { error!("ADPCM data is too short for even the magic."); - return Err(Error::AdpcmDecodingError( + return Err(Error::AdpcmDecoding( "ADPCM data is too short for even the magic.", )); } @@ -112,7 +112,7 @@ pub(crate) fn adpcm_to_pcm(bytes: &[u8]) -> Result, Error> { const FRAME_TYPE_HISILICON: &[u8] = &[0x00, 0x01]; if frame_type_bytes != FRAME_TYPE_HISILICON { error!("Unexpected ADPCM frame type: {:x?}", frame_type_bytes); - return Err(Error::AdpcmDecodingError("Unexpected ADPCM frame type")); + return Err(Error::AdpcmDecoding("Unexpected ADPCM frame type")); } // Check for valid block size @@ -126,7 +126,7 @@ pub(crate) fn adpcm_to_pcm(bytes: &[u8]) -> Result, Error> { let full_block_size = block_size + 4; // block_size + magic (2 bytes) + size (2 bytes) if !bytes.len() % full_block_size as usize == 0 { error!("ADPCM Data is not a multiple of the block size"); - return Err(Error::AdpcmDecodingError( + return Err(Error::AdpcmDecoding( "ADPCM block size does not match data length.", )); } @@ -136,7 +136,7 @@ pub(crate) fn adpcm_to_pcm(bytes: &[u8]) -> Result, Error> { // Get predictor state from block header using DVI 4 format. if bytes.len() < 8 { error!("ADPCM Block size is not long enough for header"); - return Err(Error::AdpcmDecodingError( + return Err(Error::AdpcmDecoding( "ADPCM has insufficent block size", )); } diff --git a/src/rtsp/errors.rs b/src/rtsp/errors.rs index 51c9e6d..162e91f 100644 --- a/src/rtsp/errors.rs +++ b/src/rtsp/errors.rs @@ -6,18 +6,18 @@ use err_derive::Error; pub enum Error { /// Raised when the config file fails to deserlize #[error(display = "Configuration parsing error")] - ConfigError(#[error(source)] toml::de::Error), + Config(#[error(source)] toml::de::Error), /// Raised when `neolink_core` raises an error #[error(display = "Communication error")] - ProtocolError(#[error(source)] neolink_core::Error), + Protocol(#[error(source)] neolink_core::Error), /// Raised when there is an IO error such as unable to find /// config file #[error(display = "I/O error")] - IoError(#[error(source)] std::io::Error), + Io(#[error(source)] std::io::Error), /// Raised when the config file fails validataion #[error(display = "Validation error")] - ValidationError(#[error(source)] validator::ValidationErrors), + Validation(#[error(source)] validator::ValidationErrors), /// Raised when there is an ADPCM decoding error #[error(display = "ADPCM Decoding Error")] - AdpcmDecodingError(&'static str), + AdpcmDecoding(&'static str), } diff --git a/src/rtsp/gst.rs b/src/rtsp/gst.rs index b75d8d6..b2a7cce 100644 --- a/src/rtsp/gst.rs +++ b/src/rtsp/gst.rs @@ -41,7 +41,7 @@ impl StreamOutput for GstOutputs { self.set_format(Some(format)); if let StreamFormat::ADPCM = format { let pcm = adpcm_to_pcm(data).map_err(|e| { - if let Error::AdpcmDecodingError(msg) = e { + if let Error::AdpcmDecoding(msg) = e { neolink_core::Error::OtherString(format!("ADPCM decoding error: {}", msg)) } else { neolink_core::Error::Other("Generic error during ADPCM decoding")