[][src]Trait gstreamer_audio::prelude::ClockExt

pub trait ClockExt: 'static {
    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 get_calibration(&self) -> (ClockTime, ClockTime, ClockTime, ClockTime);
fn get_internal_time(&self) -> ClockTime;
fn get_master(&self) -> Option<Clock>;
fn get_resolution(&self) -> ClockTime;
fn get_time(&self) -> ClockTime;
fn get_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>(&self, master: Option<&P>) -> Result<(), BoolError>
    where
        P: IsA<Clock>
;
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 get_property_window_size(&self) -> i32;
fn set_property_window_size(&self, window_size: i32);
fn get_property_window_threshold(&self) -> i32;
fn set_property_window_threshold(&self, window_threshold: i32);
fn connect_synced<F>(&self, f: F) -> SignalHandlerId
    where
        F: 'static + Send + Sync + Fn(&Self, bool)
;
fn connect_property_timeout_notify<F>(&self, f: F) -> SignalHandlerId
    where
        F: 'static + Send + Sync + Fn(&Self)
;
fn connect_property_window_size_notify<F>(&self, f: F) -> SignalHandlerId
    where
        F: 'static + Send + Sync + Fn(&Self)
;
fn connect_property_window_threshold_notify<F>(
        &self,
        f: F
    ) -> SignalHandlerId
    where
        F: 'static + Send + Sync + Fn(&Self)
; }

Trait containing all Clock methods.

Implementors

Clock, SystemClock

Required methods

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

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)>

Add a clock observation to the internal slaving algorithm the same as ClockExt::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 ClockExt::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

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

internal

a clock time

Returns

the converted time of the clock.

fn get_calibration(&self) -> (ClockTime, ClockTime, ClockTime, ClockTime)

Gets the internal rate and reference time of self. See ClockExt::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 get_internal_time(&self) -> ClockTime

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 get_master(&self) -> Option<Clock>

Get 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. Unref after usage.

MT safe.

fn get_resolution(&self) -> ClockTime

Get the accuracy of the clock. The accuracy of the clock is the granularity of the values returned by ClockExt::get_time.

Returns

the resolution of the clock in units of ClockTime.

MT safe.

fn get_time(&self) -> ClockTime

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 get_timeout(&self) -> ClockTime

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

Returns

the interval between samples.

fn is_synced(&self) -> bool

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
)

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 ClockExt::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 ClockExt::get_internal_time when this function is called.

Subsequent calls to ClockExt::get_time will return clock times computed as follows:

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

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

Note that ClockExt::get_time always returns increasing values so when you move the clock backwards, ClockExt::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>(&self, master: Option<&P>) -> Result<(), BoolError> where
    P: IsA<Clock>, 

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

MT safe.

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

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

resolution

The resolution to set

Returns

the new resolution of the clock.

fn set_synced(&self, synced: bool)

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

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

timeout

a timeout

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

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

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 get_property_window_size(&self) -> i32

fn set_property_window_size(&self, window_size: i32)

fn get_property_window_threshold(&self) -> i32

fn set_property_window_threshold(&self, window_threshold: i32)

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

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_property_timeout_notify<F>(&self, f: F) -> SignalHandlerId where
    F: 'static + Send + Sync + Fn(&Self), 

fn connect_property_window_size_notify<F>(&self, f: F) -> SignalHandlerId where
    F: 'static + Send + Sync + Fn(&Self), 

fn connect_property_window_threshold_notify<F>(&self, f: F) -> SignalHandlerId where
    F: 'static + Send + Sync + Fn(&Self), 

Loading content...

Implementors

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

Loading content...