gstreamermm
1.4.3
|
An abstract class for global clocks. More...
Public Member Functions | |
virtual | ~Clock () |
GstClock* | gobj () |
Provides access to the underlying C GObject. More... | |
const GstClock* | gobj () const |
Provides access to the underlying C GObject. More... | |
GstClock* | gobj_copy () |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More... | |
bool | add_observation (ClockTime slave_time, ClockTime master_time, gdouble* result) |
The time master of the master clock and the time slave of the slave clock are added to the list of observations. More... | |
bool | set_master (const Clock& master_clock) |
Set master as the master clock for clock. More... | |
Glib::RefPtr< Gst::Clock > | get_master () |
Get the master clock that clock is slaved to or 0 when the clock is not slaved to any master clock. More... | |
Glib::RefPtr< const Gst::Clock > | get_master () const |
Get the master clock that clock is slaved to or 0 when the clock is not slaved to any master clock. More... | |
ClockTime | set_resolution (ClockTime resolution) |
Set the accuracy of the clock. More... | |
ClockTime | get_resolution () const |
Get the accuracy of the clock. More... | |
ClockTime | get_time () const |
Gets the current time of the given clock. More... | |
Glib::RefPtr< Gst::ClockID > | create_single_shot_id (ClockTime time) |
Get a Gst::ClockID from clock to trigger a single shot notification at the requested time. More... | |
Glib::RefPtr< Gst::ClockID > | create_periodic_id (ClockTime start_time, ClockTime intervals) |
Get an ID from clock to trigger a periodic notification. More... | |
ClockTime | get_internal_time () const |
Gets the current internal time of the given clock. More... | |
ClockTime | adjust_unlocked (ClockTime internal_time) |
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. More... | |
ClockTime | unadjust_unlocked (ClockTime external_time) |
Converts the given external clock time to the internal time of clock, using the rate and reference time set with set_calibration(). More... | |
void | get_calibration (ClockTime&internal, ClockTime& external, ClockTime& rate_num, ClockTime& rate_denom) const |
Gets the internal rate and reference time of clock. More... | |
void | set_calibration (ClockTime internal, ClockTime external, ClockTime rate_num, ClockTime rate_denom) |
Adjusts the rate and time of clock. More... | |
Glib::PropertyProxy< guint64 > | property_timeout () |
The amount of time, in nanoseconds, to sample master and slave clocks. More... | |
Glib::PropertyProxy_ReadOnly < guint64 > | property_timeout () const |
The amount of time, in nanoseconds, to sample master and slave clocks. More... | |
Glib::PropertyProxy< int > | property_window_size () |
The size of the window used to calculate rate and offset. More... | |
Glib::PropertyProxy_ReadOnly< int > | property_window_size () const |
The size of the window used to calculate rate and offset. More... | |
Glib::PropertyProxy< int > | property_window_threshold () |
The threshold to start calculating rate and offset. More... | |
Glib::PropertyProxy_ReadOnly< int > | property_window_threshold () const |
The threshold to start calculating rate and offset. More... | |
virtual ClockTime | change_resolution_vfunc (ClockTime old_resolution, ClockTime new_resolution) |
Change the resolution of the clock. More... | |
virtual ClockTime | get_resolution_vfunc () const |
Get the resolution of the clock. More... | |
virtual ClockTime | get_internal_time_vfunc () const |
Get the internal unadjusted time of the clock. More... | |
virtual ClockReturn | wait_vfunc (const Glib::RefPtr< Gst::ClockID >& id, ClockTimeDiff& jitter) |
Perform a blocking wait for the given Gst::ClockID. More... | |
virtual ClockReturn | wait_async_vfunc (const Glib::RefPtr< Gst::ClockID >& id) |
Perform an asynchronous wait for the given Gst::ClockID. More... | |
virtual void | unschedule_vfunc (const Glib::RefPtr< Gst::ClockID >& id) |
Unblock a blocking or async wait operation. More... | |
![]() | |
virtual | ~Object () |
GstObject* | gobj () |
Provides access to the underlying C GObject. More... | |
const GstObject* | gobj () const |
Provides access to the underlying C GObject. More... | |
GstObject* | gobj_copy () |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More... | |
bool | is_element () const |
bool | is_element_factory () const |
bool | is_pad () const |
bool | is_pad_template () const |
bool | is_bin () const |
guint32 | get_flags () const |
Returns the entire set of flags for the object. More... | |
bool | set_name (const Glib::ustring& name) |
Sets the name of object, or gives object a guaranteed unique name (if name is 0 ). More... | |
Glib::ustring | get_name () const |
Returns a copy of the name of object. More... | |
bool | set_parent (const Glib::RefPtr< Gst::Object >& parent) |
Sets the parent of object to parent. More... | |
Glib::RefPtr< Gst::Object > | get_parent () |
Returns the parent of object. More... | |
Glib::RefPtr< const Gst::Object > | get_parent () const |
Returns the parent of object. More... | |
void | unparent () |
Clear the parent of object, removing the associated reference. More... | |
bool | has_ancestor (const Glib::RefPtr< const Gst::Object >& ancestor) const |
Check if object has an ancestor ancestor somewhere up in the hierarchy. More... | |
Glib::ustring | get_path_string () |
Generates a string describing the path of object in the object hierarchy. More... | |
Glib::PropertyProxy < Glib::ustring > | property_name () |
The name of the object. More... | |
Glib::PropertyProxy_ReadOnly < Glib::ustring > | property_name () const |
The name of the object. More... | |
Glib::SignalProxy2< void, const Glib::RefPtr< Object > &, GParamSpec* > | signal_deep_notify () |
int | get_refcount () const |
Static Public Member Functions | |
static GType | get_type () |
Get the GType for this class, for use with the underlying GObject type system. More... | |
![]() | |
static GType | get_type () |
Get the GType for this class, for use with the underlying GObject type system. More... | |
static bool | check_uniqueness (const Glib::ListHandle< const Gst::Object >& list, const Glib::ustring& name) |
Checks to see if there is any object named name in list. More... | |
Related Functions | |
(Note that these are not member functions.) | |
Glib::RefPtr< Gst::Clock > | wrap (GstClock* object, bool take_copy=false) |
A Glib::wrap() method for this object. More... | |
![]() | |
Glib::RefPtr< Gst::Object > | wrap (GstObject* object, bool take_copy=false) |
A Glib::wrap() method for this object. More... | |
Additional Inherited Members | |
![]() | |
virtual void | on_deep_notify (const Glib::RefPtr< Object >& prop_object, GParamSpec* prop) |
This is a default handler for the signal signal_deep_notify(). More... | |
An abstract class for global clocks.
GStreamer uses a global clock to synchronize the plugins in a pipeline. Different clock implementations are possible by implementing this abstract base class.
The Gst::Clock returns a monotonically increasing time with the method 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 stream time. Usually all renderers synchronize to the global clock using the buffer timestamps, the newsegment events and the element's base time, see Gst::Pipeline.
A clock implementation can support periodic and single shot clock notifications both synchronous and asynchronous.
One first needs to create a Gst::ClockID for the periodic or single shot notification using create_single_shot_id() or create_periodic_id().
To perform a blocking wait for the specific time of the Gst::ClockID use the Gst::ClockID::wait() method. To receive a callback when the specific time is reached in the clock use Gst::ClockID::wait_async(). Both these calls can be interrupted with the Gst::ClockID::unschedule() call. If the blocking wait is unscheduled a return value of Gst::CLOCK_UNSCHEDULED is returned.
Periodic callbacks scheduled async will be repeadedly called automatically until it is unscheduled. To schedule a sync periodic callback, Gst::ClockID::wait() should be called repeadedly.
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 Gst::ClockID that has been unscheduled cannot be used again for any wait operation, a new Gst::ClockID should be created.
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 slot will only be called for the thread registering the entry last.
None of the wait operations unref the Gst::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 Gst::ClockID has to keep a handle to the Gst::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. (The RefPtr takes care of unreffing in this case)
These clock operations do not operate on the stream 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 Gst::Clock with the set_master() method. The clock will then automatically be synchronized to this master clock by repeadedly sampling the master clock and the slave clock and recalibrating the slave clock with set_calibration(). This feature is mostly useful for plugins that have an internal clock but must operate with another clock selected by the Gst::Pipeline. They can track the offset and rate difference of their internal clock relative to the master clock by using the get_calibration() method.
The master/slave synchronisation can be tuned with the "timeout", "window-size" and "window-threshold" properties. The "timeout" property defines the interval to sample the master clock and run the calibration functions. "window-size" defines the number of samples to use when calibrating and "window-threshold" defines the minimum number of samples before the calibration is performed.
Last reviewed on 2006-08-11 (0.10.10)
|
virtual |
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 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.
slave | A time on the slave. |
master | A time on the master. |
r_squared | A pointer to hold the result. |
true
if enough observations were added to run the regression algorithm.MT safe.
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. |
|
virtual |
Change the resolution of the clock.
Not all values might be acceptable. The new resolution should be returned.
Glib::RefPtr<Gst::ClockID> Gst::Clock::create_periodic_id | ( | ClockTime | start_time, |
ClockTime | intervals | ||
) |
Get an ID from clock to trigger a periodic notification.
The periodic notifications will start at time start_time and will then be fired with the given interval. id should be unreffed after usage.
Free-function: gst_clock_id_unref
start_time | The requested start time. |
interval | The requested interval. |
MT safe.
Glib::RefPtr<Gst::ClockID> Gst::Clock::create_single_shot_id | ( | ClockTime | time | ) |
Get a Gst::ClockID from clock to trigger a single shot notification at the requested time.
The single shot id should be unreffed after usage.
Free-function: gst_clock_id_unref
time | The requested time. |
MT safe.
void Gst::Clock::get_calibration | ( | ClockTime& | internal, |
ClockTime& | external, | ||
ClockTime& | rate_num, | ||
ClockTime& | rate_denom | ||
) | const |
Gets the internal rate and reference time of clock.
See set_calibration() for more information.
internal, external, rate_num, and rate_denom can be left 0
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. |
ClockTime Gst::Clock::get_internal_time | ( | ) | const |
Gets the current internal time of the given clock.
The time is returned unadjusted for the offset and the rate.
MT safe.
|
virtual |
Get the internal unadjusted time of the clock.
Glib::RefPtr<Gst::Clock> Gst::Clock::get_master | ( | ) |
Get the master clock that clock is slaved to or 0
when the clock is not slaved to any master clock.
0
when this clock is not slaved to a master clock. Unref after usage.MT safe.
Glib::RefPtr<const Gst::Clock> Gst::Clock::get_master | ( | ) | const |
Get the master clock that clock is slaved to or 0
when the clock is not slaved to any master clock.
0
when this clock is not slaved to a master clock. Unref after usage.MT safe.
ClockTime Gst::Clock::get_resolution | ( | ) | const |
Get the accuracy of the clock.
The accuracy of the clock is the granularity of the values returned by get_time().
MT safe.
|
virtual |
Get the resolution of the clock.
ClockTime Gst::Clock::get_time | ( | ) | const |
Gets the current time of the given clock.
The time is always monotonically increasing and adjusted according to the current offset and rate.
MT safe.
|
static |
Get the GType for this class, for use with the underlying GObject type system.
|
inline |
Provides access to the underlying C GObject.
|
inline |
Provides access to the underlying C GObject.
GstClock* Gst::Clock::gobj_copy | ( | ) |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
Glib::PropertyProxy< guint64 > Gst::Clock::property_timeout | ( | ) |
The amount of time, in nanoseconds, to sample master and slave clocks.
You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy_ReadOnly< guint64 > Gst::Clock::property_timeout | ( | ) | const |
The amount of time, in nanoseconds, to sample master and slave clocks.
You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy< int > Gst::Clock::property_window_size | ( | ) |
The size of the window used to calculate rate and offset.
You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy_ReadOnly< int > Gst::Clock::property_window_size | ( | ) | const |
The size of the window used to calculate rate and offset.
You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy< int > Gst::Clock::property_window_threshold | ( | ) |
The threshold to start calculating rate and offset.
You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy_ReadOnly< int > Gst::Clock::property_window_threshold | ( | ) | const |
The threshold to start calculating rate and offset.
You rarely need to use properties because there are get_ and set_ methods for almost all of them.
void Gst::Clock::set_calibration | ( | ClockTime | internal, |
ClockTime | external, | ||
ClockTime | rate_num, | ||
ClockTime | 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 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 get_internal_time() when this function is called.
Subsequent calls to get_time() will return clock times computed as follows:
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 get_time() always returns increasing values so when you move the clock backwards, 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. |
bool Gst::Clock::set_master | ( | const Clock& | master_clock | ) |
Set master as the master clock for clock.
clock will be automatically calibrated so that 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 get_calibration().
master can be 0
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.
master | A master Gst::Clock. |
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
.MT safe.
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 Gst::CLOCK_FLAG_CAN_SET_RESOLUTION flag set.
resolution | The resolution to set. |
Converts the given external clock time to the internal time of clock, using the rate and reference time set with 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 adjust_unlocked().
external | An external clock time. |
|
virtual |
Unblock a blocking or async wait operation.
|
virtual |
Perform an asynchronous wait for the given Gst::ClockID.
|
virtual |
Perform a blocking wait for the given Gst::ClockID.
Deprecated, implement wait_jitter_vfunc() instead.
|
related |
A Glib::wrap() method for this object.
object | The C instance. |
take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref. |