GstClock: GStreamer 1.0 Core Reference Manual

## GstClock GstClock |

## Functions

#define | GST_CLOCK_TIME_IS_VALID()
#define | GST_CLOCK_STIME_IS_VALID()
#define | GST_TIME_AS_SECONDS()
#define | GST_TIME_AS_MSECONDS()
#define | GST_TIME_AS_USECONDS()
#define | GST_TIME_AS_NSECONDS()
#define | GST_CLOCK_DIFF()
#define | GST_TIMEVAL_TO_TIME()
#define | GST_TIME_TO_TIMEVAL()
#define | GST_TIMESPEC_TO_TIME()
#define | GST_TIME_TO_TIMESPEC()
gboolean | (*GstClockCallback) ()
#define | GST_CLOCK_ENTRY()
#define | GST_CLOCK_ENTRY_CLOCK()
#define | GST_CLOCK_ENTRY_TYPE()
#define | GST_CLOCK_ENTRY_TIME()
#define | GST_CLOCK_ENTRY_INTERVAL()
#define | GST_CLOCK_ENTRY_STATUS()
#define | GST_CLOCK_FLAGS()
gboolean | gst_clock_add_observation ()
gboolean | gst_clock_add_observation_unapplied ()
gboolean | gst_clock_set_master ()
GstClock * | gst_clock_get_master ()
GstClockTime | gst_clock_set_resolution ()
GstClockTime | gst_clock_get_resolution ()
GstClockTime | gst_clock_get_time ()
GstClockID | gst_clock_new_single_shot_id ()
GstClockID | gst_clock_new_periodic_id ()
gboolean | gst_clock_single_shot_id_reinit ()
gboolean | gst_clock_periodic_id_reinit ()
GstClockTime | gst_clock_get_internal_time ()
GstClockTime | gst_clock_adjust_unlocked ()
GstClockTime | gst_clock_unadjust_unlocked ()
GstClockTime | gst_clock_adjust_with_calibration ()
GstClockTime | gst_clock_unadjust_with_calibration ()
void | gst_clock_get_calibration ()
void | gst_clock_set_calibration ()
GstClockTime | gst_clock_get_timeout ()
void | gst_clock_set_timeout ()
gboolean | gst_clock_wait_for_sync ()
gboolean | gst_clock_is_synced ()
void | gst_clock_set_synced ()
GstClockTime | gst_clock_id_get_time ()
GstClockReturn | gst_clock_id_wait ()
GstClockReturn | gst_clock_id_wait_async ()
void | gst_clock_id_unschedule ()
gint | gst_clock_id_compare_func ()
GstClockID | gst_clock_id_ref ()
void | gst_clock_id_unref ()

## Properties

guint64 | timeout | Read / Write
gint | window-size | Read / Write
gint | window-threshold | Read / Write

## Signals

void | synced | Run Last

## Types and Values

struct | GstClock
struct | GstClockClass
typedef | GstClockTime
typedef | GstClockTimeDiff
typedef | GstClockID
#define | GST_CLOCK_TIME_NONE
#define | GST_CLOCK_STIME_NONE
#define | GST_SECOND
#define | GST_MSECOND
#define | GST_USECOND
#define | GST_NSECOND
struct | GstClockEntry
enum | GstClockEntryType
enum | GstClockReturn
enum | GstClockFlags

## Object Hierarchy

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

## Includes

    #include <gst/gst.h>

## Description

## Functions

### GST_CLOCK_TIME_IS_VALID()

    #define GST_CLOCK_TIME_IS_VALID(time)   (((GstClockTime)(time)) != GST_CLOCK_TIME_NONE)

### GST_CLOCK_STIME_IS_VALID()

    #define GST_CLOCK_STIME_IS_VALID(time)   (((GstClockTimeDiff)(time)) != GST_CLOCK_STIME_NONE)

### GST_TIME_AS_SECONDS()

    #define GST_TIME_AS_SECONDS(time)  ((time) / GST_SECOND)

### GST_TIME_AS_MSECONDS()

    #define GST_TIME_AS_MSECONDS(time) ((time) / G_GINT64_CONSTANT (1000000))

### GST_TIME_AS_USECONDS()

    #define GST_TIME_AS_USECONDS(time) ((time) / G_GINT64_CONSTANT (1000))

### GST_TIME_AS_NSECONDS()

    #define GST_TIME_AS_NSECONDS(time) (time)

### GST_CLOCK_DIFF()

    #define GST_CLOCK_DIFF(s, e)            (GstClockTimeDiff)((e) - (s))

### GST_TIMEVAL_TO_TIME()

    #define GST_TIMEVAL_TO_TIME(tv)         (GstClockTime)((tv).tv_sec * GST_SECOND + (tv).tv_usec * GST_USECOND)

### GST_TIME_TO_TIMEVAL()

    #define             GST_TIME_TO_TIMEVAL(t,tv)

### GST_TIMESPEC_TO_TIME()

    #define GST_TIMESPEC_TO_TIME(ts)        (GstClockTime)((ts).tv_sec * GST_SECOND + (ts).tv_nsec * GST_NSECOND)

### GST_TIME_TO_TIMESPEC()

    #define             GST_TIME_TO_TIMESPEC(t,ts)

### GstClockCallback ()

    gboolean
    (*GstClockCallback) (GstClock *clock,
                         GstClockTime time,
                         GstClockID id,
                         gpointer user_data);

### GST_CLOCK_ENTRY()

    #define GST_CLOCK_ENTRY(entry)          ((GstClockEntry *)(entry))

### GST_CLOCK_ENTRY_CLOCK()

    #define GST_CLOCK_ENTRY_CLOCK(entry)    ((entry)->clock)

### GST_CLOCK_ENTRY_TYPE()

    #define GST_CLOCK_ENTRY_TYPE(entry)     ((entry)->type)

### GST_CLOCK_ENTRY_TIME()

    #define GST_CLOCK_ENTRY_TIME(entry)     ((entry)->time)

### GST_CLOCK_ENTRY_INTERVAL()

    #define GST_CLOCK_ENTRY_INTERVAL(entry) ((entry)->interval)

### GST_CLOCK_ENTRY_STATUS()

    #define GST_CLOCK_ENTRY_STATUS(entry)   ((entry)->status)

### GST_CLOCK_FLAGS()

    #define GST_CLOCK_FLAGS(clock)  GST_OBJECT_FLAGS(clock)

### gst_clock_add_observation ()

    gboolean
    gst_clock_add_observation (GstClock *clock,
                               GstClockTime slave,
                               GstClockTime master,
                               gdouble *r_squared);

### gst_clock_add_observation_unapplied ()

    gboolean
    gst_clock_add_observation_unapplied (GstClock *clock,
                                         GstClockTime slave,
                                         GstClockTime master,
                                         gdouble *r_squared,
                                         GstClockTime *internal,
                                         GstClockTime *external,
                                         GstClockTime *rate_num,
                                         GstClockTime *rate_denom);

### gst_clock_set_master ()

    gboolean
    gst_clock_set_master (GstClock *clock,
                          GstClock *master);

### gst_clock_get_master ()

    GstClock *
    gst_clock_get_master (GstClock *clock);

### gst_clock_set_resolution ()

    GstClockTime
    gst_clock_set_resolution (GstClock *clock,
                              GstClockTime resolution);

### gst_clock_get_resolution ()

    GstClockTime
    gst_clock_get_resolution (GstClock *clock);

### gst_clock_get_time ()

    GstClockTime
    gst_clock_get_time (GstClock *clock);

### gst_clock_new_single_shot_id ()

    GstClockID
    gst_clock_new_single_shot_id (GstClock *clock,
                                  GstClockTime time);

### gst_clock_new_periodic_id ()

    GstClockID
    gst_clock_new_periodic_id (GstClock *clock,
                               GstClockTime start_time,
                               GstClockTime interval);

### gst_clock_single_shot_id_reinit ()

    gboolean
    gst_clock_single_shot_id_reinit (GstClock *clock,
                                     GstClockID id,
                                     GstClockTime time);

### gst_clock_periodic_id_reinit ()

    gboolean
    gst_clock_periodic_id_reinit (GstClock *clock,
                                  GstClockID id,
                                  GstClockTime start_time,
                                  GstClockTime interval);

### gst_clock_get_internal_time ()

    GstClockTime
    gst_clock_get_internal_time (GstClock *clock);

### gst_clock_adjust_unlocked ()

    GstClockTime
    gst_clock_adjust_unlocked (GstClock *clock,
                               GstClockTime internal);

### gst_clock_unadjust_unlocked ()

    GstClockTime
    gst_clock_unadjust_unlocked (GstClock *clock,
                                 GstClockTime external);

### gst_clock_adjust_with_calibration ()

    GstClockTime
    gst_clock_adjust_with_calibration (GstClock *clock,
                                       GstClockTime internal_target,
                                       GstClockTime cinternal,
                                       GstClockTime cexternal,
                                       GstClockTime cnum,
                                       GstClockTime cdenom);

### gst_clock_unadjust_with_calibration ()

    GstClockTime
    gst_clock_unadjust_with_calibration (GstClock *clock,
                                         GstClockTime external_target,
                                         GstClockTime cinternal,
                                         GstClockTime cexternal,
                                         GstClockTime cnum,
                                         GstClockTime cdenom);

### gst_clock_get_calibration ()

    void
    gst_clock_get_calibration (GstClock *clock,
                               GstClockTime *internal,
                               GstClockTime *external,
                               GstClockTime *rate_num,
                               GstClockTime *rate_denom);

### gst_clock_set_calibration ()

    void
    gst_clock_set_calibration (GstClock *clock,
                               GstClockTime internal,
                               GstClockTime external,
                               GstClockTime rate_num,
                               GstClockTime rate_denom);

### gst_clock_get_timeout ()

    GstClockTime
    gst_clock_get_timeout (GstClock *clock);

### gst_clock_set_timeout ()

    void
    gst_clock_set_timeout (GstClock *clock,
                           GstClockTime timeout);

### gst_clock_wait_for_sync ()

    gboolean
    gst_clock_wait_for_sync (GstClock *clock,
                             GstClockTime timeout);

### gst_clock_is_synced ()

    gboolean
    gst_clock_is_synced (GstClock *clock);

### gst_clock_set_synced ()

    void
    gst_clock_set_synced (GstClock *clock,
                          gboolean synced);

### gst_clock_id_get_time ()

    GstClockTime
    gst_clock_id_get_time (GstClockID id);

### gst_clock_id_wait ()

    GstClockReturn
    gst_clock_id_wait (GstClockID id,
                       GstClockTimeDiff *jitter);

### gst_clock_id_wait_async ()

    GstClockReturn
    gst_clock_id_wait_async (GstClockID id,
                             GstClockCallback func,
                             gpointer user_data,
                             GDestroyNotify destroy_data);

### gst_clock_id_unschedule ()

    void
    gst_clock_id_unschedule (GstClockID id);

### gst_clock_id_compare_func ()

    gint
    gst_clock_id_compare_func (gconstpointer id1,
                               gconstpointer id2);

### gst_clock_id_ref ()

    GstClockID
    gst_clock_id_ref (GstClockID id);

### gst_clock_id_unref ()

    void
    gst_clock_id_unref (GstClockID id);

## Types and Values

### struct GstClock

    struct GstClock;

### struct GstClockClass

    struct GstClockClass {
      GstObjectClass        parent_class;

      /* vtable */
      GstClockTime          (*change_resolution)    (GstClock *clock,
                                                     GstClockTime old_resolution,
                                                     GstClockTime new_resolution);
      GstClockTime          (*get_resolution)       (GstClock *clock);

      GstClockTime          (*get_internal_time)    (GstClock *clock);

      /* waiting on an ID */
      GstClockReturn        (*wait)                 (GstClock *clock, GstClockEntry *entry,
                                                     GstClockTimeDiff *jitter);
      GstClockReturn        (*wait_async)           (GstClock *clock, GstClockEntry *entry);
      void                  (*unschedule)           (GstClock *clock, GstClockEntry *entry);
    };

### GstClockTime

    typedef guint64 GstClockTime;

### GstClockTimeDiff

    typedef gint64 GstClockTimeDiff;

### GstClockID

    typedef gpointer GstClockID;

### GST_CLOCK_TIME_NONE

    #define GST_CLOCK_TIME_NONE             ((GstClockTime) -1)

### GST_CLOCK_STIME_NONE

    #define GST_CLOCK_STIME_NONE             G_MININT64

### GST_SECOND

    #define GST_SECOND  (G_USEC_PER_SEC * G_GINT64_CONSTANT (1000))

### GST_MSECOND

    #define GST_MSECOND (GST_SECOND / G_GINT64_CONSTANT (1000))

### GST_USECOND

    #define GST_USECOND (GST_SECOND / G_GINT64_CONSTANT (1000000))

### GST_NSECOND

    #define GST_NSECOND (GST_SECOND / G_GINT64_CONSTANT (1000000000))

### struct GstClockEntry

    struct GstClockEntry {
      gint                  refcount;
    };

### enum GstClockEntryType

#### Members

GST_CLOCK_ENTRY_SINGLE |  |
GST_CLOCK_ENTRY_PERIODIC |  |

### enum GstClockReturn

#### Members

GST_CLOCK_OK |  |
GST_CLOCK_EARLY |  |
GST_CLOCK_UNSCHEDULED |  |
GST_CLOCK_BUSY |  |
GST_CLOCK_BADTIME |  |
GST_CLOCK_ERROR |  |
GST_CLOCK_UNSUPPORTED |  |
GST_CLOCK_DONE |  |

### enum GstClockFlags

#### Members

GST_CLOCK_FLAG_CAN_DO_SINGLE_SYNC |  |
GST_CLOCK_FLAG_CAN_DO_SINGLE_ASYNC |  |
GST_CLOCK_FLAG_CAN_DO_PERIODIC_SYNC |  |
GST_CLOCK_FLAG_CAN_DO_PERIODIC_ASYNC |  |
GST_CLOCK_FLAG_CAN_SET_RESOLUTION |  |
GST_CLOCK_FLAG_CAN_SET_MASTER |  |
GST_CLOCK_FLAG_NEEDS_STARTUP_SYNC |  |
GST_CLOCK_FLAG_LAST |  |

## Property Details

### The `“timeout”` property

      “timeout”                  guint64

The amount of time, in nanoseconds, to sample master and slave clocks.

Flags: Read / Write

Default value: 100000000

### The `“window-size”` property

      “window-size”              gint

The size of the window used to calculate rate and offset.

Flags: Read / Write

Allowed values: [2,1024]

Default value: 32

### The `“window-threshold”` property

      “window-threshold”         gint

The threshold to start calculating rate and offset.

Flags: Read / Write

Allowed values: [2,1024]

Default value: 4

## Signal Details

### The `“synced”` signal

    void
    user_function (GstClock *gstclock,
                   gboolean  arg1,
                   gpointer  user_data)

Flags: Run Last