pub trait ClockExt: 'static {
Show 25 methods fn add_observation(
        &self,
        slave: ClockTime,
        master: ClockTime
    ) -> Option<f64>;
fn add_observation_unapplied(
        &self,
        slave: ClockTime,
        master: ClockTime
    ) -> Option<(f64, ClockTime, ClockTime, ClockTime, ClockTime)>;
fn adjust_unlocked(&self, internal: ClockTime) -> Option<ClockTime>;
fn calibration(&self) -> (ClockTime, ClockTime, ClockTime, ClockTime);
fn internal_time(&self) -> ClockTime;
fn master(&self) -> Option<Clock>;
fn resolution(&self) -> ClockTime;
fn time(&self) -> Option<ClockTime>;
fn timeout(&self) -> Option<ClockTime>;
fn is_synced(&self) -> bool;
fn set_calibration(
        &self,
        internal: ClockTime,
        external: ClockTime,
        rate_num: ClockTime,
        rate_denom: ClockTime
    );
fn set_master(
        &self,
        master: Option<&impl IsA<Clock>>
    ) -> Result<(), BoolError>;
fn set_resolution(&self, resolution: ClockTime) -> ClockTime;
fn set_synced(&self, synced: bool);
fn set_timeout(&self, timeout: impl Into<Option<ClockTime>>);
fn unadjust_unlocked(&self, external: ClockTime) -> Option<ClockTime>;
fn wait_for_sync(
        &self,
        timeout: impl Into<Option<ClockTime>>
    ) -> Result<(), BoolError>;
fn window_size(&self) -> i32;
fn set_window_size(&self, window_size: i32);
fn window_threshold(&self) -> i32;
fn set_window_threshold(&self, window_threshold: i32);
fn connect_synced<F: Fn(&Self, bool) + Send + Sync + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_timeout_notify<F: Fn(&Self) + Send + Sync + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_window_size_notify<F: Fn(&Self) + Send + Sync + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_window_threshold_notify<F: Fn(&Self) + Send + Sync + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
}
Expand description

Trait containing all Clock methods.

Implementors

Clock, SystemClock

Required methods

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.

slave

a time on the slave

master

a time on the master

Returns

true if enough observations were added to run the regression algorithm.

r_squared

a pointer to hold the result

Add a clock observation to the internal slaving algorithm the same as 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 set_calibration() with the values, or some modified version of them.

slave

a time on the slave

master

a time on the master

Returns

true if enough observations were added to run the regression algorithm.

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

Converts the given internal clock time to the external time, adjusting for the rate and reference time set with 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 unadjust_unlocked().

internal

a clock time

Returns

the converted time of the clock.

Gets the internal rate and reference time of self. See set_calibration() for more information.

internal, external, rate_num, and rate_denom can be left None if the caller is not interested in the values.

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

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

Returns

the internal time of the clock. Or GST_CLOCK_TIME_NONE when given invalid input.

Gets the master clock that self is slaved to or None when the clock is not slaved to any master clock.

Returns

a master Clock or None when this clock is not slaved to a master clock.

Gets the accuracy of the clock. The accuracy of the clock is the granularity of the values returned by time().

Returns

the resolution of the clock in units of GstClockTime.

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

Returns

the time of the clock. Or GST_CLOCK_TIME_NONE when given invalid input.

Gets the amount of time that master and slave clocks are sampled.

Returns

the interval between samples.

Checks if the clock is currently synced, by looking at whether ClockFlags::NEEDS_STARTUP_SYNC is set.

Returns

true if the clock is currently synced

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 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 internal_time() when this function is called.

Subsequent calls to time() will return clock times computed as follows:

⚠️ The following code is in C ⚠️

  time = (internal_time - internal) * rate_num / rate_denom + external

This formula is implemented in adjust_unlocked(). Of course, it tries to do the integer arithmetic as precisely as possible.

Note that time() always returns increasing values so when you move the clock backwards, time() will report the previous value until the clock catches up.

internal

a reference internal time

external

a reference external time

rate_num

the numerator of the rate of the clock relative to its internal time

rate_denom

the denominator of the rate of the clock

Sets master as the master clock for self. self will be automatically calibrated so that 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 calibration().

master can be None in which case self will not be slaved anymore. It will however keep reporting its time adjusted with the last configured rate and time offsets.

master

a master Clock

Returns

true if the clock is capable of being slaved to a master clock. Trying to set a master on a clock without the ClockFlags::CAN_SET_MASTER flag will make this function return false.

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 ClockFlags::CAN_SET_RESOLUTION flag set.

resolution

The resolution to set

Returns

the new resolution of the clock.

Sets self to synced and emits the signal::Clock::synced signal, and wakes up any thread waiting in wait_for_sync().

This function must only be called if ClockFlags::NEEDS_STARTUP_SYNC is set on the clock, and is intended to be called by subclasses only.

synced

if the clock is synced

Sets the amount of time, in nanoseconds, to sample master and slave clocks

timeout

a timeout

Implementors