# GstPtpClock

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.

## GstPtpClock

    GObject
        ╰──GInitiallyUnowned
            ╰──GstObject
                ╰──GstClock
                    ╰──GstSystemClock
                        ╰──GstPtpClock

Opaque GstPtpClock structure.

### Members

`clock` (GstSystemClock) –
No description available

### Class structure

#### GstPtpClockClass

Opaque GstPtpClockClass structure.

##### Fields

`parent_class` (GstSystemClockClass) –

parented to GstSystemClockClass

### GstNet.PtpClockClass

Opaque GstNet.PtpClockClass structure.

##### Attributes

`parent_class` (Gst.SystemClockClass) –

parented to Gst.SystemClockClass

### GstNet.PtpClockClass

Opaque GstNet.PtpClockClass structure.

##### Attributes

`parent_class` (Gst.SystemClockClass) –

parented to Gst.SystemClockClass

## GstPtpClock

    GObject
        ╰──GInitiallyUnowned
            ╰──GstObject
                ╰──GstClock
                    ╰──GstSystemClock
                        ╰──GstPtpClock

Opaque GstPtpClock structure.

### Members

`clock` (GstSystemClock) –
No description available

## GstPtpClock

    GObject
        ╰──GInitiallyUnowned
            ╰──GstObject
                ╰──GstClock
                    ╰──GstSystemClock
                        ╰──GstPtpClock

Opaque GstPtpClock structure.

### Members

`clock` (GstSystemClock) –
No description available

### Constructors

#### 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

Returns ( [transfer: full] ) –

A new GstClock

Since : 1.6

#### GstNet.PtpClock.prototype.new

    function GstNet.PtpClock.prototype.new(name: String, domain: Number): {
        // javascript wrapper for 'gst_ptp_clock_new'
    }

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 GstNet.prototype.ptp_init was not called before, this will call GstNet.prototype.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.prototype.wait_for_sync, the GstClock::synced signal and Gst.Clock.prototype.is_synced.

Parameters:

`name` ( String ) –

Name of the clock

`domain` ( Number ) –

PTP domain

Returns ( Gst.Clock ) –

A new Gst.Clock

Since : 1.6

#### GstNet.PtpClock.new

    def GstNet.PtpClock.new (name, domain):
        #python wrapper for 'gst_ptp_clock_new'

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 GstNet.ptp_init was not called before, this will call GstNet.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` ( str ) –

Name of the clock

`domain` ( int ) –

PTP domain

Returns ( Gst.Clock ) –

A new Gst.Clock

Since : 1.6

### Properties

#### domain

    “domain” guint

Flags : Read / Write / Construct Only

#### domain

    “domain” Number

Flags : Read / Write / Construct Only

#### domain

    “self.props.domain” int

Flags : Read / Write / Construct Only

#### grandmaster-clock-id

    “grandmaster-clock-id” guint64

Flags : Read

#### grandmaster-clock-id

    “grandmaster-clock-id” Number

Flags : Read

#### grandmaster_clock_id

    “self.props.grandmaster_clock_id” int

Flags : Read

#### internal-clock

    “internal-clock” GstClock *

Flags : Read

#### internal-clock

    “internal-clock” Gst.Clock

Flags : Read

#### internal_clock

    “self.props.internal_clock” Gst.Clock

Flags : Read

#### master-clock-id

    “master-clock-id” guint64

Flags : Read

#### master-clock-id

    “master-clock-id” Number

Flags : Read

#### master_clock_id

    “self.props.master_clock_id” int

Flags : Read

## Functions

### gst_ptp_deinit

    gst_ptp_deinit ()

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

### GstNet.prototype.ptp_deinit

    function GstNet.prototype.ptp_deinit(): {
        // javascript wrapper for 'gst_ptp_deinit'
    }

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

### GstNet.ptp_deinit

    def GstNet.ptp_deinit ():
        #python wrapper for 'gst_ptp_deinit'

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_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` ( [transfer: none] [array zero-terminated=1] [allow-none] ) –

network interfaces to run the clock on

Returns –

TRUE if the GStreamer PTP clock subsystem could be initialized.

Since : 1.6

### GstNet.prototype.ptp_init

    function GstNet.prototype.ptp_init(clock_id: Number, interfaces: [ String ]): {
        // javascript wrapper for 'gst_ptp_init'
    }

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 GstNet.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 GstNet.PtpClock.prototype.new with default parameters if it wasn't called before.

Parameters:

`clock_id` ( Number ) –

PTP clock id of this process' clock or GstNet.PTP_CLOCK_ID_NONE

`interfaces` ( [ String ] ) –

network interfaces to run the clock on

Returns ( Number ) –

true if the GStreamer PTP clock subsystem could be initialized.

Since : 1.6

### GstNet.ptp_init

    def GstNet.ptp_init (clock_id, interfaces):
        #python wrapper for 'gst_ptp_init'

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 GstNet.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 GstNet.PtpClock.new with default parameters if it wasn't called before.

Parameters:

`clock_id` ( int ) –

PTP clock id of this process' clock or GstNet.PTP_CLOCK_ID_NONE

`interfaces` ( [ str ] ) –

network interfaces to run the clock on

Returns ( bool ) –

True if the GStreamer PTP clock subsystem could be initialized.

Since : 1.6

### gst_ptp_is_initialized

    gboolean
    gst_ptp_is_initialized ()

Check if the GStreamer PTP clock subsystem is initialized.

Returns –

TRUE if the GStreamer PTP clock subsystem is initialized.

Since : 1.6

### GstNet.prototype.ptp_is_initialized

    function GstNet.prototype.ptp_is_initialized(): {
        // javascript wrapper for 'gst_ptp_is_initialized'
    }

Check if the GStreamer PTP clock subsystem is initialized.

Returns ( Number ) –

true if the GStreamer PTP clock subsystem is initialized.

Since : 1.6

### GstNet.ptp_is_initialized

    def GstNet.ptp_is_initialized ():
        #python wrapper for 'gst_ptp_is_initialized'

Check if the GStreamer PTP clock subsystem is initialized.

Returns ( bool ) –

True if the GStreamer PTP clock subsystem is initialized.

Since : 1.6

### gst_ptp_is_supported

    gboolean
    gst_ptp_is_supported ()

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

### GstNet.prototype.ptp_is_supported

    function GstNet.prototype.ptp_is_supported(): {
        // javascript wrapper for 'gst_ptp_is_supported'
    }

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

Returns ( Number ) –

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

Since : 1.6

### GstNet.ptp_is_supported

    def GstNet.ptp_is_supported ():
        #python wrapper for 'gst_ptp_is_supported'

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

Returns ( bool ) –

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

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

### GstNet.prototype.ptp_statistics_callback_add

    function GstNet.prototype.ptp_statistics_callback_add(callback: GstNet.PtpStatisticsCallback, user_data: Object): {
        // javascript wrapper for 'gst_ptp_statistics_callback_add'
    }

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

Parameters:

`callback` ( GstNet.PtpStatisticsCallback ) –

GstPtpStatisticsCallback to call

`user_data` ( Object ) –

Data to pass to the callback

Returns ( Number ) –

Id for the callback that can be passed to GstNet.prototype.ptp_statistics_callback_remove

Since : 1.6

### GstNet.ptp_statistics_callback_add

    def GstNet.ptp_statistics_callback_add (callback, *user_data):
        #python wrapper for 'gst_ptp_statistics_callback_add'

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

Parameters:

`callback` ( GstNet.PtpStatisticsCallback ) –

GstPtpStatisticsCallback to call

`user_data` ( variadic ) –

Data to pass to the callback

Returns ( int ) –

Id for the callback that can be passed to GstNet.ptp_statistics_callback_remove

Since : 1.6

### gst_ptp_statistics_callback_remove

    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

### GstNet.prototype.ptp_statistics_callback_remove

    function GstNet.prototype.ptp_statistics_callback_remove(id: Number): {
        // javascript wrapper for 'gst_ptp_statistics_callback_remove'
    }

Removes a PTP statistics callback that was previously added with GstNet.prototype.ptp_statistics_callback_add.

Parameters:

`id` ( Number ) –

Callback id to remove

Since : 1.6

### GstNet.ptp_statistics_callback_remove

    def GstNet.ptp_statistics_callback_remove (id):
        #python wrapper for 'gst_ptp_statistics_callback_remove'

Removes a PTP statistics callback that was previously added with GstNet.ptp_statistics_callback_add.

Parameters:

`id` ( int ) –

Callback id to remove

Since : 1.6

## Constants

### GST_PTP_CLOCK_ID_NONE

    #define GST_PTP_CLOCK_ID_NONE ((guint64) -1)

PTP clock identification that can be passed to gst_ptp_init to automatically select one based on the MAC address of interfaces

### GstNet.PTP_CLOCK_ID_NONE

PTP clock identification that can be passed to GstNet.prototype.ptp_init to automatically select one based on the MAC address of interfaces

### GstNet.PTP_CLOCK_ID_NONE

PTP clock identification that can be passed to GstNet.ptp_init to automatically select one based on the MAC address of interfaces

### GST_PTP_STATISTICS_BEST_MASTER_CLOCK_SELECTED

    #define GST_PTP_STATISTICS_BEST_MASTER_CLOCK_SELECTED "GstPtpStatisticsBestMasterClockSelected"

### GstNet.PTP_STATISTICS_BEST_MASTER_CLOCK_SELECTED

### GST_PTP_STATISTICS_NEW_DOMAIN_FOUND

    #define GST_PTP_STATISTICS_NEW_DOMAIN_FOUND           "GstPtpStatisticsNewDomainFound"

### GstNet.PTP_STATISTICS_NEW_DOMAIN_FOUND

### GST_PTP_STATISTICS_PATH_DELAY_MEASURED

    #define GST_PTP_STATISTICS_PATH_DELAY_MEASURED        "GstPtpStatisticsPathDelayMeasured"

### GstNet.PTP_STATISTICS_PATH_DELAY_MEASURED

### GST_PTP_STATISTICS_TIME_UPDATED

    #define GST_PTP_STATISTICS_TIME_UPDATED               "GstPtpStatisticsTimeUpdated"

### GstNet.PTP_STATISTICS_TIME_UPDATED

### GST_TYPE_PTP_CLOCK

    #define GST_TYPE_PTP_CLOCK \
      (gst_ptp_clock_get_type())

## Callbacks

### GstPtpStatisticsCallback

    gboolean
    (*GstPtpStatisticsCallback) (guint8 domain,
                                 const GstStructure * stats,
                                 gpointer user_data)

The statistics can be the following structures:

GST_PTP_STATISTICS_NEW_DOMAIN_FOUND: "domain" G_TYPE_UINT The domain identifier of the domain "clock" GST_TYPE_CLOCK The internal clock that is slaved to the PTP domain

GST_PTP_STATISTICS_BEST_MASTER_CLOCK_SELECTED: "domain" G_TYPE_UINT The domain identifier of the domain "master-clock-id" G_TYPE_UINT64 PTP clock identifier of the selected master clock "master-clock-port" G_TYPE_UINT PTP port number of the selected master clock "grandmaster-clock-id" G_TYPE_UINT64 PTP clock identifier of the grandmaster clock

GST_PTP_STATISTICS_PATH_DELAY_MEASURED: "domain" G_TYPE_UINT The domain identifier of the domain "mean-path-delay-avg" GST_TYPE_CLOCK_TIME Average mean path delay "mean-path-delay" GST_TYPE_CLOCK_TIME Latest mean path delay "delay-request-delay" GST_TYPE_CLOCK_TIME Delay of DELAY_REQ / DELAY_RESP messages

GST_PTP_STATISTICS_TIME_UPDATED: "domain" G_TYPE_UINT The domain identifier of the domain "mean-path-delay-avg" GST_TYPE_CLOCK_TIME Average mean path delay "local-time" GST_TYPE_CLOCK_TIME Local time that corresponds to ptp-time "ptp-time" GST_TYPE_CLOCK_TIME Newly measured PTP time at local-time "estimated-ptp-time" GST_TYPE_CLOCK_TIME Estimated PTP time based on previous measurements "discontinuity" G_TYPE_INT64 Difference between estimated and measured PTP time "synced" G_TYPE_BOOLEAN Currently synced to the remote clock "r-squared" G_TYPE_DOUBLE R² of clock estimation regression "internal-time" GST_TYPE_CLOCK_TIME Internal time clock parameter "external-time" GST_TYPE_CLOCK_TIME External time clock parameter "rate-num" G_TYPE_UINT64 Internal/external rate numerator "rate-den" G_TYPE_UINT64 Internal/external rate denominator "rate" G_TYPE_DOUBLE Internal/external rate

If FALSE is returned, the callback is removed and never called again.

Parameters:

`domain` –

PTP domain identifier

`stats` –

New statistics

`user_data` –

Data passed to gst_ptp_statistics_callback_add

Returns –
No description available

### GstNet.PtpStatisticsCallback

    function GstNet.PtpStatisticsCallback(domain: Number, stats: Gst.Structure, user_data: Object): {
        // javascript wrapper for 'GstPtpStatisticsCallback'
    }

The statistics can be the following structures:

GST_PTP_STATISTICS_NEW_DOMAIN_FOUND: "domain" G_TYPE_UINT The domain identifier of the domain "clock" GST_TYPE_CLOCK The internal clock that is slaved to the PTP domain

GST_PTP_STATISTICS_BEST_MASTER_CLOCK_SELECTED: "domain" G_TYPE_UINT The domain identifier of the domain "master-clock-id" G_TYPE_UINT64 PTP clock identifier of the selected master clock "master-clock-port" G_TYPE_UINT PTP port number of the selected master clock "grandmaster-clock-id" G_TYPE_UINT64 PTP clock identifier of the grandmaster clock

GST_PTP_STATISTICS_PATH_DELAY_MEASURED: "domain" G_TYPE_UINT The domain identifier of the domain "mean-path-delay-avg" GST_TYPE_CLOCK_TIME Average mean path delay "mean-path-delay" GST_TYPE_CLOCK_TIME Latest mean path delay "delay-request-delay" GST_TYPE_CLOCK_TIME Delay of DELAY_REQ / DELAY_RESP messages

GST_PTP_STATISTICS_TIME_UPDATED: "domain" G_TYPE_UINT The domain identifier of the domain "mean-path-delay-avg" GST_TYPE_CLOCK_TIME Average mean path delay "local-time" GST_TYPE_CLOCK_TIME Local time that corresponds to ptp-time "ptp-time" GST_TYPE_CLOCK_TIME Newly measured PTP time at local-time "estimated-ptp-time" GST_TYPE_CLOCK_TIME Estimated PTP time based on previous measurements "discontinuity" G_TYPE_INT64 Difference between estimated and measured PTP time "synced" G_TYPE_BOOLEAN Currently synced to the remote clock "r-squared" G_TYPE_DOUBLE R² of clock estimation regression "internal-time" GST_TYPE_CLOCK_TIME Internal time clock parameter "external-time" GST_TYPE_CLOCK_TIME External time clock parameter "rate-num" G_TYPE_UINT64 Internal/external rate numerator "rate-den" G_TYPE_UINT64 Internal/external rate denominator "rate" G_TYPE_DOUBLE Internal/external rate

If false is returned, the callback is removed and never called again.

Parameters:

`domain` ( Number ) –

PTP domain identifier

`stats` ( Gst.Structure ) –

New statistics

`user_data` ( Object ) –

Data passed to GstNet.prototype.ptp_statistics_callback_add

Returns ( Number ) –
No description available

### GstNet.PtpStatisticsCallback

    def GstNet.PtpStatisticsCallback (domain, stats, *user_data):
        #python wrapper for 'GstPtpStatisticsCallback'

The statistics can be the following structures:

GST_PTP_STATISTICS_NEW_DOMAIN_FOUND: "domain" G_TYPE_UINT The domain identifier of the domain "clock" GST_TYPE_CLOCK The internal clock that is slaved to the PTP domain

GST_PTP_STATISTICS_BEST_MASTER_CLOCK_SELECTED: "domain" G_TYPE_UINT The domain identifier of the domain "master-clock-id" G_TYPE_UINT64 PTP clock identifier of the selected master clock "master-clock-port" G_TYPE_UINT PTP port number of the selected master clock "grandmaster-clock-id" G_TYPE_UINT64 PTP clock identifier of the grandmaster clock

GST_PTP_STATISTICS_PATH_DELAY_MEASURED: "domain" G_TYPE_UINT The domain identifier of the domain "mean-path-delay-avg" GST_TYPE_CLOCK_TIME Average mean path delay "mean-path-delay" GST_TYPE_CLOCK_TIME Latest mean path delay "delay-request-delay" GST_TYPE_CLOCK_TIME Delay of DELAY_REQ / DELAY_RESP messages

GST_PTP_STATISTICS_TIME_UPDATED: "domain" G_TYPE_UINT The domain identifier of the domain "mean-path-delay-avg" GST_TYPE_CLOCK_TIME Average mean path delay "local-time" GST_TYPE_CLOCK_TIME Local time that corresponds to ptp-time "ptp-time" GST_TYPE_CLOCK_TIME Newly measured PTP time at local-time "estimated-ptp-time" GST_TYPE_CLOCK_TIME Estimated PTP time based on previous measurements "discontinuity" G_TYPE_INT64 Difference between estimated and measured PTP time "synced" G_TYPE_BOOLEAN Currently synced to the remote clock "r-squared" G_TYPE_DOUBLE R² of clock estimation regression "internal-time" GST_TYPE_CLOCK_TIME Internal time clock parameter "external-time" GST_TYPE_CLOCK_TIME External time clock parameter "rate-num" G_TYPE_UINT64 Internal/external rate numerator "rate-den" G_TYPE_UINT64 Internal/external rate denominator "rate" G_TYPE_DOUBLE Internal/external rate

If False is returned, the callback is removed and never called again.

Parameters:

`domain` ( int ) –

PTP domain identifier

`stats` ( Gst.Structure ) –

New statistics

`user_data` ( variadic ) –

Data passed to GstNet.ptp_statistics_callback_add

Returns ( bool ) –
No description available

The results of the search are