rtspsrc: Don't parse key data more than needed.

When an auxilliary streams are present in the SDP media,
there's no need to re-parse the SDP attributes multiple
times.
This commit is contained in:
Jan Schmidt 2015-09-04 00:06:29 +10:00
parent fe4ed1d1df
commit b38e24995b

View file

@ -1483,6 +1483,7 @@ gst_rtspsrc_collect_payloads (GstRTSPSrc * src, const GstSDPMessage * sdp,
{ {
guint i, len; guint i, len;
const gchar *proto; const gchar *proto;
GstCaps *global_caps;
/* get proto */ /* get proto */
proto = gst_sdp_media_get_proto (media); proto = gst_sdp_media_get_proto (media);
@ -1500,10 +1501,17 @@ gst_rtspsrc_collect_payloads (GstRTSPSrc * src, const GstSDPMessage * sdp,
else else
goto unknown_proto; goto unknown_proto;
/* Parse global SDP attributes once */
global_caps = gst_caps_new_empty_simple ("application/x-unknown");
GST_DEBUG ("mapping sdp session level attributes to caps");
gst_rtspsrc_sdp_attributes_to_caps (sdp->attributes, global_caps);
GST_DEBUG ("mapping sdp media level attributes to caps");
gst_rtspsrc_sdp_attributes_to_caps (media->attributes, global_caps);
len = gst_sdp_media_formats_len (media); len = gst_sdp_media_formats_len (media);
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
gint pt; gint pt;
GstCaps *caps; GstCaps *caps, *outcaps;
GstStructure *s; GstStructure *s;
const gchar *enc; const gchar *enc;
PtMapItem item; PtMapItem item;
@ -1526,19 +1534,23 @@ gst_rtspsrc_collect_payloads (GstRTSPSrc * src, const GstSDPMessage * sdp,
if (strcmp (enc, "X-ASF-PF") == 0) if (strcmp (enc, "X-ASF-PF") == 0)
stream->container = TRUE; stream->container = TRUE;
} }
GST_DEBUG ("mapping sdp session level attributes to caps");
gst_rtspsrc_sdp_attributes_to_caps (sdp->attributes, caps); /* Merge in global caps */
GST_DEBUG ("mapping sdp media level attributes to caps"); /* Intersect will merge in missing fields to the current caps */
gst_rtspsrc_sdp_attributes_to_caps (media->attributes, caps); outcaps = gst_caps_intersect (caps, global_caps);
gst_caps_unref (caps);
/* the first pt will be the default */ /* the first pt will be the default */
if (stream->ptmap->len == 0) if (stream->ptmap->len == 0)
stream->default_pt = pt; stream->default_pt = pt;
item.pt = pt; item.pt = pt;
item.caps = caps; item.caps = outcaps;
g_array_append_val (stream->ptmap, item); g_array_append_val (stream->ptmap, item);
} }
gst_caps_unref (global_caps);
return; return;
no_proto: no_proto: