rtspsrc: require a destination for multicast
authorWim Taymans <wim.taymans@collabora.co.uk>
Tue, 9 Mar 2010 16:53:32 +0000 (17:53 +0100)
committerWim Taymans <wim.taymans@collabora.co.uk>
Wed, 10 Mar 2010 10:21:20 +0000 (11:21 +0100)
When setting up the multicast sockets, we need a destination address to listen
on or else we error.

gst/rtsp/gstrtspsrc.c

index cbd2a99..3690f26 100644 (file)
@@ -2279,17 +2279,24 @@ static gboolean
 gst_rtspsrc_stream_configure_mcast (GstRTSPSrc * src, GstRTSPStream * stream,
     GstRTSPTransport * transport, GstPad ** outpad)
 {
-  gchar *uri;
+  gchar *uri, *destination;
+  gint min, max;
 
   GST_DEBUG_OBJECT (src, "creating UDP sources for multicast");
 
   /* we can remove the allocated UDP ports now */
   gst_rtspsrc_stream_free_udp (stream);
 
-  /* creating UDP source */
-  if (transport->port.min != -1) {
-    uri = g_strdup_printf ("udp://%s:%d", transport->destination,
-        transport->port.min);
+  /* we need a destination now */
+  if (!(destination = transport->destination))
+    goto no_destination;
+
+  min = transport->port.min;
+  max = transport->port.max;
+
+  /* creating UDP source for RTP */
+  if (min != -1) {
+    uri = g_strdup_printf ("udp://%s:%d", destination, min);
     stream->udpsrc[0] = gst_element_make_from_uri (GST_URI_SRC, uri, NULL);
     g_free (uri);
     if (stream->udpsrc[0] == NULL)
@@ -2303,10 +2310,9 @@ gst_rtspsrc_stream_configure_mcast (GstRTSPSrc * src, GstRTSPStream * stream,
     gst_element_set_state (stream->udpsrc[0], GST_STATE_PAUSED);
   }
 
-  /* creating another UDP source */
-  if (transport->port.max != -1) {
-    uri = g_strdup_printf ("udp://%s:%d", transport->destination,
-        transport->port.max);
+  /* creating another UDP source for RTCP */
+  if (max != -1) {
+    uri = g_strdup_printf ("udp://%s:%d", destination, max);
     stream->udpsrc[1] = gst_element_make_from_uri (GST_URI_SRC, uri, NULL);
     g_free (uri);
     if (stream->udpsrc[1] == NULL)
@@ -2326,6 +2332,11 @@ no_element:
     GST_DEBUG_OBJECT (src, "no UDP source element found");
     return FALSE;
   }
+no_destination:
+  {
+    GST_DEBUG_OBJECT (src, "no destination found");
+    return FALSE;
+  }
 }
 
 /* configure the remainder of the UDP ports */