Chaining connect_pad_added in gstreamer-rs

Guru Govindan gurunathan.govindan at
Tue Apr 4 00:38:39 UTC 2023

I am building a pipeline for an rtsp stream where there will be video and
an audio and data channel.
I connected the rtspsrc plugin to the stream and added a connect_pad_added
I detect if the received pad is an audio channel and then I add the audio
decoder and then add a connect_pad_added signal to it to receive the
`src_pad` for it which is dynamic.

For some reason the I receive the callback for the rtspsrc
`connect_pad_added`, but I dont receive the callback that I connect the
audio channel with.
Am I missing something?

I appreciate any help with this.
Here is a code snippet.


match gst::parse_launch(pipeline_str) {
    Ok(pipe_elem) => {
        let media_info = get_probe_info();

            // the elem object is a pipeline element object created
with parse_launch
            let pipeline = elem.downcast::<gst::Pipeline>().unwrap();
            let rtspsrc = match pipeline.by_name("basesrc") {
                Some(rtspsrc) => rtspsrc,
                None => {
                    log::error!("could not find audio_decoder");

            rtspsrc.connect_pad_added(move |src, src_pad| {
                let mut audio = false;
                match src_pad.current_caps() {
                    Some(caps) => {
                        let new_pad_struct =
caps.structure(0).expect("Failed to get first structure of caps for
                        for i in 0..new_pad_struct.n_fields() {
                            match new_pad_struct.nth_field_name(i).unwrap() {
                                "media" => {
                                    log::info!("media struct={:#?}",
                                    let media_type =
                                    let field_value =
                                    audio = field_value.starts_with("audio");
                                _ => {}
                    _ => {}
                if !audio {
                log::info!("it is an audio pad!!");
                let decoder = ElementFactory::make("decodebin", None).unwrap();


                let pipeline_weak = pipeline.downgrade();

                decoder.connect_pad_added(move |src, pad| {
                    log::info!("recieved connect_pad added signal!!");
                    if pad.direction() == gst::PadDirection::Src {
                        // received the src pad for the decoder!!
                        log::info!("GUGURURURU received decoder pad
from src!!!");

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the gstreamer-devel mailing list