element: add start_time field an methods
authorWim Taymans <wim.taymans@collabora.co.uk>
Tue, 26 May 2009 09:53:05 +0000 (11:53 +0200)
committerWim Taymans <wim@metal.(none)>
Fri, 29 May 2009 09:55:38 +0000 (11:55 +0200)
Add a start_time field and some methods. The start_time will contain the
running_time of when the element last went to paused. This time can be user to
report the position in PAUSED but also to do more correct clipping and
stepping later.

docs/gst/gstreamer-sections.txt
gst/gstelement.c
gst/gstelement.h
win32/common/libgstreamer.def

index 337e0c0..25ea69a 100644 (file)
@@ -482,6 +482,7 @@ GST_ELEMENT_PARENT
 GST_ELEMENT_BUS
 GST_ELEMENT_CLOCK
 GST_ELEMENT_PADS
+GST_ELEMENT_START_TIME
 GST_ELEMENT_ERROR
 GST_ELEMENT_WARNING
 GST_ELEMENT_INFO
@@ -523,6 +524,8 @@ gst_element_link_filtered
 <SUBSECTION element-properties>
 gst_element_set_base_time
 gst_element_get_base_time
+gst_element_set_start_time
+gst_element_get_start_time
 gst_element_set_bus
 gst_element_get_bus
 gst_element_get_factory
index c4815f9..c326992 100644 (file)
@@ -531,6 +531,62 @@ gst_element_get_base_time (GstElement * element)
 }
 
 /**
+ * gst_element_set_start_time:
+ * @element: a #GstElement.
+ * @time: the base time to set.
+ *
+ * Set the start time of an element. See gst_element_get_start_time().
+ *
+ * MT safe.
+ *
+ * Since: 0.10.24
+ */
+void
+gst_element_set_start_time (GstElement * element, GstClockTime time)
+{
+  GstClockTime old;
+
+  g_return_if_fail (GST_IS_ELEMENT (element));
+
+  GST_OBJECT_LOCK (element);
+  old = GST_ELEMENT_START_TIME (element);
+  GST_ELEMENT_START_TIME (element) = time;
+  GST_OBJECT_UNLOCK (element);
+
+  GST_CAT_DEBUG_OBJECT (GST_CAT_CLOCK, element,
+      "set start_time=%" GST_TIME_FORMAT ", old %" GST_TIME_FORMAT,
+      GST_TIME_ARGS (time), GST_TIME_ARGS (old));
+}
+
+/**
+ * gst_element_get_start_time:
+ * @element: a #GstElement.
+ *
+ * Returns the start time of the element. The start time is the
+ * running time of the clock when this element was last put to
+ * PAUSED. 
+ *
+ * MT safe.
+ *
+ * Returns: the start time of the element.
+ *
+ * Since: 0.10.24
+ */
+GstClockTime
+gst_element_get_start_time (GstElement * element)
+{
+  GstClockTime result;
+
+  g_return_val_if_fail (GST_IS_ELEMENT (element), GST_CLOCK_TIME_NONE);
+
+  GST_OBJECT_LOCK (element);
+  result = GST_ELEMENT_START_TIME (element);
+  GST_OBJECT_UNLOCK (element);
+
+  return result;
+}
+
+/**
  * gst_element_is_indexable:
  * @element: a #GstElement.
  *
index 65f281d..9bb1dd1 100644 (file)
@@ -263,6 +263,17 @@ typedef enum
 #define GST_ELEMENT_PADS(elem)                 (GST_ELEMENT_CAST(elem)->pads)
 
 /**
+ * GST_ELEMENT_START_TIME:
+ * @elem: a #GstElement to return the start time for.
+ *
+ * This macro returns the start_time of the @elem. The start_time is the
+ * running_time of the pipeline when the element went to PAUSED.
+ *
+ * Since: 0.10.24
+ */
+#define GST_ELEMENT_START_TIME(elem)           (GST_ELEMENT_CAST(elem)->abidata.ABI.start_time)
+
+/**
  * GST_ELEMENT_ERROR:
  * @el:     the element that generates the error
  * @domain: like CORE, LIBRARY, RESOURCE or STREAM (see #gstreamer-GstGError)
@@ -441,6 +452,8 @@ struct _GstElement
     struct {
       /* state set by application */
       GstState              target_state;
+      /* running time of the last PAUSED state */
+      GstClockTime          start_time;
     } ABI;
     /* adding + 0 to mark ABI change to be undone later */
     gpointer _gst_reserved[GST_PADDING + 0];
@@ -586,6 +599,8 @@ GstClock*           gst_element_get_clock           (GstElement *element);
 gboolean               gst_element_set_clock           (GstElement *element, GstClock *clock);
 void                   gst_element_set_base_time       (GstElement *element, GstClockTime time);
 GstClockTime           gst_element_get_base_time       (GstElement *element);
+void                   gst_element_set_start_time      (GstElement *element, GstClockTime time);
+GstClockTime           gst_element_get_start_time      (GstElement *element);
 
 /* indexes */
 gboolean               gst_element_is_indexable        (GstElement *element);
index aa161fa..3c76a32 100644 (file)
@@ -291,6 +291,7 @@ EXPORTS
        gst_element_get_pad
        gst_element_get_query_types
        gst_element_get_request_pad
+       gst_element_get_start_time
        gst_element_get_state
        gst_element_get_static_pad
        gst_element_get_type
@@ -330,6 +331,7 @@ EXPORTS
        gst_element_set_clock
        gst_element_set_index
        gst_element_set_locked_state
+       gst_element_set_start_time
        gst_element_set_state
        gst_element_state_change_return_get_name
        gst_element_state_get_name