mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-05 23:18:52 +00:00
element: Added gst_element_get_current_clock_time and gst_element_get_current_running_time
Helper functions for getting the element clock's time, and the clock time minus base time, respectively.
This commit is contained in:
parent
533fbf766e
commit
1d5a1e8235
2 changed files with 80 additions and 0 deletions
|
@ -586,6 +586,80 @@ gst_element_get_start_time (GstElement * element)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_element_get_current_running_time:
|
||||||
|
* @element: a #GstElement.
|
||||||
|
*
|
||||||
|
* Returns the running time of the element. The running time is the
|
||||||
|
* element's clock time minus its base time. Will return GST_CLOCK_TIME_NONE
|
||||||
|
* if the element has no clock, or if its base time has not been set.
|
||||||
|
*
|
||||||
|
* Returns: the running time of the element, or GST_CLOCK_TIME_NONE if the
|
||||||
|
* element has no clock or its base time has not been set.
|
||||||
|
*
|
||||||
|
* Since: 1.18
|
||||||
|
*/
|
||||||
|
GstClockTime
|
||||||
|
gst_element_get_current_running_time (GstElement * element)
|
||||||
|
{
|
||||||
|
GstClockTime base_time, clock_time;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GST_IS_ELEMENT (element), GST_CLOCK_TIME_NONE);
|
||||||
|
|
||||||
|
base_time = gst_element_get_base_time (element);
|
||||||
|
|
||||||
|
if (!GST_CLOCK_TIME_IS_VALID (base_time)) {
|
||||||
|
GST_DEBUG_OBJECT (element, "Could not determine base time");
|
||||||
|
return GST_CLOCK_TIME_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
clock_time = gst_element_get_current_clock_time (element);
|
||||||
|
|
||||||
|
if (!GST_CLOCK_TIME_IS_VALID (clock_time)) {
|
||||||
|
return GST_CLOCK_TIME_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (clock_time < base_time) {
|
||||||
|
GST_DEBUG_OBJECT (element, "Got negative current running time");
|
||||||
|
return GST_CLOCK_TIME_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return clock_time - base_time;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_element_get_current_clock_time:
|
||||||
|
* @element: a #GstElement.
|
||||||
|
*
|
||||||
|
* Returns the current clock time of the element, as in, the time of the
|
||||||
|
* element's clock, or GST_CLOCK_TIME_NONE if there is no clock.
|
||||||
|
*
|
||||||
|
* Returns: the clock time of the element, or GST_CLOCK_TIME_NONE if there is
|
||||||
|
* no clock.
|
||||||
|
*
|
||||||
|
* Since: 1.18
|
||||||
|
*/
|
||||||
|
GstClockTime
|
||||||
|
gst_element_get_current_clock_time (GstElement * element)
|
||||||
|
{
|
||||||
|
GstClock *clock = NULL;
|
||||||
|
GstClockTime ret;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GST_IS_ELEMENT (element), GST_CLOCK_TIME_NONE);
|
||||||
|
|
||||||
|
clock = gst_element_get_clock (element);
|
||||||
|
|
||||||
|
if (!clock) {
|
||||||
|
GST_DEBUG_OBJECT (element, "Element has no clock");
|
||||||
|
return GST_CLOCK_TIME_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = gst_clock_get_time (clock);
|
||||||
|
gst_object_unref (clock);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/**
|
/**
|
||||||
* gst_element_set_index:
|
* gst_element_set_index:
|
||||||
|
|
|
@ -860,6 +860,12 @@ void gst_element_set_start_time (GstElement *element, Gs
|
||||||
GST_API
|
GST_API
|
||||||
GstClockTime gst_element_get_start_time (GstElement *element);
|
GstClockTime gst_element_get_start_time (GstElement *element);
|
||||||
|
|
||||||
|
GST_API
|
||||||
|
GstClockTime gst_element_get_current_running_time (GstElement *element);
|
||||||
|
|
||||||
|
GST_API
|
||||||
|
GstClockTime gst_element_get_current_clock_time (GstElement *element);
|
||||||
|
|
||||||
/* bus */
|
/* bus */
|
||||||
|
|
||||||
GST_API
|
GST_API
|
||||||
|
|
Loading…
Reference in a new issue