Trait gstreamer::prelude::ClockExt[][src]

pub trait ClockExt: 'static {
Show 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) -> 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) -> ClockTime;
fn timeout(&self) -> ClockTime;
fn is_synced(&self) -> bool;
fn set_calibration(
        &self,
        internal: ClockTime,
        external: ClockTime,
        rate_num: ClockTime,
        rate_denom: ClockTime
    );
fn set_master<P: IsA<Clock>>(
        &self,
        master: Option<&P>
    ) -> Result<(), BoolError>;
fn set_resolution(&self, resolution: ClockTime) -> ClockTime;
fn set_synced(&self, synced: bool);
fn set_timeout(&self, timeout: ClockTime);
fn unadjust_unlocked(&self, external: ClockTime) -> ClockTime;
fn wait_for_sync(&self, timeout: 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;
}

Trait containing all Clock methods.

Implementors

crate::Clock, crate::SystemClock

Required methods

fn add_observation(&self, slave: ClockTime, master: ClockTime) -> Option<f64>[src]

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

r_squared

a pointer to hold the result

Returns

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

MT safe.

fn add_observation_unapplied(
    &self,
    slave: ClockTime,
    master: ClockTime
) -> Option<(f64, ClockTime, ClockTime, ClockTime, ClockTime)>
[src]

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

slave

a time on the slave

master

a time on the master

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

fn adjust_unlocked(&self, internal: ClockTime) -> ClockTime[src]

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

internal

a clock time

Returns

the converted time of the clock.

fn calibration(&self) -> (ClockTime, ClockTime, ClockTime, ClockTime)[src]

Gets the internal rate and reference time of self. See Self::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.

MT safe.

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

fn internal_time(&self) -> ClockTime[src]

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.

MT safe.

fn master(&self) -> Option<Clock>[src]

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

Returns

a master crate::Clock or None when this clock is not slaved to a master clock. Unref after usage.

MT safe.

fn resolution(&self) -> ClockTime[src]

Get the accuracy of the clock. The accuracy of the clock is the granularity of the values returned by [Self::get_time()].

Returns

the resolution of the clock in units of crate::ClockTime.

MT safe.

fn time(&self) -> ClockTime[src]

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.

MT safe.

fn timeout(&self) -> ClockTime[src]

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

Returns

the interval between samples.

fn is_synced(&self) -> bool[src]

Checks if the clock is currently synced.

This returns if GST_CLOCK_FLAG_NEEDS_STARTUP_SYNC is not set on the clock.

Returns

true if the clock is currently synced

fn set_calibration(
    &self,
    internal: ClockTime,
    external: ClockTime,
    rate_num: ClockTime,
    rate_denom: ClockTime
)
[src]

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 [Self::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 [Self::get_internal_time()] when this function is called.

Subsequent calls to [Self::get_time()] will return clock times computed as follows:

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

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

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

MT safe.

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

fn set_master<P: IsA<Clock>>(&self, master: Option<&P>) -> Result<(), BoolError>[src]

Set master as the master clock for self. self will be automatically calibrated so that [Self::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 [Self::get_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 crate::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 [crate::ClockFlags::CanSetMaster] flag will make this function return false.

MT safe.

fn set_resolution(&self, resolution: ClockTime) -> ClockTime[src]

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 [crate::ClockFlags::CanSetResolution] flag set.

resolution

The resolution to set

Returns

the new resolution of the clock.

fn set_synced(&self, synced: bool)[src]

Sets self to synced and emits the GstClock::synced signal, and wakes up any thread waiting in Self::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.

synced

if the clock is synced

fn set_timeout(&self, timeout: ClockTime)[src]

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

timeout

a timeout

fn unadjust_unlocked(&self, external: ClockTime) -> ClockTime[src]

Converts the given external clock time to the internal time of self, using the rate and reference time set with Self::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 Self::adjust_unlocked().

external

an external clock time

Returns

the internal time of the clock corresponding to external.

fn wait_for_sync(&self, timeout: ClockTime) -> Result<(), BoolError>[src]

Waits until self 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 GstClock::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.

timeout

timeout for waiting or GST_CLOCK_TIME_NONE

Returns

true if waiting was successful, or false on timeout

fn window_size(&self) -> i32[src]

fn set_window_size(&self, window_size: i32)[src]

fn window_threshold(&self) -> i32[src]

fn set_window_threshold(&self, window_threshold: i32)[src]

fn connect_synced<F: Fn(&Self, bool) + Send + Sync + 'static>(
    &self,
    f: F
) -> SignalHandlerId
[src]

Signaled on clocks with GST_CLOCK_FLAG_NEEDS_STARTUP_SYNC set 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.

synced

if the clock is synced now

fn connect_timeout_notify<F: Fn(&Self) + Send + Sync + 'static>(
    &self,
    f: F
) -> SignalHandlerId
[src]

fn connect_window_size_notify<F: Fn(&Self) + Send + Sync + 'static>(
    &self,
    f: F
) -> SignalHandlerId
[src]

fn connect_window_threshold_notify<F: Fn(&Self) + Send + Sync + 'static>(
    &self,
    f: F
) -> SignalHandlerId
[src]

Loading content...

Implementors

impl<O: IsA<Clock>> ClockExt for O[src]

fn add_observation(&self, slave: ClockTime, master: ClockTime) -> Option<f64>[src]

fn add_observation_unapplied(
    &self,
    slave: ClockTime,
    master: ClockTime
) -> Option<(f64, ClockTime, ClockTime, ClockTime, ClockTime)>
[src]

fn adjust_unlocked(&self, internal: ClockTime) -> ClockTime[src]

fn calibration(&self) -> (ClockTime, ClockTime, ClockTime, ClockTime)[src]

fn internal_time(&self) -> ClockTime[src]

fn master(&self) -> Option<Clock>[src]

fn resolution(&self) -> ClockTime[src]

fn time(&self) -> ClockTime[src]

fn timeout(&self) -> ClockTime[src]

fn is_synced(&self) -> bool[src]

fn set_calibration(
    &self,
    internal: ClockTime,
    external: ClockTime,
    rate_num: ClockTime,
    rate_denom: ClockTime
)
[src]

fn set_master<P: IsA<Clock>>(&self, master: Option<&P>) -> Result<(), BoolError>[src]

fn set_resolution(&self, resolution: ClockTime) -> ClockTime[src]

fn set_synced(&self, synced: bool)[src]

fn set_timeout(&self, timeout: ClockTime)[src]

fn unadjust_unlocked(&self, external: ClockTime) -> ClockTime[src]

fn wait_for_sync(&self, timeout: ClockTime) -> Result<(), BoolError>[src]

fn window_size(&self) -> i32[src]

fn set_window_size(&self, window_size: i32)[src]

fn window_threshold(&self) -> i32[src]

fn set_window_threshold(&self, window_threshold: i32)[src]

fn connect_synced<F: Fn(&Self, bool) + Send + Sync + 'static>(
    &self,
    f: F
) -> SignalHandlerId
[src]

fn connect_timeout_notify<F: Fn(&Self) + Send + Sync + 'static>(
    &self,
    f: F
) -> SignalHandlerId
[src]

fn connect_window_size_notify<F: Fn(&Self) + Send + Sync + 'static>(
    &self,
    f: F
) -> SignalHandlerId
[src]

fn connect_window_threshold_notify<F: Fn(&Self) + Send + Sync + 'static>(
    &self,
    f: F
) -> SignalHandlerId
[src]

Loading content...