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
This commit is contained in:
parent
21bfa428d1
commit
a6744a915b
@ -416,6 +416,7 @@ gst_decklink_video_sink_prepare (GstBaseSink * bsink, GstBuffer * buffer)
|
|||||||
HRESULT ret;
|
HRESULT ret;
|
||||||
GstClockTime timestamp, duration;
|
GstClockTime timestamp, duration;
|
||||||
GstClockTime running_time, running_time_duration;
|
GstClockTime running_time, running_time_duration;
|
||||||
|
GstClockTime latency, render_delay, ts_offset;
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (self, "Preparing buffer %p", buffer);
|
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_segment_to_running_time (&GST_BASE_SINK_CAST (self)->segment,
|
||||||
GST_FORMAT_TIME, timestamp + duration) - running_time;
|
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,
|
ret = self->output->output->CreateVideoFrame (self->info.width,
|
||||||
self->info.height, self->info.stride[0], bmdFormat8BitYUV,
|
self->info.height, self->info.stride[0], bmdFormat8BitYUV,
|
||||||
bmdFrameFlagDefault, &frame);
|
bmdFrameFlagDefault, &frame);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user