Struct gstreamer::Clock [−]
pub struct Clock(_, _);
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 SystemClock
.
The Clock
returns a monotonically increasing time with the method
ClockExt::get_time
. Its accuracy and base time depend on the specific
clock implementation but time is always expressed in nanoseconds. Since the
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 Pipeline
.
A clock implementation can support periodic and single shot clock notifications both synchronous and asynchronous.
One first needs to create a ClockID
for the periodic or single shot
notification using ClockExt::new_single_shot_id
or
ClockExt::new_periodic_id
.
To perform a blocking wait for the specific time of the ClockID
use the
Clock::id_wait
. To receive a callback when the specific time is reached
in the clock use Clock::id_wait_async
. Both these calls can be
interrupted with the Clock::id_unschedule
call. If the blocking wait is
unscheduled a return value of ClockReturn::Unscheduled
is returned.
Periodic callbacks scheduled async will be repeatedly called automatically
until it is unscheduled. To schedule a sync periodic callback,
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 ClockID
that has been unscheduled cannot be used again for any wait
operation, a new ClockID
should be created and the old unscheduled one
should be destroyed with Clock::id_unref
.
It is possible to perform a blocking wait on the same ClockID
from
multiple threads. However, registering the same ClockID
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 ClockID
, 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 ClockID
has to
keep a handle to the ClockID
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 ClockFlags::CanSetMaster
flag set, it can be
slaved to another Clock
with the ClockExt::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 ClockExt::set_calibration
. This feature is mostly useful for
plugins that have an internal clock but must operate with another clock
selected by the Pipeline
. They can track the offset and rate difference
of their internal clock relative to the master clock by using the
ClockExt::get_calibration
function.
The master/slave synchronisation can be tuned with the Clock:timeout
,
Clock:window-size
and Clock:window-threshold
properties.
The Clock:timeout
property defines the interval to sample the master
clock and run the calibration functions. Clock:window-size
defines the
number of samples to use when calibrating and Clock:window-threshold
defines the minimum number of samples before the calibration is performed.
Implements
Methods
impl Clock
[src]
impl Clock
pub fn adjust_with_calibration(
internal_target: ClockTime,
cinternal: ClockTime,
cexternal: ClockTime,
cnum: ClockTime,
cdenom: ClockTime
) -> ClockTime
[src]
pub fn adjust_with_calibration(
internal_target: ClockTime,
cinternal: ClockTime,
cexternal: ClockTime,
cnum: ClockTime,
cdenom: ClockTime
) -> ClockTime
pub fn unadjust_with_calibration(
external_target: ClockTime,
cinternal: ClockTime,
cexternal: ClockTime,
cnum: ClockTime,
cdenom: ClockTime
) -> ClockTime
[src]
pub fn unadjust_with_calibration(
external_target: ClockTime,
cinternal: ClockTime,
cexternal: ClockTime,
cnum: ClockTime,
cdenom: ClockTime
) -> ClockTime
Trait Implementations
impl Clone for Clock
impl Clone for Clock
fn clone(&self) -> Clock
fn clone(&self) -> Clock
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Hash for Clock
impl Hash for Clock
fn hash<__H: Hasher>(&self, state: &mut __H)
fn hash<__H: Hasher>(&self, state: &mut __H)
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl Ord for Clock
impl Ord for Clock
fn cmp(&self, other: &Clock) -> Ordering
fn cmp(&self, other: &Clock) -> Ordering
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
impl StaticType for Clock
impl StaticType for Clock
fn static_type() -> Type
fn static_type() -> Type
Returns the type identifier of Self
.
impl<T: IsA<Object>> PartialEq<T> for Clock
impl<T: IsA<Object>> PartialEq<T> for Clock
fn eq(&self, other: &T) -> bool
fn eq(&self, other: &T) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
impl Eq for Clock
impl Eq for Clock
impl<T: IsA<Object>> PartialOrd<T> for Clock
impl<T: IsA<Object>> PartialOrd<T> for Clock
fn partial_cmp(&self, other: &T) -> Option<Ordering>
fn partial_cmp(&self, other: &T) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn gt(&self, other: &Rhs) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn ge(&self, other: &Rhs) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Debug for Clock
impl Debug for Clock
impl IsA<Object> for Clock
impl IsA<Object> for Clock
impl IsA<Object> for Clock
impl IsA<Object> for Clock
impl Send for Clock
[src]
impl Send for Clock
impl Sync for Clock
[src]
impl Sync for Clock
impl IsA<Clock> for SystemClock
impl IsA<Clock> for SystemClock