From 4d4f3c3cc4647b1534e3bbe857ecc4f7ebf8b979 Mon Sep 17 00:00:00 2001 From: Tomasz Zajac Date: Fri, 28 Oct 2016 08:47:01 +0200 Subject: [PATCH] sdp: Parse rtcp-fb media attributes https://bugzilla.gnome.org/show_bug.cgi?id=769698 --- gst-libs/gst/sdp/gstsdpmessage.c | 70 ++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/gst-libs/gst/sdp/gstsdpmessage.c b/gst-libs/gst/sdp/gstsdpmessage.c index 77192524e7..e5341db243 100644 --- a/gst-libs/gst/sdp/gstsdpmessage.c +++ b/gst-libs/gst/sdp/gstsdpmessage.c @@ -3270,6 +3270,73 @@ gst_sdp_parse_rtpmap (const gchar * rtpmap, gint * payload, gchar ** name, return TRUE; } +/** + * gst_sdp_media_add_rtcp_fb_attributes_from_media: + * @media: a #GstSDPMedia + * @pt: payload type + * @caps: a #GstCaps + * + * Parse given @media for "rtcp-fb" attributes and add it to the @caps. + * + * Mapping of caps from SDP fields: + * + * a=rtcp-fb:(payload) (param1) [param2]... + * + * Returns: a #GstSDPResult. + */ +static GstSDPResult +gst_sdp_media_add_rtcp_fb_attributes_from_media (const GstSDPMedia * media, + gint pt, GstCaps * caps) +{ + const gchar *rtcp_fb; + gchar *p, *to_free; + gint payload, i; + GstStructure *s; + + g_return_val_if_fail (media != NULL, GST_SDP_EINVAL); + g_return_val_if_fail (caps != NULL && GST_IS_CAPS (caps), GST_SDP_EINVAL); + + s = gst_caps_get_structure (caps, 0); + + for (i = 0;; i++) { + gboolean all_formats = FALSE; + + if ((rtcp_fb = gst_sdp_media_get_attribute_val_n (media, + "rtcp-fb", i)) == NULL) + break; + + /* p is now of the format attr... */ + to_free = p = g_strdup (rtcp_fb); + + /* check if it applies to all formats */ + if (*p == '*') { + p++; + all_formats = TRUE; + } else { + PARSE_INT (p, " ", payload); + } + + if (all_formats || (payload != -1 && payload == pt)) { + gchar *tmp, *key; + + SKIP_SPACES (p); + + /* replace space with '-' */ + key = g_strdup_printf ("rtcp-fb-%s", p); + + for (tmp = key; (tmp = strchr (tmp, ' ')); ++tmp) { + *tmp = '-'; + } + + gst_structure_set (s, key, G_TYPE_BOOLEAN, TRUE, NULL); + GST_DEBUG ("adding caps: %s=TRUE", key); + g_free (key); + } else + g_free (to_free); + } + return GST_SDP_OK; +} + /** * gst_sdp_media_get_caps_from_media: * @media: a #GstSDPMedia @@ -3439,6 +3506,9 @@ gst_sdp_media_get_caps_from_media (const GstSDPMedia * media, gint pt) } } + /* parse rtcp-fb: field */ + gst_sdp_media_add_rtcp_fb_attributes_from_media (media, pt, caps); + return caps; /* ERRORS */