rtcpbuffer: Add function to manipulation the data in RTCP feedback packets
authorOlivier CrĂȘte <olivier.crete@collabora.co.uk>
Thu, 26 Aug 2010 16:34:11 +0000 (12:34 -0400)
committerWim Taymans <wim.taymans@collabora.co.uk>
Tue, 5 Oct 2010 14:19:14 +0000 (16:19 +0200)
Add methods to get/set the length of the Feedback Control Information (FCI) as
well as getting a pointer to the FCI itself.

docs/libs/gst-plugins-base-libs-sections.txt
gst-libs/gst/rtp/gstrtcpbuffer.c
gst-libs/gst/rtp/gstrtcpbuffer.h

index d8c50f1..44b2ec7 100644 (file)
@@ -1218,6 +1218,10 @@ gst_rtcp_packet_fb_set_sender_ssrc
 gst_rtcp_packet_fb_get_media_ssrc
 gst_rtcp_packet_fb_set_media_ssrc
 
+gst_rtcp_packet_fb_get_fci_length
+gst_rtcp_packet_fb_set_fci_length
+gst_rtcp_packet_fb_get_fci
+
 gst_rtcp_ntp_to_unix
 gst_rtcp_unix_to_ntp
 
index 9177b39..096f79e 100644 (file)
@@ -1943,3 +1943,89 @@ gst_rtcp_sdes_name_to_type (const gchar * name)
 
   return GST_RTCP_SDES_PRIV;
 }
+
+/**
+ * gst_rtcp_packet_fb_get_fci_length:
+ * @packet: a valid RTPFB or PSFB #GstRTCPPacket
+ *
+ * Get the length of the Feedback Control Information attached to a
+ * RTPFB or PSFB @packet.
+ *
+ * Returns: The length of the FCI in 32-bit words.
+ *
+ * Since: 0.10.31
+ */
+guint16
+gst_rtcp_packet_fb_get_fci_length (GstRTCPPacket * packet)
+{
+  guint8 *data;
+
+  g_return_val_if_fail (packet != NULL, 0);
+  g_return_val_if_fail (packet->type == GST_RTCP_TYPE_RTPFB ||
+      packet->type == GST_RTCP_TYPE_PSFB, 0);
+  g_return_val_if_fail (GST_IS_BUFFER (packet->buffer), 0);
+
+  data = GST_BUFFER_DATA (packet->buffer) + packet->offset + 2;
+
+  return GST_READ_UINT16_BE (data) - 2;
+}
+
+/**
+ * gst_rtcp_packet_fb_set_fci_length:
+ * @packet: a valid RTPFB or PSFB #GstRTCPPacket
+ * @wordlen: Length of the FCI in 32-bit words
+ *
+ * Set the length of the Feedback Control Information attached to a
+ * RTPFB or PSFB @packet.
+ *
+ * Returns: %TRUE if there was enough space in the packet to add this much FCI
+ *
+ * Since: 0.10.31
+ */
+gboolean
+gst_rtcp_packet_fb_set_fci_length (GstRTCPPacket * packet, guint16 wordlen)
+{
+  guint8 *data;
+
+  g_return_val_if_fail (packet != NULL, FALSE);
+  g_return_val_if_fail (packet->type == GST_RTCP_TYPE_RTPFB ||
+      packet->type == GST_RTCP_TYPE_PSFB, FALSE);
+  g_return_val_if_fail (GST_IS_BUFFER (packet->buffer), FALSE);
+
+  if (GST_BUFFER_SIZE (packet->buffer) < packet->offset + ((wordlen + 3) * 4))
+    return FALSE;
+
+  data = GST_BUFFER_DATA (packet->buffer) + packet->offset + 2;
+  wordlen += 2;
+  GST_WRITE_UINT16_BE (data, wordlen);
+
+  return TRUE;
+}
+
+/**
+ * gst_rtcp_packet_fb_get_fci:
+ * @packet: a valid RTPFB or PSFB #GstRTCPPacket
+ *
+ * Get the Feedback Control Information attached to a RTPFB or PSFB @packet.
+ *
+ * Returns: a pointer to the FCI
+ *
+ * Since: 0.10.31
+ */
+guint8 *
+gst_rtcp_packet_fb_get_fci (GstRTCPPacket * packet)
+{
+  guint8 *data;
+
+  g_return_val_if_fail (packet != NULL, NULL);
+  g_return_val_if_fail (packet->type == GST_RTCP_TYPE_RTPFB ||
+      packet->type == GST_RTCP_TYPE_PSFB, NULL);
+  g_return_val_if_fail (GST_IS_BUFFER (packet->buffer), NULL);
+
+  data = GST_BUFFER_DATA (packet->buffer) + packet->offset;
+
+  if (GST_READ_UINT16_BE (data + 2) <= 2)
+    return NULL;
+
+  return data + 12;
+}
index b051571..6f57fad 100644 (file)
@@ -269,6 +269,9 @@ guint32         gst_rtcp_packet_fb_get_media_ssrc     (GstRTCPPacket *packet);
 void            gst_rtcp_packet_fb_set_media_ssrc     (GstRTCPPacket *packet, guint32 ssrc);
 GstRTCPFBType   gst_rtcp_packet_fb_get_type           (GstRTCPPacket *packet);
 void            gst_rtcp_packet_fb_set_type           (GstRTCPPacket *packet, GstRTCPFBType type);
+guint16         gst_rtcp_packet_fb_get_fci_length     (GstRTCPPacket *packet);
+gboolean        gst_rtcp_packet_fb_set_fci_length     (GstRTCPPacket *packet, guint16 wordlen);
+guint8 *        gst_rtcp_packet_fb_get_fci            (GstRTCPPacket *packet);
 
 /* helper functions */
 guint64         gst_rtcp_ntp_to_unix                  (guint64 ntptime);