baseparse: use _set_duration to configure duration update interval
authorMark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>
Wed, 22 Sep 2010 12:13:17 +0000 (14:13 +0200)
committerTim-Philipp Müller <tim.muller@collabora.co.uk>
Fri, 8 Apr 2011 14:44:52 +0000 (15:44 +0100)
... as it logically belongs there as one or the other; either subclass
can provide a duration, or an estimate must be made (reguarly updated).

gst/audioparsers/gstbaseparse.c
gst/audioparsers/gstbaseparse.h

index 73da287..c73d096 100644 (file)
@@ -2106,11 +2106,13 @@ gst_base_parse_sink_activate_pull (GstPad * sinkpad, gboolean active)
  * @duration: duration value.
  *
  * Sets the duration of the currently playing media. Subclass can use this
- * when it notices a change in the media duration.
- */
+ * when it is able to determine duration and/or notices a change in the media
+ * duration.  Alternatively, if @interval is non-zero (default), then stream
+ * duration is determined based on estimated bitrate, and updated every @interval
+ * frames. */
 void
 gst_base_parse_set_duration (GstBaseParse * parse,
-    GstFormat fmt, gint64 duration)
+    GstFormat fmt, gint64 duration, gint interval)
 {
   g_return_if_fail (parse != NULL);
 
@@ -2126,6 +2128,14 @@ gst_base_parse_set_duration (GstBaseParse * parse,
   parse->priv->duration = duration;
   parse->priv->duration_fmt = fmt;
   GST_DEBUG_OBJECT (parse, "set duration: %" G_GINT64_FORMAT, duration);
+  if (fmt == GST_FORMAT_TIME && GST_CLOCK_TIME_IS_VALID (duration)) {
+    if (interval != 0) {
+      GST_DEBUG_OBJECT (parse, "valid duration provided, disabling estimate");
+      interval = 0;
+    }
+  }
+  GST_DEBUG_OBJECT (parse, "set update interval: %d", interval);
+  parse->priv->update_interval = interval;
   GST_BASE_PARSE_UNLOCK (parse);
 }
 
@@ -2195,28 +2205,23 @@ gst_base_parse_set_passthrough (GstBaseParse * parse, gboolean passthrough)
  * @parse: the #GstBaseParse to set
  * @fps_num: frames per second (numerator).
  * @fps_den: frames per second (denominator).
- * @interval: duration update interval in frames.
  *
  * If frames per second is configured, parser can take care of buffer duration
- * and timestamping. If #interval is non-zero (default), then stream duration
- * is determined based on frame and byte counts, and updated every #interval
- * frames.
+ * and timestamping.
  */
 void
 gst_base_parse_set_frame_props (GstBaseParse * parse, guint fps_num,
-    guint fps_den, gint interval)
+    guint fps_den)
 {
   g_return_if_fail (parse != NULL);
 
   GST_BASE_PARSE_LOCK (parse);
   parse->priv->fps_num = fps_num;
   parse->priv->fps_den = fps_den;
-  parse->priv->update_interval = interval;
   if (!fps_num || !fps_den) {
     GST_DEBUG_OBJECT (parse, "invalid fps (%d/%d), ignoring parameters",
         fps_num, fps_den);
     fps_num = fps_den = 0;
-    interval = 0;
     parse->priv->frame_duration = GST_CLOCK_TIME_NONE;
   } else {
     parse->priv->frame_duration =
@@ -2225,7 +2230,6 @@ gst_base_parse_set_frame_props (GstBaseParse * parse, guint fps_num,
   }
   GST_LOG_OBJECT (parse, "set fps: %d/%d => duration: %" G_GINT64_FORMAT " ms",
       fps_num, fps_den, parse->priv->frame_duration / GST_MSECOND);
-  GST_LOG_OBJECT (parse, "set update interval: %d", interval);
   GST_BASE_PARSE_UNLOCK (parse);
 }
 
index 958e38c..8d913b1 100644 (file)
@@ -284,8 +284,7 @@ GstFlowReturn gst_base_parse_push_buffer (GstBaseParse *parse,
                                           GstBuffer *buffer);
 
 void gst_base_parse_set_duration (GstBaseParse *parse,
-                                  GstFormat fmt,
-                                  gint64 duration);
+                                  GstFormat fmt, gint64 duration, gint interval);
 
 void gst_base_parse_set_seek (GstBaseParse * parse,
                               GstBaseParseSeekable seek, guint bitrate);
@@ -295,7 +294,7 @@ void gst_base_parse_set_min_frame_size (GstBaseParse *parse,
 void gst_base_parse_set_passthrough (GstBaseParse * parse, gboolean passthrough);
 
 void gst_base_parse_set_frame_props (GstBaseParse * parse, guint fps_num,
-                                     guint fps_den, gint interval);
+                                     guint fps_den);
 
 gboolean gst_base_parse_get_sync (GstBaseParse * parse);