Chaining connect_pad_added in gstreamer-rs
Guru Govindan
gurunathan.govindan at gmail.com
Tue Apr 4 00:38:39 UTC 2023
Hi,
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
signal.
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) => {
set_pipeline_elem(Some(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");
return;
}
};
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
audio");
for i in 0..new_pad_struct.n_fields() {
match new_pad_struct.nth_field_name(i).unwrap() {
"media" => {
log::info!("media struct={:#?}",
new_pad_struct);
let media_type =
new_pad_struct.value("media").unwrap();
let field_value =
media_type.get::<&str>().unwrap();
audio = field_value.starts_with("audio");
break;
}
_ => {}
}
}
}
_ => {}
}
if !audio {
return;
}
log::info!("it is an audio pad!!");
let decoder = ElementFactory::make("decodebin", None).unwrap();
pipeline.add(&decoder).unwrap();
src_pad.link(&decoder.static_pad("sink").unwrap()).unwrap();
log::info!("linked rtspsrc.audio->decoder.sink!!");
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: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20230403/959464b4/attachment.htm>
More information about the gstreamer-devel
mailing list