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.
This commit is contained in:
Olivier Crête 2010-08-26 12:34:11 -04:00 committed by Wim Taymans
parent 96aa439867
commit 582417e031
3 changed files with 93 additions and 0 deletions

View 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

View 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;
}

View 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);