Commit 86edcadc authored by Johann Prieur's avatar Johann Prieur Committed by Wim Taymans
Browse files

RTCP: add beginnings of Feedback messages

Add the beginnings of parsing and constructing Feedback messages.
Fixes #577610.
parent 5eed96dc
...@@ -1015,6 +1015,7 @@ GST_RTCP_VALID_VALUE ...@@ -1015,6 +1015,7 @@ GST_RTCP_VALID_VALUE
GstRTCPType GstRTCPType
GstRTCPPacket GstRTCPPacket
GstRTCPSDESType GstRTCPSDESType
GstRTCPFBType
gst_rtcp_buffer_new_take_data gst_rtcp_buffer_new_take_data
gst_rtcp_buffer_new_copy_data gst_rtcp_buffer_new_copy_data
...@@ -1068,6 +1069,15 @@ gst_rtcp_packet_bye_get_reason_len ...@@ -1068,6 +1069,15 @@ gst_rtcp_packet_bye_get_reason_len
gst_rtcp_packet_bye_get_reason gst_rtcp_packet_bye_get_reason
gst_rtcp_packet_bye_set_reason gst_rtcp_packet_bye_set_reason
gst_rtcp_packet_fb_get_type
gst_rtcp_packet_fb_set_type
gst_rtcp_packet_fb_get_sender_ssrc
gst_rtcp_packet_fb_set_sender_ssrc
gst_rtcp_packet_fb_get_media_ssrc
gst_rtcp_packet_fb_set_media_ssrc
gst_rtcp_ntp_to_unix gst_rtcp_ntp_to_unix
gst_rtcp_unix_to_ntp gst_rtcp_unix_to_ntp
......
...@@ -449,6 +449,11 @@ gst_rtcp_buffer_add_packet (GstBuffer * buffer, GstRTCPType type, ...@@ -449,6 +449,11 @@ gst_rtcp_buffer_add_packet (GstBuffer * buffer, GstRTCPType type,
case GST_RTCP_TYPE_APP: case GST_RTCP_TYPE_APP:
len = 12; len = 12;
break; break;
case GST_RTCP_TYPE_RTPFB:
len = 12;
break;
case GST_RTCP_TYPE_PSFB:
len = 12;
default: default:
goto unknown_type; goto unknown_type;
} }
...@@ -1636,6 +1641,163 @@ no_space: ...@@ -1636,6 +1641,163 @@ no_space:
} }
} }
/**
* gst_rtcp_packet_fb_get_sender_ssrc:
* @packet: a valid RTPFB or PSFB #GstRTCPPacket
*
* Get the sender SSRC field of the RTPFB or PSFB @packet.
*
* Returns: the sender SSRC.
*
* Since: 0.10.23
*/
guint32
gst_rtcp_packet_fb_get_sender_ssrc (GstRTCPPacket * packet)
{
guint8 *data;
guint32 ssrc;
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);
/* skip header */
data += packet->offset + 4;
ssrc = GST_READ_UINT32_BE (data);
return ssrc;
}
/**
* gst_rtcp_packet_fb_set_sender_ssrc:
* @packet: a valid RTPFB or PSFB #GstRTCPPacket
* @ssrc: a sender SSRC
*
* Set the sender SSRC field of the RTPFB or PSFB @packet.
*
* Since: 0.10.23
*/
void
gst_rtcp_packet_fb_set_sender_ssrc (GstRTCPPacket * packet, guint32 ssrc)
{
guint8 *data;
g_return_if_fail (packet != NULL);
g_return_if_fail (packet->type == GST_RTCP_TYPE_RTPFB ||
packet->type == GST_RTCP_TYPE_PSFB);
g_return_if_fail (GST_IS_BUFFER (packet->buffer));
data = GST_BUFFER_DATA (packet->buffer);
/* skip header */
data += packet->offset + 4;
GST_WRITE_UINT32_BE (data, ssrc);
}
/**
* gst_rtcp_packet_fb_get_media_ssrc:
* @packet: a valid RTPFB or PSFB #GstRTCPPacket
*
* Get the media SSRC field of the RTPFB or PSFB @packet.
*
* Returns: the media SSRC.
*
* Since: 0.10.23
*/
guint32
gst_rtcp_packet_fb_get_media_ssrc (GstRTCPPacket * packet)
{
guint8 *data;
guint32 ssrc;
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);
/* skip header and sender ssrc */
data += packet->offset + 8;
ssrc = GST_READ_UINT32_BE (data);
return ssrc;
}
/**
* gst_rtcp_packet_fb_set_media_ssrc:
* @packet: a valid RTPFB or PSFB #GstRTCPPacket
* @ssrc: a media SSRC
*
* Set the media SSRC field of the RTPFB or PSFB @packet.
*
* Since: 0.10.23
*/
void
gst_rtcp_packet_fb_set_media_ssrc (GstRTCPPacket * packet, guint32 ssrc)
{
guint8 *data;
g_return_if_fail (packet != NULL);
g_return_if_fail (packet->type == GST_RTCP_TYPE_RTPFB ||
packet->type == GST_RTCP_TYPE_PSFB);
g_return_if_fail (GST_IS_BUFFER (packet->buffer));
data = GST_BUFFER_DATA (packet->buffer);
/* skip header and sender ssrc */
data += packet->offset + 8;
GST_WRITE_UINT32_BE (data, ssrc);
}
/**
* gst_rtcp_packet_fb_get_type:
* @packet: a valid RTPFB or PSFB #GstRTCPPacket
*
* Get the feedback message type of the FB @packet.
*
* Returns: The feedback message type.
*
* Since: 0.10.23
*/
GstRTCPFBType
gst_rtcp_packet_fb_get_type (GstRTCPPacket * packet)
{
g_return_val_if_fail (packet != NULL, GST_RTCP_FB_TYPE_INVALID);
g_return_val_if_fail (packet->type == GST_RTCP_TYPE_RTPFB ||
packet->type == GST_RTCP_TYPE_PSFB, GST_RTCP_FB_TYPE_INVALID);
return packet->count;
}
/**
* gst_rtcp_packet_fb_set_type:
* @packet: a valid RTPFB or PSFB #GstRTCPPacket
* @type: the #GstRTCPFBType to set
*
* Set the feedback message type of the FB @packet.
*
* Since: 0.10.23
*/
void
gst_rtcp_packet_fb_set_type (GstRTCPPacket * packet, GstRTCPFBType type)
{
guint8 *data;
g_return_if_fail (packet != NULL);
g_return_if_fail (packet->type == GST_RTCP_TYPE_RTPFB ||
packet->type == GST_RTCP_TYPE_PSFB);
g_return_if_fail (GST_IS_BUFFER (packet->buffer));
data = GST_BUFFER_DATA (packet->buffer);
data[packet->offset] = (data[packet->offset] & 0xe0) | type;
packet->count = type;
}
/** /**
* gst_rtcp_ntp_to_unix: * gst_rtcp_ntp_to_unix:
* @ntptime: an NTP timestamp * @ntptime: an NTP timestamp
......
...@@ -42,6 +42,8 @@ G_BEGIN_DECLS ...@@ -42,6 +42,8 @@ G_BEGIN_DECLS
* @GST_RTCP_TYPE_SDES: Source description * @GST_RTCP_TYPE_SDES: Source description
* @GST_RTCP_TYPE_BYE: Goodbye * @GST_RTCP_TYPE_BYE: Goodbye
* @GST_RTCP_TYPE_APP: Application defined * @GST_RTCP_TYPE_APP: Application defined
* @GST_RTCP_TYPE_RTPFB: Transport layer feedback. Since: 0.10.23
* @GST_RTCP_TYPE_PSFB: Payload-specific feedback. Since: 0.10.23
* *
* Different RTCP packet types. * Different RTCP packet types.
*/ */
...@@ -52,9 +54,37 @@ typedef enum ...@@ -52,9 +54,37 @@ typedef enum
GST_RTCP_TYPE_RR = 201, GST_RTCP_TYPE_RR = 201,
GST_RTCP_TYPE_SDES = 202, GST_RTCP_TYPE_SDES = 202,
GST_RTCP_TYPE_BYE = 203, GST_RTCP_TYPE_BYE = 203,
GST_RTCP_TYPE_APP = 204 GST_RTCP_TYPE_APP = 204,
GST_RTCP_TYPE_RTPFB = 205,
GST_RTCP_TYPE_PSFB = 206
} GstRTCPType; } GstRTCPType;
/**
* GstRTCPFBType:
* @GST_RTCP_FB_TYPE_INVALID: Invalid type
* @GST_RTCP_RTPFB_TYPE_NACK: Generic NACK
* @GST_RTCP_PSFB_TYPE_PLI: Picture Loss Indication
* @GST_RTCP_PSFB_TYPE_SLI: Slice Loss Indication
* @GST_RTCP_PSFB_TYPE_RPSI: Reference Picture Selection Indication
* @GST_RTCP_PSFB_TYPE_AFB: Application layer Feedback
*
* Different types of feedback messages.
*
* Since: 0.10.23
*/
typedef enum
{
/* generic */
GST_RTCP_FB_TYPE_INVALID = 0,
/* RTPFB types */
GST_RTCP_RTPFB_TYPE_NACK = 1,
/* PSFB types */
GST_RTCP_PSFB_TYPE_PLI = 1,
GST_RTCP_PSFB_TYPE_SLI = 2,
GST_RTCP_PSFB_TYPE_RPSI = 3,
GST_RTCP_PSFB_TYPE_AFB = 15
} GstRTCPFBType;
/** /**
* GstRTCPSDESType: * GstRTCPSDESType:
* @GST_RTCP_SDES_INVALID: Invalid SDES entry * @GST_RTCP_SDES_INVALID: Invalid SDES entry
...@@ -232,6 +262,14 @@ guint8 gst_rtcp_packet_bye_get_reason_len (GstRTCPPacket *packet); ...@@ -232,6 +262,14 @@ guint8 gst_rtcp_packet_bye_get_reason_len (GstRTCPPacket *packet);
gchar* gst_rtcp_packet_bye_get_reason (GstRTCPPacket *packet); gchar* gst_rtcp_packet_bye_get_reason (GstRTCPPacket *packet);
gboolean gst_rtcp_packet_bye_set_reason (GstRTCPPacket *packet, const gchar *reason); gboolean gst_rtcp_packet_bye_set_reason (GstRTCPPacket *packet, const gchar *reason);
/* feedback packets */
guint32 gst_rtcp_packet_fb_get_sender_ssrc (GstRTCPPacket *packet);
void gst_rtcp_packet_fb_set_sender_ssrc (GstRTCPPacket *packet, guint32 ssrc);
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);
/* helper functions */ /* helper functions */
guint64 gst_rtcp_ntp_to_unix (guint64 ntptime); guint64 gst_rtcp_ntp_to_unix (guint64 ntptime);
guint64 gst_rtcp_unix_to_ntp (guint64 unixtime); guint64 gst_rtcp_unix_to_ntp (guint64 unixtime);
......
...@@ -33,6 +33,12 @@ EXPORTS ...@@ -33,6 +33,12 @@ EXPORTS
gst_rtcp_packet_bye_get_reason_len gst_rtcp_packet_bye_get_reason_len
gst_rtcp_packet_bye_get_ssrc_count gst_rtcp_packet_bye_get_ssrc_count
gst_rtcp_packet_bye_set_reason gst_rtcp_packet_bye_set_reason
gst_rtcp_packet_fb_get_media_ssrc
gst_rtcp_packet_fb_get_sender_ssrc
gst_rtcp_packet_fb_get_type
gst_rtcp_packet_fb_set_media_ssrc
gst_rtcp_packet_fb_set_sender_ssrc
gst_rtcp_packet_fb_set_type
gst_rtcp_packet_get_count gst_rtcp_packet_get_count
gst_rtcp_packet_get_length gst_rtcp_packet_get_length
gst_rtcp_packet_get_padding gst_rtcp_packet_get_padding
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment