timecodestamper: Don't fail the latency query in LTC mode if we have no framerate
authorSebastian Dröge <sebastian@centricular.com>
Tue, 5 Nov 2024 12:23:05 +0000 (14:23 +0200)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Wed, 6 Nov 2024 15:45:02 +0000 (15:45 +0000)
Only in LTC mode we introduce additional latency that is depending on only on a
property and not on the framerate, so waiting for the framerate is not necessary.

In all other modes no latency is introduced at all and the latency query can
simply be proxied.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7846>

subprojects/gst-plugins-bad/gst/timecode/gsttimecodestamper.c

index c1440b83df44d12e0b6fd6fbffc78c60a5dfb808..5f92dd418991f150ca931916f3997f28a9ddfa1e 100644 (file)
@@ -1028,31 +1028,27 @@ gst_timecodestamper_query (GstBaseTransform * trans,
       res =
           gst_pad_query_default (GST_BASE_TRANSFORM_SRC_PAD (trans),
           GST_OBJECT_CAST (trans), query);
+      if (!res)
+        return FALSE;
+
+      gst_query_parse_latency (query, &live, &min_latency, &max_latency);
       g_mutex_lock (&timecodestamper->mutex);
-      if (res && timecodestamper->fps_n && timecodestamper->fps_d) {
-        gst_query_parse_latency (query, &live, &min_latency, &max_latency);
-        if (live && timecodestamper->ltcpad) {
-          /* Introduce additional LTC for waiting for LTC timecodes. The
-           * LTC library introduces some as well as the encoding of the LTC
-           * signal. */
-          latency = timecodestamper->ltc_extra_latency;
-          min_latency += latency;
-          if (max_latency != GST_CLOCK_TIME_NONE)
-            max_latency += latency;
-          timecodestamper->latency = min_latency;
-          GST_DEBUG_OBJECT (timecodestamper,
-              "Reporting latency min %" GST_TIME_FORMAT " max %" GST_TIME_FORMAT
-              " ours %" GST_TIME_FORMAT, GST_TIME_ARGS (min_latency),
-              GST_TIME_ARGS (max_latency), GST_TIME_ARGS (latency));
-          gst_query_set_latency (query, live, min_latency, max_latency);
-        } else {
-          timecodestamper->latency = 0;
-        }
-      } else if (res) {
-        GST_ERROR_OBJECT (timecodestamper,
-            "Need a known, non-variable framerate to answer LATENCY query");
-        res = FALSE;
-        timecodestamper->latency = GST_CLOCK_TIME_NONE;
+      if (live && timecodestamper->ltcpad) {
+        /* Introduce additional LTC for waiting for LTC timecodes. The
+         * LTC library introduces some as well as the encoding of the LTC
+         * signal. */
+        latency = timecodestamper->ltc_extra_latency;
+        min_latency += latency;
+        if (max_latency != GST_CLOCK_TIME_NONE)
+          max_latency += latency;
+        timecodestamper->latency = min_latency;
+        GST_DEBUG_OBJECT (timecodestamper,
+            "Reporting latency min %" GST_TIME_FORMAT " max %" GST_TIME_FORMAT
+            " ours %" GST_TIME_FORMAT, GST_TIME_ARGS (min_latency),
+            GST_TIME_ARGS (max_latency), GST_TIME_ARGS (latency));
+        gst_query_set_latency (query, live, min_latency, max_latency);
+      } else {
+        timecodestamper->latency = 0;
       }
       g_mutex_unlock (&timecodestamper->mutex);