From: Olivier CrĂȘte Date: Thu, 26 Aug 2010 16:34:11 +0000 (-0400) Subject: rtcpbuffer: Add function to manipulation the data in RTCP feedback packets X-Git-Tag: RELEASE-0.10.31~121 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=582417e0319506be2c0722a1f555b5f523773f5a;p=platform%2Fupstream%2Fgst-plugins-base.git rtcpbuffer: Add function to manipulation the data in RTCP feedback packets Add methods to get/set the length of the Feedback Control Information (FCI) as well as getting a pointer to the FCI itself. --- diff --git a/docs/libs/gst-plugins-base-libs-sections.txt b/docs/libs/gst-plugins-base-libs-sections.txt index d8c50f1..44b2ec7 100644 --- a/docs/libs/gst-plugins-base-libs-sections.txt +++ b/docs/libs/gst-plugins-base-libs-sections.txt @@ -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 diff --git a/gst-libs/gst/rtp/gstrtcpbuffer.c b/gst-libs/gst/rtp/gstrtcpbuffer.c index 9177b39..096f79e 100644 --- a/gst-libs/gst/rtp/gstrtcpbuffer.c +++ b/gst-libs/gst/rtp/gstrtcpbuffer.c @@ -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; +} diff --git a/gst-libs/gst/rtp/gstrtcpbuffer.h b/gst-libs/gst/rtp/gstrtcpbuffer.h index b051571..6f57fad 100644 --- a/gst-libs/gst/rtp/gstrtcpbuffer.h +++ b/gst-libs/gst/rtp/gstrtcpbuffer.h @@ -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);