docs/design/part-live-source.txt: Add docs on how live sources should timestamp.
authorWim Taymans <wim.taymans@gmail.com>
Tue, 11 Sep 2007 23:27:42 +0000 (23:27 +0000)
committerWim Taymans <wim.taymans@gmail.com>
Tue, 11 Sep 2007 23:27:42 +0000 (23:27 +0000)
Original commit message from CVS:
* docs/design/part-live-source.txt:
Add docs on how live sources should timestamp.
* libs/gst/base/gstbasesrc.c: (gst_base_src_do_sync):
Add some more debug info.
For subclasses that are live and like to sync, add aditional startup
latency to sync time and timestamps so that we timstamp according to the
design doc.

ChangeLog
docs/design/part-live-source.txt
libs/gst/base/gstbasesrc.c

index 15046c5..f50c3a9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2007-09-11  Wim Taymans  <wim.taymans@gmail.com>
+
+       * docs/design/part-live-source.txt:
+       Add docs on how live sources should timestamp.
+
+       * libs/gst/base/gstbasesrc.c: (gst_base_src_do_sync):
+       Add some more debug info.
+       For subclasses that are live and like to sync, add aditional startup
+       latency to sync time and timestamps so that we timstamp according to the
+       design doc.
+
 2007-09-11  Tim-Philipp Müller  <tim at centricular dot net>
 
        * gst/gstbuffer.c:
index 5969133..0e472ff 100644 (file)
@@ -46,3 +46,15 @@ The latency is the time it takes to construct one buffer of data. This latency
 is exposed with a LATENCY query.
 
 See part-latency.txt.
+
+
+Timestamps
+----------
+
+Live sources always timestamp their buffers with the running_time of the
+pipeline. This is needed to be able to match the timestamps of different live
+sources in order to synchronize them.
+
+This is in contrast to non-live sources, which timestamp their buffers starting
+from running_time 0.
+
index 0432855..275eeeb 100644 (file)
@@ -1507,6 +1507,9 @@ gst_base_src_do_sync (GstBaseSrc * basesrc, GstBuffer * buffer)
   if (basesrc->priv->startup_latency == -1) {
     now = gst_clock_get_time (clock);
 
+    GST_LOG_OBJECT (basesrc, "startup timestamp: %" GST_TIME_FORMAT,
+        GST_TIME_ARGS (timestamp));
+
     /* startup latency is the diff between when we went to PLAYING (base_time)
      * and the current clock time */
     if (now > base_time)
@@ -1514,7 +1517,7 @@ gst_base_src_do_sync (GstBaseSrc * basesrc, GstBuffer * buffer)
     else
       basesrc->priv->startup_latency = 0;
 
-    GST_LOG_OBJECT (basesrc, "startup latency: %" GST_TIME_FORMAT,
+    GST_LOG_OBJECT (basesrc, "startup running_time: %" GST_TIME_FORMAT,
         GST_TIME_ARGS (basesrc->priv->startup_latency));
 
     if (!GST_CLOCK_TIME_IS_VALID (timestamp)) {
@@ -1524,6 +1527,9 @@ gst_base_src_do_sync (GstBaseSrc * basesrc, GstBuffer * buffer)
         timestamp = 0;
 
       GST_BUFFER_TIMESTAMP (buffer) = timestamp;
+
+      GST_LOG_OBJECT (basesrc, "created timestamp: %" GST_TIME_FORMAT,
+          GST_TIME_ARGS (timestamp));
     }
 
     /* we have a timestamp, we can subtract it from the startup_latency when it is
@@ -1534,6 +1540,9 @@ gst_base_src_do_sync (GstBaseSrc * basesrc, GstBuffer * buffer)
       else
         basesrc->priv->startup_latency = 0;
     }
+
+    GST_LOG_OBJECT (basesrc, "startup latency: %" GST_TIME_FORMAT,
+        GST_TIME_ARGS (basesrc->priv->startup_latency));
   } else {
     /* not the first buffer, the timestamp is the diff between the clock and
      * base_time */
@@ -1548,6 +1557,16 @@ gst_base_src_do_sync (GstBaseSrc * basesrc, GstBuffer * buffer)
   if (!GST_CLOCK_TIME_IS_VALID (start))
     goto invalid_start;
 
+  if (basesrc->is_live) {
+    /* live source and we need to sync, add startup latency to timestamp to
+     * get the real running_time */
+    if (timestamp != -1) {
+      start += basesrc->priv->startup_latency;
+      GST_BUFFER_TIMESTAMP (buffer) =
+          timestamp + basesrc->priv->startup_latency;
+    }
+  }
+
   GST_LOG_OBJECT (basesrc,
       "waiting for clock, base time %" GST_TIME_FORMAT
       ", stream_start %" GST_TIME_FORMAT,