GstRtpBuffer and GstBaseTransform Filter

Mandar Joshi emailmandar at gmail.com
Fri Oct 13 13:20:07 UTC 2017


Hello everyone,
I would like to write an element that adds
gst_rtp_buffer_add_extension_onebyte_header to GstRtpBuffer.

I am able to add a 4 byte data in a GstBaseTransform element and
receive it over RTSP using the following pipelines

------------------------------------------------------------------------------------------------------------
./test-launch "( audiotestsrc ! audioconvert ! opusenc !
mywriteelement ! rtpopuspay name=pay0  )"

gst-launch-1.0 rtspsrc location=rtsp://127.0.0.1:8554/test !
rtpopusdepay ! myreadelement !  fakesink
-------------------------------------------------------------------------------------------------------------

For this, I am using the following in the transform function:


static GstFlowReturn gst_youraydio_identity_transform
(GstBaseTransform * trans, GstBuffer * in, GstBuffer *out) {
  GstMyWriteElement *filter = ...

  GstMapInfo map;

  if (gst_buffer_map (in, &map, GST_MAP_READ) == FALSE) {
    g_print ("gst_buffer_map failed\n");
    return GST_BASE_TRANSFORM_FLOW_DROPPED;
  }

  gst_buffer_fill(out, 0, map.data, map.size);
  gst_buffer_unmap (in, &map);

  gst_rtp_buffer_allocate_data (out, 4, 0, 0);
  guint8 misc_data[4] = { 1, 2, 3, 4 };
  GstRTPBuffer rtp = { NULL, };
  guint16 bits;
  guint size;
  gpointer pointer;
  gst_rtp_buffer_map (out, GST_MAP_READWRITE, &rtp);
  gst_rtp_buffer_add_extension_onebyte_header (&rtp, 5, misc_data, 4);
  gst_rtp_buffer_get_extension_onebyte_header (&rtp, 5, 0, &pointer, &size);
  guint8 *data = (guint8 *) pointer;
  printf ("Size: %d Data: %d %d %d %d\n", size, data[0], data[1],
data[2], data[3]);
  gst_rtp_buffer_unmap (&rtp);

  return GST_FLOW_OK;
}
------------------------------------------------------------------------------------------------------------

With the above code, I am able to receive the data added using
onbyte_header but the audio doesn't go through. I guess the problem
lies in my usage of gst_rtp_buffer_allocate_data which according to
the docs [1] says  "all previous memory in buffer will be freed". So,
if this is the case, how do I preserve data in the GstBuffer and add
custom data to GstRtpBuffer.
----------------------------------------------------------------------------------------------------------

I read ndufresne's post here
http://gstreamer-devel.966125.n4.nabble.com/streaming-video-metadata-td4669761.html
where he has used a pad probe. I can't use that approach because I
want to use a gst-rtsp-server factory to stream data. So, I would like
to write an element.gst

Any possible solutions?

Regards
Mandar Joshi

[1] https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-libs/html/gst-plugins-base-libs-GstRTPBuffer.html#gst-rtp-buffer-allocate-data


More information about the gstreamer-devel mailing list