From 4aac973ecfb9533f451a821437f47608941025b1 Mon Sep 17 00:00:00 2001 From: Andrew Eikum Date: Mon, 11 Oct 2021 13:02:23 -0500 Subject: [PATCH] media-converter: Add an option to disable dumping audio to disk CW-Bug-Id: #19009 --- media-converter/src/audioconv.rs | 46 ++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/media-converter/src/audioconv.rs b/media-converter/src/audioconv.rs index cfe2a555..5d5ec232 100644 --- a/media-converter/src/audioconv.rs +++ b/media-converter/src/audioconv.rs @@ -204,6 +204,14 @@ static DUMP_FOZDB: Lazy>> = Lazy::new(|| } }); +static DUMPING_DISABLED: Lazy = Lazy::new(|| { + let v = match std::env::var("MEDIACONV_AUDIO_DONT_DUMP") { + Err(_) => { return false; }, + Ok(c) => c, + }; + return v != "0"; +}); + #[derive(Clone)] struct NeedTranscodeHead { wmaversion: i32, @@ -368,25 +376,29 @@ impl StreamState { } if !found { - gst_trace!(CAT, "recording stream id {}", self.cur_hash); - db.write_entry(AUDIOCONV_FOZ_TAG_CODECINFO, - self.buffers[0].0, - &mut self.codec_info.as_ref().unwrap().serialize().as_slice(), - fossilize::CRCCheck::WithCRC) - .map_err(|e| gst_loggable_error!(CAT, "Unable to write stream header: {:?}", e))?; + if *DUMPING_DISABLED { + gst_trace!(CAT, "dumping disabled, so not recording stream id {}", self.cur_hash); + } else { + gst_trace!(CAT, "recording stream id {}", self.cur_hash); + db.write_entry(AUDIOCONV_FOZ_TAG_CODECINFO, + self.buffers[0].0, + &mut self.codec_info.as_ref().unwrap().serialize().as_slice(), + fossilize::CRCCheck::WithCRC) + .map_err(|e| gst_loggable_error!(CAT, "Unable to write stream header: {:?}", e))?; - db.write_entry(AUDIOCONV_FOZ_TAG_STREAM, - self.cur_hash, - &mut StreamStateSerializer::new(self), - fossilize::CRCCheck::WithCRC) - .map_err(|e| gst_loggable_error!(CAT, "Unable to write stream: {:?}", e))?; + db.write_entry(AUDIOCONV_FOZ_TAG_STREAM, + self.cur_hash, + &mut StreamStateSerializer::new(self), + fossilize::CRCCheck::WithCRC) + .map_err(|e| gst_loggable_error!(CAT, "Unable to write stream: {:?}", e))?; - for buffer in self.buffers.iter() { - db.write_entry(AUDIOCONV_FOZ_TAG_AUDIODATA, - buffer.0, - &mut buffer.1.as_slice(), - fossilize::CRCCheck::WithCRC) - .map_err(|e| gst_loggable_error!(CAT, "Unable to write audio data: {:?}", e))?; + for buffer in self.buffers.iter() { + db.write_entry(AUDIOCONV_FOZ_TAG_AUDIODATA, + buffer.0, + &mut buffer.1.as_slice(), + fossilize::CRCCheck::WithCRC) + .map_err(|e| gst_loggable_error!(CAT, "Unable to write audio data: {:?}", e))?; + } } } }