Klasse Clock

Alle implementierten Schnittstellen:
PointerInterface
Bekannte direkte Unterklassen:
SystemClock

public class Clock extends PropertyHolder
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 #GstSystemClock.

The #GstClock returns a monotonically increasing time with the method
gst_clock_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
#GST_EVENT_SEGMENT events and the element's base time, see #GstPipeline.

A clock implementation can support periodic and single shot clock
notifications both synchronous and asynchronous.

One first needs to create a #GstClockID for the periodic or single shot
notification using gst_clock_new_single_shot_id() or
gst_clock_new_periodic_id().

To perform a blocking wait for the specific time of the #GstClockID use
gst_clock_id_wait(). To receive a callback when the specific time is reached
in the clock use gst_clock_id_wait_async(). Both these calls can be
interrupted with the gst_clock_id_unschedule() call. If the blocking wait is
unscheduled a return value of #GST_CLOCK_UNSCHEDULED is returned.

Periodic callbacks scheduled async will be repeatedly called automatically
until they are unscheduled. To schedule a sync periodic callback,
gst_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 #GstClockID that has been unscheduled cannot be used again for any wait
operation, a new #GstClockID should be created and the old unscheduled one
should be destroyed with gst_clock_id_unref().

It is possible to perform a blocking wait on the same #GstClockID from
multiple threads. However, registering the same #GstClockID 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 #GstClockID, 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 #GstClockID has to
keep a handle to the #GstClockID 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 #GST_CLOCK_FLAG_CAN_SET_MASTER flag set, it can be
slaved to another #GstClock with gst_clock_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 gst_clock_set_calibration(). This feature is mostly useful for
plugins that have an internal clock but must operate with another clock
selected by the #GstPipeline. They can track the offset and rate difference
of their internal clock relative to the master clock by using the
gst_clock_get_calibration() function.

The master/slave synchronisation can be tuned with the #GstClock:timeout,
#GstClock:window-size and #GstClock:window-threshold properties.
The #GstClock:timeout property defines the interval to sample the master
clock and run the calibration functions. #GstClock:window-size defines the
number of samples to use when calibrating and #GstClock:window-threshold
defines the minimum number of samples before the calibration is performed.

https://gstreamer.freedesktop.org/documentation/gstreamer/gi-index.html

  • Felddetails Linksymbol

  • Konstruktordetails Linksymbol

  • Methodendetails Linksymbol

    • getClassHandler Linksymbol

      public static ClassHandler getClassHandler()
    • addObservation Linksymbol

      public boolean addObservation(long observation_internal, long observation_external, @Nonnull Dbl r_squared)
      The time @observation_external of the external or master clock and the time
      @observation_internal of the internal or 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.
      Parameter:
      observation_internal - a time on the internal clock
      observation_external - a time on the external clock
      r_squared - a pointer to hold the result
      Gibt zurück:
      %TRUE if enough observations were added to run the regression algorithm.
    • adjustUnlocked Linksymbol

      public long adjustUnlocked(long internal)
      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().
      Parameter:
      internal - a clock time
      Gibt zurück:
      the converted time of the clock.
    • adjustWithCalibration Linksymbol

      public long adjustWithCalibration(long internal_target, long cinternal, long cexternal, long cnum, long cdenom)
      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
      Parameter:
      internal_target - a clock time
      cinternal - a reference internal time
      cexternal - a reference external time
      cnum - the numerator of the rate of the clock relative to its internal time
      cdenom - the denominator of the rate of the clock
      Gibt zurück:
      the converted time of the clock.
    • getInternalTime Linksymbol

      public long getInternalTime()
      Gets the current internal time of the given clock. The time is returned
      unadjusted for the offset and the rate.
      Gibt zurück:
      the internal time of the clock. Or %GST_CLOCK_TIME_NONE when given invalid input.
    • getMaster Linksymbol

      public Clock getMaster()
      Gets the master clock that @clock is slaved to or %NULL when the clock is
      not slaved to any master clock.
      Gibt zurück:
      a master #GstClock or %NULL when this clock is not slaved to a master clock.
    • getResolution Linksymbol

      public long getResolution()
      Gets the accuracy of the clock. The accuracy of the clock is the granularity
      of the values returned by gst_clock_get_time().
      Gibt zurück:
      the resolution of the clock in units of #GstClockTime.
    • getTime Linksymbol

      public long getTime()
      Gets the current time of the given clock. The time is always
      monotonically increasing and adjusted according to the current
      offset and rate.
      Gibt zurück:
      the time of the clock. Or %GST_CLOCK_TIME_NONE when given invalid input.
    • getTimeout Linksymbol

      public long getTimeout()
      Gets the amount of time that master and slave clocks are sampled.
      Gibt zurück:
      the interval between samples.
    • isSynced Linksymbol

      public boolean isSynced()
      Checks if the clock is currently synced, by looking at whether
      %GST_CLOCK_FLAG_NEEDS_STARTUP_SYNC is set.
      Gibt zurück:
      %TRUE if the clock is currently synced
    • setCalibration Linksymbol

      public void setCalibration(long internal, long external, long rate_num, long rate_denom)
      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:

      ``` C
      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.
      Parameter:
      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
    • setMaster Linksymbol

      public boolean setMaster(@Nullable Clock master)
      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 %NULL 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.
      Parameter:
      master - a master #GstClock
      Gibt zurück:
      %TRUE if the clock is capable of being slaved to a master clock. Trying to set a master on a clock without the #GST_CLOCK_FLAG_CAN_SET_MASTER flag will make this function return %FALSE.
    • setResolution Linksymbol

      public long setResolution(long resolution)
      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.
      Parameter:
      resolution - The resolution to set
      Gibt zurück:
      the new resolution of the clock.
    • setSynced Linksymbol

      public void setSynced(boolean synced)
      Sets @clock to synced and emits the #GstClock::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.
      Parameter:
      synced - if the clock is synced
    • setTimeout Linksymbol

      public void setTimeout(long timeout)
      Sets the amount of time, in nanoseconds, to sample master and slave
      clocks
      Parameter:
      timeout - a timeout
    • unadjustUnlocked Linksymbol

      public long unadjustUnlocked(long external)
      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().
      Parameter:
      external - an external clock time
      Gibt zurück:
      the internal time of the clock corresponding to @external.
    • unadjustWithCalibration Linksymbol

      public long unadjustWithCalibration(long external_target, long cinternal, long cexternal, long cnum, long cdenom)
      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
      Parameter:
      external_target - a clock time
      cinternal - a reference internal time
      cexternal - a reference external time
      cnum - the numerator of the rate of the clock relative to its internal time
      cdenom - the denominator of the rate of the clock
      Gibt zurück:
      the converted time of the clock.
    • waitForSync Linksymbol

      public boolean waitForSync(long timeout)
      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 #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.
      Parameter:
      timeout - timeout for waiting or %GST_CLOCK_TIME_NONE
      Gibt zurück:
      %TRUE if waiting was successful, or %FALSE on timeout
    • onSynced Linksymbol

      public SignalHandler onSynced(Clock.OnSynced signal)
      Connect to signal "synced".
      See Clock.OnSynced.onSynced(boolean) for signal description.
      Field SIGNAL_ON_SYNCED contains original signal name and can be used as resource reference.
      Parameter:
      signal - callback function (lambda).
      Gibt zurück:
      SignalHandler. Can be used to disconnect signal and to release callback function.
    • idCompareFunc Linksymbol

      public static int idCompareFunc(@Nullable Pointer id1, @Nullable Pointer id2)
      Compares the two #GstClockID instances. This function can be used
      as a GCompareFunc when sorting ids.
      Parameter:
      id1 - A #GstClockID
      id2 - A #GstClockID to compare with
      Gibt zurück:
      negative value if `a < b`; zero if `a = b`; positive value if `a > b`
    • getTypeID Linksymbol

      public static long getTypeID()
    • getParentTypeID Linksymbol

      public static long getParentTypeID()
    • getTypeSize Linksymbol

      public static TypeSystem.TypeSize getTypeSize()
    • getParentTypeSize Linksymbol

      public static TypeSystem.TypeSize getParentTypeSize()
    • getInstanceSize Linksymbol

      public static int getInstanceSize()