GstPtpClock: GStreamer 1.0 Library Reference Manual

## GstPtpClock GstPtpClock — Special clock that synchronizes to a remote time provider via PTP (IEEE1588:2008). |

## Functions

gboolean | gst_ptp_init ()
void | gst_ptp_deinit ()
gboolean | gst_ptp_is_initialized ()
gboolean | gst_ptp_is_supported ()
GstClock * | gst_ptp_clock_new ()
gulong | gst_ptp_statistics_callback_add ()
void | gst_ptp_statistics_callback_remove ()

## Types and Values

struct | GstPtpClock

## Includes

    #include <gst/net/net.h>

## Description

GstPtpClock implements a PTP (IEEE1588:2008) ordinary clock in slave-only mode, that allows a GStreamer pipeline to synchronize to a PTP network clock in some specific domain.

The PTP subsystem can be initialized with `gst_ptp_init()`, which then starts a helper process to do the actual communication via the PTP ports. This is required as PTP listens on ports < 1024 and thus requires special privileges. Once this helper process is started, the main process will synchronize to all PTP domains that are detected on the selected interfaces.

gst_ptp_clock_new() then allows to create a GstClock that provides the PTP time from a master clock inside a specific PTP domain. This clock will only return valid timestamps once the timestamps in the PTP domain are known. To check this, you can use `gst_clock_wait_for_sync()`, the GstClock::synced signal and `gst_clock_is_synced()`.

To gather statistics about the PTP clock synchronization, `gst_ptp_statistics_callback_add()` can be used. This gives the application the possibility to collect all kinds of statistics from the clock synchronization.

## Functions

### gst_ptp_init ()

    gboolean
    gst_ptp_init (guint64 clock_id,
                  gchar **interfaces);

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.

#### Parameters

clock_id | PTP clock id of this process' clock or `GST_PTP_CLOCK_ID_NONE` |
interfaces | network interfaces to run the clock on. | [transfer none][array zero-terminated=1]

#### Returns

`TRUE` if the GStreamer PTP clock subsystem could be initialized.

Since: 1.6

### gst_ptp_deinit ()

    void
    gst_ptp_deinit (void);

Deinitialize the GStreamer PTP subsystem and stop the PTP clock. If there are any remaining GstPtpClock instances, they won't be further synchronized to the PTP network clock.

Since: 1.6

### gst_ptp_is_initialized ()

    gboolean
    gst_ptp_is_initialized (void);

Check if the GStreamer PTP clock subsystem is initialized.

#### Returns

`TRUE` if the GStreamer PTP clock subsystem is intialized.

Since: 1.6

### gst_ptp_is_supported ()

    gboolean
    gst_ptp_is_supported (void);

Check if PTP clocks are generally supported on this system, and if previous initializations did not fail.

#### Returns

`TRUE` if PTP clocks are generally supported on this system, and previous initializations did not fail.

Since: 1.6

### gst_ptp_clock_new ()

    GstClock *
    gst_ptp_clock_new (const gchar *name,
                       guint domain);

Creates a new PTP clock instance that exports the PTP time of the master clock in `domain` . This clock can be slaved to other clocks as needed.

If `gst_ptp_init()` was not called before, this will call `gst_ptp_init()` with default parameters.

This clock only returns valid timestamps after it received the first times from the PTP master clock on the network. Once this happens the GstPtpClock::internal-clock property will become non-NULL. You can check this with `gst_clock_wait_for_sync()`, the GstClock::synced signal and `gst_clock_is_synced()`.

#### Parameters

name | Name of the clock |
domain | PTP domain |

Since: 1.6

### gst_ptp_statistics_callback_add ()

    gulong
    gst_ptp_statistics_callback_add (GstPtpStatisticsCallback callback,
                                     gpointer user_data,
                                     GDestroyNotify destroy_data);

Installs a new statistics callback for gathering PTP statistics. See GstPtpStatisticsCallback for a list of statistics that are provided.

#### Parameters

callback | GstPtpStatisticsCallback to call |
user_data | Data to pass to the callback |
destroy_data | GDestroyNotify to destroy the data |

#### Returns

Id for the callback that can be passed to `gst_ptp_statistics_callback_remove()`

Since: 1.6

### gst_ptp_statistics_callback_remove ()

    void
    gst_ptp_statistics_callback_remove (gulong id);

Removes a PTP statistics callback that was previously added with `gst_ptp_statistics_callback_add()`.

#### Parameters

id | Callback id to remove |

Since: 1.6

## Types and Values

### struct GstPtpClock

    struct GstPtpClock {
      GstSystemClock clock;
    };

Opaque GstPtpClock structure.

## See Also

GstClock, GstNetClientClock, GstPipeline