From d2d2ac43e8af28f13f0935386b612bee50c0b5b3 Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Thu, 8 Feb 2024 23:03:29 +0900 Subject: [PATCH] ccconverter: Send gap event if generated output is empty Sends a gap event if nothing to output for a given input buffer. For example, an input buffer might not contain any caption data for downstream requested field, then we need to inform downstream of the case. Part-of: --- .../ext/closedcaption/gstccconverter.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/subprojects/gst-plugins-bad/ext/closedcaption/gstccconverter.c b/subprojects/gst-plugins-bad/ext/closedcaption/gstccconverter.c index ffbf11d8b9..88cfe12c49 100644 --- a/subprojects/gst-plugins-bad/ext/closedcaption/gstccconverter.c +++ b/subprojects/gst-plugins-bad/ext/closedcaption/gstccconverter.c @@ -1703,6 +1703,25 @@ gst_cc_converter_generate_output (GstBaseTransform * base, GstBuffer ** outbuf) if (gst_buffer_get_size (*outbuf) <= 0) { gst_buffer_unref (*outbuf); *outbuf = NULL; + + if (inbuf && GST_BUFFER_PTS_IS_VALID (inbuf)) { + GstClockTime dur = 0; + GstEvent *gap; + + GST_TRACE_OBJECT (self, "Empty generated output for input %" + GST_PTR_FORMAT, inbuf); + + if (GST_BUFFER_DURATION_IS_VALID (inbuf)) { + dur = GST_BUFFER_DURATION (inbuf); + } else if (self->in_fps_n > 0 && self->in_fps_d > 0) { + dur = gst_util_uint64_scale (GST_SECOND, + self->in_fps_d, self->in_fps_n); + } + + gap = gst_event_new_gap (GST_BUFFER_PTS (inbuf), dur); + gst_pad_push_event (GST_BASE_TRANSFORM_SRC_PAD (self), gap); + } + ret = GST_FLOW_OK; }