From 41c003ab00e0d98af89ef5a14f7a51bfcd8dcdf6 Mon Sep 17 00:00:00 2001 From: Dave Patrick Caberto Date: Wed, 6 Mar 2024 17:01:29 +0800 Subject: [PATCH] refactor(pipeline): use more general fn name --- src/area_selector/mod.rs | 2 +- src/pipeline.rs | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/area_selector/mod.rs b/src/area_selector/mod.rs index b0e4bb64..ffd03721 100644 --- a/src/area_selector/mod.rs +++ b/src/area_selector/mod.rs @@ -220,7 +220,7 @@ impl AreaSelector { let pipeline = gst::Pipeline::new(); imp.pipeline.set(pipeline.clone()).unwrap(); - let videosrc_bin = pipeline::make_pipewiresrc_bin(fd, streams, PREVIEW_FRAMERATE)?; + let videosrc_bin = pipeline::make_videosrc_bin(fd, streams, PREVIEW_FRAMERATE)?; let gtksink = gst::ElementFactory::make("gtk4paintablesink").build()?; let paintable = gtksink.property::("paintable"); diff --git a/src/pipeline.rs b/src/pipeline.rs index e6f49232..edc1760d 100644 --- a/src/pipeline.rs +++ b/src/pipeline.rs @@ -87,7 +87,7 @@ impl PipelineBuilder { let pipeline = gst::Pipeline::new(); - let videosrc_bin = make_pipewiresrc_bin(self.fd, &self.streams, self.framerate) + let videosrc_bin = make_videosrc_bin(self.fd, &self.streams, self.framerate) .context("Failed to create videosrc bin")?; let videoenc_queue = gst::ElementFactory::make("queue") .name("kooha-videoenc-queue") @@ -130,7 +130,7 @@ impl PipelineBuilder { self.record_microphone .then(|| make_pulsesrc(DeviceClass::Source, "kooha-microphone-src")), ]; - let audiosrc_bin = make_pulsesrc_bin( + let audiosrc_bin = make_audiosrc_bin( &pulsesrcs .into_iter() .flatten() @@ -259,11 +259,7 @@ fn make_videocrop(data: &SelectAreaData) -> Result { /// pipewiresrc2 -> videoflip -> | -> compositor -> videorate /// | /// pipewiresrcn -> videoflip -> | -pub fn make_pipewiresrc_bin( - fd: RawFd, - streams: &[Stream], - framerate: Framerate, -) -> Result { +pub fn make_videosrc_bin(fd: RawFd, streams: &[Stream], framerate: Framerate) -> Result { let bin = gst::Bin::builder().name("kooha-pipewiresrc-bin").build(); let videorate = gst::ElementFactory::make("videorate") @@ -368,7 +364,7 @@ fn make_pulsesrc(class: DeviceClass, element_name: &str) -> Result /// pulsesrc2 -> audiorate -> | -> audiomixer /// | /// pulsesrcn -> audiorate -> | -fn make_pulsesrc_bin<'a>( +fn make_audiosrc_bin<'a>( pulsesrcs: impl IntoIterator, ) -> Result { let bin = gst::Bin::builder().name("kooha-pulsesrc-bin").build();