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.

clock :The clock that triggered the callback
time :The time it was triggered
id :The id that expired
user_data :user data passed in the async_wait call


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_STOPPEDThe clock is stopped.
GST_CLOCK_TIMEOUTThe operation timed out.
GST_CLOCK_EARLYThe operation was scheduled too late.
GST_CLOCK_ERRORAn error occured


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.

s :the first time
e :the second time


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

tv :the timeval to convert


GST_TIME_TO_TIMEVAL()

#define     GST_TIME_TO_TIMEVAL(t,tv)

Convert a GstClockTime to a GTimeVal

t :The GstClockTime to convert
tv :The target timeval


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.

clock : a GstClock to modify
speed : the speed to set on the clock


gst_clock_get_speed ()

gdouble     gst_clock_get_speed             (GstClock *clock);

Gets the speed of the given clock.

clock : a GstClock to query
Returns : the speed of the 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.

clock : a GstClock to set state of
active : flag indicating if the clock should be activated (TRUE) or deactivated


gst_clock_is_active ()

gboolean    gst_clock_is_active             (GstClock *clock);

Checks if the given clock is active.

clock : a GstClock to query
Returns : TRUE if the clock is active.


gst_clock_reset ()

void        gst_clock_reset                 (GstClock *clock);

Reset the clock to time 0.

clock : a GstClock to reset


gst_clock_handle_discont ()

gboolean    gst_clock_handle_discont        (GstClock *clock,
                                             guint64 time);

Notifies the clock of a discontinuity in time.

clock : a GstClock to notify of the discontinuity
time : The new time
Returns : TRUE if the clock was updated. It is possible that the clock was not updated by this call because only the first discontinuitity in the pipeline is honoured.


gst_clock_async_supported ()

gboolean    gst_clock_async_supported       (GstClock *clock);

Checks if this clock can support asynchronous notification.

clock : a GstClock to query
Returns : TRUE if async notification is supported.


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.

clock : a GstClock to wait on
time : The GstClockTime to wait for
jitter : The jitter
Returns : the GstClockReturn result of the operation.


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.

clock : a GstClock to wait on
time : The GstClockTime to wait for
func : The callback function
user_data : User data passed in the calback
Returns : the clock id or NULL when async notification is not supported.


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.

clock : The clock to cancel the request on
id : The id to cancel


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.

clock : The clock to wait on
interval : The interval between notifications
func : The callback function
user_data : User data passed in the calback
Returns : the clock id or NULL when async notification is not supported.


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.

clock : The clock to cancel the request on
id : The id to cancel


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().

clock : The clock to wait on
id : The clock id to wait on
jitter : The jitter
Returns : result of the operation.


gst_clock_get_next_id ()

GstClockID  gst_clock_get_next_id           (GstClock *clock);

Get the clockid of the next event.

clock : The clock to query
Returns : a clockid or NULL is no event is pending.


gst_clock_unlock_id ()

void        gst_clock_unlock_id             (GstClock *clock,
                                             GstClockID id);

Unlock the ClockID.

clock : The clock that own the id
id : The clockid to unlock


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.

clock : a GstClock to query
Returns : the time of the clock.


gst_clock_id_get_time ()

GstClockTime gst_clock_id_get_time          (GstClockID id);

Get the time of the clock ID

id : The clockid to query
Returns : the time of the given clock id


gst_clock_get_resolution ()

guint64     gst_clock_get_resolution        (GstClock *clock);

Get the accuracy of the clock.

clock : The clock get the resolution of
Returns : the resolution of the clock in microseconds.


gst_clock_set_resolution ()

void        gst_clock_set_resolution        (GstClock *clock,
                                             guint64 resolution);

Set the accuracy of the clock.

clock : The clock set the resolution on
resolution : The resolution to set

See Also

GstSystemClock