GstClock

Name

GstClock -- Abstract class for global clocks

Synopsis


#include <gst/gst.h>


typedef     GstClockTime;
typedef     GstClockTimeDiff;
void        (*GstClockCallback)             (GstClock *clock,
                                             GstClockTime time,
                                             GstClockID id,
                                             gpointer user_data);
typedef     GstClockID;
enum        GstClockReturn;
#define     GST_CLOCK_TIME_NONE
#define     GST_SECOND
#define     GST_MSECOND
#define     GST_USECOND
#define     GST_NSECOND
#define     GST_CLOCK_DIFF                  (s, e)
#define     GST_TIMEVAL_TO_TIME             (tv)
#define     GST_TIME_TO_TIMEVAL             (t,tv)
struct      GstClock;
void        gst_clock_set_speed             (GstClock *clock,
                                             gdouble speed);
gdouble     gst_clock_get_speed             (GstClock *clock);
void        gst_clock_set_active            (GstClock *clock,
                                             gboolean active);
gboolean    gst_clock_is_active             (GstClock *clock);
void        gst_clock_reset                 (GstClock *clock);
gboolean    gst_clock_handle_discont        (GstClock *clock,
                                             guint64 time);
gboolean    gst_clock_async_supported       (GstClock *clock);
GstClockReturn gst_clock_wait               (GstClock *clock,
                                             GstClockTime time,
                                             GstClockTimeDiff *jitter);
GstClockID  gst_clock_wait_async            (GstClock *clock,
                                             GstClockTime time,
                                             GstClockCallback func,
                                             gpointer user_data);
void        gst_clock_cancel_wait_async     (GstClock *clock,
                                             GstClockID id);
GstClockID  gst_clock_notify_async          (GstClock *clock,
                                             GstClockTime interval,
                                             GstClockCallback func,
                                             gpointer user_data);
void        gst_clock_remove_notify_async   (GstClock *clock,
                                             GstClockID id);
GstClockReturn gst_clock_wait_id            (GstClock *clock,
                                             GstClockID id,
                                             GstClockTimeDiff *jitter);
GstClockID  gst_clock_get_next_id           (GstClock *clock);
void        gst_clock_unlock_id             (GstClock *clock,
                                             GstClockID id);
GstClockTime gst_clock_get_time             (GstClock *clock);
GstClockTime gst_clock_id_get_time          (GstClockID id);
guint64     gst_clock_get_resolution        (GstClock *clock);
void        gst_clock_set_resolution        (GstClock *clock,
                                             guint64 resolution);

Object Hierarchy


  GObject
   +----GstObject
         +----GstClock

Description

GStreamer uses a global clock to synchronise the plugins in a pipeline. Different clock implementations are possible by implementing this abstract base class.

The clock time is always measured in nanoseconds, with the clock being set to 0 when the pipeline goes to READY. Usually all renderers sync to the global clock so that the clock is always a good measure of the time in the pipeline.

Details

GstClockTime

typedef guint64 	GstClockTime;

A datatype to hold a time, measured in nanoseconds.


GstClockTimeDiff

typedef gint64 		GstClockTimeDiff;

A datatype to hold a timedifference, measured in nanoseconds.


GstClockCallback ()

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

The function prototype of the callback.


GstClockID

typedef gpointer 	GstClockID;

A detatype to hold the handle to an outstanding async clock callback


enum GstClockReturn

typedef enum
{
  GST_CLOCK_STOPPED 	= 0,
  GST_CLOCK_TIMEOUT 	= 1,
  GST_CLOCK_EARLY 	= 2,
  GST_CLOCK_ERROR 	= 3
} GstClockReturn;

The return value of a clock operation.


GST_CLOCK_TIME_NONE

#define GST_CLOCK_TIME_NONE  ((guint64)-1)

Constant to define an undefined clock time


GST_SECOND

#define GST_SECOND  ((guint64)G_USEC_PER_SEC * 1000LL)

Constant that defines one GStreamer second


GST_MSECOND

#define GST_MSECOND ((guint64)GST_SECOND/1000LL)

Constant that defines one GStreamer millisecond


GST_USECOND

#define GST_USECOND ((guint64)GST_SECOND/1000000LL)

Constant that defines one GStreamer microsecond


GST_NSECOND

#define GST_NSECOND ((guint64)GST_SECOND/1000000000LL)

Constant that defines one GStreamer nanosecond


GST_CLOCK_DIFF()

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

Calculate a difference between to clock times.


GST_TIMEVAL_TO_TIME()

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

Convert a GTimeVal to a GstClockTime


GST_TIME_TO_TIMEVAL()

#define     GST_TIME_TO_TIMEVAL(t,tv)

Convert a GstClockTime to a GTimeVal


struct GstClock

struct GstClock;

The opaque data structure of the clock.


gst_clock_set_speed ()

void        gst_clock_set_speed             (GstClock *clock,
                                             gdouble speed);

Sets the speed on the given clock. 1.0 is the default speed.


gst_clock_get_speed ()

gdouble     gst_clock_get_speed             (GstClock *clock);

Gets the speed of the given clock.


gst_clock_set_active ()

void        gst_clock_set_active            (GstClock *clock,
                                             gboolean active);

Activates or deactivates the clock based on the active parameter. As soon as the clock is activated, the time will start ticking.


gst_clock_is_active ()

gboolean    gst_clock_is_active             (GstClock *clock);

Checks if the given clock is active.


gst_clock_reset ()

void        gst_clock_reset                 (GstClock *clock);

Reset the clock to time 0.


gst_clock_handle_discont ()

gboolean    gst_clock_handle_discont        (GstClock *clock,
                                             guint64 time);

Notifies the clock of a discontinuity in time.


gst_clock_async_supported ()

gboolean    gst_clock_async_supported       (GstClock *clock);

Checks if this clock can support asynchronous notification.


gst_clock_wait ()

GstClockReturn gst_clock_wait               (GstClock *clock,
                                             GstClockTime time,
                                             GstClockTimeDiff *jitter);

Wait and block till the clock reaches the specified time. The jitter value contains the difference between the requested time and the actual time, negative values indicate that the requested time was allready passed when this call was made.


gst_clock_wait_async ()

GstClockID  gst_clock_wait_async            (GstClock *clock,
                                             GstClockTime time,
                                             GstClockCallback func,
                                             gpointer user_data);

Register a callback on the given clock that will be triggered when the clock has reached the given time. A ClockID is returned that can be used to cancel the request.


gst_clock_cancel_wait_async ()

void        gst_clock_cancel_wait_async     (GstClock *clock,
                                             GstClockID id);

Cancel an outstanding async notification request with the given ID.


gst_clock_notify_async ()

GstClockID  gst_clock_notify_async          (GstClock *clock,
                                             GstClockTime interval,
                                             GstClockCallback func,
                                             gpointer user_data);

Register a callback on the given clock that will be periodically triggered with the specified interval. A ClockID is returned that can be used to cancel the request.


gst_clock_remove_notify_async ()

void        gst_clock_remove_notify_async   (GstClock *clock,
                                             GstClockID id);

Cancel an outstanding async notification request with the given ID.


gst_clock_wait_id ()

GstClockReturn gst_clock_wait_id            (GstClock *clock,
                                             GstClockID id,
                                             GstClockTimeDiff *jitter);

Wait and block on the clockid obtained with gst_clock_wait_async. The jitter value is described in gst_clock_wait().


gst_clock_get_next_id ()

GstClockID  gst_clock_get_next_id           (GstClock *clock);

Get the clockid of the next event.


gst_clock_unlock_id ()

void        gst_clock_unlock_id             (GstClock *clock,
                                             GstClockID id);

Unlock the ClockID.


gst_clock_get_time ()

GstClockTime gst_clock_get_time             (GstClock *clock);

Gets the current time of the given clock. The time is always monotonically increasing.


gst_clock_id_get_time ()

GstClockTime gst_clock_id_get_time          (GstClockID id);

Get the time of the clock ID


gst_clock_get_resolution ()

guint64     gst_clock_get_resolution        (GstClock *clock);

Get the accuracy of the clock.


gst_clock_set_resolution ()

void        gst_clock_set_resolution        (GstClock *clock,
                                             guint64 resolution);

Set the accuracy of the clock.

See Also

GstSystemClock