Clock

Description GStreamer uses a global clock to synchronize the plugins in a pipeline. Different clock implementations are possible by implementing this abstract base class. The GstClock returns a monotonically increasing time with the method gst_clock_get_time(). Its accuracy and base time depend on the specific clock implementation but time is always expressed in nanoseconds. Since the baseline of the clock is undefined, the clock time returned is not meaningful in itself, what matters are the deltas between two clock times. The time returned by a clock is called the absolute time. The pipeline uses the clock to calculate the stream time. Usually all renderers synchronize to the global clock using the buffer timestamps, the newsegment events and the element's base time, see GstPipeline. A clock implementation can support periodic and single shot clock notifications both synchronous and asynchronous. One first needs to create a GstClockID for the periodic or single shot notification using gst_clock_new_single_shot_id() or gst_clock_new_periodic_id(). To perform a blocking wait for the specific time of the GstClockID use the gst_clock_id_wait(). To receive a callback when the specific time is reached in the clock use gst_clock_id_wait_async(). Both these calls can be interrupted with the gst_clock_id_unschedule() call. If the blocking wait is unscheduled a return value of GST_CLOCK_UNSCHEDULED is returned. Periodic callbacks scheduled async will be repeadedly called automatically until it is unscheduled. To schedule a sync periodic callback, gst_clock_id_wait() should be called repeadedly. The async callbacks can happen from any thread, either provided by the core or from a streaming thread. The application should be prepared for this. A GstClockID that has been unscheduled cannot be used again for any wait operation, a new GstClockID should be created and the old unscheduled one should be destroyed wirth gst_clock_id_unref(). It is possible to perform a blocking wait on the same GstClockID from multiple threads. However, registering the same GstClockID for multiple async notifications is not possible, the callback will only be called for the thread registering the entry last. None of the wait operations unref the GstClockID, the owner is responsible for unreffing the ids itself. This holds for both periodic and single shot notifications. The reason being that the owner of the GstClockID has to keep a handle to the GstClockID to unblock the wait on FLUSHING events or state changes and if the entry would be unreffed automatically, the handle might become invalid without any notification. These clock operations do not operate on the stream time, so the callbacks will also occur when not in PLAYING state as if the clock just keeps on running. Some clocks however do not progress when the element that provided the clock is not PLAYING. When a clock has the GST_CLOCK_FLAG_CAN_SET_MASTER flag set, it can be slaved to another GstClock with the gst_clock_set_master(). The clock will then automatically be synchronized to this master clock by repeadedly sampling the master clock and the slave clock and recalibrating the slave clock with gst_clock_set_calibration(). This feature is mostly useful for plugins that have an internal clock but must operate with another clock selected by the GstPipeline. They can track the offset and rate difference of their internal clock relative to the master clock by using the gst_clock_get_calibration() function. The master/slave synchronisation can be tuned with the "timeout", "window-size" and "window-threshold" properties. The "timeout" property defines the interval to sample the master clock and run the calibration functions. "window-size" defines the number of samples to use when calibrating and "window-threshold" defines the minimum number of samples before the calibration is performed. Last reviewed on 2006-08-11 (0.10.10)

Constructors

this
this(GstClock* gstClock)

Sets our main struct and passes it to the parent class

Members

Functions

addObservation
int addObservation(GstClockTime slave, GstClockTime master, double rSquared)

The time master of the master clock and the time slave of the slave clock are added to the list of observations. If enough observations are available, a linear regression algorithm is run on the observations and clock is recalibrated. If this functions returns TRUE, r_squared will contain the correlation coefficient of the interpollation. A value of 1.0 means a perfect regression was performed. This value can be used to control the sampling frequency of the master and slave clocks.

adjustUnlocked
GstClockTime adjustUnlocked(GstClockTime internal)

Converts the given internal clock time to the external time, adjusting for the rate and reference time set with gst_clock_set_calibration() and making sure that the returned time is increasing. This function should be called with the clock's OBJECT_LOCK held and is mainly used by clock subclasses. This function is te reverse of gst_clock_unadjust_unlocked().

getCalibration
void getCalibration(GstClockTime internal, GstClockTime external, GstClockTime rateNum, GstClockTime rateDenom)

Gets the internal rate and reference time of clock. See gst_clock_set_calibration() for more information. internal, external, rate_num, and rate_denom can be left NULL if the caller is not interested in the values. MT safe.

getClockStruct
GstClock* getClockStruct()
Undocumented in source. Be warned that the author may not have intended to support it.
getInternalTime
GstClockTime getInternalTime()

Gets the current internal time of the given clock. The time is returned unadjusted for the offset and the rate.

getMaster
Clock getMaster()

Get the master clock that clock is slaved to or NULL when the clock is not slaved to any master clock.

getResolution
GstClockTime getResolution()

Get the accuracy of the clock. The accuracy of the clock is the granularity of the values returned by gst_clock_get_time().

getStruct
void* getStruct()

the main Gtk struct as a void*

getTime
GstClockTime getTime()

Gets the current time of the given clock. The time is always monotonically increasing and adjusted according to the current offset and rate.

newPeriodicId
GstClockID newPeriodicId(GstClockTime startTime, GstClockTime interval)

Get an ID from clock to trigger a periodic notification. The periodeic notifications will be start at time start_time and will then be fired with the given interval. id should be unreffed after usage.

newSingleShotId
GstClockID newSingleShotId(GstClockTime time)

Get a GstClockID from clock to trigger a single shot notification at the requested time. The single shot id should be unreffed after usage.

setCalibration
void setCalibration(GstClockTime internal, GstClockTime external, GstClockTime rateNum, GstClockTime rateDenom)

Adjusts the rate and time of clock. A rate of 1/1 is the normal speed of the clock. Values bigger than 1/1 make the clock go faster. internal and external are calibration parameters that arrange that gst_clock_get_time() should have been external at internal time internal. This internal time should not be in the future; that is, it should be less than the value of gst_clock_get_internal_time() when this function is called. Subsequent calls to gst_clock_get_time() will return clock times computed as

setMaster
int setMaster(Clock master)

Set master as the master clock for clock. clock will be automatically calibrated so that gst_clock_get_time() reports the same time as the master clock. A clock provider that slaves its clock to a master can get the current calibration values with gst_clock_get_calibration(). master can be NULL in which case clock will not be slaved anymore. It will however keep reporting its time adjusted with the last configured rate and time offsets.

setResolution
GstClockTime setResolution(GstClockTime resolution)

Set the accuracy of the clock. Some clocks have the possibility to operate with different accuracy at the expense of more resource usage. There is normally no need to change the default resolution of a clock. The resolution of a clock can only be changed if the clock has the GST_CLOCK_FLAG_CAN_SET_RESOLUTION flag set.

setStruct
void setStruct(GObject* obj)
Undocumented in source. Be warned that the author may not have intended to support it.
unadjustUnlocked
GstClockTime unadjustUnlocked(GstClockTime external)

Converts the given external clock time to the internal time of clock, using the rate and reference time set with gst_clock_set_calibration(). This function should be called with the clock's OBJECT_LOCK held and is mainly used by clock subclasses. This function is te reverse of gst_clock_adjust_unlocked().

Static functions

idCompareFunc
int idCompareFunc(void* id1, void* id2)

Compares the two GstClockID instances. This function can be used as a GCompareFunc when sorting ids.

idGetTime
GstClockTime idGetTime(GstClockID id)

Get the time of the clock ID

idRef
GstClockID idRef(GstClockID id)

Increase the refcount of given id.

idUnref
void idUnref(GstClockID id)

Unref given id. When the refcount reaches 0 the GstClockID will be freed. MT safe.

idUnschedule
void idUnschedule(GstClockID id)

Cancel an outstanding request with id. This can either be an outstanding async notification or a pending sync notification. After this call, id cannot be used anymore to receive sync or async notifications, you need to create a new GstClockID. MT safe.

idWait
GstClockReturn idWait(GstClockID id, GstClockTimeDiff jitter)

Perform a blocking wait on id. id should have been created with gst_clock_new_single_shot_id() or gst_clock_new_periodic_id() and should not have been unscheduled with a call to gst_clock_id_unschedule(). If the jitter argument is not NULL and this function returns GST_CLOCK_OK or GST_CLOCK_EARLY, it will contain the difference against the clock and the time of id when this method was called. Positive values indicate how late id was relative to the clock (in which case this function will return GST_CLOCK_EARLY). Negative values indicate how much time was spent waiting on the clock before this function returned.

idWaitAsync
GstClockReturn idWaitAsync(GstClockID id, GstClockCallback func, void* userData)

Register a callback on the given GstClockID id with the given function and user_data. When passing a GstClockID with an invalid time to this function, the callback will be called immediatly with a time set to GST_CLOCK_TIME_NONE. The callback will be called when the time of id has been reached.

Variables

gstClock
GstClock* gstClock;

the main Gtk struct

Inherited Members

From ObjectGst

gstObject
GstObject* gstObject;

the main Gtk struct

getObjectGstStruct
GstObject* getObjectGstStruct()
Undocumented in source. Be warned that the author may not have intended to support it.
getStruct
void* getStruct()

the main Gtk struct as a void*

setStruct
void setStruct(GObject* obj)
Undocumented in source. Be warned that the author may not have intended to support it.
connectedSignals
int[string] connectedSignals;
onDeepNotifyListeners
void delegate(ObjectGst, ParamSpec, ObjectGst)[] onDeepNotifyListeners;
Undocumented in source.
addOnDeepNotify
void addOnDeepNotify(void delegate(ObjectGst, ParamSpec, ObjectGst) dlg, ConnectFlags connectFlags)

The deep notify signal is used to be notified of property changes. It is typically attached to the toplevel bin to receive notifications from all the elements contained in that bin.

callBackDeepNotify
void callBackDeepNotify(GstObject* gstobjectStruct, GstObject* propObject, GParamSpec* prop, ObjectGst _objectGst)
Undocumented in source. Be warned that the author may not have intended to support it.
onObjectSavedListeners
void delegate(void*, ObjectGst)[] onObjectSavedListeners;
Undocumented in source.
addOnObjectSaved
void addOnObjectSaved(void delegate(void*, ObjectGst) dlg, ConnectFlags connectFlags)

Trigered whenever a new object is saved to XML. You can connect to this signal to insert custom XML tags into the core XML.

callBackObjectSaved
void callBackObjectSaved(GstObject* gstobjectStruct, void* xmlNode, ObjectGst _objectGst)
Undocumented in source. Be warned that the author may not have intended to support it.
onParentSetListeners
void delegate(ObjectG, ObjectGst)[] onParentSetListeners;
Undocumented in source.
addOnParentSet
void addOnParentSet(void delegate(ObjectG, ObjectGst) dlg, ConnectFlags connectFlags)

Emitted when the parent of an object is set.

callBackParentSet
void callBackParentSet(GstObject* gstobjectStruct, GObject* parent, ObjectGst _objectGst)
Undocumented in source. Be warned that the author may not have intended to support it.
onParentUnsetListeners
void delegate(ObjectG, ObjectGst)[] onParentUnsetListeners;
Undocumented in source.
addOnParentUnset
void addOnParentUnset(void delegate(ObjectG, ObjectGst) dlg, ConnectFlags connectFlags)

Emitted when the parent of an object is unset.

callBackParentUnset
void callBackParentUnset(GstObject* gstobjectStruct, GObject* parent, ObjectGst _objectGst)
Undocumented in source. Be warned that the author may not have intended to support it.
setName
int setName(string name)

Sets the name of object, or gives object a guaranteed unique name (if name is NULL). This function makes a copy of the provided name, so the caller retains ownership of the name it sent.

getName
string getName()

Returns a copy of the name of object. Caller should g_free() the return value after usage. For a nameless object, this returns NULL, which you can safely g_free() as well.

setParent
int setParent(ObjectGst parent)

Sets the parent of object to parent. The object's reference count will be incremented, and any floating reference will be removed (see gst_object_sink()). This function causes the parent-set signal to be emitted when the parent was successfully set.

getParent
ObjectGst getParent()

Returns the parent of object. This function increases the refcount of the parent object so you should gst_object_unref() it after usage.

unparent
void unparent()

Clear the parent of object, removing the associated reference. This function decreases the refcount of object. MT safe. Grabs and releases object's lock.

getNamePrefix
string getNamePrefix()

Returns a copy of the name prefix of object. Caller should g_free() the return value after usage. For a prefixless object, this returns NULL, which you can safely g_free() as well.

setNamePrefix
void setNamePrefix(string namePrefix)

Sets the name prefix of object to name_prefix. This function makes a copy of the provided name prefix, so the caller retains ownership of the name prefix it sent. MT safe. This function grabs and releases object's LOCK.

defaultDeepNotify
void defaultDeepNotify(ObjectG object, ObjectGst orig, ParamSpec pspec, string[] excludedProps)

A default deep_notify signal callback for an object. The user data should contain a pointer to an array of strings that should be excluded from the notify. The default handler will print the new value of the property using g_print. MT safe. This function grabs and releases object's LOCK for getting its path string.

defaultError
void defaultError(ErrorG error, string dbug)

A default error function. The default handler will simply print the error string using g_print.

checkUniqueness
int checkUniqueness(ListG list, string name)

Checks to see if there is any object named name in list. This function does not do any locking of any kind. You might want to protect the provided list with the lock of the owner of the list. This function will lock each GstObject in the list to compare the name, so be carefull when passing a list with a locked object.

hasAncestor
int hasAncestor(ObjectGst ancestor)

Check if object has an ancestor ancestor somewhere up in the hierarchy.

doref
void* doref(void* object)

Increments the refence count on object. This function does not take the lock on object because it relies on atomic refcounting. This object returns the input parameter to ease writing

unref
void unref(void* object)

Decrements the refence count on object. If reference count hits zero, destroy object. This function does not take the lock on object as it relies on atomic refcounting. The unref method should never be called with the LOCK held since this might deadlock the dispose function.

sink
void sink(void* object)

If object was floating, the GST_OBJECT_FLOATING flag is removed and object is unreffed. When object was not floating, this function does nothing. Any newly created object has a refcount of 1 and is floating. This function should be used when creating a new object to symbolically 'take ownership' of object. This done by first doing a gst_object_ref() to keep a reference to object and then gst_object_sink() to remove and unref any floating references to object. Use gst_object_set_parent() to have this done for you. MT safe. This function grabs and releases object lock.

replace
void replace(ObjectGst oldobj, ObjectGst newobj)

Unrefs the GstObject pointed to by oldobj, refs newobj and puts newobj in *oldobj. Be carefull when calling this function, it does not take any locks. You might want to lock the object owning oldobj pointer before calling this function. Make sure not to LOCK oldobj because it might be unreffed which could cause a deadlock when it is disposed.

getPathString
string getPathString()

Generates a string describing the path of object in the object hierarchy. Only useful (or used) for debugging.

Meta