/** * gst_rtp_buffer_get_extension_data: * @buffer: the buffer * @bits: location for result bits * @data: location for data * @wordlen: location for length of @data in 32 bits words * * Get the extension data. @bits will contain the extension 16 bits of custom * data. @data will point to the data in the extension and @wordlen will contain * the length of @data in 32 bits words. * * If @buffer did not contain an extension, this function will return %FALSE * with @bits, @data and @wordlen unchanged. * * Returns: TRUE if @buffer had the extension bit set. * * Since: 0.10.15 */ gboolean gst_rtp_buffer_get_extension_data (GstBuffer * buffer, guint16 * bits, gpointer * data, guint * wordlen) { guint len; guint8 *pdata; pdata = GST_BUFFER_DATA (buffer); if (!GST_RTP_HEADER_EXTENSION (pdata)) return FALSE; /* move to the extension */ len = GST_RTP_HEADER_LEN + GST_RTP_HEADER_CSRC_SIZE (pdata); pdata += len; if (bits) *bits = GST_READ_UINT16_BE (pdata); if (wordlen) *wordlen = GST_READ_UINT16_BE (pdata + 2); if (data) *data = pdata + 4; return TRUE; }
/** * gst_rtp_buffer_allocate_data: * @buffer: a #GstBuffer * @payload_len: the length of the payload * @pad_len: the amount of padding * @csrc_count: the number of CSRC entries * * Allocate enough data in @buffer to hold an RTP packet with @csrc_count CSRCs, * a payload length of @payload_len and padding of @pad_len. * MALLOCDATA of @buffer will be overwritten and will not be freed. * All other RTP header fields will be set to 0/FALSE. */ void gst_rtp_buffer_allocate_data (GstBuffer * buffer, guint payload_len, guint8 pad_len, guint8 csrc_count) { guint len; guint8 *data; g_return_if_fail (csrc_count <= 15); g_return_if_fail (GST_IS_BUFFER (buffer)); len = GST_RTP_HEADER_LEN + csrc_count * sizeof (guint32) + payload_len + pad_len; data = g_malloc (len); GST_BUFFER_MALLOCDATA (buffer) = data; GST_BUFFER_DATA (buffer) = data; GST_BUFFER_SIZE (buffer) = len; /* fill in defaults */ GST_RTP_HEADER_VERSION (data) = GST_RTP_VERSION; GST_RTP_HEADER_PADDING (data) = FALSE; GST_RTP_HEADER_EXTENSION (data) = FALSE; GST_RTP_HEADER_CSRC_COUNT (data) = csrc_count; memset (GST_RTP_HEADER_CSRC_LIST_OFFSET (data, 0), 0, csrc_count * sizeof (guint32)); GST_RTP_HEADER_MARKER (data) = FALSE; GST_RTP_HEADER_PAYLOAD_TYPE (data) = 0; GST_RTP_HEADER_SEQ (data) = 0; GST_RTP_HEADER_TIMESTAMP (data) = 0; GST_RTP_HEADER_SSRC (data) = 0; }
EXPORT_C #endif gboolean gst_rtp_buffer_get_extension_data (GstBuffer * buffer, guint16 * bits, gpointer * data, guint * wordlen) { guint len; guint8 *pdata; g_return_val_if_fail (GST_IS_BUFFER (buffer), FALSE); g_return_val_if_fail (GST_BUFFER_DATA (buffer) != NULL, FALSE); if (!GST_RTP_HEADER_EXTENSION (buffer)) return FALSE; /* move to the extension */ len = GST_RTP_HEADER_LEN + GST_RTP_HEADER_CSRC_SIZE (buffer); pdata = GST_BUFFER_DATA (buffer) + len; if (bits) *bits = GST_READ_UINT16_BE (pdata); if (wordlen) *wordlen = GST_READ_UINT16_BE (pdata + 2); if (data) *data = pdata + 4; return TRUE; }
EXPORT_C #endif void gst_rtp_buffer_set_extension (GstBuffer * buffer, gboolean extension) { GST_RTP_HEADER_EXTENSION (GST_BUFFER_DATA (buffer)) = extension; }
EXPORT_C #endif gboolean gst_rtp_buffer_get_extension (GstBuffer * buffer) { return GST_RTP_HEADER_EXTENSION (GST_BUFFER_DATA (buffer)); }
EXPORT_C #endif void gst_rtp_buffer_set_extension (GstBuffer * buffer, gboolean extension) { g_return_if_fail (GST_IS_BUFFER (buffer)); g_return_if_fail (GST_BUFFER_DATA (buffer) != NULL); GST_RTP_HEADER_EXTENSION (buffer) = extension; }
EXPORT_C #endif gboolean gst_rtp_buffer_get_extension (GstBuffer * buffer) { g_return_val_if_fail (GST_IS_BUFFER (buffer), FALSE); g_return_val_if_fail (GST_BUFFER_DATA (buffer) != NULL, FALSE); return GST_RTP_HEADER_EXTENSION (buffer); }
/** * gst_rtp_buffer_get_header_len: * @buffer: the buffer * * Return the total length of the header in @buffer. This include the length of * the fixed header, the CSRC list and the extension header. * * Returns: The total length of the header in @buffer. */ guint gst_rtp_buffer_get_header_len (GstBuffer * buffer) { guint len; guint8 *data; data = GST_BUFFER_DATA (buffer); len = GST_RTP_HEADER_LEN + GST_RTP_HEADER_CSRC_SIZE (data); if (GST_RTP_HEADER_EXTENSION (data)) len += GST_READ_UINT16_BE (data + len + 2) * 4 + 4; return len; }
EXPORT_C #endif guint gst_rtp_buffer_get_header_len (GstBuffer * buffer) { guint len; g_return_val_if_fail (GST_IS_BUFFER (buffer), 0); len = GST_RTP_HEADER_LEN + GST_RTP_HEADER_CSRC_SIZE (buffer); if (GST_RTP_HEADER_EXTENSION (buffer)) len += GST_READ_UINT16_BE (GST_BUFFER_DATA (buffer) + len + 2) * 4 + 4; return len; }