rtspsrc: refactor payload handling
authorWim Taymans <wtaymans@redhat.com>
Tue, 4 Mar 2014 10:34:39 +0000 (11:34 +0100)
committerWim Taymans <wtaymans@redhat.com>
Tue, 4 Mar 2014 10:34:39 +0000 (11:34 +0100)
gst/rtsp/gstrtspsrc.c

index 6a26768..bf032dc 100644 (file)
@@ -1299,6 +1299,41 @@ gst_rtspsrc_collect_connections (GstRTSPSrc * src, const GstSDPMessage * sdp,
   }
 }
 
+static void
+gst_rtspsrc_collect_payloads (GstRTSPSrc * src, const GstSDPMessage * sdp,
+    const GstSDPMedia * media, GstRTSPStream * stream)
+{
+  const gchar *payload;
+
+  /* we must have a payload. No payload means we cannot create caps */
+  /* FIXME, handle multiple formats. The problem here is that we just want to
+   * take the first available format that we can handle but in order to do that
+   * we need to scan for depayloader plugins. Scanning for payloader plugins is
+   * also suboptimal because the user maybe just wants to save the raw stream
+   * and then we don't care. */
+  if ((payload = gst_sdp_media_get_format (media, 0))) {
+    stream->pt = atoi (payload);
+    /* convert caps */
+    stream->caps = gst_rtspsrc_media_to_caps (stream->pt, media);
+
+    GST_DEBUG ("mapping sdp session level attributes to caps");
+    gst_rtspsrc_sdp_attributes_to_caps (sdp->attributes, stream->caps);
+    GST_DEBUG ("mapping sdp media level attributes to caps");
+    gst_rtspsrc_sdp_attributes_to_caps (media->attributes, stream->caps);
+
+    if (stream->pt >= 96) {
+      /* If we have a dynamic payload type, see if we have a stream with the
+       * same payload number. If there is one, they are part of the same
+       * container and we only need to add one pad. */
+      if (find_stream (src, &stream->pt, (gpointer) find_stream_by_pt)) {
+        stream->container = TRUE;
+        GST_DEBUG ("found another stream with pt %d, marking as container",
+            stream->pt);
+      }
+    }
+  }
+}
+
 static const gchar *
 get_aggregate_control (GstRTSPSrc * src)
 {
@@ -1321,7 +1356,6 @@ gst_rtspsrc_create_stream (GstRTSPSrc * src, GstSDPMessage * sdp, gint idx)
 {
   GstRTSPStream *stream;
   const gchar *control_url;
-  const gchar *payload;
   const GstSDPMedia *media;
 
   /* get media, should not return NULL */
@@ -1349,33 +1383,8 @@ gst_rtspsrc_create_stream (GstRTSPSrc * src, GstSDPMessage * sdp, gint idx)
   /* collect connection info */
   gst_rtspsrc_collect_connections (src, sdp, media, stream);
 
-  /* we must have a payload. No payload means we cannot create caps */
-  /* FIXME, handle multiple formats. The problem here is that we just want to
-   * take the first available format that we can handle but in order to do that
-   * we need to scan for depayloader plugins. Scanning for payloader plugins is
-   * also suboptimal because the user maybe just wants to save the raw stream
-   * and then we don't care. */
-  if ((payload = gst_sdp_media_get_format (media, 0))) {
-    stream->pt = atoi (payload);
-    /* convert caps */
-    stream->caps = gst_rtspsrc_media_to_caps (stream->pt, media);
-
-    GST_DEBUG ("mapping sdp session level attributes to caps");
-    gst_rtspsrc_sdp_attributes_to_caps (sdp->attributes, stream->caps);
-    GST_DEBUG ("mapping sdp media level attributes to caps");
-    gst_rtspsrc_sdp_attributes_to_caps (media->attributes, stream->caps);
+  gst_rtspsrc_collect_payloads (src, sdp, media, stream);
 
-    if (stream->pt >= 96) {
-      /* If we have a dynamic payload type, see if we have a stream with the
-       * same payload number. If there is one, they are part of the same
-       * container and we only need to add one pad. */
-      if (find_stream (src, &stream->pt, (gpointer) find_stream_by_pt)) {
-        stream->container = TRUE;
-        GST_DEBUG ("found another stream with pt %d, marking as container",
-            stream->pt);
-      }
-    }
-  }
   /* collect port number */
   stream->port = gst_sdp_media_get_port (media);