From 04bf6e95d7b5705bed6ba152f3a307f21f05f69f Mon Sep 17 00:00:00 2001 From: Dave Patrick Caberto Date: Mon, 22 Jul 2024 20:12:40 +0800 Subject: [PATCH] remove videoflip --- src/pipeline.rs | 43 +++++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/src/pipeline.rs b/src/pipeline.rs index 22557890..0a20d5b5 100644 --- a/src/pipeline.rs +++ b/src/pipeline.rs @@ -176,14 +176,6 @@ fn make_pipewiresrc(fd: RawFd, path: &str) -> Result { Ok(src) } -fn make_videoflip() -> Result { - let videoflip = gst::ElementFactory::make("videoflip") - .property_from_str("video-direction", "auto") - .build()?; - - Ok(videoflip) -} - /// Create a videocrop element that computes the crop from the given coordinates /// and size. fn make_videocrop(data: &SelectAreaData) -> Result { @@ -247,15 +239,15 @@ fn make_videocrop(data: &SelectAreaData) -> Result { /// /// Single stream: /// -/// pipewiresrc -> videoflip -> videorate +/// pipewiresrc -> videorate /// /// Multiple streams: /// -/// pipewiresrc1 -> videoflip -> | -/// | -/// pipewiresrc2 -> videoflip -> | -> compositor -> videorate -/// | -/// pipewiresrcn -> videoflip -> | +/// pipewiresrc1 -> | +/// | +/// pipewiresrc2 -> | -> compositor -> videorate +/// | +/// pipewiresrcn -> | pub fn make_videosrc_bin( fd: RawFd, streams: &[Stream], @@ -283,9 +275,8 @@ pub fn make_videosrc_bin( [] => bail!("No streams provided"), [stream] => { let pipewiresrc = make_pipewiresrc(fd, &stream.node_id().to_string())?; - let videoflip = make_videoflip()?; - bin.add_many([&pipewiresrc, &videoflip])?; - gst::Element::link_many([&pipewiresrc, &videoflip, &videorate])?; + bin.add(&pipewiresrc)?; + pipewiresrc.link(&videorate)?; } streams => { let compositor = gst::ElementFactory::make("compositor").build()?; @@ -295,18 +286,22 @@ pub fn make_videosrc_bin( let mut last_pos = 0; for stream in streams { let pipewiresrc = make_pipewiresrc(fd, &stream.node_id().to_string())?; - let videoflip = make_videoflip()?; - bin.add_many([&pipewiresrc, &videoflip])?; - pipewiresrc.link_filtered( - &videoflip, - &optional_dmabuf_feature_caps(gst::Structure::builder("video/x-raw").build()), - )?; + let pipewiresrc_capsfilter = gst::ElementFactory::make("capsfilter") + .property( + "caps", + &optional_dmabuf_feature_caps( + gst::Structure::builder("video/x-raw").build(), + ), + ) + .build()?; + bin.add_many([&pipewiresrc, &pipewiresrc_capsfilter])?; + pipewiresrc.link(&pipewiresrc_capsfilter)?; let compositor_sink_pad = compositor .request_pad_simple("sink_%u") .context("Failed to request sink_%u pad from compositor")?; compositor_sink_pad.set_property("xpos", last_pos); - videoflip + pipewiresrc_capsfilter .static_pad("src") .unwrap() .link(&compositor_sink_pad)?;