diff --git a/ChangeLog b/ChangeLog index 15046c5933..f50c3a9032 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2007-09-11 Wim Taymans + + * 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 * gst/gstbuffer.c: diff --git a/docs/design/part-live-source.txt b/docs/design/part-live-source.txt index 59691334fe..0e472ffa02 100644 --- a/docs/design/part-live-source.txt +++ b/docs/design/part-live-source.txt @@ -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. + diff --git a/libs/gst/base/gstbasesrc.c b/libs/gst/base/gstbasesrc.c index 043285590d..275eeeb431 100644 --- a/libs/gst/base/gstbasesrc.c +++ b/libs/gst/base/gstbasesrc.c @@ -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,