File webkit2gtk3-old-gstreamer.patch of Package webkit2gtk3.23158

diff -urpN webkitgtk-2.34.5.gtk/Source/cmake/GStreamerChecks.cmake webkitgtk-2.34.5.gstreamer/Source/cmake/GStreamerChecks.cmake
--- webkitgtk-2.34.5.gtk/Source/cmake/GStreamerChecks.cmake	2021-10-21 03:52:10.000000000 -0500
+++ webkitgtk-2.34.5.gstreamer/Source/cmake/GStreamerChecks.cmake	2022-02-09 15:50:49.969206778 -0600
@@ -28,7 +28,7 @@ if (ENABLE_VIDEO OR ENABLE_WEB_AUDIO)
               list(APPEND GSTREAMER_COMPONENTS audio fft)
           endif ()
 
-          find_package(GStreamer 1.14.0 REQUIRED COMPONENTS ${GSTREAMER_COMPONENTS})
+          find_package(GStreamer 1.8.3 REQUIRED COMPONENTS ${GSTREAMER_COMPONENTS})
 
           if (ENABLE_WEB_AUDIO)
               if (NOT PC_GSTREAMER_AUDIO_FOUND OR NOT PC_GSTREAMER_FFT_FOUND)
@@ -42,17 +42,29 @@ if (ENABLE_VIDEO OR ENABLE_WEB_AUDIO)
               endif ()
           endif ()
 
-          if (USE_GSTREAMER_MPEGTS AND NOT PC_GSTREAMER_MPEGTS_FOUND)
-              message(FATAL_ERROR "GStreamer MPEG-TS is needed for USE_GSTREAMER_MPEGTS.")
+    if (USE_GSTREAMER_MPEGTS)
+        if (NOT PC_GSTREAMER_MPEGTS_FOUND)
+            message(FATAL_ERROR "GStreamer MPEG-TS is needed for USE_GSTREAMER_MPEGTS.")
+        endif ()
           endif ()
 
-          if (USE_GSTREAMER_GL AND NOT PC_GSTREAMER_GL_FOUND)
-              message(FATAL_ERROR "GStreamerGL is needed for USE_GSTREAMER_GL.")
+    if (USE_GSTREAMER_GL)
+        if (PC_GSTREAMER_VERSION VERSION_LESS "1.10")
+            message(FATAL_ERROR "GStreamer 1.10 is needed for USE_GSTREAMER_GL.")
+        else ()
+            if (NOT PC_GSTREAMER_GL_FOUND)
+                message(FATAL_ERROR "GStreamerGL is needed for USE_GSTREAMER_GL.")
+            endif ()
+        endif ()
           endif ()
       endif ()
 endif ()
 
+
 if (ENABLE_MEDIA_STREAM AND ENABLE_WEB_RTC)
+    if (PC_GSTREAMER_VERSION VERSION_LESS "1.12")
+        message(FATAL_ERROR "GStreamer 1.12 is needed for ENABLE_WEB_RTC.")
+    endif ()
     SET_AND_EXPOSE_TO_BUILD(USE_LIBWEBRTC TRUE)
 else ()
     SET_AND_EXPOSE_TO_BUILD(USE_LIBWEBRTC FALSE)
diff -urpN webkitgtk-2.34.5.gtk/Source/WebCore/platform/audio/gstreamer/AudioFileReaderGStreamer.cpp webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/audio/gstreamer/AudioFileReaderGStreamer.cpp
--- webkitgtk-2.34.5.gtk/Source/WebCore/platform/audio/gstreamer/AudioFileReaderGStreamer.cpp	2022-02-08 07:34:31.000000000 -0600
+++ webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/audio/gstreamer/AudioFileReaderGStreamer.cpp	2022-02-09 15:50:49.969206778 -0600
@@ -143,7 +143,7 @@ AudioFileReader::~AudioFileReader()
 
 GstFlowReturn AudioFileReader::handleSample(GstAppSink* sink)
 {
-    auto sample = adoptGRef(gst_app_sink_try_pull_sample(sink, 0));
+    auto sample = adoptGRef(gst_app_sink_pull_sample(sink));
     if (!sample)
         return gst_app_sink_is_eos(sink) ? GST_FLOW_EOS : GST_FLOW_ERROR;
 
diff -urpN webkitgtk-2.34.5.gtk/Source/WebCore/platform/audio/gstreamer/AudioSourceProviderGStreamer.cpp webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/audio/gstreamer/AudioSourceProviderGStreamer.cpp
--- webkitgtk-2.34.5.gtk/Source/WebCore/platform/audio/gstreamer/AudioSourceProviderGStreamer.cpp	2022-02-08 07:34:31.000000000 -0600
+++ webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/audio/gstreamer/AudioSourceProviderGStreamer.cpp	2022-02-09 15:50:49.969206778 -0600
@@ -171,7 +171,7 @@ void AudioSourceProviderGStreamer::provi
 GstFlowReturn AudioSourceProviderGStreamer::handleSample(GstAppSink* sink, bool isPreroll)
 {
     GST_TRACE("Pulling audio sample from the sink");
-    auto sample = adoptGRef(isPreroll ? gst_app_sink_try_pull_preroll(sink, 0) : gst_app_sink_try_pull_sample(sink, 0));
+    auto sample = adoptGRef(isPreroll ? gst_app_sink_pull_preroll(sink) : gst_app_sink_pull_sample(sink));
     if (!sample)
         return gst_app_sink_is_eos(sink) ? GST_FLOW_EOS : GST_FLOW_ERROR;
 
diff -urpN webkitgtk-2.34.5.gtk/Source/WebCore/platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp
--- webkitgtk-2.34.5.gtk/Source/WebCore/platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp	2021-10-21 03:52:09.000000000 -0500
+++ webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp	2022-02-09 15:50:49.973206799 -0600
@@ -79,6 +79,7 @@ struct _WebKitWebAudioSrcPrivate {
 
     GRefPtr<GstBufferPool> pool;
 
+    bool enableGapBufferSupport;
     bool hasRenderedAudibleFrame { false };
 
     Lock dispatchToRenderThreadLock;
@@ -93,6 +94,11 @@ struct _WebKitWebAudioSrcPrivate {
         sourcePad = webkitGstGhostPadFromStaticTemplate(&srcTemplate, "src", nullptr);
 
         g_rec_mutex_init(&mutex);
+
+        // GAP buffer support is enabled only for GStreamer 1.12.5 because of a
+        // memory leak that was fixed in that version.
+        // https://bugzilla.gnome.org/show_bug.cgi?id=793067
+        enableGapBufferSupport = webkitGstCheckVersion(1, 12, 5);
     }
 
     ~_WebKitWebAudioSrcPrivate()
@@ -375,7 +381,7 @@ static void webKitWebAudioSrcRenderAndPu
         GST_BUFFER_TIMESTAMP(buffer.get()) = outputTimestamp.position.nanoseconds();
         GST_BUFFER_DURATION(buffer.get()) = duration;
 
-        if (priv->bus->channel(i)->isSilent())
+        if (priv->enableGapBufferSupport && priv->bus->channel(i)->isSilent())
             GST_BUFFER_FLAG_SET(buffer.get(), GST_BUFFER_FLAG_GAP);
 
         if (failed)
@@ -434,7 +440,9 @@ static GstStateChangeReturn webKitWebAud
     auto* src = WEBKIT_WEB_AUDIO_SRC(element);
     auto* priv = src->priv;
 
+#if GST_CHECK_VERSION(1, 14, 0)
     GST_DEBUG_OBJECT(element, "%s", gst_state_change_get_name(transition));
+#endif
 
     switch (transition) {
     case GST_STATE_CHANGE_NULL_TO_READY:
diff -urpN webkitgtk-2.34.5.gtk/Source/WebCore/platform/graphics/gstreamer/AudioTrackPrivateGStreamer.cpp webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/graphics/gstreamer/AudioTrackPrivateGStreamer.cpp
--- webkitgtk-2.34.5.gtk/Source/WebCore/platform/graphics/gstreamer/AudioTrackPrivateGStreamer.cpp	2022-02-08 07:34:31.000000000 -0600
+++ webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/graphics/gstreamer/AudioTrackPrivateGStreamer.cpp	2022-02-09 16:56:44.666085996 -0600
@@ -39,6 +39,7 @@ AudioTrackPrivateGStreamer::AudioTrackPr
 {
 }
 
+#if GST_CHECK_VERSION(1, 10, 0)
 AudioTrackPrivateGStreamer::AudioTrackPrivateGStreamer(WeakPtr<MediaPlayerPrivateGStreamer> player, unsigned index, GRefPtr<GstStream>&& stream)
     : TrackPrivateBaseGStreamer(TrackPrivateBaseGStreamer::TrackType::Audio, this, index, WTFMove(stream))
     , m_player(player)
@@ -51,19 +52,24 @@ AudioTrackPrivateGStreamer::AudioTrackPr
         gst_stream_set_stream_flags(m_stream.get(), static_cast<GstStreamFlags>(streamFlags | GST_STREAM_FLAG_SELECT));
     }
 }
+#endif
 
 AudioTrackPrivate::Kind AudioTrackPrivateGStreamer::kind() const
 {
+#if GST_CHECK_VERSION(1, 10, 0)
     if (m_stream.get() && gst_stream_get_stream_flags(m_stream.get()) & GST_STREAM_FLAG_SELECT)
         return AudioTrackPrivate::Kind::Main;
+#endif
 
     return AudioTrackPrivate::kind();
 }
 
 void AudioTrackPrivateGStreamer::disconnect()
 {
+#if GST_CHECK_VERSION(1, 10, 0)
     if (m_stream)
         g_signal_handlers_disconnect_matched(m_stream.get(), G_SIGNAL_MATCH_DATA, 0, 0, nullptr, nullptr, this);
+#endif
 
     m_player = nullptr;
     TrackPrivateBaseGStreamer::disconnect();
diff -urpN webkitgtk-2.34.5.gtk/Source/WebCore/platform/graphics/gstreamer/AudioTrackPrivateGStreamer.h webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/graphics/gstreamer/AudioTrackPrivateGStreamer.h
--- webkitgtk-2.34.5.gtk/Source/WebCore/platform/graphics/gstreamer/AudioTrackPrivateGStreamer.h	2021-10-21 03:52:09.000000000 -0500
+++ webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/graphics/gstreamer/AudioTrackPrivateGStreamer.h	2022-02-09 15:50:49.973206799 -0600
@@ -42,10 +42,12 @@ public:
         return adoptRef(*new AudioTrackPrivateGStreamer(player, index, WTFMove(pad), shouldHandleStreamStartEvent));
     }
 
+#if GST_CHECK_VERSION(1, 10, 0)
     static Ref<AudioTrackPrivateGStreamer> create(WeakPtr<MediaPlayerPrivateGStreamer> player, unsigned index, GRefPtr<GstStream>&& stream)
     {
         return adoptRef(*new AudioTrackPrivateGStreamer(player, index, WTFMove(stream)));
     }
+#endif
 
     Kind kind() const final;
 
@@ -62,7 +64,9 @@ public:
 
 private:
     AudioTrackPrivateGStreamer(WeakPtr<MediaPlayerPrivateGStreamer>, unsigned index, GRefPtr<GstPad>&&, bool shouldHandleStreamStartEvent);
+#if GST_CHECK_VERSION(1, 10, 0)
     AudioTrackPrivateGStreamer(WeakPtr<MediaPlayerPrivateGStreamer>, unsigned index, GRefPtr<GstStream>&&);
+#endif
 
     WeakPtr<MediaPlayerPrivateGStreamer> m_player;
 };
diff -urpN webkitgtk-2.34.5.gtk/Source/WebCore/platform/graphics/gstreamer/eme/GStreamerEMEUtilities.h webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/graphics/gstreamer/eme/GStreamerEMEUtilities.h
--- webkitgtk-2.34.5.gtk/Source/WebCore/platform/graphics/gstreamer/eme/GStreamerEMEUtilities.h	2021-10-21 03:52:09.000000000 -0500
+++ webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/graphics/gstreamer/eme/GStreamerEMEUtilities.h	2022-02-09 15:50:49.973206799 -0600
@@ -79,7 +79,7 @@ public:
     const String& systemId() const { return m_systemId; }
     String payloadContainerType() const
     {
-#if GST_CHECK_VERSION(1, 16, 0)
+#if GST_CHECK_VERSION(1, 15, 0)
         if (m_systemId == GST_PROTECTION_UNSPECIFIED_SYSTEM_ID)
             return "webm"_s;
 #endif
diff -urpN webkitgtk-2.34.5.gtk/Source/WebCore/platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.cpp webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.cpp
--- webkitgtk-2.34.5.gtk/Source/WebCore/platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.cpp	2021-10-21 03:52:09.000000000 -0500
+++ webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.cpp	2022-02-09 15:50:49.973206799 -0600
@@ -148,7 +148,7 @@ static GstCaps* transformCaps(GstBaseTra
             // GST_PROTECTION_UNSPECIFIED_SYSTEM_ID was added in the GStreamer
             // developement git master which will ship as version 1.16.0.
             gst_structure_set_name(outgoingStructure.get(),
-#if GST_CHECK_VERSION(1, 16, 0)
+#if GST_CHECK_VERSION(1, 15, 0)
                 !g_strcmp0(klass->protectionSystemId(self), GST_PROTECTION_UNSPECIFIED_SYSTEM_ID) ? "application/x-webm-enc" :
 #endif
                 "application/x-cenc");
diff -urpN webkitgtk-2.34.5.gtk/Source/WebCore/platform/graphics/gstreamer/GLVideoSinkGStreamer.cpp webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/graphics/gstreamer/GLVideoSinkGStreamer.cpp
--- webkitgtk-2.34.5.gtk/Source/WebCore/platform/graphics/gstreamer/GLVideoSinkGStreamer.cpp	2021-10-21 03:52:09.000000000 -0500
+++ webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/graphics/gstreamer/GLVideoSinkGStreamer.cpp	2022-02-09 15:50:49.973206799 -0600
@@ -157,7 +157,11 @@ std::optional<GRefPtr<GstContext>> reque
     if (!g_strcmp0(contextType, "gst.gl.app_context")) {
         GstContext* appContext = gst_context_new("gst.gl.app_context", TRUE);
         GstStructure* structure = gst_context_writable_structure(appContext);
+#if GST_CHECK_VERSION(1, 12, 0)
         gst_structure_set(structure, "context", GST_TYPE_GL_CONTEXT, gstGLContext, nullptr);
+#else
+        gst_structure_set(structure, "context", GST_GL_TYPE_CONTEXT, gstGLContext, nullptr);
+#endif
         return adoptGRef(appContext);
     }
 
@@ -178,11 +182,15 @@ static bool setGLContext(GstElement* ele
 
 static GstStateChangeReturn webKitGLVideoSinkChangeState(GstElement* element, GstStateChange transition)
 {
+#if GST_CHECK_VERSION(1, 14, 0)
     GST_DEBUG_OBJECT(element, "%s", gst_state_change_get_name(transition));
+#endif
 
     switch (transition) {
     case GST_STATE_CHANGE_NULL_TO_READY:
+#if GST_CHECK_VERSION(1, 14, 0)
     case GST_STATE_CHANGE_READY_TO_READY:
+#endif
     case GST_STATE_CHANGE_READY_TO_PAUSED: {
         if (!setGLContext(element, GST_GL_DISPLAY_CONTEXT_TYPE))
             return GST_STATE_CHANGE_FAILURE;
diff -urpN webkitgtk-2.34.5.gtk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp
--- webkitgtk-2.34.5.gtk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp	2021-10-21 03:52:09.000000000 -0500
+++ webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp	2022-02-09 15:50:49.973206799 -0600
@@ -397,6 +397,7 @@ template <> void derefGPtr<GstQuery>(Gst
         gst_query_unref(ptr);
 }
 
+#if GST_CHECK_VERSION(1, 10, 0)
 template <> GRefPtr<GstStream> adoptGRef(GstStream* ptr)
 {
     return GRefPtr<GstStream>(ptr, GRefPtrAdopt);
@@ -434,6 +435,7 @@ template <> void derefGPtr<GstStreamColl
     if (ptr)
         gst_object_unref(ptr);
 }
+#endif
 
 template <>
 GRefPtr<GstClock> adoptGRef(GstClock* ptr)
diff -urpN webkitgtk-2.34.5.gtk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h
--- webkitgtk-2.34.5.gtk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h	2021-10-21 03:52:09.000000000 -0500
+++ webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h	2022-02-09 15:50:49.973206799 -0600
@@ -120,6 +120,7 @@ GRefPtr<WebKitWebSrc> ensureGRef(WebKitW
 template<> WebKitWebSrc* refGPtr<WebKitWebSrc>(WebKitWebSrc* ptr);
 template<> void derefGPtr<WebKitWebSrc>(WebKitWebSrc* ptr);
 
+#if GST_CHECK_VERSION(1, 10, 0)
 template<> GRefPtr<GstStream> adoptGRef(GstStream*);
 template<> GstStream* refGPtr<GstStream>(GstStream*);
 template<> void derefGPtr<GstStream>(GstStream*);
@@ -127,6 +128,7 @@ template<> void derefGPtr<GstStream>(Gst
 template<> GRefPtr<GstStreamCollection> adoptGRef(GstStreamCollection*);
 template<> GstStreamCollection* refGPtr<GstStreamCollection>(GstStreamCollection*);
 template<> void derefGPtr<GstStreamCollection>(GstStreamCollection*);
+#endif
 
 template<> GRefPtr<GstClock> adoptGRef(GstClock*);
 template<> GstClock* refGPtr<GstClock>(GstClock*);
diff -urpN webkitgtk-2.34.5.gtk/Source/WebCore/platform/graphics/gstreamer/GStreamerAudioMixer.cpp webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/graphics/gstreamer/GStreamerAudioMixer.cpp
--- webkitgtk-2.34.5.gtk/Source/WebCore/platform/graphics/gstreamer/GStreamerAudioMixer.cpp	2021-12-13 04:50:35.000000000 -0600
+++ webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/graphics/gstreamer/GStreamerAudioMixer.cpp	2022-02-09 15:50:49.973206799 -0600
@@ -57,8 +57,9 @@ GStreamerAudioMixer::GStreamerAudioMixer
 
 void GStreamerAudioMixer::ensureState(GstStateChange stateChange)
 {
+#if GST_CHECK_VERSION(1, 14, 0)
     GST_DEBUG_OBJECT(m_pipeline.get(), "Handling %s transition (%u mixer pads)", gst_state_change_get_name(stateChange), m_mixer->numsinkpads);
-
+#endif
     switch (stateChange) {
     case GST_STATE_CHANGE_READY_TO_PAUSED:
         gst_element_set_state(m_pipeline.get(), GST_STATE_PAUSED);
diff -urpN webkitgtk-2.34.5.gtk/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp
--- webkitgtk-2.34.5.gtk/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp	2021-12-13 07:31:34.000000000 -0600
+++ webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp	2022-02-09 15:50:49.973206799 -0600
@@ -54,7 +54,7 @@
 #include "WebKitMediaSourceGStreamer.h"
 #endif
 
-#if ENABLE(MEDIA_STREAM)
+#if ENABLE(MEDIA_STREAM) && GST_CHECK_VERSION(1, 10, 0)
 #include "GStreamerMediaStreamSource.h"
 #endif
 
@@ -315,8 +315,9 @@ void registerWebKitGStreamerElements()
         gst_element_register(nullptr, "webkitclearkey", GST_RANK_PRIMARY + 200, WEBKIT_TYPE_MEDIA_CK_DECRYPT);
 #endif
 
-#if ENABLE(MEDIA_STREAM)
-        gst_element_register(nullptr, "mediastreamsrc", GST_RANK_PRIMARY, WEBKIT_TYPE_MEDIA_STREAM_SRC);
+#if ENABLE(MEDIA_STREAM) && GST_CHECK_VERSION(1, 10, 0)
+        if (webkitGstCheckVersion(1, 10, 0))
+            gst_element_register(nullptr, "mediastreamsrc", GST_RANK_PRIMARY, WEBKIT_TYPE_MEDIA_STREAM_SRC);
 #endif
 
 #if ENABLE(MEDIA_SOURCE)
diff -urpN webkitgtk-2.34.5.gtk/Source/WebCore/platform/graphics/gstreamer/ImageDecoderGStreamer.cpp webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/graphics/gstreamer/ImageDecoderGStreamer.cpp
--- webkitgtk-2.34.5.gtk/Source/WebCore/platform/graphics/gstreamer/ImageDecoderGStreamer.cpp	2022-02-08 07:34:31.000000000 -0600
+++ webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/graphics/gstreamer/ImageDecoderGStreamer.cpp	2022-02-09 15:50:49.973206799 -0600
@@ -252,12 +252,12 @@ void ImageDecoderGStreamer::InnerDecoder
     static GstAppSinkCallbacks callbacks = {
         nullptr,
         [](GstAppSink* sink, gpointer userData) -> GstFlowReturn {
-            auto sample = adoptGRef(gst_app_sink_try_pull_preroll(sink, 0));
+            auto sample = adoptGRef(gst_app_sink_pull_preroll(sink));
             static_cast<ImageDecoderGStreamer*>(userData)->notifySample(WTFMove(sample));
             return GST_FLOW_OK;
         },
         [](GstAppSink* sink, gpointer userData) -> GstFlowReturn {
-            auto sample = adoptGRef(gst_app_sink_try_pull_sample(sink, 0));
+            auto sample = adoptGRef(gst_app_sink_pull_sample(sink));
             static_cast<ImageDecoderGStreamer*>(userData)->notifySample(WTFMove(sample));
             return GST_FLOW_OK;
         },
@@ -337,6 +337,7 @@ void ImageDecoderGStreamer::InnerDecoder
         g_warning("Error: %d, %s. Debug output: %s", error->code, error->message, debug.get());
         m_decoder.setHasEOS();
         break;
+#if GST_CHECK_VERSION(1, 10, 0)
     case GST_MESSAGE_STREAM_COLLECTION: {
         GRefPtr<GstStreamCollection> collection;
         gst_message_parse_stream_collection(message, &collection.outPtr());
@@ -349,6 +350,7 @@ void ImageDecoderGStreamer::InnerDecoder
                 if (streamType == GST_STREAM_TYPE_VIDEO) {
                     streams = g_list_append(streams, const_cast<char*>(gst_stream_get_stream_id(stream)));
                     break;
+#endif
                 }
             }
             if (streams) {
diff -urpN webkitgtk-2.34.5.gtk/Source/WebCore/platform/graphics/gstreamer/InbandTextTrackPrivateGStreamer.cpp webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/graphics/gstreamer/InbandTextTrackPrivateGStreamer.cpp
--- webkitgtk-2.34.5.gtk/Source/WebCore/platform/graphics/gstreamer/InbandTextTrackPrivateGStreamer.cpp	2021-10-21 03:52:09.000000000 -0500
+++ webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/graphics/gstreamer/InbandTextTrackPrivateGStreamer.cpp	2022-02-09 15:50:49.973206799 -0600
@@ -43,6 +43,7 @@ InbandTextTrackPrivateGStreamer::InbandT
 {
 }
 
+#if GST_CHECK_VERSION(1, 10, 0)
 InbandTextTrackPrivateGStreamer::InbandTextTrackPrivateGStreamer(unsigned index, GRefPtr<GstStream>&& stream)
     : InbandTextTrackPrivate(CueFormat::WebVTT)
     , TrackPrivateBaseGStreamer(TrackPrivateBaseGStreamer::TrackType::Text, this, index, WTFMove(stream))
@@ -55,6 +56,7 @@ InbandTextTrackPrivateGStreamer::InbandT
     const char* mediaType = capsMediaType(caps.get());
     m_kind = g_str_has_prefix(mediaType, "closedcaption/") ? Kind::Captions : Kind::Subtitles;
 }
+#endif
 
 void InbandTextTrackPrivateGStreamer::handleSample(GRefPtr<GstSample> sample)
 {
diff -urpN webkitgtk-2.34.5.gtk/Source/WebCore/platform/graphics/gstreamer/InbandTextTrackPrivateGStreamer.h webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/graphics/gstreamer/InbandTextTrackPrivateGStreamer.h
--- webkitgtk-2.34.5.gtk/Source/WebCore/platform/graphics/gstreamer/InbandTextTrackPrivateGStreamer.h	2021-10-21 03:52:09.000000000 -0500
+++ webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/graphics/gstreamer/InbandTextTrackPrivateGStreamer.h	2022-02-09 15:50:49.973206799 -0600
@@ -47,10 +47,12 @@ public:
         return create(index, WTFMove(pad));
     }
 
+#if GST_CHECK_VERSION(1, 10, 0)
     static Ref<InbandTextTrackPrivateGStreamer> create(unsigned index, GRefPtr<GstStream>&& stream)
     {
         return adoptRef(*new InbandTextTrackPrivateGStreamer(index, WTFMove(stream)));
     }
+#endif
 
     Kind kind() const final { return m_kind; }
     AtomString id() const final { return m_id; }
@@ -62,7 +64,9 @@ public:
 
 private:
     InbandTextTrackPrivateGStreamer(unsigned index, GRefPtr<GstPad>&&, bool shouldHandleStreamStartEvent);
+#if GST_CHECK_VERSION(1, 10, 0)
     InbandTextTrackPrivateGStreamer(unsigned index, GRefPtr<GstStream>&&);
+#endif
 
     void notifyTrackOfSample();
 
diff -urpN webkitgtk-2.34.5.gtk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
--- webkitgtk-2.34.5.gtk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp	2022-01-20 09:39:38.000000000 -0600
+++ webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp	2022-02-09 15:50:49.973206799 -0600
@@ -53,7 +53,7 @@
 #include "TextSinkGStreamer.h"
 #include "VideoTrackPrivateGStreamer.h"
 
-#if ENABLE(MEDIA_STREAM)
+#if ENABLE(MEDIA_STREAM) && GST_CHECK_VERSION(1, 10, 0)
 #include "GStreamerMediaStreamSource.h"
 #include "MediaStreamPrivate.h"
 #endif
@@ -135,6 +135,14 @@ using namespace std;
 static const FloatSize s_holePunchDefaultFrameSize(1280, 720);
 #endif
 
+static void convertToInternalProtocol(URL& url)
+{
+    if (webkitGstCheckVersion(1, 12, 0))
+        return;
+    if (url.protocolIsInHTTPFamily() || url.protocolIsBlob())
+        url.setProtocol(makeString("webkit+", url.protocol()));
+}
+
 static void initializeDebugCategory()
 {
     static std::once_flag onceFlag;
@@ -346,11 +354,18 @@ void MediaPlayerPrivateGStreamer::load(c
 #if ENABLE(MEDIA_STREAM)
 void MediaPlayerPrivateGStreamer::load(MediaStreamPrivate& stream)
 {
+#if GST_CHECK_VERSION(1, 10, 0)
     m_streamPrivate = &stream;
     load(String("mediastream://") + stream.id());
     syncOnClock(false);
 
     m_player->play();
+#else
+    // Properly fail so the global MediaPlayer tries to fallback to the next MediaPlayerPrivate.
+    m_networkState = MediaPlayer::FormatError;
+    m_player->networkStateChanged();
+    notImplemented();
+#endif
 }
 #endif
 
@@ -820,15 +835,20 @@ bool MediaPlayerPrivateGStreamer::hasSin
 
 std::optional<bool> MediaPlayerPrivateGStreamer::wouldTaintOrigin(const SecurityOrigin& origin) const
 {
-    GST_TRACE_OBJECT(pipeline(), "Checking %u origins", m_origins.size());
-    for (auto& responseOrigin : m_origins) {
-        if (!origin.isSameOriginDomain(*responseOrigin)) {
-            GST_DEBUG_OBJECT(pipeline(), "Found reachable response origin");
-            return true;
+    if (webkitGstCheckVersion(1, 12, 0)) {
+        GST_TRACE_OBJECT(pipeline(), "Checking %u origins", m_origins.size());
+        for (auto& responseOrigin : m_origins) {
+            if (!origin.isSameOriginDomain(*responseOrigin)) {
+                GST_DEBUG_OBJECT(pipeline(), "Found reachable response origin");
+                return true;
+            }
         }
     }
-    GST_DEBUG_OBJECT(pipeline(), "No valid response origin found");
-    return false;
+
+    // GStreamer < 1.12 has an incomplete uridownloader implementation so we
+    // can't use WebKitWebSrc for adaptive fragments downloading if this
+    // version is detected.
+    return m_hasTaintedOrigin;
 }
 
 void MediaPlayerPrivateGStreamer::simulateAudioInterruption()
@@ -871,7 +891,7 @@ void MediaPlayerPrivateGStreamer::source
 
     if (WEBKIT_IS_WEB_SRC(m_source.get())) {
         webKitWebSrcSetMediaPlayer(WEBKIT_WEB_SRC_CAST(m_source.get()), m_player, m_referrer);
-#if ENABLE(MEDIA_STREAM)
+#if ENABLE(MEDIA_STREAM) && GST_CHECK_VERSION(1, 10, 0)
     } else if (WEBKIT_IS_MEDIA_STREAM_SRC(sourceElement)) {
         auto stream = m_streamPrivate.get();
         ASSERT(stream);
@@ -926,6 +946,7 @@ void MediaPlayerPrivateGStreamer::setPla
         cleanURLString = cleanURLString.substring(0, url.pathEnd());
 
     m_url = URL(URL(), cleanURLString);
+    convertToInternalProtocol(m_url);
     GST_INFO_OBJECT(pipeline(), "Load %s", m_url.string().utf8().data());
     g_object_set(m_pipeline.get(), "uri", m_url.string().utf8().data(), nullptr);
 }
@@ -1359,6 +1380,7 @@ void MediaPlayerPrivateGStreamer::update
 
 void MediaPlayerPrivateGStreamer::playbin3SendSelectStreamsIfAppropriate()
 {
+#if GST_CHECK_VERSION(1, 10, 0)
     ASSERT(!m_isLegacyPlaybin);
 
     bool haveDifferentStreamIds = (m_wantedAudioStreamId != m_currentAudioStreamId || m_wantedVideoStreamId != m_currentVideoStreamId);
@@ -1384,8 +1406,10 @@ void MediaPlayerPrivateGStreamer::playbi
     m_waitingForStreamsSelectedEvent = true;
     gst_element_send_event(m_pipeline.get(), gst_event_new_select_streams(streams));
     g_list_free_full(streams, reinterpret_cast<GDestroyNotify>(g_free));
+#endif
 }
 
+#if GST_CHECK_VERSION(1, 10, 0)
 void MediaPlayerPrivateGStreamer::updateTracks(const GRefPtr<GstStreamCollection>& streamCollection)
 {
     ASSERT(!m_isLegacyPlaybin);
@@ -1459,6 +1483,7 @@ void MediaPlayerPrivateGStreamer::update
 
     m_player->mediaEngineUpdated();
 }
+#endif // GST_CHECK_VERSION(1, 10, 0)
 
 void MediaPlayerPrivateGStreamer::videoChangedCallback(MediaPlayerPrivateGStreamer* player)
 {
@@ -1467,6 +1492,7 @@ void MediaPlayerPrivateGStreamer::videoC
     });
 }
 
+#if GST_CHECK_VERSION(1, 10, 0)
 void MediaPlayerPrivateGStreamer::handleStreamCollectionMessage(GstMessage* message)
 {
     if (m_isLegacyPlaybin)
@@ -1506,6 +1532,7 @@ void MediaPlayerPrivateGStreamer::handle
     else
         callOnMainThread(WTFMove(callback));
 }
+#endif
 
 bool MediaPlayerPrivateGStreamer::handleNeedContextMessage(GstMessage* message)
 {
@@ -1843,6 +1870,7 @@ void MediaPlayerPrivateGStreamer::handle
             GST_DEBUG_OBJECT(pipeline(), "Processing HTTP headers: %" GST_PTR_FORMAT, structure);
             if (const char* uri = gst_structure_get_string(structure, "uri")) {
                 URL url(URL(), uri);
+                convertToInternalProtocol(url);
                 m_origins.add(SecurityOrigin::create(url));
 
                 if (url != m_url) {
@@ -1881,6 +1909,11 @@ void MediaPlayerPrivateGStreamer::handle
         } else if (gst_structure_has_name(structure, "webkit-network-statistics")) {
             if (gst_structure_get(structure, "read-position", G_TYPE_UINT64, &m_networkReadPosition, "size", G_TYPE_UINT64, &m_httpResponseTotalSize, nullptr))
                 GST_DEBUG_OBJECT(pipeline(), "Updated network read position %" G_GUINT64_FORMAT ", size: %" G_GUINT64_FORMAT, m_networkReadPosition, m_httpResponseTotalSize);
+        } else if (gst_structure_has_name(structure, "adaptive-streaming-statistics")) {
+            if (WEBKIT_IS_WEB_SRC(m_source.get()) && !webkitGstCheckVersion(1, 12, 0)) {
+                if (const char* uri = gst_structure_get_string(structure, "uri"))
+                    m_hasTaintedOrigin = webKitSrcWouldTaintOrigin(WEBKIT_WEB_SRC_CAST(m_source.get()), SecurityOrigin::create(URL(URL(), uri)));
+            }
         } else if (gst_structure_has_name(structure, "GstCacheDownloadComplete")) {
             GST_INFO_OBJECT(pipeline(), "Stream is fully downloaded, stopping monitoring downloading progress.");
             m_fillTimer.stop();
@@ -1895,6 +1928,7 @@ void MediaPlayerPrivateGStreamer::handle
     case GST_MESSAGE_TOC:
         processTableOfContents(message);
         break;
+#if GST_CHECK_VERSION(1, 10, 0)
     case GST_MESSAGE_STREAMS_SELECTED: {
         if (m_isLegacyPlaybin)
             break;
@@ -1922,6 +1956,7 @@ void MediaPlayerPrivateGStreamer::handle
         playbin3SendSelectStreamsIfAppropriate();
         break;
     }
+#endif
     default:
         GST_DEBUG_OBJECT(pipeline(), "Unhandled GStreamer message type: %s", GST_MESSAGE_TYPE_NAME(message));
         break;
@@ -2508,7 +2543,7 @@ MediaPlayer::SupportsType MediaPlayerPri
 #endif
 
     if (parameters.isMediaStream) {
-#if ENABLE(MEDIA_STREAM)
+#if ENABLE(MEDIA_STREAM) && GST_CHECK_VERSION (1, 10, 0)
         return MediaPlayer::SupportsType::IsSupported;
 #else
         return result;
@@ -2612,9 +2647,11 @@ void MediaPlayerPrivateGStreamer::create
 
     // MSE and Mediastream require playbin3. Regular playback can use playbin3 on-demand with the
     // WEBKIT_GST_USE_PLAYBIN3 environment variable.
+#if GST_CHECK_VERSION(1, 10, 0)
     const char* usePlaybin3 = g_getenv("WEBKIT_GST_USE_PLAYBIN3");
     if ((isMediaSource() || url.protocolIs("mediastream") || (usePlaybin3 && equal(usePlaybin3, "1"))))
         playbinName = "playbin3";
+#endif
 
     ASSERT(!m_pipeline);
 
@@ -2657,10 +2694,12 @@ void MediaPlayerPrivateGStreamer::create
     // synchronously in the same main thread tick to make the tracks information available to JS no
     // later than "updateend". There is no such limitation otherwise (if playbin3 is enabled or in
     // MediaStream cases).
+#if GST_CHECK_VERSION(1, 10, 0)
     auto streamCollectionSignalName = makeString(isMediaSource() ? "sync-" : "", "message::stream-collection");
     g_signal_connect_swapped(bus.get(), streamCollectionSignalName.ascii().data(), G_CALLBACK(+[](MediaPlayerPrivateGStreamer* player, GstMessage* message) {
         player->handleStreamCollectionMessage(message);
     }), this);
+#endif
 
     g_object_set(m_pipeline.get(), "mute", m_player->muted(), nullptr);
 
diff -urpN webkitgtk-2.34.5.gtk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h
--- webkitgtk-2.34.5.gtk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h	2021-12-13 04:50:35.000000000 -0600
+++ webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h	2022-02-09 15:50:49.977206820 -0600
@@ -53,6 +53,16 @@ typedef struct _GstMpegtsSection GstMpeg
 #if USE(LIBEPOXY)
 // Include the <epoxy/gl.h> header before <gst/gl/gl.h>.
 #include <epoxy/gl.h>
+
+// Workaround build issue with RPi userland GLESv2 headers and libepoxy <https://webkit.org/b/185639>
+#if !GST_CHECK_VERSION(1, 14, 0)
+#include <gst/gl/gstglconfig.h>
+#if defined(GST_GL_HAVE_WINDOW_DISPMANX) && GST_GL_HAVE_WINDOW_DISPMANX
+#define __gl2_h_
+#undef GST_GL_HAVE_GLSYNC
+#define GST_GL_HAVE_GLSYNC 1
+#endif
+#endif // !GST_CHECK_VERSION(1, 14, 0)
 #endif // USE(LIBEPOXY)
 
 #define GST_USE_UNSTABLE_API
@@ -247,8 +257,12 @@ protected:
         AudioChanged = 1 << 2,
         VolumeChanged = 1 << 3,
         MuteChanged = 1 << 4,
+#if GST_CHECK_VERSION (1, 10, 0)
         TextChanged = 1 << 5,
         StreamCollectionChanged = 1 << 7
+#else
+        TextChanged = 1 << 5
+#endif
     };
 
     static bool isAvailable();
@@ -464,7 +478,9 @@ private:
 
     void setPlaybinURL(const URL& urlString);
 
+#if GST_CHECK_VERSION (1, 10, 0)
     void updateTracks(const GRefPtr<GstStreamCollection>&);
+#endif
     void videoSinkCapsChanged(GstPad*);
     void updateVideoSizeAndOrientationFromCaps(const GstCaps*);
     bool hasFirstVideoSampleReachedSink() const;
diff -urpN webkitgtk-2.34.5.gtk/Source/WebCore/platform/graphics/gstreamer/PlatformDisplayGStreamer.cpp webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/graphics/gstreamer/PlatformDisplayGStreamer.cpp
--- webkitgtk-2.34.5.gtk/Source/WebCore/platform/graphics/gstreamer/PlatformDisplayGStreamer.cpp	2021-05-17 08:22:42.000000000 -0500
+++ webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/graphics/gstreamer/PlatformDisplayGStreamer.cpp	2022-02-09 15:50:49.977206820 -0600
@@ -98,13 +98,21 @@ bool PlatformDisplay::tryEnsureGstGLCont
     if (!contextHandle)
         return false;
 
-    m_gstGLDisplay = adoptGRef(createGstGLDisplay(*this));
+    bool shouldAdoptRef = webkitGstCheckVersion(1, 14, 0);
+
+    if (shouldAdoptRef)
+        m_gstGLDisplay = adoptGRef(createGstGLDisplay(*this));
+    else
+        m_gstGLDisplay = createGstGLDisplay(*this);
     if (!m_gstGLDisplay)
         return false;
 
     GstGLPlatform glPlatform = sharedContext->isEGLContext() ? GST_GL_PLATFORM_EGL : GST_GL_PLATFORM_GLX;
 
-    m_gstGLContext = adoptGRef(gst_gl_context_new_wrapped(m_gstGLDisplay.get(), reinterpret_cast<guintptr>(contextHandle), glPlatform, glAPI));
+    if (shouldAdoptRef)
+        m_gstGLContext = adoptGRef(gst_gl_context_new_wrapped(m_gstGLDisplay.get(), reinterpret_cast<guintptr>(contextHandle), glPlatform, glAPI));
+    else
+        m_gstGLContext = gst_gl_context_new_wrapped(m_gstGLDisplay.get(), reinterpret_cast<guintptr>(contextHandle), glPlatform, glAPI);
 
     // Activate and fill the GStreamer wrapped context with the Webkit's shared one.
     auto* previousActiveContext = GLContext::current();
diff -urpN webkitgtk-2.34.5.gtk/Source/WebCore/platform/graphics/gstreamer/TrackPrivateBaseGStreamer.cpp webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/graphics/gstreamer/TrackPrivateBaseGStreamer.cpp
--- webkitgtk-2.34.5.gtk/Source/WebCore/platform/graphics/gstreamer/TrackPrivateBaseGStreamer.cpp	2021-10-21 03:52:09.000000000 -0500
+++ webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/graphics/gstreamer/TrackPrivateBaseGStreamer.cpp	2022-02-09 15:50:49.977206820 -0600
@@ -85,6 +85,7 @@ TrackPrivateBaseGStreamer::TrackPrivateB
     tagsChanged();
 }
 
+#if GST_CHECK_VERSION(1, 10, 0)
 TrackPrivateBaseGStreamer::TrackPrivateBaseGStreamer(TrackType type, TrackPrivateBase* owner, unsigned index, GRefPtr<GstStream>&& stream)
     : m_notifier(MainThreadNotifier<MainThreadNotification>::create())
     , m_index(index)
@@ -98,6 +99,7 @@ TrackPrivateBaseGStreamer::TrackPrivateB
     // We can't call notifyTrackOfTagsChanged() directly, because we need tagsChanged() to setup m_tags.
     tagsChanged();
 }
+#endif
 
 void TrackPrivateBaseGStreamer::setPad(GRefPtr<GstPad>&& pad)
 {
@@ -135,8 +137,10 @@ void TrackPrivateBaseGStreamer::disconne
 {
     m_tags.clear();
 
+#if GST_CHECK_VERSION(1, 10, 0)
     if (m_stream)
         m_stream.clear();
+#endif
 
     m_notifier->cancelPendingNotifications();
 
@@ -174,8 +178,11 @@ void TrackPrivateBaseGStreamer::tagsChan
             }
             i++;
         } while (tagEvent);
-    } else if (m_stream)
+    }
+#if GST_CHECK_VERSION(1, 10, 0)
+    else if (m_stream)
         tags = adoptGRef(gst_stream_get_tags(m_stream.get()));
+#endif
 
     if (!tags)
         tags = adoptGRef(gst_tag_list_new_empty());
diff -urpN webkitgtk-2.34.5.gtk/Source/WebCore/platform/graphics/gstreamer/TrackPrivateBaseGStreamer.h webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/graphics/gstreamer/TrackPrivateBaseGStreamer.h
--- webkitgtk-2.34.5.gtk/Source/WebCore/platform/graphics/gstreamer/TrackPrivateBaseGStreamer.h	2021-10-21 03:52:09.000000000 -0500
+++ webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/graphics/gstreamer/TrackPrivateBaseGStreamer.h	2022-02-09 15:50:49.977206820 -0600
@@ -59,7 +59,9 @@ public:
 
     void setIndex(unsigned index) { m_index =  index; }
 
+#if GST_CHECK_VERSION(1, 10, 0)
     GstStream* stream() { return m_stream.get(); }
+#endif
 
     // Used for MSE, where the initial caps of the pad are relevant for initializing the matching pad in the
     // playback pipeline.
@@ -68,7 +70,9 @@ public:
 
 protected:
     TrackPrivateBaseGStreamer(TrackType, TrackPrivateBase*, unsigned index, GRefPtr<GstPad>&&, bool shouldHandleStreamStartEvent);
+#if GST_CHECK_VERSION(1, 10, 0)
     TrackPrivateBaseGStreamer(TrackType, TrackPrivateBase*, unsigned index, GRefPtr<GstStream>&&);
+#endif
 
     void notifyTrackOfTagsChanged();
     void notifyTrackOfStreamChanged();
@@ -86,7 +90,9 @@ protected:
     AtomString m_id;
     GRefPtr<GstPad> m_pad;
     GRefPtr<GstPad> m_bestUpstreamPad;
+#if GST_CHECK_VERSION(1, 10, 0)
     GRefPtr<GstStream> m_stream;
+#endif
     unsigned long m_eventProbe { 0 };
     GRefPtr<GstCaps> m_initialCaps;
 
diff -urpN webkitgtk-2.34.5.gtk/Source/WebCore/platform/graphics/gstreamer/VideoTrackPrivateGStreamer.cpp webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/graphics/gstreamer/VideoTrackPrivateGStreamer.cpp
--- webkitgtk-2.34.5.gtk/Source/WebCore/platform/graphics/gstreamer/VideoTrackPrivateGStreamer.cpp	2022-02-08 07:34:31.000000000 -0600
+++ webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/graphics/gstreamer/VideoTrackPrivateGStreamer.cpp	2022-02-09 17:46:33.480654849 -0600
@@ -39,6 +39,7 @@ VideoTrackPrivateGStreamer::VideoTrackPr
 {
 }
 
+#if GST_CHECK_VERSION(1, 10, 0)
 VideoTrackPrivateGStreamer::VideoTrackPrivateGStreamer(WeakPtr<MediaPlayerPrivateGStreamer> player, unsigned index, GRefPtr<GstStream>&& stream)
     : TrackPrivateBaseGStreamer(TrackPrivateBaseGStreamer::TrackType::Video, this, index, WTFMove(stream))
     , m_player(player)
@@ -59,11 +60,14 @@ VideoTrackPrivate::Kind VideoTrackPrivat
 
     return VideoTrackPrivate::kind();
 }
+#endif
 
 void VideoTrackPrivateGStreamer::disconnect()
 {
+#if GST_CHECK_VERSION(1, 10, 0)
     if (m_stream)
         g_signal_handlers_disconnect_matched(m_stream.get(), G_SIGNAL_MATCH_DATA, 0, 0, nullptr, nullptr, this);
+#endif
 
     m_player = nullptr;
     TrackPrivateBaseGStreamer::disconnect();
diff -urpN webkitgtk-2.34.5.gtk/Source/WebCore/platform/graphics/gstreamer/VideoTrackPrivateGStreamer.h webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/graphics/gstreamer/VideoTrackPrivateGStreamer.h
--- webkitgtk-2.34.5.gtk/Source/WebCore/platform/graphics/gstreamer/VideoTrackPrivateGStreamer.h	2021-10-21 03:52:09.000000000 -0500
+++ webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/graphics/gstreamer/VideoTrackPrivateGStreamer.h	2022-02-09 15:50:49.977206820 -0600
@@ -43,12 +43,14 @@ public:
         return adoptRef(*new VideoTrackPrivateGStreamer(player, index, WTFMove(pad), shouldHandleStreamStartEvent));
     }
 
+#if GST_CHECK_VERSION(1, 10, 0)
     static Ref<VideoTrackPrivateGStreamer> create(WeakPtr<MediaPlayerPrivateGStreamer> player, unsigned index, GRefPtr<GstStream>&& stream)
     {
         return adoptRef(*new VideoTrackPrivateGStreamer(player, index, WTFMove(stream)));
     }
 
     Kind kind() const final;
+#endif
 
     void disconnect() final;
 
@@ -63,7 +65,9 @@ public:
 
 private:
     VideoTrackPrivateGStreamer(WeakPtr<MediaPlayerPrivateGStreamer>, unsigned index, GRefPtr<GstPad>&&, bool shouldHandleStreamStartEvent);
+#if GST_CHECK_VERSION(1, 10, 0)
     VideoTrackPrivateGStreamer(WeakPtr<MediaPlayerPrivateGStreamer>, unsigned index, GRefPtr<GstStream>&&);
+#endif
 
     WeakPtr<MediaPlayerPrivateGStreamer> m_player;
 };
diff -urpN webkitgtk-2.34.5.gtk/Source/WebCore/platform/graphics/gstreamer/WebKitAudioSinkGStreamer.cpp webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/graphics/gstreamer/WebKitAudioSinkGStreamer.cpp
--- webkitgtk-2.34.5.gtk/Source/WebCore/platform/graphics/gstreamer/WebKitAudioSinkGStreamer.cpp	2021-10-21 03:52:09.000000000 -0500
+++ webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/graphics/gstreamer/WebKitAudioSinkGStreamer.cpp	2022-02-09 15:50:49.977206820 -0600
@@ -256,7 +256,9 @@ static GstStateChangeReturn webKitAudioS
     auto* sink = WEBKIT_AUDIO_SINK(element);
     auto* priv = sink->priv;
 
+#if GST_CHECK_VERSION(1, 14, 0)
     GST_DEBUG_OBJECT(sink, "Handling %s transition", gst_state_change_get_name(stateChange));
+#endif
 
     auto& mixer = GStreamerAudioMixer::singleton();
     if (priv->interAudioSink && stateChange == GST_STATE_CHANGE_NULL_TO_READY)
diff -urpN webkitgtk-2.34.5.gtk/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp
--- webkitgtk-2.34.5.gtk/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp	2021-10-21 03:52:09.000000000 -0500
+++ webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp	2022-02-09 15:50:49.977206820 -0600
@@ -465,8 +465,12 @@ static GstFlowReturn webKitWebSrcCreate(
     // 1) webKitWebSrcSetMediaPlayer() is called by MediaPlayerPrivateGStreamer by means of hooking playbin's
     //    "source-setup" event. This doesn't work for additional WebKitWebSrc elements created by adaptivedemux.
     //
-    // 2) A GstContext query made here.
-    if (!members->player) {
+    // 2) A GstContext query made here. Because of a bug, this only works in GStreamer >= 1.12.
+    //
+    // As a compatibility workaround, the http: URI protocol is only registered for gst>=1.12; otherwise using
+    // webkit+http:, which is used by MediaPlayerPrivateGStreamer but not by adaptivedemux's additional source
+    // elements, therefore using souphttpsrc instead and not routing traffic through the NetworkProcess.
+    if (webkitGstCheckVersion(1, 12, 0) && !members->player) {
         members.runUnlocked([src, baseSrc]() {
             GRefPtr<GstQuery> query = adoptGRef(gst_query_new_context(WEBKIT_WEB_SRC_PLAYER_CONTEXT_TYPE_NAME));
             if (gst_pad_peer_query(GST_BASE_SRC_PAD(baseSrc), query.get())) {
@@ -866,9 +870,15 @@ static GstURIType webKitWebSrcUriGetType
 const gchar* const* webKitWebSrcGetProtocols(GType)
 {
     static const char* protocols[4];
-    protocols[0] = "http";
-    protocols[1] = "https";
-    protocols[2] = "blob";
+    if (webkitGstCheckVersion(1, 12, 0)) {
+        protocols[0] = "http";
+        protocols[1] = "https";
+        protocols[2] = "blob";
+    } else {
+        protocols[0] = "webkit+http";
+        protocols[1] = "webkit+https";
+        protocols[2] = "webkit+blob";
+    }
     protocols[3] = nullptr;
     return protocols;
 }
@@ -876,6 +886,10 @@ const gchar* const* webKitWebSrcGetProto
 static URL convertPlaybinURI(const char* uriString)
 {
     URL url(URL(), uriString);
+    if (!webkitGstCheckVersion(1, 12, 0)) {
+        ASSERT(url.protocol().substring(0, 7) == "webkit+");
+        url.setProtocol(url.protocol().substring(7).toString());
+    }
     return url;
 }
 
diff -urpN webkitgtk-2.34.5.gtk/Source/WebCore/platform/graphics/ImageDecoder.cpp webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/graphics/ImageDecoder.cpp
--- webkitgtk-2.34.5.gtk/Source/WebCore/platform/graphics/ImageDecoder.cpp	2021-05-17 08:22:42.000000000 -0500
+++ webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/graphics/ImageDecoder.cpp	2022-02-09 15:50:49.977206820 -0600
@@ -40,10 +40,6 @@
 #include "ImageDecoderAVFObjC.h"
 #endif
 
-#if USE(GSTREAMER) && ENABLE(VIDEO)
-#include "ImageDecoderGStreamer.h"
-#endif
-
 namespace WebCore {
 
 #if ENABLE(GPU_PROCESS) && HAVE(AVASSETREADER)
@@ -100,11 +96,6 @@ RefPtr<ImageDecoder> ImageDecoder::creat
     }
 #endif
 
-#if USE(GSTREAMER) && ENABLE(VIDEO)
-    if (ImageDecoderGStreamer::canDecodeType(mimeType))
-        return ImageDecoderGStreamer::create(data, mimeType, alphaOption, gammaAndColorProfileOption);
-#endif
-
 #if USE(CG)
     return ImageDecoderCG::create(data, alphaOption, gammaAndColorProfileOption);
 #elif USE(DIRECT2D)
@@ -139,11 +130,6 @@ bool ImageDecoder::supportsMediaType(Med
 #endif
 #endif
 
-#if USE(GSTREAMER) && ENABLE(VIDEO)
-    if (ImageDecoderGStreamer::supportsMediaType(type))
-        return true;
-#endif
-
     return false;
 }
 
diff -urpN webkitgtk-2.34.5.gtk/Source/WebCore/platform/GStreamer.cmake webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/GStreamer.cmake
--- webkitgtk-2.34.5.gtk/Source/WebCore/platform/GStreamer.cmake	2021-10-21 03:52:09.000000000 -0500
+++ webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/GStreamer.cmake	2022-02-09 15:50:49.977206820 -0600
@@ -15,7 +15,6 @@ if (ENABLE_VIDEO OR ENABLE_WEB_AUDIO)
         platform/graphics/gstreamer/GstAllocatorFastMalloc.cpp
         platform/graphics/gstreamer/GStreamerRegistryScanner.cpp
         platform/graphics/gstreamer/GStreamerVideoFrameHolder.cpp
-        platform/graphics/gstreamer/ImageDecoderGStreamer.cpp
         platform/graphics/gstreamer/InbandTextTrackPrivateGStreamer.cpp
         platform/graphics/gstreamer/MediaEngineConfigurationFactoryGStreamer.cpp
         platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
@@ -146,13 +145,17 @@ if (ENABLE_VIDEO)
     endif ()
 
     if (ENABLE_MEDIA_STREAM OR ENABLE_WEB_RTC)
-        list(APPEND WebCore_SYSTEM_INCLUDE_DIRECTORIES
-            ${GSTREAMER_CODECPARSERS_INCLUDE_DIRS}
-        )
-        if (NOT USE_GSTREAMER_FULL)
-            list(APPEND WebCore_LIBRARIES
-                ${GSTREAMER_CODECPARSERS_LIBRARIES}
+        if (PC_GSTREAMER_VERSION VERSION_LESS "1.10")
+            message(FATAL_ERROR "GStreamer 1.10 is needed for ENABLE_MEDIA_STREAM or ENABLE_WEB_RTC")
+        else ()
+            list(APPEND WebCore_SYSTEM_INCLUDE_DIRECTORIES
+                ${GSTREAMER_CODECPARSERS_INCLUDE_DIRS}
             )
+            if (NOT USE_GSTREAMER_FULL)
+                list(APPEND WebCore_LIBRARIES
+                    ${GSTREAMER_CODECPARSERS_LIBRARIES}
+                )
+            endif ()
         endif ()
     endif ()
 endif ()
diff -urpN webkitgtk-2.34.5.gtk/Source/WebCore/platform/mediastream/gstreamer/GStreamerCapturer.cpp webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/mediastream/gstreamer/GStreamerCapturer.cpp
--- webkitgtk-2.34.5.gtk/Source/WebCore/platform/mediastream/gstreamer/GStreamerCapturer.cpp	2021-10-21 03:52:09.000000000 -0500
+++ webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/mediastream/gstreamer/GStreamerCapturer.cpp	2022-02-09 15:50:49.977206820 -0600
@@ -22,7 +22,8 @@
 
 #include "config.h"
 
-#if ENABLE(VIDEO) && ENABLE(MEDIA_STREAM) && USE(GSTREAMER)
+#if 0
+
 #include "GStreamerCapturer.h"
 
 #include <gst/app/gstappsink.h>
@@ -238,4 +239,4 @@ void GStreamerCapturer::setInterrupted(b
 
 } // namespace WebCore
 
-#endif // ENABLE(VIDEO) && ENABLE(MEDIA_STREAM) && USE(GSTREAMER)
+#endif // ENABLE(VIDEO) && ENABLE(MEDIA_STREAM) && USE(GSTREAMER) && GST_CHECK_VERSION(1, 10, 0)
diff -urpN webkitgtk-2.34.5.gtk/Source/WebCore/platform/mediastream/gstreamer/GStreamerMediaStreamSource.cpp webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/mediastream/gstreamer/GStreamerMediaStreamSource.cpp
--- webkitgtk-2.34.5.gtk/Source/WebCore/platform/mediastream/gstreamer/GStreamerMediaStreamSource.cpp	2021-10-21 03:52:09.000000000 -0500
+++ webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/mediastream/gstreamer/GStreamerMediaStreamSource.cpp	2022-02-09 15:50:49.977206820 -0600
@@ -24,7 +24,7 @@
 #include "config.h"
 #include "GStreamerMediaStreamSource.h"
 
-#if ENABLE(VIDEO) && ENABLE(MEDIA_STREAM) && USE(GSTREAMER)
+#if 0
 
 #include "AudioTrackPrivateMediaStream.h"
 #include "GStreamerAudioData.h"
@@ -480,7 +480,9 @@ static void webkitMediaStreamSrcDispose(
 
 static GstStateChangeReturn webkitMediaStreamSrcChangeState(GstElement* element, GstStateChange transition)
 {
+#if GST_CHECK_VERSION(1, 14, 0)
     GST_DEBUG_OBJECT(element, "%s", gst_state_change_get_name(transition));
+#endif
     WebKitMediaStreamSrc* self = WEBKIT_MEDIA_STREAM_SRC_CAST(element);
 
     if (transition == GST_STATE_CHANGE_PAUSED_TO_READY) {
@@ -766,4 +768,4 @@ GstElement* webkitMediaStreamSrcNew()
     return GST_ELEMENT_CAST(g_object_new(webkit_media_stream_src_get_type(), nullptr));
 }
 
-#endif // ENABLE(VIDEO) && ENABLE(MEDIA_STREAM) && USE(GSTREAMER)
+#endif // ENABLE(VIDEO) && ENABLE(MEDIA_STREAM) && USE(GSTREAMER) && GST_CHECK_VERSION(1, 10, 0)
diff -urpN webkitgtk-2.34.5.gtk/Source/WebCore/platform/MIMETypeRegistry.cpp webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/MIMETypeRegistry.cpp
--- webkitgtk-2.34.5.gtk/Source/WebCore/platform/MIMETypeRegistry.cpp	2021-10-21 03:52:09.000000000 -0500
+++ webkitgtk-2.34.5.gstreamer/Source/WebCore/platform/MIMETypeRegistry.cpp	2022-02-09 15:50:49.977206820 -0600
@@ -61,10 +61,6 @@
 #include "PreviewConverter.h"
 #endif
 
-#if USE(GSTREAMER) && ENABLE(VIDEO)
-#include "ImageDecoderGStreamer.h"
-#endif
-
 namespace WebCore {
 
 static String normalizedImageMIMEType(const String&);
@@ -433,11 +429,6 @@ bool MIMETypeRegistry::isSupportedImageV
         return true;
 #endif
 
-#if USE(GSTREAMER) && ENABLE(VIDEO)
-    if (ImageDecoderGStreamer::supportsContainerType(mimeType))
-        return true;
-#endif
-
     return false;
 }
 
openSUSE Build Service is sponsored by