Commit 85c75bb2 authored by Mathieu Duponchelle's avatar Mathieu Duponchelle 🐸 Committed by Olivier Crête

webrtc: expose ice-transport-policy property

This is the equivalent of iceTransportPolicy in the RTCConfiguration
dictionary.

Only two values are implemented:

* all: default behaviour
* relay: only gather relay candidates

The third member of the iceTransportPolicy enum, "public", is
obsolete.
parent 73c6530d
Pipeline #16127 passed with stages
in 18 minutes and 28 seconds
......@@ -273,8 +273,7 @@ gst_webrtc_bin_pad_new (const gchar * name, GstPadDirection direction)
G_DEFINE_TYPE_WITH_CODE (GstWebRTCBin, gst_webrtc_bin, GST_TYPE_BIN,
G_ADD_PRIVATE (GstWebRTCBin)
GST_DEBUG_CATEGORY_INIT (gst_webrtc_bin_debug, "webrtcbin", 0,
"webrtcbin element");
);
"webrtcbin element"););
static GstPad *_connect_input_stream (GstWebRTCBin * webrtc,
GstWebRTCBinPad * pad);
......@@ -325,6 +324,7 @@ enum
PROP_STUN_SERVER,
PROP_TURN_SERVER,
PROP_BUNDLE_POLICY,
PROP_ICE_TRANSPORT_POLICY,
};
static guint gst_webrtc_bin_signals[LAST_SIGNAL] = { 0 };
......@@ -4712,6 +4712,12 @@ gst_webrtc_bin_set_property (GObject * object, guint prop_id,
webrtc->bundle_policy = g_value_get_enum (value);
}
break;
case PROP_ICE_TRANSPORT_POLICY:
webrtc->ice_transport_policy = g_value_get_enum (value);
g_object_set (webrtc->priv->ice, "force-relay",
webrtc->ice_transport_policy ==
GST_WEBRTC_ICE_TRANSPORT_POLICY_RELAY ? TRUE : FALSE, NULL);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -4773,6 +4779,9 @@ gst_webrtc_bin_get_property (GObject * object, guint prop_id,
case PROP_BUNDLE_POLICY:
g_value_set_enum (value, webrtc->bundle_policy);
break;
case PROP_ICE_TRANSPORT_POLICY:
g_value_set_enum (value, webrtc->ice_transport_policy);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -4958,6 +4967,14 @@ gst_webrtc_bin_class_init (GstWebRTCBinClass * klass)
GST_WEBRTC_BUNDLE_POLICY_NONE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class,
PROP_ICE_TRANSPORT_POLICY,
g_param_spec_enum ("ice-transport-policy", "ICE Transport Policy",
"The policy to apply for ICE transport",
GST_TYPE_WEBRTC_ICE_TRANSPORT_POLICY,
GST_WEBRTC_ICE_TRANSPORT_POLICY_ALL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* GstWebRTCBin::create-offer:
* @object: the #GstWebRtcBin
......
......@@ -81,6 +81,7 @@ struct _GstWebRTCBin
GstWebRTCSessionDescription *pending_remote_description;
GstWebRTCBundlePolicy bundle_policy;
GstWebRTCICETransportPolicy ice_transport_policy;
GstWebRTCBinPrivate *priv;
};
......
......@@ -59,6 +59,7 @@ enum
PROP_TURN_SERVER,
PROP_CONTROLLER,
PROP_AGENT,
PROP_FORCE_RELAY,
};
static guint gst_webrtc_ice_signals[LAST_SIGNAL] = { 0 };
......@@ -79,8 +80,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)
......@@ -826,6 +827,10 @@ gst_webrtc_ice_set_property (GObject * object, guint prop_id,
g_object_set_property (G_OBJECT (ice->priv->nice_agent),
"controlling-mode", value);
break;
case PROP_FORCE_RELAY:
g_object_set_property (G_OBJECT (ice->priv->nice_agent),
"force-relay", value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -858,6 +863,10 @@ gst_webrtc_ice_get_property (GObject * object, guint prop_id,
case PROP_AGENT:
g_value_set_object (value, ice->priv->nice_agent);
break;
case PROP_FORCE_RELAY:
g_object_get_property (G_OBJECT (ice->priv->nice_agent),
"force-relay", value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -924,6 +933,12 @@ gst_webrtc_ice_class_init (GstWebRTCICEClass * klass)
"ICE agent in use by this object", NICE_TYPE_AGENT,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class,
PROP_FORCE_RELAY,
g_param_spec_boolean ("force-relay", "Force Relay",
"Force all traffic to go through a relay.", FALSE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* GstWebRTCICE::on-ice-candidate:
* @object: the #GstWebRtcBin
......
......@@ -339,4 +339,18 @@ typedef enum /*<underscore_name=gst_webrtc_bundle_policy>*/
GST_WEBRTC_BUNDLE_POLICY_MAX_BUNDLE,
} GstWebRTCBundlePolicy;
/**
* GstWebRTCICETransportPolicy:
* GST_WEBRTC_ICE_TRANSPORT_POLICY_ALL: all
* GST_WEBRTC_ICE_TRANSPORT_POLICY_RELAY: relay
*
* See https://tools.ietf.org/html/draft-ietf-rtcweb-jsep-24#section-4.1.1
* for more information.
*/
typedef enum /*<underscore_name=gst_webrtc_ice_transport_policy>*/
{
GST_WEBRTC_ICE_TRANSPORT_POLICY_ALL,
GST_WEBRTC_ICE_TRANSPORT_POLICY_RELAY,
} GstWebRTCICETransportPolicy;
#endif /* __GST_WEBRTC_FWD_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment