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
This commit is contained in:
Wim Taymans 2012-11-16 12:00:14 +01:00
parent 5025b3f1b3
commit cc9cb26be1

View file

@ -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 */