From cc9cb26be16e51fe748a01b2a75be91c35bcfc1e Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 16 Nov 2012 12:00:14 +0100 Subject: [PATCH] rtspsrc: propose ports in multicast When the user configured a port-range, propose ports from this range as the multicast ports. The server is free to ignore this request but if it honours it, increment our ports so that we suggest the next port pair for the next stream. Fixes https://bugzilla.gnome.org/show_bug.cgi?id=639420 --- gst/rtsp/gstrtspsrc.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/gst/rtsp/gstrtspsrc.c b/gst/rtsp/gstrtspsrc.c index c38edd6..0292c8b 100644 --- a/gst/rtsp/gstrtspsrc.c +++ b/gst/rtsp/gstrtspsrc.c @@ -4914,6 +4914,14 @@ gst_rtspsrc_create_transports_string (GstRTSPSrc * src, if (add_udp_str) g_string_append (result, "/UDP"); g_string_append (result, ";multicast"); + if (src->next_port_num != 0) { + if (src->client_port_range.max > 0 && + src->next_port_num >= src->client_port_range.max) + goto no_ports; + + g_string_append_printf (result, ";client_port=%d-%d", + src->next_port_num, src->next_port_num + 1); + } } else if (protocols & GST_RTSP_LOWER_TRANS_TCP) { GST_DEBUG_OBJECT (src, "adding TCP"); @@ -4933,6 +4941,11 @@ failed: GST_ERROR ("extension gave error %d", res); return res; } +no_ports: + { + GST_ERROR ("no more ports available"); + return GST_RTSP_ERROR; + } } static GstRTSPResult @@ -5276,6 +5289,12 @@ gst_rtspsrc_setup_streams (GstRTSPSrc * src, gboolean async) /* only allow multicast for other streams */ GST_DEBUG_OBJECT (src, "stream %p as UDP multicast", stream); protocols = GST_RTSP_LOWER_TRANS_UDP_MCAST; + /* if the server selected our ports, increment our counters so that + * we select a new port later */ + if (src->next_port_num == transport.port.min && + src->next_port_num + 1 == transport.port.max) { + src->next_port_num += 2; + } break; case GST_RTSP_LOWER_TRANS_UDP: /* only allow unicast for other streams */ -- 2.7.4