Hello! I’m trying to create a module that handles RTP packets from an external (custom) network and processes them with GStreamer. Currently, I’m having trouble building such a pipeline. If I manually strip the RTP header and pass the payload to aacparse
, then to avdec
, and so on, it works as expected (ignoring issues caused by out-of-order packets).
However, if I try to push the raw RTP packets and use rtpjitterbuffer
and rtpmp4gdepay
as the first elements, I get a negotiation error. I suspect there’s something wrong with my caps. Here’s the pipeline creation code:
Pipeline's creation
fn runpipeline(...) -> Result<..., Box<dyn Error>> {
let pipeline = Pipeline::default();
// Works if headers stripped
// let caps = Caps::builder("audio/mpeg")
// .field("mpegversion", 4i32)
// .field("stream-format", "raw")
// .field("channels", 2i32)
// .field("rate", 44100i32)
// .field("codec_data", Buffer::from_slice([0x12, 0x10]))
// .build();
let caps = Caps::builder("application/x-rtp")
.field("media", "audio")
.field("clock-rate", 44100i32)
.field("payload", 96i32)
.field("encoding-name", "MPEG4-GENERIC")
.field("channels", 2i32)
.field("config", Buffer::from_slice([0x12, 0x10]))
.build();
let appsrc = AppSrc::builder()
.caps(&caps)
.format(Format::Time)
.is_live(true)
.do_timestamp(true)
.build();
let jitterbuffer = ElementFactory::make("rtpjitterbuffer").build()?;
let depay = ElementFactory::make("rtpmp4gdepay").build()?;
let parse = ElementFactory::make("aacparse").build()?;
let decode = ElementFactory::make("avdec_aac").build()?;
let convert = ElementFactory::make("audioconvert").build()?;
let resample = ElementFactory::make("audioresample").build()?;
let wavenc = ElementFactory::make("wavenc").build()?;
let sink = ElementFactory::make("filesink")
.property("location", format!("audio_{id}.wav"))
.build()?;
pipeline.add_many([
appsrc.upcast_ref(),
&jitterbuffer,
&depay,
&parse,
&decode,
&convert,
&resample,
&wavenc,
&sink,
])?;
Element::link_many([
appsrc.upcast_ref(),
&jitterbuffer,
&depay,
&parse,
&decode,
&convert,
&resample,
&wavenc,
&sink,
])?;
...
}