From f83ac624e3e88bd06e932596e052c5848dce462d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 10 Feb 2015 15:30:44 +0100 Subject: [PATCH] decklinkvideosrc: Add the diff between the pipeline base time and when we start to play Add the diff between the external time when we went to playing and the external time when the pipeline went to playing. Otherwise we will always start outputting from 0 instead of the current running time. --- sys/decklink/gstdecklinkvideosrc.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sys/decklink/gstdecklinkvideosrc.cpp b/sys/decklink/gstdecklinkvideosrc.cpp index 08d8b287ac..0d65814cb3 100644 --- a/sys/decklink/gstdecklinkvideosrc.cpp +++ b/sys/decklink/gstdecklinkvideosrc.cpp @@ -381,11 +381,23 @@ gst_decklink_video_src_convert_to_external_clock (GstDecklinkVideoSrc * self, if (rate_n != rate_d && self->internal_base_time != GST_CLOCK_TIME_NONE) { GstClockTime internal_timestamp = *timestamp; + GstClockTimeDiff external_start_time_diff; // Convert to the running time corresponding to both clock times internal -= self->internal_base_time; external -= self->external_base_time; + // Add the diff between the external time when we + // went to playing and the external time when the + // pipeline went to playing. Otherwise we will + // always start outputting from 0 instead of the + // current running time. + external_start_time_diff = + gst_element_get_base_time (GST_ELEMENT_CAST (self)); + external_start_time_diff = + self->external_base_time - external_start_time_diff; + external += external_start_time_diff; + // Get the difference in the internal time, note // that the capture time is internal time. // Then scale this difference and offset it to