summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2015-09-03 16:36:57 +0300
committerSebastian Dröge <sebastian@centricular.com>2015-09-09 16:59:02 +0300
commitb6498c32f3971bffbc4424353264932e7c47a7fc (patch)
treec1f1a1ddb0ab536a5e1ee3bfffb0991e17f53973 /sys
parenta6744a915b22c0cd602ba6cdcea1a48babf6030b (diff)
downloadgstreamer-plugins-bad-b6498c32f3971bffbc4424353264932e7c47a7fc.tar.gz
decklinkvideosink: Handle pipelines where the running time does not start around 0 properly
We were converting all times to our internal running times, that is the time the sink itself spent in PLAYING already. But forgot to do that for the running time calculated from the buffer timestamps. As such, all buffers were scheduled much later if the pipeline's running time did not start at 0. This happens for example if a base time is explicitly set on the pipeline. https://bugzilla.gnome.org/show_bug.cgi?id=754528
Diffstat (limited to 'sys')
-rw-r--r--sys/decklink/gstdecklinkvideosink.cpp30
1 files changed, 26 insertions, 4 deletions
diff --git a/sys/decklink/gstdecklinkvideosink.cpp b/sys/decklink/gstdecklinkvideosink.cpp
index 6a701a3b9..c72454ab0 100644
--- a/sys/decklink/gstdecklinkvideosink.cpp
+++ b/sys/decklink/gstdecklinkvideosink.cpp
@@ -354,12 +354,34 @@ convert_to_internal_clock (GstDecklinkVideoSink * self,
gst_clock_get_calibration (self->output->clock, &internal, &external,
&rate_n, &rate_d);
- if (rate_n != rate_d && self->internal_base_time != GST_CLOCK_TIME_NONE) {
+ if (self->internal_base_time != GST_CLOCK_TIME_NONE) {
GstClockTime external_timestamp = *timestamp;
+ GstClockTime base_time;
// Convert to the running time corresponding to both clock times
- internal -= self->internal_base_time;
- external -= self->external_base_time;
+ if (internal < self->internal_base_time)
+ internal = 0;
+ else
+ internal -= self->internal_base_time;
+
+ if (external < self->external_base_time)
+ external = 0;
+ else
+ external -= self->external_base_time;
+
+ // Convert timestamp to the "running time" since we started scheduled
+ // playback, that is the difference between the pipeline's base time
+ // and our own base time.
+ base_time = gst_element_get_base_time (GST_ELEMENT_CAST (self));
+ if (base_time > self->external_base_time)
+ base_time = 0;
+ else
+ base_time = self->external_base_time - base_time;
+
+ if (external_timestamp < base_time)
+ external_timestamp = 0;
+ else
+ external_timestamp = external_timestamp - base_time;
// Get the difference in the external time, note
// that the running time is external time.
@@ -398,7 +420,7 @@ convert_to_internal_clock (GstDecklinkVideoSink * self,
GST_TIME_ARGS (external), ((gdouble) rate_n) / ((gdouble) rate_d));
}
} else {
- GST_LOG_OBJECT (self, "No clock conversion needed, relative rate is 1.0");
+ GST_LOG_OBJECT (self, "No clock conversion needed, not started yet");
}
} else {
GST_LOG_OBJECT (self, "No clock conversion needed, same clocks");