From 7536d96d7c0fcc5a56e8d99c53a3ff5ee05a91dd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Olivier=20Cr=C3=AAte?= Date: Mon, 23 Aug 2010 14:24:21 -0400 Subject: [PATCH] rtpbuffer: Add function to transform a GstBuffer into a GstBufferList Add a new function called gst_rtp_buffer_list_from_buffer() that takes a GstBuffer containing a RTP packets and spits out a GstBufferList containing two buffers, one with the header and the other with the payload. --- docs/libs/gst-plugins-base-libs-sections.txt | 1 + gst-libs/gst/rtp/gstrtpbuffer.c | 35 ++++++++++++++++++++++++++++ gst-libs/gst/rtp/gstrtpbuffer.h | 3 +++ 3 files changed, 39 insertions(+) diff --git a/docs/libs/gst-plugins-base-libs-sections.txt b/docs/libs/gst-plugins-base-libs-sections.txt index ccd57a5..d8c50f1 100644 --- a/docs/libs/gst-plugins-base-libs-sections.txt +++ b/docs/libs/gst-plugins-base-libs-sections.txt @@ -1288,6 +1288,7 @@ gst_rtp_buffer_new_take_data gst_rtp_buffer_new_copy_data gst_rtp_buffer_new_allocate gst_rtp_buffer_new_allocate_len +gst_rtp_buffer_list_from_buffer gst_rtp_buffer_calc_header_len gst_rtp_buffer_calc_packet_len diff --git a/gst-libs/gst/rtp/gstrtpbuffer.c b/gst-libs/gst/rtp/gstrtpbuffer.c index b470730..68fc67a 100644 --- a/gst-libs/gst/rtp/gstrtpbuffer.c +++ b/gst-libs/gst/rtp/gstrtpbuffer.c @@ -2022,3 +2022,38 @@ gst_rtp_buffer_list_add_extension_twobytes_header (GstBufferListIterator * it, return retval; } + +/** + * gst_rtp_buffer_list_from_buffer: + * @buffer: a #GstBuffer containing a RTP packet + * + * Splits a #GstBuffer into a #GstBufferList containing separate + * buffers for the header and data sections. + * + * Returns: a #GstBufferList + */ + +GstBufferList * +gst_rtp_buffer_list_from_buffer (GstBuffer * buffer) +{ + GstBufferList *bufferlist; + GstBuffer *sub; + GstBufferListIterator *it; + guint8 *payload; + + bufferlist = gst_buffer_list_new (); + + it = gst_buffer_list_iterate (bufferlist); + gst_buffer_list_iterator_add_group (it); + + payload = gst_rtp_buffer_get_payload (buffer); + sub = gst_buffer_create_sub (buffer, 0, payload - GST_BUFFER_DATA (buffer)); + gst_buffer_list_iterator_add (it, sub); + + sub = gst_rtp_buffer_get_payload_buffer (buffer); + gst_buffer_list_iterator_add (it, sub); + + gst_buffer_list_iterator_free (it); + + return bufferlist; +} diff --git a/gst-libs/gst/rtp/gstrtpbuffer.h b/gst-libs/gst/rtp/gstrtpbuffer.h index 064a908..c82fd71 100644 --- a/gst-libs/gst/rtp/gstrtpbuffer.h +++ b/gst-libs/gst/rtp/gstrtpbuffer.h @@ -45,6 +45,9 @@ GstBuffer* gst_rtp_buffer_new_copy_data (gpointer data, guint len); GstBuffer* gst_rtp_buffer_new_allocate (guint payload_len, guint8 pad_len, guint8 csrc_count); GstBuffer* gst_rtp_buffer_new_allocate_len (guint packet_len, guint8 pad_len, guint8 csrc_count); +GstBufferList* gst_rtp_buffer_list_from_buffer (GstBuffer * buffer); + + guint gst_rtp_buffer_calc_header_len (guint8 csrc_count); guint gst_rtp_buffer_calc_packet_len (guint payload_len, guint8 pad_len, guint8 csrc_count); guint gst_rtp_buffer_calc_payload_len (guint packet_len, guint8 pad_len, guint8 csrc_count); -- 2.7.4