From 9ed4054a940677c123fdf7bdd8080616a690a6bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 10 Feb 2015 16:01:19 +0100 Subject: [PATCH] decklinkvideosrc: Apply the diff between element and pipeline "base" time in all cases Even if both clocks have the same rate, we need to apply this diff. Only when it's the same clock we don't, as it's our clock then. --- sys/decklink/gstdecklinkvideosrc.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/sys/decklink/gstdecklinkvideosrc.cpp b/sys/decklink/gstdecklinkvideosrc.cpp index 0d65814cb3..75ff75285b 100644 --- a/sys/decklink/gstdecklinkvideosrc.cpp +++ b/sys/decklink/gstdecklinkvideosrc.cpp @@ -376,28 +376,18 @@ gst_decklink_video_src_convert_to_external_clock (GstDecklinkVideoSrc * self, clock = gst_element_get_clock (GST_ELEMENT_CAST (self)); if (clock && clock != self->input->clock) { GstClockTime internal, external, rate_n, rate_d; + GstClockTimeDiff external_start_time_diff; + gst_clock_get_calibration (self->input->clock, &internal, &external, &rate_n, &rate_d); 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 @@ -437,6 +427,17 @@ gst_decklink_video_src_convert_to_external_clock (GstDecklinkVideoSrc * self, } else { GST_LOG_OBJECT (self, "No clock conversion needed, relative rate is 1.0"); } + + // 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; + *timestamp += external_start_time_diff; } else { GST_LOG_OBJECT (self, "No clock conversion needed, same clocks"); }