I've attempted to create a pipeline for receiving RTP video/audio streams via Gstreamer using the gstreamer-rs crate, but I am not having much luck. Here is a quick distillation of my approach:
let udp_src = ElementFactory::make("udpsrc", Some("udp_src"))?;
udp_src.set_property("port", &5004);
udp_src.set_property("caps", &"application/x-rtp".to_string());
let rtpbin = ElementFactory::make("rtpbin", Some("rtp_bin"))?;
let pipeline = Pipeline::new(Some("RTP Pipeline"));
pipeline.add_many(&[&udp_src, &rtpbin]);
udp_src.link(&rtpbin)?;
rtpbin.connect_pad_added(move |src, src_pad| {
println!("Received new pad {} from {}", src_pad.get_name(), src.get_name());
let new_pad_caps = src_pad.get_current_caps().expect("Failed to get caps of new pad");
let new_pad_struct = new_pad_caps.get_structure(0).expect("Failed to get first structure of caps");
let new_pad_type = new_pad_struct.get_name();
println!("{}", new_pad_type);
});
But I'm not getting anything from the connect_pad_added when I run the code and send UDP signals to the specified port. I'm not even sure if this is the right approach, and would appreciate any directions on where to find examples or pointers on how to use rtpbin with udpsrc.