summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/webrtc/gstwebrtcice.c57
-rw-r--r--ext/webrtc/gstwebrtcice.h3
-rw-r--r--ext/webrtc/icestream.c19
3 files changed, 79 insertions, 0 deletions
diff --git a/ext/webrtc/gstwebrtcice.c b/ext/webrtc/gstwebrtcice.c
index 8f3050835..886856cc9 100644
--- a/ext/webrtc/gstwebrtcice.c
+++ b/ext/webrtc/gstwebrtcice.c
@@ -56,6 +56,8 @@ enum
PROP_AGENT,
PROP_ICE_TCP,
PROP_ICE_UDP,
+ PROP_MIN_RTP_PORT,
+ PROP_MAX_RTP_PORT,
};
static guint gst_webrtc_ice_signals[LAST_SIGNAL] = { 0 };
@@ -991,6 +993,21 @@ gst_webrtc_ice_set_property (GObject * object, guint prop_id,
g_object_set_property (G_OBJECT (ice->priv->nice_agent),
"ice-udp", value);
break;
+
+ case PROP_MIN_RTP_PORT:
+ ice->min_rtp_port = g_value_get_uint (value);
+ if (ice->min_rtp_port > ice->max_rtp_port)
+ g_warning ("Set min-rtp-port to %u which is larger than"
+ " max-rtp-port %u", ice->min_rtp_port, ice->max_rtp_port);
+ break;
+
+ case PROP_MAX_RTP_PORT:
+ ice->max_rtp_port = g_value_get_uint (value);
+ if (ice->min_rtp_port > ice->max_rtp_port)
+ g_warning ("Set max-rtp-port to %u which is smaller than"
+ " min-rtp-port %u", ice->max_rtp_port, ice->min_rtp_port);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -1015,6 +1032,15 @@ gst_webrtc_ice_get_property (GObject * object, guint prop_id,
g_object_get_property (G_OBJECT (ice->priv->nice_agent),
"ice-udp", value);
break;
+
+ case PROP_MIN_RTP_PORT:
+ g_value_set_uint (value, ice->min_rtp_port);
+ break;
+
+ case PROP_MAX_RTP_PORT:
+ g_value_set_uint (value, ice->max_rtp_port);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -1102,6 +1128,37 @@ gst_webrtc_ice_class_init (GstWebRTCICEClass * klass)
TRUE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
+ * GstWebRTCICE:min-rtp-port:
+ *
+ * Minimum port for local rtp port range.
+ * min-rtp-port must be <= max-rtp-port
+ *
+ * Since: 1.20
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_MIN_RTP_PORT,
+ g_param_spec_uint ("min-rtp-port", "ICE RTP candidate min port",
+ "Minimum port for local rtp port range. "
+ "min-rtp-port must be <= max-rtp-port",
+ 0, 65535, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ /**
+ * GstWebRTCICE:max-rtp-port:
+ *
+ * Maximum port for local rtp port range.
+ * min-rtp-port must be <= max-rtp-port
+ *
+ * Since: 1.20
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_MAX_RTP_PORT,
+ g_param_spec_uint ("max-rtp-port", "ICE RTP candidate max port",
+ "Maximum port for local rtp port range. "
+ "max-rtp-port must be >= min-rtp-port",
+ 0, 65535, 65535,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
+
+ /**
* GstWebRTCICE::add-local-ip-address:
* @object: the #GstWebRTCICE
* @address: The local IP address
diff --git a/ext/webrtc/gstwebrtcice.h b/ext/webrtc/gstwebrtcice.h
index 283672fe9..5e7543c80 100644
--- a/ext/webrtc/gstwebrtcice.h
+++ b/ext/webrtc/gstwebrtcice.h
@@ -51,6 +51,9 @@ struct _GstWebRTCICE
GHashTable *turn_servers;
GstWebRTCICEPrivate *priv;
+
+ guint min_rtp_port;
+ guint max_rtp_port;
};
struct _GstWebRTCICEClass
diff --git a/ext/webrtc/icestream.c b/ext/webrtc/icestream.c
index 36363f2c6..924c9cbd7 100644
--- a/ext/webrtc/icestream.c
+++ b/ext/webrtc/icestream.c
@@ -46,6 +46,7 @@ struct _GstWebRTCICEStreamPrivate
{
gboolean gathered;
GList *transports;
+ gboolean gathering_started;
};
#define gst_webrtc_ice_stream_parent_class parent_class
@@ -187,6 +188,24 @@ gst_webrtc_ice_stream_gather_candidates (GstWebRTCICEStream * stream)
}
g_object_get (stream->ice, "agent", &agent, NULL);
+
+ if (!stream->priv->gathering_started) {
+ if (stream->ice->min_rtp_port != 0 || stream->ice->max_rtp_port != 65535) {
+ if (stream->ice->min_rtp_port > stream->ice->max_rtp_port) {
+ GST_ERROR_OBJECT (stream->ice,
+ "invalid port range: min-rtp-port %d must be <= max-rtp-port %d",
+ stream->ice->min_rtp_port, stream->ice->max_rtp_port);
+ return FALSE;
+ }
+
+ nice_agent_set_port_range (agent, stream->stream_id,
+ NICE_COMPONENT_TYPE_RTP, stream->ice->min_rtp_port,
+ stream->ice->max_rtp_port);
+ }
+ /* mark as gathering started to prevent changing ports again */
+ stream->priv->gathering_started = TRUE;
+ }
+
if (!nice_agent_gather_candidates (agent, stream->stream_id)) {
g_object_unref (agent);
return FALSE;