mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
webrtc: allow setting local IP addresses
If a local IP address is specified, ICE gathering can be much faster in environments where there are multiple IP addreses but only some are usable (for example, if you are running docker on the machine). Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1223>
This commit is contained in:
parent
3fc8818824
commit
ca754245e9
3 changed files with 54 additions and 5 deletions
|
@ -325,8 +325,7 @@ gst_webrtc_bin_pad_new (const gchar * name, GstPadDirection direction)
|
||||||
G_DEFINE_TYPE_WITH_CODE (GstWebRTCBin, gst_webrtc_bin, GST_TYPE_BIN,
|
G_DEFINE_TYPE_WITH_CODE (GstWebRTCBin, gst_webrtc_bin, GST_TYPE_BIN,
|
||||||
G_ADD_PRIVATE (GstWebRTCBin)
|
G_ADD_PRIVATE (GstWebRTCBin)
|
||||||
GST_DEBUG_CATEGORY_INIT (gst_webrtc_bin_debug, "webrtcbin", 0,
|
GST_DEBUG_CATEGORY_INIT (gst_webrtc_bin_debug, "webrtcbin", 0,
|
||||||
"webrtcbin element");
|
"webrtcbin element"););
|
||||||
);
|
|
||||||
|
|
||||||
static GstPad *_connect_input_stream (GstWebRTCBin * webrtc,
|
static GstPad *_connect_input_stream (GstWebRTCBin * webrtc,
|
||||||
GstWebRTCBinPad * pad);
|
GstWebRTCBinPad * pad);
|
||||||
|
@ -349,6 +348,7 @@ enum
|
||||||
ADD_TURN_SERVER_SIGNAL,
|
ADD_TURN_SERVER_SIGNAL,
|
||||||
CREATE_DATA_CHANNEL_SIGNAL,
|
CREATE_DATA_CHANNEL_SIGNAL,
|
||||||
ON_DATA_CHANNEL_SIGNAL,
|
ON_DATA_CHANNEL_SIGNAL,
|
||||||
|
ADD_LOCAL_IP_ADDRESS_SIGNAL,
|
||||||
LAST_SIGNAL,
|
LAST_SIGNAL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -5025,6 +5025,18 @@ gst_webrtc_bin_add_turn_server (GstWebRTCBin * webrtc, const gchar * uri)
|
||||||
return gst_webrtc_ice_add_turn_server (webrtc->priv->ice, uri);
|
return gst_webrtc_ice_add_turn_server (webrtc->priv->ice, uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gst_webrtc_bin_add_local_ip_address (GstWebRTCBin * webrtc,
|
||||||
|
const gchar * address)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GST_IS_WEBRTC_BIN (webrtc), FALSE);
|
||||||
|
g_return_val_if_fail (address != NULL, FALSE);
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (webrtc, "Adding local IP address: %s", address);
|
||||||
|
|
||||||
|
return gst_webrtc_ice_add_local_ip_address (webrtc->priv->ice, address);
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
copy_sticky_events (GstPad * pad, GstEvent ** event, gpointer user_data)
|
copy_sticky_events (GstPad * pad, GstEvent ** event, gpointer user_data)
|
||||||
{
|
{
|
||||||
|
@ -6426,6 +6438,20 @@ gst_webrtc_bin_class_init (GstWebRTCBinClass * klass)
|
||||||
G_CALLBACK (gst_webrtc_bin_add_turn_server), NULL, NULL, NULL,
|
G_CALLBACK (gst_webrtc_bin_add_turn_server), NULL, NULL, NULL,
|
||||||
G_TYPE_BOOLEAN, 1, G_TYPE_STRING);
|
G_TYPE_BOOLEAN, 1, G_TYPE_STRING);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GstWebRTCBin::add-local-ip-address:
|
||||||
|
* @object: the #GstWebRtcBin
|
||||||
|
* @address: The local IP address
|
||||||
|
*
|
||||||
|
* Add a local IP address to use for ICE candidate gathering. If none
|
||||||
|
* are supplied, they will be discovered automatically
|
||||||
|
*/
|
||||||
|
gst_webrtc_bin_signals[ADD_LOCAL_IP_ADDRESS_SIGNAL] =
|
||||||
|
g_signal_new_class_handler ("add-local-ip-address",
|
||||||
|
G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
|
||||||
|
G_CALLBACK (gst_webrtc_bin_add_local_ip_address), NULL, NULL,
|
||||||
|
g_cclosure_marshal_generic, G_TYPE_BOOLEAN, 1, G_TYPE_STRING);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GstWebRTCBin::create-data-channel:
|
* GstWebRTCBin::create-data-channel:
|
||||||
* @object: the #GstWebRTCBin
|
* @object: the #GstWebRTCBin
|
||||||
|
|
|
@ -82,8 +82,8 @@ struct _GstWebRTCICEPrivate
|
||||||
#define gst_webrtc_ice_parent_class parent_class
|
#define gst_webrtc_ice_parent_class parent_class
|
||||||
G_DEFINE_TYPE_WITH_CODE (GstWebRTCICE, gst_webrtc_ice,
|
G_DEFINE_TYPE_WITH_CODE (GstWebRTCICE, gst_webrtc_ice,
|
||||||
GST_TYPE_OBJECT, G_ADD_PRIVATE (GstWebRTCICE)
|
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
|
static gboolean
|
||||||
_unlock_pc_thread (GMutex * lock)
|
_unlock_pc_thread (GMutex * lock)
|
||||||
|
@ -670,6 +670,28 @@ done:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gst_webrtc_ice_add_local_ip_address (GstWebRTCICE * ice, const gchar * address)
|
||||||
|
{
|
||||||
|
gboolean ret = FALSE;
|
||||||
|
NiceAddress nice_addr;
|
||||||
|
|
||||||
|
nice_address_init (&nice_addr);
|
||||||
|
|
||||||
|
ret = nice_address_set_from_string (&nice_addr, address);
|
||||||
|
|
||||||
|
if (ret) {
|
||||||
|
ret = nice_agent_add_local_address (ice->priv->nice_agent, &nice_addr);
|
||||||
|
if (!ret) {
|
||||||
|
GST_ERROR_OBJECT (ice, "Failed to add local address to NiceAgent");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
GST_ERROR_OBJECT (ice, "Failed to initialize NiceAddress [%s]", address);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gst_webrtc_ice_set_local_credentials (GstWebRTCICE * ice,
|
gst_webrtc_ice_set_local_credentials (GstWebRTCICE * ice,
|
||||||
GstWebRTCICEStream * stream, gchar * ufrag, gchar * pwd)
|
GstWebRTCICEStream * stream, gchar * ufrag, gchar * pwd)
|
||||||
|
|
|
@ -81,7 +81,8 @@ gboolean gst_webrtc_ice_set_remote_credentials (GstWebRTCIC
|
||||||
gchar * pwd);
|
gchar * pwd);
|
||||||
gboolean gst_webrtc_ice_add_turn_server (GstWebRTCICE * ice,
|
gboolean gst_webrtc_ice_add_turn_server (GstWebRTCICE * ice,
|
||||||
const gchar * uri);
|
const gchar * uri);
|
||||||
|
gboolean gst_webrtc_ice_add_local_ip_address (GstWebRTCICE * ice,
|
||||||
|
const gchar * address);
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __GST_WEBRTC_ICE_H__ */
|
#endif /* __GST_WEBRTC_ICE_H__ */
|
||||||
|
|
Loading…
Reference in a new issue