mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
netclientclock: Implement resolval of hostnames
Just allowing IPs here is not ideal and implementing DNS resolval is easy.
This commit is contained in:
parent
2bfa204c30
commit
9f36b4383b
1 changed files with 23 additions and 7 deletions
|
@ -898,14 +898,28 @@ gst_net_client_clock_start (GstNetClientClock * self)
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
GSocketFamily family;
|
GSocketFamily family;
|
||||||
GPollFD dummy_pollfd;
|
GPollFD dummy_pollfd;
|
||||||
|
GResolver *resolver = NULL;
|
||||||
|
GError *err = NULL;
|
||||||
|
|
||||||
g_return_val_if_fail (self->priv->address != NULL, FALSE);
|
g_return_val_if_fail (self->priv->address != NULL, FALSE);
|
||||||
g_return_val_if_fail (self->priv->servaddr == NULL, FALSE);
|
g_return_val_if_fail (self->priv->servaddr == NULL, FALSE);
|
||||||
|
|
||||||
/* create target address */
|
/* create target address */
|
||||||
inetaddr = g_inet_address_new_from_string (self->priv->address);
|
inetaddr = g_inet_address_new_from_string (self->priv->address);
|
||||||
if (inetaddr == NULL)
|
if (inetaddr == NULL) {
|
||||||
goto bad_address;
|
GList *results;
|
||||||
|
|
||||||
|
resolver = g_resolver_get_default ();
|
||||||
|
|
||||||
|
results =
|
||||||
|
g_resolver_lookup_by_name (resolver, self->priv->address, NULL, &err);
|
||||||
|
if (!results)
|
||||||
|
goto failed_to_resolve;
|
||||||
|
|
||||||
|
inetaddr = G_INET_ADDRESS (g_object_ref (results->data));
|
||||||
|
g_resolver_free_addresses (results);
|
||||||
|
g_object_unref (resolver);
|
||||||
|
}
|
||||||
|
|
||||||
family = g_inet_address_get_family (inetaddr);
|
family = g_inet_address_get_family (inetaddr);
|
||||||
|
|
||||||
|
@ -980,10 +994,12 @@ getsockname_error:
|
||||||
g_object_unref (socket);
|
g_object_unref (socket);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
bad_address:
|
failed_to_resolve:
|
||||||
{
|
{
|
||||||
GST_ERROR_OBJECT (self, "inet_address_new_from_string('%s') failed",
|
GST_ERROR_OBJECT (self, "resolving '%s' failed: %s",
|
||||||
self->priv->address);
|
self->priv->address, err->message);
|
||||||
|
g_clear_error (&err);
|
||||||
|
g_object_unref (resolver);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
no_thread:
|
no_thread:
|
||||||
|
@ -1028,7 +1044,7 @@ gst_net_client_clock_stop (GstNetClientClock * self)
|
||||||
/**
|
/**
|
||||||
* gst_net_client_clock_new:
|
* gst_net_client_clock_new:
|
||||||
* @name: a name for the clock
|
* @name: a name for the clock
|
||||||
* @remote_address: the address of the remote clock provider
|
* @remote_address: the address or hostname of the remote clock provider
|
||||||
* @remote_port: the port of the remote clock provider
|
* @remote_port: the port of the remote clock provider
|
||||||
* @base_time: initial time of the clock
|
* @base_time: initial time of the clock
|
||||||
*
|
*
|
||||||
|
@ -1072,7 +1088,7 @@ gst_ntp_clock_init (GstNtpClock * self)
|
||||||
/**
|
/**
|
||||||
* gst_ntp_clock_new:
|
* gst_ntp_clock_new:
|
||||||
* @name: a name for the clock
|
* @name: a name for the clock
|
||||||
* @remote_address: the address of the remote clock provider
|
* @remote_address: the address or hostname of the remote clock provider
|
||||||
* @remote_port: the port of the remote clock provider
|
* @remote_port: the port of the remote clock provider
|
||||||
* @base_time: initial time of the clock
|
* @base_time: initial time of the clock
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue