mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 19:51:11 +00:00
ptp: Add new gst_ptp_init_full()
This takes a free-form GstStructure as parameter that allows to easily extend it with new configuration at a later time without having to add new API. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5649>
This commit is contained in:
parent
d6c425fc58
commit
12159cb294
2 changed files with 57 additions and 9 deletions
|
@ -2667,31 +2667,37 @@ count_directories (const char *filepath)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_ptp_init:
|
* gst_ptp_init_full:
|
||||||
* @clock_id: PTP clock id of this process' clock or %GST_PTP_CLOCK_ID_NONE
|
* @config: Configuration for initializing the GStreamer PTP subsystem
|
||||||
* @interfaces: (transfer none) (array zero-terminated=1) (allow-none): network interfaces to run the clock on
|
|
||||||
*
|
*
|
||||||
* Initialize the GStreamer PTP subsystem and create a PTP ordinary clock in
|
* Initialize the GStreamer PTP subsystem and create a PTP ordinary clock in
|
||||||
* slave-only mode for all domains on the given @interfaces with the
|
* slave-only mode according to the @config.
|
||||||
* given @clock_id.
|
|
||||||
*
|
*
|
||||||
* If @clock_id is %GST_PTP_CLOCK_ID_NONE, a clock id is automatically
|
* @config is a #GstStructure with the following optional fields:
|
||||||
* generated from the MAC address of the first network interface.
|
* * #guint64 `clock-id`: The clock ID to use for the local clock. If the
|
||||||
|
* clock-id is not provided or %GST_PTP_CLOCK_ID_NONE is provided, a clock
|
||||||
|
* id is automatically generated from the MAC address of the first network
|
||||||
|
* interface.
|
||||||
|
* * #GStrv `interfaces`: The interface names to listen on for PTP packets. If
|
||||||
|
* none are provided then all compatible interfaces will be used.
|
||||||
*
|
*
|
||||||
* This function is automatically called by gst_ptp_clock_new() with default
|
* This function is automatically called by gst_ptp_clock_new() with default
|
||||||
* parameters if it wasn't called before.
|
* parameters if it wasn't called before.
|
||||||
*
|
*
|
||||||
* Returns: %TRUE if the GStreamer PTP clock subsystem could be initialized.
|
* Returns: %TRUE if the GStreamer PTP clock subsystem could be initialized.
|
||||||
*
|
*
|
||||||
* Since: 1.6
|
* Since: 1.24
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
gst_ptp_init (guint64 clock_id, gchar ** interfaces)
|
gst_ptp_init_full (const GstStructure * config)
|
||||||
{
|
{
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
const gchar *env;
|
const gchar *env;
|
||||||
gchar **argv = NULL;
|
gchar **argv = NULL;
|
||||||
gint argc, argc_c;
|
gint argc, argc_c;
|
||||||
|
guint64 clock_id = GST_CLOCK_TIME_NONE;
|
||||||
|
const GValue *v;
|
||||||
|
gchar **interfaces = NULL;
|
||||||
GError *err = NULL;
|
GError *err = NULL;
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_INIT (ptp_debug, "ptp", 0, "PTP clock");
|
GST_DEBUG_CATEGORY_INIT (ptp_debug, "ptp", 0, "PTP clock");
|
||||||
|
@ -2720,8 +2726,12 @@ gst_ptp_init (guint64 clock_id, gchar ** interfaces)
|
||||||
}
|
}
|
||||||
|
|
||||||
argc = 1;
|
argc = 1;
|
||||||
|
gst_structure_get_uint64(config, "clock-id", &clock_id);
|
||||||
if (clock_id != GST_PTP_CLOCK_ID_NONE)
|
if (clock_id != GST_PTP_CLOCK_ID_NONE)
|
||||||
argc += 2;
|
argc += 2;
|
||||||
|
v = gst_structure_get_value (config, "interfaces");
|
||||||
|
if (v && G_VALUE_HOLDS (v, G_TYPE_STRV))
|
||||||
|
interfaces = g_value_get_boxed (v);
|
||||||
if (interfaces != NULL)
|
if (interfaces != NULL)
|
||||||
argc += 2 * g_strv_length (interfaces);
|
argc += 2 * g_strv_length (interfaces);
|
||||||
|
|
||||||
|
@ -2911,6 +2921,40 @@ done:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_ptp_init:
|
||||||
|
* @clock_id: PTP clock id of this process' clock or %GST_PTP_CLOCK_ID_NONE
|
||||||
|
* @interfaces: (transfer none) (array zero-terminated=1) (allow-none): network interfaces to run the clock on
|
||||||
|
*
|
||||||
|
* Initialize the GStreamer PTP subsystem and create a PTP ordinary clock in
|
||||||
|
* slave-only mode for all domains on the given @interfaces with the
|
||||||
|
* given @clock_id.
|
||||||
|
*
|
||||||
|
* If @clock_id is %GST_PTP_CLOCK_ID_NONE, a clock id is automatically
|
||||||
|
* generated from the MAC address of the first network interface.
|
||||||
|
*
|
||||||
|
* This function is automatically called by gst_ptp_clock_new() with default
|
||||||
|
* parameters if it wasn't called before.
|
||||||
|
*
|
||||||
|
* Returns: %TRUE if the GStreamer PTP clock subsystem could be initialized.
|
||||||
|
*
|
||||||
|
* Since: 1.6
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
gst_ptp_init (guint64 clock_id, gchar ** interfaces)
|
||||||
|
{
|
||||||
|
GstStructure *config;
|
||||||
|
gboolean ret;
|
||||||
|
|
||||||
|
config = gst_structure_new ("config/ptp",
|
||||||
|
"clock-id", G_TYPE_UINT64, clock_id,
|
||||||
|
"interfaces", G_TYPE_STRV, interfaces, NULL);
|
||||||
|
ret = gst_ptp_init_full (config);
|
||||||
|
gst_structure_free (config);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_ptp_deinit:
|
* gst_ptp_deinit:
|
||||||
*
|
*
|
||||||
|
|
|
@ -88,6 +88,10 @@ gboolean gst_ptp_is_initialized (void);
|
||||||
GST_NET_API
|
GST_NET_API
|
||||||
gboolean gst_ptp_init (guint64 clock_id,
|
gboolean gst_ptp_init (guint64 clock_id,
|
||||||
gchar ** interfaces);
|
gchar ** interfaces);
|
||||||
|
|
||||||
|
GST_NET_API
|
||||||
|
gboolean gst_ptp_init_full (const GstStructure *config);
|
||||||
|
|
||||||
GST_NET_API
|
GST_NET_API
|
||||||
void gst_ptp_deinit (void);
|
void gst_ptp_deinit (void);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue