Don't decode adpcm

This commit is contained in:
QuantumEntangledAndy committed 2021-08-04 17:22:41 +07:00
1 parent 3404345410
commit 8acf004ad0
4 files changed
+26 -17

No files matched your search

+3 -3
View File
@@ -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),
}
+3 -10
View File
@@ -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
+1 -1
View File
@@ -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;
+19 -3
View File
@@ -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<Vec<u8>>) {
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::<Pipeline>()
.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)
}