diff --git a/src/rtsp/errors.rs b/src/rtsp/errors.rs index 162e91f..19d0c68 100644 --- a/src/rtsp/errors.rs +++ b/src/rtsp/errors.rs @@ -17,7 +17,7 @@ pub enum Error { /// Raised when the config file fails validataion #[error(display = "Validation error")] Validation(#[error(source)] validator::ValidationErrors), - /// Raised when there is an ADPCM decoding error - #[error(display = "ADPCM Decoding Error")] - AdpcmDecoding(&'static str), + // Raised when there is an ADPCM decoding error + // #[error(display = "ADPCM Decoding Error")] + // AdpcmDecoding(&'static str), } diff --git a/src/rtsp/gst.rs b/src/rtsp/gst.rs index eb7b50d..7b4fb0b 100644 --- a/src/rtsp/gst.rs +++ b/src/rtsp/gst.rs @@ -1,8 +1,8 @@ //! This module provides an "RtspServer" abstraction that allows consumers of its API to feed it //! data using an ordinary std::io::Write interface. pub(crate) use self::maybe_app_src::MaybeAppSrc; -use super::adpcm::adpcm_to_pcm; -use super::errors::Error; +// use super::adpcm::adpcm_to_pcm; +// use super::errors::Error; use gstreamer::prelude::Cast; use gstreamer::{Bin, Structure}; use gstreamer_app::AppSrc; @@ -81,14 +81,7 @@ impl StreamOutput for GstOutputs { } BcMedia::Adpcm(payload) => { self.set_format(Some(StreamFormat::Adpcm((payload.data.len() - 4) as u16))); - let pcm = adpcm_to_pcm(&payload.data).map_err(|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") - } - })?; - self.audsrc.write_all(&pcm)?; + self.audsrc.write_all(&payload.data)?; } _ => { //Ignore other BcMedia like InfoV1 and InfoV2 diff --git a/src/rtsp/mod.rs b/src/rtsp/mod.rs index 5c8d4c6..accf06a 100644 --- a/src/rtsp/mod.rs +++ b/src/rtsp/mod.rs @@ -37,7 +37,7 @@ use std::sync::Arc; use std::time::Duration; use validator::Validate; -mod adpcm; +// mod adpcm; /// The command line parameters for this subcommand mod cmdline; mod config; diff --git a/src/talk/gst.rs b/src/talk/gst.rs index 05c4f25..a469295 100644 --- a/src/talk/gst.rs +++ b/src/talk/gst.rs @@ -1,5 +1,5 @@ use gstreamer::{ - element_error, parse_launch, prelude::*, ClockTime, FlowError, FlowSuccess, MessageView, + element_error, parse_launch, prelude::*, Caps, ClockTime, FlowError, FlowSuccess, MessageView, Pipeline, ResourceError, State, }; use gstreamer_app::{AppSink, AppSinkCallbacks}; @@ -125,7 +125,7 @@ fn set_data_channel(appsink: &AppSink, tx: SyncSender>) { element_error!( appsink, ResourceError::Failed, - ("Failed to interprete buffer as S16 PCM") + ("Failed to interprete buffer as u8 ADPCM") ); FlowError::Error @@ -161,7 +161,7 @@ fn create_pipeline( source, sample_rate, volume, block_align ); - // log::info!("{}", launch_str); + log::info!("{}", launch_str); // Parse the pipeline we want to probe from a static in-line string. // Here we give our audiotestsrc a name, so we can retrieve that element @@ -171,5 +171,21 @@ fn create_pipeline( .dynamic_cast::() .map_err(Error::GstreamerElement)?; + let appsink = get_sink(&pipeline)?; + + // Tell the appsink what format we want. It will then be the audiotestsrc's job to + // provide the format we request. + // This can be set after linking the two objects, because format negotiation between + // both elements will happen during pre-rolling of the pipeline. + appsink.set_caps(Some(&Caps::new_simple( + "audio/x-adpcm", + &[ + ("layout", &"dvi"), + ("block_align", &(block_align as i32)), + ("channels", &(1i32)), + ("rate", &(sample_rate as i32)), + ], + ))); + Ok(pipeline) }