From d8bea77230eb69ceffbc4f79ac4657d7dc6f7172 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 31 Dec 2007 19:11:39 +0000 Subject: [PATCH] docs/design/part-synchronisation.txt: Some more info on how the stream_time in GstBaseSink is done. Original commit message from CVS: * docs/design/part-synchronisation.txt: Some more info on how the stream_time in GstBaseSink is done. --- ChangeLog | 5 +++++ docs/design/part-synchronisation.txt | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/ChangeLog b/ChangeLog index 85ede12..8494df7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-12-31 Wim Taymans + + * docs/design/part-synchronisation.txt: + Some more info on how the stream_time in GstBaseSink is done. + 2007-12-30 Tim-Philipp Müller * tests/check/generic/sinks.c: (gst_sinks_suite): diff --git a/docs/design/part-synchronisation.txt b/docs/design/part-synchronisation.txt index 1ac8453..c19e6ea 100644 --- a/docs/design/part-synchronisation.txt +++ b/docs/design/part-synchronisation.txt @@ -180,5 +180,29 @@ event as follows: For negative rates, B.timestamp will go backwards from NS.stop to NS.start, making the stream time go backwards. +In the PLAYING state, it is also possible to use the pipeline clock to derive +the current stream_time. + +Give the two formulas above to match the clock times with buffer timestamps +allows us to rewrite the above formula for stream_time (and for positive rates). + + C.running_time = absolute_time - base_time + B.running_time = (B.timestamp - NS.start) / NS.abs_rate + NS.accum + + => + absolute_time - base_time = (B.timestamp - NS.start) / NS.abs_rate + NS.accum + + => + absolute_time - base_time = (B.timestamp - NS.start) / NS.abs_rate + NS.accum + + => + (B.timestamp - NS.start) = (absolute_time - base_time - NS.accum) * NS.abs_rate + + => + stream_time = (absolute_time - base_time - NS.accum) * NS.abs_rate * NS.abs_applied_rate + NS.time + +This last formula is typically used in sinks to report the current position in +an accurate and efficient way. + Note that the stream time is never used for synchronisation against the clock. -- 2.7.4