Class: Gst::Clock
Overview
GStreamer clock class. Override the vmethods to implement the clock
functionality.
Direct Known Subclasses
Class Method Summary collapse
-
.id_compare_func(id1, id2) ⇒ Integer
Compares the two Gst::ClockID instances.
-
.id_get_clock(id) ⇒ Gst::Clock
This function returns the underlying clock.
-
.id_get_time(id) ⇒ Gst::ClockTime
Gets the time of the clock ID.
-
.id_ref(id) ⇒ Gst::ClockID
Increases the refcount of given id.
-
.id_unref(id) ⇒ nil
Unrefs given id.
-
.id_unschedule(id) ⇒ nil
Cancels an outstanding request with id.
-
.id_uses_clock(id, clock) ⇒ Boolean
This function returns whether id uses clock as the underlying clock.
-
.id_wait(id, jitter) ⇒ Gst::ClockReturn
Performs a blocking wait on id.
-
.id_wait_async(id, func, user_data, destroy_data) ⇒ Gst::ClockReturn
Registers a callback on the given Gst::ClockID id with the given function and user_data.
Instance Method Summary collapse
-
#add_observation(slave, master, r_squared) ⇒ Boolean
The time master of the master clock and the time slave of the slave clock are added to the list of observations.
-
#add_observation_unapplied(slave, master, r_squared, internal, external, rate_num, rate_denom) ⇒ Boolean
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.
-
#adjust_unlocked(internal) ⇒ Gst::ClockTime
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.
-
#adjust_with_calibration(internal_target, cinternal, cexternal, cnum, cdenom) ⇒ Gst::ClockTime
Converts the given internal_target clock time to the external time, using the passed calibration parameters.
-
#get_calibration(internal, external, rate_num, rate_denom) ⇒ nil
Gets the internal rate and reference time of clock.
-
#internal_time ⇒ Gst::ClockTime
Gets the current internal time of the given clock.
-
#is_synced ⇒ Boolean
Checks if the clock is currently synced, by looking at whether %GST_CLOCK_FLAG_NEEDS_STARTUP_SYNC is set.
-
#master ⇒ Gst::Clock
Gets the master clock that clock is slaved to or nil when the clock is not slaved to any master clock.
-
#master=(master) ⇒ Boolean
Sets master as the master clock for clock.
-
#new_periodic_id(start_time, interval) ⇒ Gst::ClockID
Gets an ID from clock to trigger a periodic notification.
-
#new_single_shot_id(time) ⇒ Gst::ClockID
Gets a Gst::ClockID from clock to trigger a single shot notification at the requested time.
-
#periodic_id_reinit(id, start_time, interval) ⇒ Boolean
Reinitializes the provided periodic id to the provided start time and interval.
-
#resolution ⇒ Gst::ClockTime
Gets the accuracy of the clock.
-
#resolution=(resolution) ⇒ Gst::ClockTime
Sets the accuracy of the clock.
-
#set_calibration(internal, external, rate_num, rate_denom) ⇒ nil
Adjusts the rate and time of clock.
-
#single_shot_id_reinit(id, time) ⇒ Boolean
Reinitializes the provided single shot id to the provided time.
-
#synced=(synced) ⇒ nil
Sets clock to synced and emits the Gst::Clock::synced signal, and wakes up any thread waiting in gst_clock_wait_for_sync().
-
#time ⇒ Gst::ClockTime
Gets the current time of the given clock.
-
#timeout ⇒ Integer
Timeout.
- #timeout=(timeout) ⇒ Integer
-
#unadjust_unlocked(external) ⇒ Gst::ClockTime
Converts the given external clock time to the internal time of clock, using the rate and reference time set with gst_clock_set_calibration().
-
#unadjust_with_calibration(external_target, cinternal, cexternal, cnum, cdenom) ⇒ Gst::ClockTime
Converts the given external_target clock time to the internal time, using the passed calibration parameters.
-
#wait_for_sync(timeout) ⇒ Boolean
Waits until clock is synced for reporting the current time.
-
#window_size ⇒ Integer
Window-size.
- #window_size=(window_size) ⇒ Integer
-
#window_threshold ⇒ Integer
Window-threshold.
- #window_threshold=(window_threshold) ⇒ Integer
Methods inherited from Object
#add_control_binding, check_uniqueness, #control_bindings_disabled=, #control_rate, #control_rate=, default_deep_notify, #default_error, #get_control_binding, #get_g_value_array, #get_value, #get_value_array, #has_active_control_bindings, #has_ancestor, #has_as_ancestor, #has_as_parent, #name, #name=, #parent, #parent=, #path_string, #ref, ref_sink, #remove_control_binding, replace, #set_control_binding_disabled, #suggest_next_sync, #sync_values, #unparent, #unref
Class Method Details
.id_compare_func(id1, id2) ⇒ Integer
Compares the two Gst::ClockID instances. This function can be used
as a GCompareFunc when sorting ids.
.id_get_clock(id) ⇒ Gst::Clock
This function returns the underlying clock.
.id_get_time(id) ⇒ Gst::ClockTime
Gets the time of the clock ID
.id_ref(id) ⇒ Gst::ClockID
Increases the refcount of given id.
.id_unref(id) ⇒ nil
Unrefs given id. When the refcount reaches 0 the
Gst::ClockID will be freed.
.id_unschedule(id) ⇒ nil
Cancels 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 Gst::ClockID.
.id_uses_clock(id, clock) ⇒ Boolean
This function returns whether id uses clock as the underlying clock.
clock can be NULL, 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.
.id_wait(id, jitter) ⇒ Gst::ClockReturn
Performs 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 nil 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.
if the current clock time is past the time of id, #GST_CLOCK_OK if
id was scheduled in time. #GST_CLOCK_UNSCHEDULED if id was
unscheduled with gst_clock_id_unschedule().
.id_wait_async(id, func, user_data, destroy_data) ⇒ Gst::ClockReturn
Registers a callback on the given Gst::ClockID id with the given
function and user_data. When passing a Gst::ClockID 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.
Instance Method Details
#add_observation(slave, master, r_squared) ⇒ Boolean
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 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.
regression algorithm.
#add_observation_unapplied(slave, master, r_squared, internal, external, rate_num, rate_denom) ⇒ Boolean
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.
regression algorithm.
#adjust_unlocked(internal) ⇒ Gst::ClockTime
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) ⇒ Gst::ClockTime
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 clock parameter is unused and can be NULL
#get_calibration(internal, external, rate_num, rate_denom) ⇒ nil
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 nil if the
caller is not interested in the values.
#internal_time ⇒ Gst::ClockTime
Gets the current internal time of the given clock. The time is returned
unadjusted for the offset and the rate.
given invalid input.
#is_synced ⇒ Boolean
Checks if the clock is currently synced, by looking at whether
%GST_CLOCK_FLAG_NEEDS_STARTUP_SYNC is set.
#master ⇒ Gst::Clock
Gets the master clock that clock is slaved to or nil when the clock is
not slaved to any master clock.
#master=(master) ⇒ Boolean
Sets 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 nil 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.
Trying to set a master on a clock without the
#GST_CLOCK_FLAG_CAN_SET_MASTER flag will make this function return false.
#new_periodic_id(start_time, interval) ⇒ Gst::ClockID
Gets an ID from clock to trigger a periodic notification.
The periodic notifications will start at time start_time and
will then be fired with the given interval.
#new_single_shot_id(time) ⇒ Gst::ClockID
Gets a Gst::ClockID from clock to trigger a single shot
notification at the requested time.
#periodic_id_reinit(id, start_time, interval) ⇒ Boolean
Reinitializes the provided periodic id to the provided start time and
interval. Does not modify the reference count.
time, else false.
#resolution ⇒ Gst::ClockTime
Gets the accuracy of the clock. The accuracy of the clock is the granularity
of the values returned by gst_clock_get_time().
#resolution=(resolution) ⇒ Gst::ClockTime
Sets 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.
#set_calibration(internal, external, rate_num, rate_denom) ⇒ nil
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
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.
#single_shot_id_reinit(id, time) ⇒ Boolean
Reinitializes the provided single shot id to the provided time. Does not
modify the reference count.
time, else false.
#synced=(synced) ⇒ nil
Sets clock to synced and emits the Gst::Clock::synced signal, and wakes up any
thread waiting in gst_clock_wait_for_sync().
This function must only be called if %GST_CLOCK_FLAG_NEEDS_STARTUP_SYNC
is set on the clock, and is intended to be called by subclasses only.
#time ⇒ Gst::ClockTime
Gets the current time of the given clock. The time is always
monotonically increasing and adjusted according to the current
offset and rate.
given invalid input.
#timeout ⇒ Integer
Returns timeout.
#timeout=(timeout) ⇒ Integer
#unadjust_unlocked(external) ⇒ Gst::ClockTime
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 the reverse of gst_clock_adjust_unlocked().
#unadjust_with_calibration(external_target, cinternal, cexternal, cnum, cdenom) ⇒ Gst::ClockTime
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 clock parameter is unused and can be NULL
#wait_for_sync(timeout) ⇒ Boolean
Waits until clock is synced for reporting the current time. If timeout
is %GST_CLOCK_TIME_NONE it will wait forever, otherwise it will time out
after timeout nanoseconds.
For asynchronous waiting, the Gst::Clock::synced signal can be used.
This returns immediately with true if %GST_CLOCK_FLAG_NEEDS_STARTUP_SYNC
is not set on the clock, or if the clock is already synced.
#window_size ⇒ Integer
Returns window-size.
#window_size=(window_size) ⇒ Integer
#window_threshold ⇒ Integer
Returns window-threshold.