summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@collabora.co.uk>2012-11-16 12:00:14 +0100
committerWim Taymans <wim.taymans@collabora.co.uk>2012-11-16 15:43:05 +0100
commit0d2f590cfb6cb2ea0a467a2cb7dd7e02485cf34b (patch)
tree50b91a08f54e15530bb17a9b01e5730c05e67cd2
parent07f89f0a2078c228b749459ea989ff459ced24e7 (diff)
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
-rw-r--r--gst/rtsp/gstrtspsrc.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/gst/rtsp/gstrtspsrc.c b/gst/rtsp/gstrtspsrc.c
index 6e95f56df4..066994c117 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 */