Not able to create in place RTP plugin which add extra info to extension
Hi,
I have a simple rtp filter plugin (rtpcustom)
with 'application/x-rtp' caps on sink and source. The whole purpose of this plugin is to add some data to the extension.
As sink and source caps are the same, I am using transform_ip (overriding BaseTransform).
Below is transform_ip :
impl BaseTransformImpl for RtpCustom {
const MODE: gst_base::subclass::BaseTransformMode =
gst_base::subclass::BaseTransformMode::AlwaysInPlace;
const PASSTHROUGH_ON_SAME_CAPS: bool = false;
const TRANSFORM_IP_ON_PASSTHROUGH: bool = false;
fn transform_ip(&self, element: &Self::Type, buf: &mut gst::BufferRef) -> Result<gst::FlowSuccess, gst::FlowError> {
let mut new_buf = unsafe {gst::Buffer::from_glib_full(buf.as_mut_ptr())};
if (new_buf.is_writable()) {
let mut rtp_buffer = RTPBuffer::from_buffer_writable(&mut new_buf).unwrap();
let had_extension = rtp_buffer.is_extension();
let extension_data: [u8; 4] = [100, 101, 102, 103];
rtp_buffer.add_extension_onebyte_header(1, &extension_data).map_err(|_| {
gst::element_error!(element,
gst::ResourceError::Read,
["Add extension one byte failed"]
);
gst::FlowError::Error
});
gst_debug!(
CAT,
obj: element,
"Wrote to copy for buf {} : {} : {:?}", had_extension, rtp_buffer.is_extension(), rtp_buffer
);
}
Ok(gst::FlowSuccess::Ok)
}
}
When i run pipeline GST_DEBUG="rtpt:7" gst-launch-1.0 rtspsrc location="rtsp://127.0.0.1:8090/stream" ! rtpcustom ! decodebin ! autovideosink
I get the following error
(gst-launch-1.0:57976): GStreamer-CRITICAL **: 16:34:36.512: gst_pad_push: assertion 'GST_IS_BUFFER (buffer)' failed
ERROR: from element /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstUDPSrc:udpsrc0: Internal data stream error.
I also tried
let mut new_buf = unsafe {gst::Buffer::from_glib_none(buf.as_mut_ptr())};
But in this case, buffer is not writable.