webrtc: Allow toggling TCP and UDP candidates

Add some properties to allow TCP and UDP candidates to be toggled.  This
is useful in cases where someone is using this element in an environment
where it is known in advance whether a given transport will work or not
and will prevent wasting time generating and checking candidate pairs
that will not succeed.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1223>
This commit is contained in:
Chris Ayoup 2020-04-16 22:37:35 +00:00 committed by GStreamer Merge Bot
parent 98600942e4
commit 3fc8818824
2 changed files with 50 additions and 2 deletions

View file

@ -369,6 +369,8 @@ enum
PROP_TURN_SERVER,
PROP_BUNDLE_POLICY,
PROP_ICE_TRANSPORT_POLICY,
PROP_ICE_TCP,
PROP_ICE_UDP,
};
static guint gst_webrtc_bin_signals[LAST_SIGNAL] = { 0 };
@ -5838,6 +5840,8 @@ gst_webrtc_bin_set_property (GObject * object, guint prop_id,
switch (prop_id) {
case PROP_STUN_SERVER:
case PROP_TURN_SERVER:
case PROP_ICE_TCP:
case PROP_ICE_UDP:
g_object_set_property (G_OBJECT (webrtc->priv->ice), pspec->name, value);
break;
case PROP_BUNDLE_POLICY:
@ -5909,6 +5913,8 @@ gst_webrtc_bin_get_property (GObject * object, guint prop_id,
break;
case PROP_STUN_SERVER:
case PROP_TURN_SERVER:
case PROP_ICE_TCP:
case PROP_ICE_UDP:
g_object_get_property (G_OBJECT (webrtc->priv->ice), pspec->name, value);
break;
case PROP_BUNDLE_POLICY:
@ -6179,6 +6185,18 @@ gst_webrtc_bin_class_init (GstWebRTCBinClass * klass)
GST_WEBRTC_ICE_TRANSPORT_POLICY_ALL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class,
PROP_ICE_TCP,
g_param_spec_boolean ("ice-tcp", "ICE TCP",
"Whether the agent should use ICE-TCP when gathering candidates",
TRUE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class,
PROP_ICE_UDP,
g_param_spec_boolean ("ice-udp", "ICE UDP",
"Whether the agent should use ICE-UDP when gathering candidates",
TRUE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* GstWebRTCBin::create-offer:
* @object: the #webrtcbin

View file

@ -60,6 +60,8 @@ enum
PROP_CONTROLLER,
PROP_AGENT,
PROP_FORCE_RELAY,
PROP_ICE_TCP,
PROP_ICE_UDP,
};
static guint gst_webrtc_ice_signals[LAST_SIGNAL] = { 0 };
@ -80,8 +82,8 @@ struct _GstWebRTCICEPrivate
#define gst_webrtc_ice_parent_class parent_class
G_DEFINE_TYPE_WITH_CODE (GstWebRTCICE, gst_webrtc_ice,
GST_TYPE_OBJECT, G_ADD_PRIVATE (GstWebRTCICE)
GST_DEBUG_CATEGORY_INIT (gst_webrtc_ice_debug, "webrtcice", 0,
"webrtcice"););
GST_DEBUG_CATEGORY_INIT (gst_webrtc_ice_debug, "webrtcice", 0, "webrtcice");
);
static gboolean
_unlock_pc_thread (GMutex * lock)
@ -833,6 +835,14 @@ gst_webrtc_ice_set_property (GObject * object, guint prop_id,
g_object_set_property (G_OBJECT (ice->priv->nice_agent),
"force-relay", value);
break;
case PROP_ICE_TCP:
g_object_set_property (G_OBJECT (ice->priv->nice_agent),
"ice-tcp", value);
break;
case PROP_ICE_UDP:
g_object_set_property (G_OBJECT (ice->priv->nice_agent),
"ice-udp", value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -869,6 +879,14 @@ gst_webrtc_ice_get_property (GObject * object, guint prop_id,
g_object_get_property (G_OBJECT (ice->priv->nice_agent),
"force-relay", value);
break;
case PROP_ICE_TCP:
g_object_get_property (G_OBJECT (ice->priv->nice_agent),
"ice-tcp", value);
break;
case PROP_ICE_UDP:
g_object_get_property (G_OBJECT (ice->priv->nice_agent),
"ice-udp", value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -957,6 +975,18 @@ gst_webrtc_ice_class_init (GstWebRTCICEClass * klass)
"Force all traffic to go through a relay.", FALSE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class,
PROP_ICE_TCP,
g_param_spec_boolean ("ice-tcp", "ICE TCP",
"Whether the agent should use ICE-TCP when gathering candidates",
TRUE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class,
PROP_ICE_UDP,
g_param_spec_boolean ("ice-udp", "ICE UDP",
"Whether the agent should use ICE-UDP when gathering candidates",
TRUE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* GstWebRTCICE::on-ice-candidate:
* @object: the #GstWebRTCBin