From a6744a915b22c0cd602ba6cdcea1a48babf6030b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 7 Sep 2015 13:36:19 +0300 Subject: decklinkvideosink: Consider pipeline latency, render delay and ts offset when scheduling frames Without this, we will schedule all frames too late in live pipelines. https://bugzilla.gnome.org/show_bug.cgi?id=754666 --- sys/decklink/gstdecklinkvideosink.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'sys') diff --git a/sys/decklink/gstdecklinkvideosink.cpp b/sys/decklink/gstdecklinkvideosink.cpp index 9a7c6d42e..6a701a3b9 100644 --- a/sys/decklink/gstdecklinkvideosink.cpp +++ b/sys/decklink/gstdecklinkvideosink.cpp @@ -416,6 +416,7 @@ gst_decklink_video_sink_prepare (GstBaseSink * bsink, GstBuffer * buffer) HRESULT ret; GstClockTime timestamp, duration; GstClockTime running_time, running_time_duration; + GstClockTime latency, render_delay, ts_offset; gint i; GST_DEBUG_OBJECT (self, "Preparing buffer %p", buffer); @@ -439,6 +440,28 @@ gst_decklink_video_sink_prepare (GstBaseSink * bsink, GstBuffer * buffer) gst_segment_to_running_time (&GST_BASE_SINK_CAST (self)->segment, GST_FORMAT_TIME, timestamp + duration) - running_time; + /* See gst_base_sink_adjust_time() */ + latency = gst_base_sink_get_latency (bsink); + render_delay = gst_base_sink_get_render_delay (bsink); + ts_offset = gst_base_sink_get_ts_offset (bsink); + + running_time += latency; + + if (ts_offset < 0) { + ts_offset = -ts_offset; + if (ts_offset < running_time) + running_time -= ts_offset; + else + running_time = 0; + } else { + running_time += ts_offset; + } + + if (running_time > render_delay) + running_time -= render_delay; + else + running_time = 0; + ret = self->output->output->CreateVideoFrame (self->info.width, self->info.height, self->info.stride[0], bmdFormat8BitYUV, bmdFrameFlagDefault, &frame); -- cgit v1.2.1