Gst.Clock¶
| Subclasses: | Gst.SystemClock | 
|---|
Methods¶
| Inherited: | Gst.Object (27), GObject.Object (37) | 
|---|---|
| Structs: | GObject.ObjectClass (5) | 
| class | id_compare_func(id1, id2) | 
| class | id_get_clock(id) | 
| class | id_get_time(id) | 
| class | id_ref(id) | 
| class | id_unref(id) | 
| class | id_unschedule(id) | 
| class | id_uses_clock(id, clock) | 
| class | id_wait(id) | 
| class | id_wait_async(id, func, *user_data) | 
| add_observation(slave, master) | |
| add_observation_unapplied(slave, master) | |
| adjust_unlocked(internal) | |
| adjust_with_calibration(internal_target, cinternal, cexternal, cnum, cdenom) | |
| get_calibration() | |
| get_internal_time() | |
| get_master() | |
| get_resolution() | |
| get_time() | |
| get_timeout() | |
| is_synced() | |
| new_periodic_id(start_time, interval) | |
| new_single_shot_id(time) | |
| periodic_id_reinit(id, start_time, interval) | |
| set_calibration(internal, external, rate_num, rate_denom) | |
| set_master(master) | |
| set_resolution(resolution) | |
| set_synced(synced) | |
| set_timeout(timeout) | |
| single_shot_id_reinit(id, time) | |
| unadjust_unlocked(external) | |
| unadjust_with_calibration(external_target, cinternal, cexternal, cnum, cdenom) | |
| wait_for_sync(timeout) | 
Virtual Methods¶
| Inherited: | Gst.Object (1), GObject.Object (7) | 
|---|
| do_change_resolution(old_resolution, new_resolution) | |
| do_get_internal_time() | |
| do_get_resolution() | |
| do_unschedule(entry) | |
| do_wait(entry, jitter) | |
| do_wait_async(entry) | 
Properties¶
| Inherited: | Gst.Object (2) | 
|---|
| Name | Type | Flags | Short Description | 
|---|---|---|---|
| timeout | int | r/w | The amount of time, in nanoseconds, to sample master and slave clocks | 
| window-size | int | r/w | The size of the window used to calculate rate and offset | 
| window-threshold | int | r/w | The threshold to start calculating rate and offset | 
Signals¶
| Inherited: | Gst.Object (1), GObject.Object (1) | 
|---|
| Name | Short Description | 
|---|---|
| synced | Signaled on clocks with Gst.ClockFlags.NEEDS_STARTUP_SYNCset once the clock is synchronized, or when it completely lost synchronization. | 
Fields¶
| Inherited: | Gst.Object (1), GObject.Object (1) | 
|---|
| Name | Type | Access | Description | 
|---|---|---|---|
| object | Gst.Object | r | 
Class Details¶
- 
class Gst.Clock(**kwargs)¶
- Bases: - Gst.Object- Abstract: - Yes - Structure: - Gst.ClockClass- GStreamer uses a global clock to synchronize the plugins in a pipeline. Different clock implementations are possible by implementing this abstract base class or, more conveniently, by subclassing - Gst.SystemClock.- The - Gst.Clockreturns 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.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 running time. Usually all renderers synchronize to the global clock using the buffer timestamps, the newsegment events and the element’s base time, see - Gst.Pipeline.- 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.ClockReturn.UNSCHEDULEDis returned.- Periodic callbacks scheduled async will be repeatedly called automatically until it is unscheduled. To schedule a sync periodic callback, - Gst.Clock.id_wait() should be called repeatedly.- 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 with - 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 running 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.ClockFlags.CAN_SET_MASTERflag set, it can be slaved to another- Gst.Clockwith the- Gst.Clock.set_master(). The clock will then automatically be synchronized to this master clock by repeatedly 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- Gst.Pipeline. 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 - Gst.Clock- :timeout,- Gst.Clock- :window-sizeand- Gst.Clock- :window-thresholdproperties. The- Gst.Clock- :timeoutproperty defines the interval to sample the master clock and run the calibration functions.- Gst.Clock- :window-sizedefines the number of samples to use when calibrating and- Gst.Clock- :window-thresholddefines the minimum number of samples before the calibration is performed.- New in version the. - 
classmethod id_compare_func(id1, id2)[source]¶
- Parameters: - Returns: - negative value if a < b; zero if a = b; positive value if a > b - MT safe. - Return type: - Compares the two #GstClockID instances. This function can be used as a - GLib.CompareFuncwhen sorting ids.
 - 
classmethod id_get_clock(id)[source]¶
- Parameters: - id ( - object) – a #GstClockID- Returns: - a - Gst.Clockor- Nonewhen the underlying clock has been freed. Unref after usage.- MT safe. - Return type: - Gst.Clockor- None- This function returns the underlying clock. - New in version 1.16. 
 - 
classmethod id_get_time(id)[source]¶
- Parameters: - id ( - object) – The #GstClockID to query- Returns: - the time of the given clock id. - MT safe. - Return type: - int- Get the time of the clock ID 
 - 
classmethod id_ref(id)[source]¶
- Parameters: - id ( - object) – The #GstClockID to ref- Returns: - The same #GstClockID with increased refcount. - MT safe. - Return type: - object- Increase the refcount of given id. 
 - 
classmethod id_unref(id)[source]¶
- Parameters: - id ( - object) – The #GstClockID to unref- Unref given id. When the refcount reaches 0 the #GstClockID will be freed. - MT safe. 
 - 
classmethod id_unschedule(id)[source]¶
- Parameters: - id ( - object) – The id to unschedule- 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. 
 - 
classmethod id_uses_clock(id, clock)[source]¶
- Parameters: - Returns: - whether the clock id uses the same underlying - Gst.Clockclock.- MT safe. - Return type: - This function returns whether id uses clock as the underlying clock. clock can be - None, in which case the return value indicates whether the underlying clock has been freed. If this is the case, the id is no longer usable and should be freed.- New in version 1.16. 
 - 
classmethod id_wait(id)[source]¶
- Parameters: - id ( - object) – The #GstClockID to wait on- Returns: - the result of the blocking wait. - Gst.ClockReturn.EARLYwill be returned if the current clock time is past the time of id,- Gst.ClockReturn.OKif id was scheduled in time.- Gst.ClockReturn.UNSCHEDULEDif id was unscheduled with- Gst.Clock.id_unschedule().- MT safe. - jitter: - a pointer that will contain the jitter, can be - None.- Return type: - ( - Gst.ClockReturn, jitter:- int)- 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 - Noneand this function returns- Gst.ClockReturn.OKor- Gst.ClockReturn.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.ClockReturn.EARLY). Negative values indicate how much time was spent waiting on the clock before this function returned.
 - 
classmethod id_wait_async(id, func, *user_data)[source]¶
- Parameters: - id (object) – a #GstClockID to wait on
- func (Gst.ClockCallback) – The callback function
- user_data (objectorNone) – User data passed in the callback
 - Returns: - the result of the non blocking wait. - MT safe. - Return type: - 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 immediately with a time set to - Gst.CLOCK_TIME_NONE. The callback will be called when the time of id has been reached.- The callback func can be invoked from any thread, either provided by the core or from a streaming thread. The application should be prepared for this. 
- id (
 - 
add_observation(slave, master)[source]¶
- Parameters: - Returns: - Trueif enough observations were added to run the regression algorithm.- MT safe. - r_squared: - a pointer to hold the result - Return type: - 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 self is recalibrated. - If this functions returns - True, r_squared will contain the correlation coefficient of the interpolation. 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.
 - 
add_observation_unapplied(slave, master)[source]¶
- Parameters: - Returns: - r_squared: - a pointer to hold the result - internal: - a location to store the internal time - external: - a location to store the external time - rate_num: - a location to store the rate numerator - rate_denom: - a location to store the rate denominator - Return type: - ( - bool, r_squared:- float, internal:- int, external:- int, rate_num:- int, rate_denom:- int)- Add a clock observation to the internal slaving algorithm the same as - Gst.Clock.add_observation(), and return the result of the master clock estimation, without updating the internal calibration.- The caller can then take the results and call - Gst.Clock.set_calibration() with the values, or some modified version of them.- New in version 1.6. 
 - 
adjust_unlocked(internal)[source]¶
- Parameters: - internal ( - int) – a clock time- Returns: - the converted time of the clock. - Return type: - int- 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 the reverse of - Gst.Clock.unadjust_unlocked().
 - 
adjust_with_calibration(internal_target, cinternal, cexternal, cnum, cdenom)[source]¶
- Parameters: - Returns: - the converted time of the clock. - Return type: - Converts the given internal_target clock time to the external time, using the passed calibration parameters. This function performs the same calculation as - Gst.Clock.adjust_unlocked() when called using the current calibration parameters, but doesn’t ensure a monotonically increasing result as- Gst.Clock.adjust_unlocked() does.- Note: The self parameter is unused and can be - None- New in version 1.6. 
 - 
get_calibration()[source]¶
- Returns: - internal: - a location to store the internal time - external: - a location to store the external time - rate_num: - a location to store the rate numerator - rate_denom: - a location to store the rate denominator - Return type: - (internal: - int, external:- int, rate_num:- int, rate_denom:- int)- Gets the internal rate and reference time of self. See - Gst.Clock.set_calibration() for more information.- internal, external, rate_num, and rate_denom can be left - Noneif the caller is not interested in the values.- MT safe. 
 - 
get_internal_time()[source]¶
- Returns: - the internal time of the clock. Or - Gst.CLOCK_TIME_NONEwhen given invalid input.- MT safe. - Return type: - int- Gets the current internal time of the given clock. The time is returned unadjusted for the offset and the rate. 
 - 
get_master()[source]¶
- Returns: - a master - Gst.Clockor- Nonewhen this clock is not slaved to a master clock. Unref after usage.- MT safe. - Return type: - Gst.Clockor- None- Get the master clock that self is slaved to or - Nonewhen the clock is not slaved to any master clock.
 - 
get_resolution()[source]¶
- Returns: - the resolution of the clock in units of #GstClockTime. - MT safe. - Return type: - int- Get the accuracy of the clock. The accuracy of the clock is the granularity of the values returned by - Gst.Clock.get_time().
 - 
get_time()[source]¶
- Returns: - the time of the clock. Or - Gst.CLOCK_TIME_NONEwhen given invalid input.- MT safe. - Return type: - int- Gets the current time of the given clock. The time is always monotonically increasing and adjusted according to the current offset and rate. 
 - 
get_timeout()[source]¶
- Returns: - the interval between samples. - Return type: - int- Get the amount of time that master and slave clocks are sampled. 
 - 
is_synced()[source]¶
- Returns: - Trueif the clock is currently synced- Return type: - bool- Checks if the clock is currently synced. - This returns if - Gst.ClockFlags.NEEDS_STARTUP_SYNCis not set on the clock.- New in version 1.6. 
 - 
new_periodic_id(start_time, interval)[source]¶
- Parameters: - Returns: - a #GstClockID that can be used to request the time notification. - MT safe. - Return type: - Get an ID from self to trigger a periodic notification. The periodic notifications will start at time start_time and will then be fired with the given interval. id should be unreffed after usage. - Free-function: - Gst.Clock.id_unref
 - 
new_single_shot_id(time)[source]¶
- Parameters: - time ( - int) – the requested time- Returns: - a #GstClockID that can be used to request the time notification. - MT safe. - Return type: - object- Get a #GstClockID from self to trigger a single shot notification at the requested time. The single shot id should be unreffed after usage. - Free-function: - Gst.Clock.id_unref
 - 
periodic_id_reinit(id, start_time, interval)[source]¶
- Parameters: - Returns: - Trueif the GstClockID could be reinitialized to the provided time, else- False.- Return type: - Reinitializes the provided periodic id to the provided start time and interval. Does not modify the reference count. 
 - 
set_calibration(internal, external, rate_num, rate_denom)[source]¶
- Parameters: - Adjusts the rate and time of self. 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 follows:- time = (internal_time - internal) * rate_num / rate_denom + external- This formula is implemented in - Gst.Clock.adjust_unlocked(). Of course, it tries to do the integer arithmetic as precisely as possible.- Note that - Gst.Clock.get_time() always returns increasing values so when you move the clock backwards,- Gst.Clock.get_time() will report the previous value until the clock catches up.- MT safe. 
 - 
set_master(master)[source]¶
- Parameters: - master ( - Gst.Clockor- None) – a master- Gst.Clock- Returns: - Trueif the clock is capable of being slaved to a master clock. Trying to set a master on a clock without the- Gst.ClockFlags.CAN_SET_MASTERflag will make this function return- False.- MT safe. - Return type: - bool- Set master as the master clock for self. self 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 - Nonein which case self will not be slaved anymore. It will however keep reporting its time adjusted with the last configured rate and time offsets.
 - 
set_resolution(resolution)[source]¶
- Parameters: - resolution ( - int) – The resolution to set- Returns: - the new resolution of the clock. - Return type: - int- 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.ClockFlags.CAN_SET_RESOLUTIONflag set.
 - 
set_synced(synced)[source]¶
- Parameters: - synced ( - bool) – if the clock is synced- Sets self to synced and emits the - Gst.Clock- ::syncedsignal, and wakes up any thread waiting in- Gst.Clock.wait_for_sync().- This function must only be called if - Gst.ClockFlags.NEEDS_STARTUP_SYNCis set on the clock, and is intended to be called by subclasses only.- New in version 1.6. 
 - 
set_timeout(timeout)[source]¶
- Parameters: - timeout ( - int) – a timeout- Set the amount of time, in nanoseconds, to sample master and slave clocks 
 - 
single_shot_id_reinit(id, time)[source]¶
- Parameters: - Returns: - Trueif the GstClockID could be reinitialized to the provided time, else- False.- Return type: - Reinitializes the provided single shot id to the provided time. Does not modify the reference count. 
 - 
unadjust_unlocked(external)[source]¶
- Parameters: - external ( - int) – an external clock time- Returns: - the internal time of the clock corresponding to external. - Return type: - int- Converts the given external clock time to the internal time of self, 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 the reverse of - Gst.Clock.adjust_unlocked().
 - 
unadjust_with_calibration(external_target, cinternal, cexternal, cnum, cdenom)[source]¶
- Parameters: - Returns: - the converted time of the clock. - Return type: - Converts the given external_target clock time to the internal time, using the passed calibration parameters. This function performs the same calculation as - Gst.Clock.unadjust_unlocked() when called using the current calibration parameters.- Note: The self parameter is unused and can be - None- New in version 1.8. 
 - 
wait_for_sync(timeout)[source]¶
- Parameters: - timeout ( - int) – timeout for waiting or- Gst.CLOCK_TIME_NONE- Returns: - Trueif waiting was successful, or- Falseon timeout- Return type: - bool- Waits until self is synced for reporting the current time. If timeout is - Gst.CLOCK_TIME_NONEit will wait forever, otherwise it will time out after timeout nanoseconds.- For asynchronous waiting, the - Gst.Clock- ::syncedsignal can be used.- This returns immediately with - Trueif- Gst.ClockFlags.NEEDS_STARTUP_SYNCis not set on the clock, or if the clock is already synced.- New in version 1.6. 
 - 
do_change_resolution(old_resolution, new_resolution) virtual¶
- Parameters: - Return type: 
 - 
do_get_internal_time() virtual¶
- Returns: - the internal time of the clock. Or - Gst.CLOCK_TIME_NONEwhen given invalid input.- MT safe. - Return type: - int- Gets the current internal time of the given clock. The time is returned unadjusted for the offset and the rate. 
 - 
do_get_resolution() virtual¶
- Returns: - the resolution of the clock in units of #GstClockTime. - MT safe. - Return type: - int- Get the accuracy of the clock. The accuracy of the clock is the granularity of the values returned by - Gst.Clock.get_time().
 - 
do_unschedule(entry) virtual¶
- Parameters: - entry ( - Gst.ClockEntry) –
 - 
do_wait(entry, jitter) virtual¶
- Parameters: - entry (Gst.ClockEntry) –
- jitter (int) –
 - Return type: 
- entry (
 - 
do_wait_async(entry) virtual¶
- Parameters: - entry ( - Gst.ClockEntry) –- Return type: - Gst.ClockReturn
 
- 
classmethod 
Signal Details¶
- 
Gst.Clock.signals.synced(clock, synced)¶
- Signal Name: - synced- Flags: - Parameters: - Signaled on clocks with - Gst.ClockFlags.NEEDS_STARTUP_SYNCset once the clock is synchronized, or when it completely lost synchronization. This signal will not be emitted on clocks without the flag.- This signal will be emitted from an arbitrary thread, most likely not the application’s main thread. - New in version 1.6. 
Property Details¶
- 
Gst.Clock.props.timeout¶
- Name: - timeout- Type: - int- Default Value: - 100000000- Flags: - READABLE,- WRITABLE- The amount of time, in nanoseconds, to sample master and slave clocks