Unify mic and file input source in talk

Update talk sources to use new input format
Quick fix to input sources
This commit is contained in:
Andrew King authored and Andrew committed 2021-08-07 16:05:32 +07:00
1 parent 8b6cc4be7a
commit 5ca8eae8f4
2 files changed
+5 -20

No files matched your search

+2 -17
View File
@@ -8,26 +8,11 @@ use std::sync::mpsc::{sync_channel, Receiver, SyncSender};
use super::errors::Error; use super::errors::Error;
use byte_slice_cast::*; use byte_slice_cast::*;
pub(super) fn file_input( pub(super) fn from_input(
filename: &str, input_src: &str,
volume: f32, volume: f32,
block_align: u16, block_align: u16,
sample_rate: u16, sample_rate: u16,
) -> Result<Receiver<Vec<u8>>, Error> {
let pipeline = create_pipeline(
&format!("filesrc location={}", filename),
volume,
block_align,
sample_rate,
)?;
input(pipeline)
}
pub(super) fn mic_input(
volume: f32,
block_align: u16,
sample_rate: u16,
input_src:&str,
) -> Result<Receiver<Vec<u8>>, Error> { ) -> Result<Receiver<Vec<u8>>, Error> {
let pipeline = create_pipeline(input_src, volume, block_align, sample_rate)?; let pipeline = create_pipeline(input_src, volume, block_align, sample_rate)?;
input(pipeline) input(pipeline)
+3 -3
View File
@@ -79,13 +79,13 @@ pub fn main(opt: Opt) -> Result<(), Error> {
} }
let rx = match (&opt.file_path, &opt.microphone) { let rx = match (&opt.file_path, &opt.microphone) {
(Some(path), false) => gst::file_input( (Some(path), false) => gst::from_input(
path.to_str().expect("File path not UTF8 complient"), &format!("filesrc location={}", path.to_str().expect("File path not UTF8 complient")),
opt.volume, opt.volume,
block_size, block_size,
sample_rate, sample_rate,
)?, )?,
(None, true) => gst::mic_input(opt.volume, block_size, sample_rate, &opt.input_src)?, (None, true) => gst::from_input(&opt.input_src, opt.volume, block_size, sample_rate)?,
_ => unreachable!(), _ => unreachable!(),
}; };