From 079ea274ddf97d0165e72665f90b114088bd7092 Mon Sep 17 00:00:00 2001 From: Philippe Normand Date: Thu, 8 Dec 2022 18:16:47 +0000 Subject: [PATCH] cefdemux: Vendor 1.18 GStreamer API This should be reverted once we bump our dependency to GStreamer >= 1.18. --- gstcefdemux.cc | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/gstcefdemux.cc b/gstcefdemux.cc index ddb6ee5..5cba7fa 100644 --- a/gstcefdemux.cc +++ b/gstcefdemux.cc @@ -89,6 +89,58 @@ typedef struct GstFlowReturn combined; } AudioPushData; +#if !GST_CHECK_VERSION(1, 18, 0) +static GstClockTime +gst_element_get_current_clock_time (GstElement * element) +{ + GstClock *clock = NULL; + GstClockTime ret; + + g_return_val_if_fail (GST_IS_ELEMENT (element), GST_CLOCK_TIME_NONE); + + clock = gst_element_get_clock (element); + + if (!clock) { + GST_DEBUG_OBJECT (element, "Element has no clock"); + return GST_CLOCK_TIME_NONE; + } + + ret = gst_clock_get_time (clock); + gst_object_unref (clock); + + return ret; +} + +static GstClockTime +gst_element_get_current_running_time (GstElement * element) +{ + GstClockTime base_time, clock_time; + + g_return_val_if_fail (GST_IS_ELEMENT (element), GST_CLOCK_TIME_NONE); + + base_time = gst_element_get_base_time (element); + + if (!GST_CLOCK_TIME_IS_VALID (base_time)) { + GST_DEBUG_OBJECT (element, "Could not determine base time"); + return GST_CLOCK_TIME_NONE; + } + + clock_time = gst_element_get_current_clock_time (element); + + if (!GST_CLOCK_TIME_IS_VALID (clock_time)) { + return GST_CLOCK_TIME_NONE; + } + + if (clock_time < base_time) { + GST_DEBUG_OBJECT (element, "Got negative current running time"); + return GST_CLOCK_TIME_NONE; + } + + return clock_time - base_time; +} +#endif + + static gboolean gst_cef_demux_push_audio_buffer (GstBuffer **buffer, guint idx, AudioPushData *push_data) {