gstreamer-rs: how to find elements in a pipeline?

Sebastian Dröge sebastian at centricular.com
Wed Sep 21 07:49:49 UTC 2022


On Mon, 2022-09-19 at 13:42 +0100, Tim-Philipp Müller via gstreamer-devel wrote:
> Hi,
> 
> > I am currently using the rust implementation of the gstreamer
> > interface (gstreamer-rs) and I am wondering why I can not find a way
> > to the get elements in an existing pipeline.
> > 
> > I am using gstreamer::parse_launch() to start a pipeline from a
> > string description because I find it much more clearer to give the
> > pipeline in string form compared to use the element creators which
> > gstreamer-rs provides.
> > 
> > In python I could use the pipeline.get_by_name() function but this
> > one seems to be missing in gstreamer-rs and pipeline does not seem to
> > behave like a Bin in kind of giving access to it's elements.
> > 
> > Here is an example code which I would expect to be able to use:
> > 
> > --
> > gstreamer::parse_launch("videotestsrc name=test_src !
> > autovideosink",true);
> > 
> > let testsrc = gstreamer::get_by_name("test_src").unwrap;
> > --
> > 
> > But get_by_name is not provided. Is anyone able to give me a hint on
> > how to do this?
> 
> Try something like:
> 
>    let pipeline = gstreamer::parse_launch("...")
>       .expect("Error creating pipeline");
>       
>    let testsrc = pipeline.by_name("test_src").unwrap();

To add to this answer, you can search for the C function names in the
gstreamer-rs documentation, e.g.:
  https://gstreamer.pages.freedesktop.org/gstreamer-rs/stable/latest/docs/?search=gst_bin_get_by_name

The "get" part of the function is omitted because in Rust plain getters
usually don't have the prefix. See
  https://rust-lang.github.io/api-guidelines/naming.html#getter-names-follow-rust-convention-c-getter

-- 
Sebastian Dröge, Centricular Ltd · https://www.centricular.com


More information about the gstreamer-devel mailing list