diff -urp webkitgtk-2.44.0.orig/Source/cmake/GStreamerChecks.cmake webkitgtk-2.44.0/Source/cmake/GStreamerChecks.cmake
--- webkitgtk-2.44.0.orig/Source/cmake/GStreamerChecks.cmake	2024-03-16 01:45:51.284670000 -0500
+++ webkitgtk-2.44.0/Source/cmake/GStreamerChecks.cmake	2024-03-19 13:09:31.670485759 -0500
@@ -36,7 +36,7 @@ if (ENABLE_VIDEO OR ENABLE_WEB_AUDIO)
               list(APPEND GSTREAMER_COMPONENTS webrtc)
           endif ()
 
-          find_package(GStreamer 1.18.4 REQUIRED COMPONENTS ${GSTREAMER_COMPONENTS})
+          find_package(GStreamer 1.16.2 REQUIRED COMPONENTS ${GSTREAMER_COMPONENTS})
 
           if (ENABLE_WEB_AUDIO)
               if (NOT PC_GSTREAMER_AUDIO_FOUND OR NOT PC_GSTREAMER_FFT_FOUND)
diff -urp webkitgtk-2.44.0.orig/Source/WebCore/platform/audio/gstreamer/AudioSourceProviderGStreamer.cpp webkitgtk-2.44.0/Source/WebCore/platform/audio/gstreamer/AudioSourceProviderGStreamer.cpp
--- webkitgtk-2.44.0.orig/Source/WebCore/platform/audio/gstreamer/AudioSourceProviderGStreamer.cpp	2024-03-16 01:45:50.388671400 -0500
+++ webkitgtk-2.44.0/Source/WebCore/platform/audio/gstreamer/AudioSourceProviderGStreamer.cpp	2024-03-19 13:09:31.670485759 -0500
@@ -123,7 +123,10 @@ AudioSourceProviderGStreamer::AudioSourc
     g_signal_connect_swapped(decodebin, "pad-added", G_CALLBACK(+[](AudioSourceProviderGStreamer* provider, GstPad* pad) {
         auto padCaps = adoptGRef(gst_pad_query_caps(pad, nullptr));
         bool isAudio = doCapsHaveType(padCaps.get(), "audio");
-        RELEASE_ASSERT(isAudio);
+        if (webkitGstCheckVersion(1, 18, 0))
+            RELEASE_ASSERT(isAudio);
+        else if (!isAudio)
+            return;
 
         auto sinkPad = adoptGRef(gst_element_get_static_pad(provider->m_audioSinkBin.get(), "sink"));
         gst_pad_link(pad, sinkPad.get());
diff -urp webkitgtk-2.44.0.orig/Source/WebCore/platform/graphics/gstreamer/GLVideoSinkGStreamer.cpp webkitgtk-2.44.0/Source/WebCore/platform/graphics/gstreamer/GLVideoSinkGStreamer.cpp
--- webkitgtk-2.44.0.orig/Source/WebCore/platform/graphics/gstreamer/GLVideoSinkGStreamer.cpp	2024-03-16 01:45:50.476671200 -0500
+++ webkitgtk-2.44.0/Source/WebCore/platform/graphics/gstreamer/GLVideoSinkGStreamer.cpp	2024-03-19 13:09:31.670485759 -0500
@@ -186,12 +186,13 @@ static void webKitGLVideoSinkGetProperty
     WebKitGLVideoSink* sink = WEBKIT_GL_VIDEO_SINK(object);
 
     switch (propertyId) {
-    case PROP_STATS: {
-        GUniqueOutPtr<GstStructure> stats;
-        g_object_get(sink->priv->appSink.get(), "stats", &stats.outPtr(), nullptr);
-        gst_value_set_structure(value, stats.get());
+    case PROP_STATS:
+        if (webkitGstCheckVersion(1, 18, 0)) {
+            GUniqueOutPtr<GstStructure> stats;
+            g_object_get(sink->priv->appSink.get(), "stats", &stats.outPtr(), nullptr);
+            gst_value_set_structure(value, stats.get());
+        }
         break;
-    }
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, paramSpec);
         RELEASE_ASSERT_NOT_REACHED();
diff -urp webkitgtk-2.44.0.orig/Source/WebCore/platform/graphics/gstreamer/GStreamerAudioMixer.cpp webkitgtk-2.44.0/Source/WebCore/platform/graphics/gstreamer/GStreamerAudioMixer.cpp
--- webkitgtk-2.44.0.orig/Source/WebCore/platform/graphics/gstreamer/GStreamerAudioMixer.cpp	2024-03-16 01:45:50.480671400 -0500
+++ webkitgtk-2.44.0/Source/WebCore/platform/graphics/gstreamer/GStreamerAudioMixer.cpp	2024-03-19 13:09:31.670485759 -0500
@@ -32,7 +32,7 @@ GST_DEBUG_CATEGORY_STATIC(webkit_media_g
 
 bool GStreamerAudioMixer::isAvailable()
 {
-    return isGStreamerPluginAvailable("inter") && isGStreamerPluginAvailable("audiomixer");
+    return webkitGstCheckVersion(1, 18, 0) && isGStreamerPluginAvailable("inter") && isGStreamerPluginAvailable("audiomixer");
 }
 
 GStreamerAudioMixer& GStreamerAudioMixer::singleton()
diff -urp webkitgtk-2.44.0.orig/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp webkitgtk-2.44.0/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp
--- webkitgtk-2.44.0.orig/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp	2024-03-16 01:47:05.632925300 -0500
+++ webkitgtk-2.44.0/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp	2024-03-19 13:09:31.673819107 -0500
@@ -115,6 +115,24 @@ GstPad* webkitGstGhostPadFromStaticTempl
     return pad;
 }
 
+#if !GST_CHECK_VERSION(1, 18, 0)
+void webkitGstVideoFormatInfoComponent(const GstVideoFormatInfo* info, guint plane, gint components[GST_VIDEO_MAX_COMPONENTS])
+{
+    guint c, i = 0;
+
+    /* Reverse mapping of info->plane. */
+    for (c = 0; c < GST_VIDEO_FORMAT_INFO_N_COMPONENTS(info); c++) {
+        if (GST_VIDEO_FORMAT_INFO_PLANE(info, c) == plane) {
+            components[i] = c;
+            i++;
+        }
+    }
+
+    for (c = i; c < GST_VIDEO_MAX_COMPONENTS; c++)
+        components[c] = -1;
+}
+#endif
+
 #if ENABLE(VIDEO)
 bool getVideoSizeAndFormatFromCaps(const GstCaps* caps, WebCore::IntSize& size, GstVideoFormat& format, int& pixelAspectRatioNumerator, int& pixelAspectRatioDenominator, int& stride)
 {
@@ -504,6 +522,7 @@ void deinitializeGStreamer()
     teardownGStreamerImageDecoders();
 #endif
 
+#if GST_CHECK_VERSION(1, 18, 0)
     bool isLeaksTracerActive = false;
     auto activeTracers = gst_tracing_get_active_tracers();
     while (activeTracers) {
@@ -528,6 +547,7 @@ void deinitializeGStreamer()
     }
 
     gst_deinit();
+#endif
 }
 
 unsigned getGstPlayFlag(const char* nick)
@@ -849,6 +869,36 @@ String gstStructureToJSONString(const Gs
     return value->toJSONString();
 }
 
+#if !GST_CHECK_VERSION(1, 18, 0)
+GstClockTime webkitGstElementGetCurrentRunningTime(GstElement* element)
+{
+    g_return_val_if_fail(GST_IS_ELEMENT(element), GST_CLOCK_TIME_NONE);
+
+    auto baseTime = gst_element_get_base_time(element);
+    if (!GST_CLOCK_TIME_IS_VALID(baseTime)) {
+        GST_DEBUG_OBJECT(element, "Could not determine base time");
+        return GST_CLOCK_TIME_NONE;
+    }
+
+    auto clock = adoptGRef(gst_element_get_clock(element));
+    if (!clock) {
+        GST_DEBUG_OBJECT(element, "Element has no clock");
+        return GST_CLOCK_TIME_NONE;
+    }
+
+    auto clockTime = gst_clock_get_time(clock.get());
+    if (!GST_CLOCK_TIME_IS_VALID(clockTime))
+        return GST_CLOCK_TIME_NONE;
+
+    if (clockTime < baseTime) {
+        GST_DEBUG_OBJECT(element, "Got negative current running time");
+        return GST_CLOCK_TIME_NONE;
+    }
+
+    return clockTime - baseTime;
+}
+#endif
+
 GstClockTime webkitGstInitTime()
 {
     return s_webkitGstInitTime;
@@ -906,6 +956,7 @@ PlatformVideoColorSpace videoColorSpaceF
     case GST_VIDEO_TRANSFER_BT709:
         colorSpace.transfer = PlatformVideoTransferCharacteristics::Bt709;
         break;
+#if GST_CHECK_VERSION(1, 18, 0)
     case GST_VIDEO_TRANSFER_BT601:
         colorSpace.transfer = PlatformVideoTransferCharacteristics::Smpte170m;
         break;
@@ -918,6 +969,7 @@ PlatformVideoColorSpace videoColorSpaceF
     case GST_VIDEO_TRANSFER_BT2020_10:
         colorSpace.transfer = PlatformVideoTransferCharacteristics::Bt2020_10bit;
         break;
+#endif
     case GST_VIDEO_TRANSFER_BT2020_12:
         colorSpace.transfer = PlatformVideoTransferCharacteristics::Bt2020_12bit;
         break;
@@ -1036,6 +1088,7 @@ void fillVideoInfoColorimetryFromColorSp
         case PlatformVideoTransferCharacteristics::Bt709:
             GST_VIDEO_INFO_COLORIMETRY(info).transfer = GST_VIDEO_TRANSFER_BT709;
             break;
+#if GST_CHECK_VERSION(1, 18, 0)
         case PlatformVideoTransferCharacteristics::Smpte170m:
             GST_VIDEO_INFO_COLORIMETRY(info).transfer = GST_VIDEO_TRANSFER_BT601;
             break;
@@ -1048,6 +1101,7 @@ void fillVideoInfoColorimetryFromColorSp
         case PlatformVideoTransferCharacteristics::Bt2020_10bit:
             GST_VIDEO_INFO_COLORIMETRY(info).transfer = GST_VIDEO_TRANSFER_BT2020_10;
             break;
+#endif
         case PlatformVideoTransferCharacteristics::Bt2020_12bit:
             GST_VIDEO_INFO_COLORIMETRY(info).transfer = GST_VIDEO_TRANSFER_BT2020_12;
             break;
diff -urp webkitgtk-2.44.0.orig/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.h webkitgtk-2.44.0/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.h
--- webkitgtk-2.44.0.orig/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.h	2024-03-16 01:45:50.480671400 -0500
+++ webkitgtk-2.44.0/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.h	2024-03-19 13:09:31.673819107 -0500
@@ -56,6 +56,15 @@ inline bool webkitGstCheckVersion(guint
     return true;
 }
 
+// gst_video_format_info_component() is GStreamer 1.18 API, so for older versions we use a local
+// vendored copy of the function.
+#if !GST_CHECK_VERSION(1, 18, 0)
+#define GST_VIDEO_MAX_COMPONENTS 4
+void webkitGstVideoFormatInfoComponent(const GstVideoFormatInfo*, guint, gint components[GST_VIDEO_MAX_COMPONENTS]);
+
+#define gst_video_format_info_component webkitGstVideoFormatInfoComponent
+#endif
+
 #define GST_VIDEO_CAPS_TYPE_PREFIX  "video/"
 #define GST_AUDIO_CAPS_TYPE_PREFIX  "audio/"
 #define GST_TEXT_CAPS_TYPE_PREFIX   "text/"
@@ -382,6 +391,13 @@ GstElement* makeGStreamerBin(const char*
 
 String gstStructureToJSONString(const GstStructure*);
 
+// gst_element_get_current_running_time() is GStreamer 1.18 API, so for older versions we use a local
+// vendored copy of the function.
+#if !GST_CHECK_VERSION(1, 18, 0)
+GstClockTime webkitGstElementGetCurrentRunningTime(GstElement*);
+#define gst_element_get_current_running_time webkitGstElementGetCurrentRunningTime
+#endif
+
 GstClockTime webkitGstInitTime();
 
 PlatformVideoColorSpace videoColorSpaceFromCaps(const GstCaps*);
diff -urp webkitgtk-2.44.0.orig/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp webkitgtk-2.44.0/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
--- webkitgtk-2.44.0.orig/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp	2024-03-16 01:47:05.636925200 -0500
+++ webkitgtk-2.44.0/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp	2024-03-19 13:09:31.673819107 -0500
@@ -520,7 +520,6 @@ bool MediaPlayerPrivateGStreamer::doSeek
 
     auto seekStart = toGstClockTime(startTime);
     auto seekStop = toGstClockTime(endTime);
-    GST_DEBUG_OBJECT(pipeline(), "[Seek] Performing actual seek to %" GST_TIMEP_FORMAT " (endTime: %" GST_TIMEP_FORMAT ") at rate %f", &seekStart, &seekStop, rate);
     return gst_element_seek(m_pipeline.get(), rate, GST_FORMAT_TIME, m_seekFlags, GST_SEEK_TYPE_SET, seekStart, GST_SEEK_TYPE_SET, seekStop);
 }
 
@@ -3425,9 +3424,11 @@ static uint32_t fourccValue(GstVideoForm
     case GST_VIDEO_FORMAT_P010_10LE:
     case GST_VIDEO_FORMAT_P010_10BE:
         return uint32_t(DMABufFormat::FourCC::P010);
+#if GST_CHECK_VERSION(1, 18, 0)
     case GST_VIDEO_FORMAT_P016_LE:
     case GST_VIDEO_FORMAT_P016_BE:
         return uint32_t(DMABufFormat::FourCC::P016);
+#endif
     default:
         break;
     }
@@ -4292,7 +4293,29 @@ GstElement* MediaPlayerPrivateGStreamer:
         g_signal_connect_swapped(m_videoSink.get(), "repaint-cancelled", G_CALLBACK(repaintCancelledCallback), this);
     }
 
-    return m_videoSink.get();
+    GstElement* videoSink = nullptr;
+    if (!webkitGstCheckVersion(1, 18, 0)) {
+        m_fpsSink = makeGStreamerElement("fpsdisplaysink", "sink");
+        if (m_fpsSink) {
+            g_object_set(m_fpsSink.get(), "silent", TRUE , nullptr);
+
+            // Turn off text overlay unless tracing is enabled.
+            if (gst_debug_category_get_threshold(webkit_media_player_debug) < GST_LEVEL_TRACE)
+                g_object_set(m_fpsSink.get(), "text-overlay", FALSE , nullptr);
+
+            if (gstObjectHasProperty(m_fpsSink.get(), "video-sink")) {
+                g_object_set(m_fpsSink.get(), "video-sink", m_videoSink.get(), nullptr);
+                videoSink = m_fpsSink.get();
+            } else
+                m_fpsSink = nullptr;
+        }
+    }
+
+    if (!m_fpsSink)
+        videoSink = m_videoSink.get();
+
+    ASSERT(videoSink);
+    return videoSink;
 }
 
 void MediaPlayerPrivateGStreamer::setStreamVolumeElement(GstStreamVolume* volume)
@@ -4322,19 +4345,29 @@ void MediaPlayerPrivateGStreamer::setStr
 
 bool MediaPlayerPrivateGStreamer::updateVideoSinkStatistics()
 {
+    if (!webkitGstCheckVersion(1, 18, 0) && !m_fpsSink)
+        return false;
+
     if (!m_videoSink)
         return false;
 
     uint64_t totalVideoFrames = 0;
     uint64_t droppedVideoFrames = 0;
-    GUniqueOutPtr<GstStructure> stats;
-    g_object_get(m_videoSink.get(), "stats", &stats.outPtr(), nullptr);
+    if (webkitGstCheckVersion(1, 18, 0)) {
+        GUniqueOutPtr<GstStructure> stats;
+        g_object_get(m_videoSink.get(), "stats", &stats.outPtr(), nullptr);
 
-    if (!gst_structure_get_uint64(stats.get(), "rendered", &totalVideoFrames))
-        return false;
+        if (!gst_structure_get_uint64(stats.get(), "rendered", &totalVideoFrames))
+            return false;
 
-    if (!gst_structure_get_uint64(stats.get(), "dropped", &droppedVideoFrames))
-        return false;
+        if (!gst_structure_get_uint64(stats.get(), "dropped", &droppedVideoFrames))
+            return false;
+    } else if (m_fpsSink) {
+        unsigned renderedFrames, droppedFrames;
+        g_object_get(m_fpsSink.get(), "frames-rendered", &renderedFrames, "frames-dropped", &droppedFrames, nullptr);
+        totalVideoFrames = renderedFrames;
+        droppedVideoFrames = droppedFrames;
+    }
 
     // Caching is required so that metrics queries performed after EOS still return valid values.
     if (totalVideoFrames)
diff -urp webkitgtk-2.44.0.orig/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h webkitgtk-2.44.0/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h
--- webkitgtk-2.44.0.orig/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h	2024-03-16 01:45:50.480671400 -0500
+++ webkitgtk-2.44.0/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h	2024-03-19 13:09:31.673819107 -0500
@@ -616,6 +616,7 @@ private:
     uint64_t m_networkReadPosition { 0 };
     mutable uint64_t m_readPositionAtLastDidLoadingProgress { 0 };
 
+    GRefPtr<GstElement> m_fpsSink { nullptr };
     uint64_t m_totalVideoFrames { 0 };
     uint64_t m_droppedVideoFrames { 0 };
     uint64_t m_decodedVideoFrames { 0 };
diff -urp webkitgtk-2.44.0.orig/Source/WebCore/platform/gstreamer/GStreamerCodecUtilities.cpp webkitgtk-2.44.0/Source/WebCore/platform/gstreamer/GStreamerCodecUtilities.cpp
--- webkitgtk-2.44.0.orig/Source/WebCore/platform/gstreamer/GStreamerCodecUtilities.cpp	2024-03-16 01:45:50.504671300 -0500
+++ webkitgtk-2.44.0/Source/WebCore/platform/gstreamer/GStreamerCodecUtilities.cpp	2024-03-19 13:08:50.036962275 -0500
@@ -174,7 +174,11 @@ static std::pair<GRefPtr<GstCaps>, GRefP
     else if (transfer == VPConfigurationTransferCharacteristics::BT_470_7_BG)
         GST_VIDEO_INFO_COLORIMETRY(&info).transfer = GST_VIDEO_TRANSFER_GAMMA28;
     else if (transfer == VPConfigurationTransferCharacteristics::BT_601_7)
+#if GST_CHECK_VERSION(1, 18, 0)
         GST_VIDEO_INFO_COLORIMETRY(&info).transfer = GST_VIDEO_TRANSFER_BT601;
+#else
+        GST_VIDEO_INFO_COLORIMETRY(&info).transfer = GST_VIDEO_TRANSFER_UNKNOWN;
+#endif
     else if (transfer == VPConfigurationTransferCharacteristics::SMPTE_ST_240)
         GST_VIDEO_INFO_COLORIMETRY(&info).transfer = GST_VIDEO_TRANSFER_SMPTE240M;
     else if (transfer == VPConfigurationTransferCharacteristics::Linear)
@@ -189,16 +193,28 @@ static std::pair<GRefPtr<GstCaps>, GRefP
         GST_WARNING("VPConfigurationTransferCharacteristics::IEC_61966_2_1 not supported");
         GST_VIDEO_INFO_COLORIMETRY(&info).transfer = GST_VIDEO_TRANSFER_UNKNOWN;
     } else if (transfer == VPConfigurationTransferCharacteristics::BT_2020_10bit)
+#if GST_CHECK_VERSION(1, 18, 0)
         GST_VIDEO_INFO_COLORIMETRY(&info).transfer = GST_VIDEO_TRANSFER_BT2020_10;
+#else
+        GST_VIDEO_INFO_COLORIMETRY(&info).transfer = GST_VIDEO_TRANSFER_UNKNOWN;
+#endif
     else if (transfer == VPConfigurationTransferCharacteristics::BT_2020_12bit)
         GST_VIDEO_INFO_COLORIMETRY(&info).transfer = GST_VIDEO_TRANSFER_BT2020_12;
     else if (transfer == VPConfigurationTransferCharacteristics::SMPTE_ST_2084)
+#if GST_CHECK_VERSION(1, 18, 0)
         GST_VIDEO_INFO_COLORIMETRY(&info).transfer = GST_VIDEO_TRANSFER_SMPTE2084;
+#else
+        GST_VIDEO_INFO_COLORIMETRY(&info).transfer = GST_VIDEO_TRANSFER_UNKNOWN;
+#endif
     else if (transfer == VPConfigurationTransferCharacteristics::SMPTE_ST_428_1) {
         GST_WARNING("VPConfigurationTransferCharacteristics::SMPTE_ST_428_1 not supported");
         GST_VIDEO_INFO_COLORIMETRY(&info).transfer = GST_VIDEO_TRANSFER_UNKNOWN;
     } else if (transfer == VPConfigurationTransferCharacteristics::BT_2100_HLG)
+#if GST_CHECK_VERSION(1, 18, 0)
         GST_VIDEO_INFO_COLORIMETRY(&info).transfer = GST_VIDEO_TRANSFER_ARIB_STD_B67;
+#else
+        GST_VIDEO_INFO_COLORIMETRY(&info).transfer = GST_VIDEO_TRANSFER_UNKNOWN;
+#endif
 
     auto matrix = parameters->matrixCoefficients;
     if (matrix == VPConfigurationMatrixCoefficients::Identity)
