mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-10-06 10:42:22 +00:00
ptp: Correctly parse clock ID from the commandline parameters in the helper
Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/2652 Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4813>
This commit is contained in:
parent
da06637e4e
commit
06586fd92f
1 changed files with 28 additions and 1 deletions
|
@ -71,10 +71,37 @@ static gboolean verbose = FALSE;
|
||||||
static guint64 clock_id = (guint64) - 1;
|
static guint64 clock_id = (guint64) - 1;
|
||||||
static guint8 clock_id_array[8];
|
static guint8 clock_id_array[8];
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
parse_clock_id (const gchar * option_name, const gchar * value, gpointer data,
|
||||||
|
GError ** err)
|
||||||
|
{
|
||||||
|
gchar *endptr;
|
||||||
|
guint64 v;
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
|
v = g_ascii_strtoull (value, &endptr, 16);
|
||||||
|
if (endptr == NULL || *endptr != '\0') {
|
||||||
|
g_set_error (err, G_OPTION_ERROR, G_OPTION_ERROR_UNKNOWN_OPTION,
|
||||||
|
"Cannot parse integer value \"%s\" for --clock-id", value);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (errno != 0) {
|
||||||
|
g_set_error (err, G_OPTION_ERROR, G_OPTION_ERROR_UNKNOWN_OPTION,
|
||||||
|
"Cannot parse integer value \"%s\" for --clock-id: %s", value,
|
||||||
|
g_strerror (errno));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
clock_id = v;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static GOptionEntry opt_entries[] = {
|
static GOptionEntry opt_entries[] = {
|
||||||
{"interface", 'i', 0, G_OPTION_ARG_STRING_ARRAY, &ifaces,
|
{"interface", 'i', 0, G_OPTION_ARG_STRING_ARRAY, &ifaces,
|
||||||
"Interface to listen on", NULL},
|
"Interface to listen on", NULL},
|
||||||
{"clock-id", 'c', 0, G_OPTION_ARG_INT64, &clock_id,
|
{"clock-id", 'c', 0, G_OPTION_ARG_CALLBACK, parse_clock_id,
|
||||||
"PTP clock id", NULL},
|
"PTP clock id", NULL},
|
||||||
{"verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose,
|
{"verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose,
|
||||||
"Be verbose", NULL},
|
"Be verbose", NULL},
|
||||||
|
|
Loading…
Reference in a new issue