diff --git a/gst/rtsp/gstrtspsrc.c b/gst/rtsp/gstrtspsrc.c index c38edd6aa3..0292c8b55d 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 */