diff options
author | Ilya Kreymer <ikreymer@gmail.com> | 2019-08-15 08:25:26 -0700 |
---|---|---|
committer | GStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org> | 2021-03-01 14:42:17 +0000 |
commit | 92626535c7136725dfab0857d6c3900e041084b7 (patch) | |
tree | 380b15119cdcb0621137cde75c6ad3d943558675 /ext/webrtc/gstwebrtcice.c | |
parent | 3a3965e5cfe138400a709ab7936659520209fc63 (diff) | |
download | gstreamer-plugins-bad-92626535c7136725dfab0857d6c3900e041084b7.tar.gz |
webrtc ice: Add 'min/max-rtp-port' props for setting RTP port range
default min port == 0, max port == 65535 -- if min port == 0, uses existing random port selection (range ignored)
add 'gathering_started' flag to avoid changing ports after gathering has started
validity checks: min port <= max port enforced, error thrown otherwise
include tests to ensure port range is being utilized (by @hhardy)
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/119>
Diffstat (limited to 'ext/webrtc/gstwebrtcice.c')
-rw-r--r-- | ext/webrtc/gstwebrtcice.c | 57 |
1 files changed, 57 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 |