diff -urp webkitgtk-2.42.1.gstreamer1.16/Source/cmake/GStreamerChecks.cmake webkitgtk-2.42.1.gstreamer1.12/Source/cmake/GStreamerChecks.cmake
--- webkitgtk-2.42.1.gstreamer1.16/Source/cmake/GStreamerChecks.cmake	2023-10-09 16:57:58.866182263 -0500
+++ webkitgtk-2.42.1.gstreamer1.12/Source/cmake/GStreamerChecks.cmake	2023-10-09 16:59:22.153291064 -0500
@@ -36,7 +36,7 @@ if (ENABLE_VIDEO OR ENABLE_WEB_AUDIO)
               list(APPEND GSTREAMER_COMPONENTS webrtc)
           endif ()
 
-          find_package(GStreamer 1.16.2 REQUIRED COMPONENTS ${GSTREAMER_COMPONENTS})
+          find_package(GStreamer 1.10.0 REQUIRED COMPONENTS ${GSTREAMER_COMPONENTS})
 
           if (ENABLE_WEB_AUDIO)
               if (NOT PC_GSTREAMER_AUDIO_FOUND OR NOT PC_GSTREAMER_FFT_FOUND)
diff -urp webkitgtk-2.42.1.gstreamer1.16/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceGStreamer.cpp webkitgtk-2.42.1.gstreamer1.12/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceGStreamer.cpp
--- webkitgtk-2.42.1.gstreamer1.16/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceGStreamer.cpp	2023-09-19 03:27:49.255704400 -0500
+++ webkitgtk-2.42.1.gstreamer1.12/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceGStreamer.cpp	2023-10-09 16:59:22.153291064 -0500
@@ -68,7 +68,9 @@ void MediaStreamAudioSource::consumeAudi
     GST_BUFFER_FLAG_SET(buffer.get(), GST_BUFFER_FLAG_LIVE);
 
     copyBusData(bus, buffer.get(), muted());
+#if GST_CHECK_VERSION(1, 16, 0)
     gst_buffer_add_audio_meta(buffer.get(), &info, numberOfFrames, nullptr);
+#endif
     auto sample = adoptGRef(gst_sample_new(buffer.get(), caps.get(), nullptr, nullptr));
     GStreamerAudioData audioBuffer(WTFMove(sample), info);
     GStreamerAudioStreamDescription description(&info);
diff -urp webkitgtk-2.42.1.gstreamer1.16/Source/WebCore/platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp webkitgtk-2.42.1.gstreamer1.12/Source/WebCore/platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp
--- webkitgtk-2.42.1.gstreamer1.16/Source/WebCore/platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp	2023-09-19 03:27:49.763694000 -0500
+++ webkitgtk-2.42.1.gstreamer1.12/Source/WebCore/platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp	2023-10-09 16:59:22.153291064 -0500
@@ -77,6 +77,7 @@ struct _WebKitWebAudioSrcPrivate {
 
     GRefPtr<GstBufferPool> pool;
 
+    bool enableGapBufferSupport;
     bool hasRenderedAudibleFrame { false };
 
     Lock dispatchToRenderThreadLock;
@@ -91,6 +92,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()
@@ -318,7 +324,9 @@ static GRefPtr<GstBuffer> webKitWebAudio
     // Attach audio meta on buffer.
     GstAudioInfo info;
     gst_audio_info_from_caps(&info, priv->caps.get());
+#if GST_CHECK_VERSION(1, 16, 0)
     gst_buffer_add_audio_meta(buffer.get(), &info, priv->framesToPull, nullptr);
+#endif
 
     GstMappedBuffer mappedBuffer(buffer.get(), GST_MAP_READWRITE);
     ASSERT(mappedBuffer);
@@ -365,7 +373,7 @@ static void webKitWebAudioSrcRenderAndPu
     GST_BUFFER_TIMESTAMP(buffer.get()) = outputTimestamp.position.nanoseconds();
     GST_BUFFER_DURATION(buffer.get()) = duration;
 
-    if (priv->bus->isSilent())
+    if (priv->enableGapBufferSupport && priv->bus->isSilent())
         GST_BUFFER_FLAG_SET(buffer.get(), GST_BUFFER_FLAG_GAP);
 
     // Leak the buffer ref, because gst_app_src_push_buffer steals it.
@@ -420,7 +428,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 -urp webkitgtk-2.42.1.gstreamer1.16/Source/WebCore/platform/graphics/gstreamer/eme/GStreamerEMEUtilities.h webkitgtk-2.42.1.gstreamer1.12/Source/WebCore/platform/graphics/gstreamer/eme/GStreamerEMEUtilities.h
--- webkitgtk-2.42.1.gstreamer1.16/Source/WebCore/platform/graphics/gstreamer/eme/GStreamerEMEUtilities.h	2023-09-19 03:27:49.855692100 -0500
+++ webkitgtk-2.42.1.gstreamer1.12/Source/WebCore/platform/graphics/gstreamer/eme/GStreamerEMEUtilities.h	2023-10-09 16:59:22.153291064 -0500
@@ -61,8 +61,10 @@ public:
     const String& systemId() const { return m_systemId; }
     String payloadContainerType() const
     {
+#if GST_CHECK_VERSION(1, 16, 0)
         if (m_systemId == GST_PROTECTION_UNSPECIFIED_SYSTEM_ID ""_s)
             return "webm"_s;
+#endif
         return "cenc"_s;
     }
 
@@ -111,8 +113,10 @@ public:
     static constexpr auto s_WidevineKeySystem = "com.widevine.alpha"_s;
     static constexpr auto s_PlayReadyUUID = WEBCORE_GSTREAMER_EME_UTILITIES_PLAYREADY_UUID ""_s;
     static constexpr std::array<ASCIILiteral, 2> s_PlayReadyKeySystems = { "com.microsoft.playready"_s,  "com.youtube.playready"_s };
+#if GST_CHECK_VERSION(1, 16, 0)
     static constexpr auto s_unspecifiedUUID = GST_PROTECTION_UNSPECIFIED_SYSTEM_ID ""_s;
     static constexpr auto s_unspecifiedKeySystem = GST_PROTECTION_UNSPECIFIED_SYSTEM_ID ""_s;
+#endif
 
     static bool isClearKeyKeySystem(const String& keySystem)
     {
@@ -144,6 +148,7 @@ public:
         return equalIgnoringASCIICase(uuid, s_PlayReadyUUID);
     }
 
+#if GST_CHECK_VERSION(1, 16, 0)
     static bool isUnspecifiedKeySystem(const String& keySystem)
     {
         return equalIgnoringASCIICase(keySystem, s_unspecifiedKeySystem);
@@ -153,6 +158,7 @@ public:
     {
         return equalIgnoringASCIICase(uuid, s_unspecifiedUUID);
     }
+#endif
 
     static const char* keySystemToUuid(const String& keySystem)
     {
@@ -165,8 +171,10 @@ public:
         if (isPlayReadyKeySystem(keySystem))
             return s_PlayReadyUUID;
 
+#if GST_CHECK_VERSION(1, 16, 0)
         if (isUnspecifiedKeySystem(keySystem))
             return s_unspecifiedUUID;
+#endif
 
         ASSERT_NOT_REACHED();
         return { };
@@ -183,8 +191,10 @@ public:
         if (isPlayReadyUUID(uuid))
             return s_PlayReadyKeySystems[0];
 
+#if GST_CHECK_VERSION(1, 16, 0)
         if (isUnspecifiedUUID(uuid))
             return s_unspecifiedKeySystem;
+#endif
 
         ASSERT_NOT_REACHED();
         return ""_s;
diff -urp webkitgtk-2.42.1.gstreamer1.16/Source/WebCore/platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.cpp webkitgtk-2.42.1.gstreamer1.12/Source/WebCore/platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.cpp
--- webkitgtk-2.42.1.gstreamer1.16/Source/WebCore/platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.cpp	2023-09-19 03:27:49.855692100 -0500
+++ webkitgtk-2.42.1.gstreamer1.12/Source/WebCore/platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.cpp	2023-10-09 16:59:22.153291064 -0500
@@ -171,8 +171,11 @@ 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(), !g_strcmp0(klass->protectionSystemId(self),
-                    GST_PROTECTION_UNSPECIFIED_SYSTEM_ID) ? "application/x-webm-enc" : "application/x-cenc");
+                gst_structure_set_name(outgoingStructure.get(),
+#if GST_CHECK_VERSION(1, 16, 0)
+                    !g_strcmp0(klass->protectionSystemId(self), GST_PROTECTION_UNSPECIFIED_SYSTEM_ID) ? "application/x-webm-enc" :
+#endif
+                    "application/x-cenc");
             }
         }
 
diff -urp webkitgtk-2.42.1.gstreamer1.16/Source/WebCore/platform/graphics/gstreamer/GLVideoSinkGStreamer.cpp webkitgtk-2.42.1.gstreamer1.12/Source/WebCore/platform/graphics/gstreamer/GLVideoSinkGStreamer.cpp
--- webkitgtk-2.42.1.gstreamer1.16/Source/WebCore/platform/graphics/gstreamer/GLVideoSinkGStreamer.cpp	2023-10-09 16:57:58.866182263 -0500
+++ webkitgtk-2.42.1.gstreamer1.12/Source/WebCore/platform/graphics/gstreamer/GLVideoSinkGStreamer.cpp	2023-10-09 16:59:22.153291064 -0500
@@ -88,7 +88,25 @@ static void webKitGLVideoSinkConstructed
     ASSERT(colorconvert);
     gst_bin_add_many(GST_BIN_CAST(sink), upload, colorconvert, sink->priv->appSink.get(), nullptr);
 
-    GRefPtr<GstCaps> caps = adoptGRef(gst_caps_from_string("video/x-raw, format = (string) " GST_GL_CAPS_FORMAT));
+    // Workaround until we can depend on GStreamer 1.16.2.
+    // https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/commit/8d32de090554cf29fe359f83aa46000ba658a693
+    // Forcing a color conversion to RGBA here allows glupload to internally use
+    // an uploader that adds a VideoMeta, through the TextureUploadMeta caps
+    // feature, without needing the patch above. However this specific caps
+    // feature is going to be removed from GStreamer so it is considered a
+    // short-term workaround. This code path most likely will have a negative
+    // performance impact on embedded platforms as well. Downstream embedders
+    // are highly encouraged to cherry-pick the patch linked above in their BSP
+    // and set the WEBKIT_GST_NO_RGBA_CONVERSION environment variable until
+    // GStreamer 1.16.2 is released.
+    // See also https://bugs.webkit.org/show_bug.cgi?id=201422
+    GRefPtr<GstCaps> caps;
+    if (webkitGstCheckVersion(1, 16, 2) || getenv("WEBKIT_GST_NO_RGBA_CONVERSION"))
+        caps = adoptGRef(gst_caps_from_string("video/x-raw, format = (string) " GST_GL_CAPS_FORMAT));
+    else {
+        GST_INFO_OBJECT(sink, "Forcing RGBA as GStreamer is not new enough.");
+        caps = adoptGRef(gst_caps_from_string("video/x-raw, format = (string) RGBA"));
+    }
     gst_caps_set_features(caps.get(), 0, gst_caps_features_new(GST_CAPS_FEATURE_MEMORY_GL_MEMORY, nullptr));
     g_object_set(sink->priv->appSink.get(), "caps", caps.get(), nullptr);
 
@@ -141,7 +159,11 @@ std::optional<GRefPtr<GstContext>> reque
     if (!g_strcmp0(contextType, "gst.gl.app_context")) {
         GRefPtr<GstContext> appContext = adoptGRef(gst_context_new("gst.gl.app_context", TRUE));
         GstStructure* structure = gst_context_writable_structure(appContext.get());
+#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 appContext;
     }
 
@@ -162,11 +184,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 -urp webkitgtk-2.42.1.gstreamer1.16/Source/WebCore/platform/graphics/gstreamer/GStreamerAudioMixer.cpp webkitgtk-2.42.1.gstreamer1.12/Source/WebCore/platform/graphics/gstreamer/GStreamerAudioMixer.cpp
--- webkitgtk-2.42.1.gstreamer1.16/Source/WebCore/platform/graphics/gstreamer/GStreamerAudioMixer.cpp	2023-10-09 16:57:58.866182263 -0500
+++ webkitgtk-2.42.1.gstreamer1.12/Source/WebCore/platform/graphics/gstreamer/GStreamerAudioMixer.cpp	2023-10-09 16:59:22.153291064 -0500
@@ -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 -urp webkitgtk-2.42.1.gstreamer1.16/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp webkitgtk-2.42.1.gstreamer1.12/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp
--- webkitgtk-2.42.1.gstreamer1.16/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp	2023-10-09 16:57:58.866182263 -0500
+++ webkitgtk-2.42.1.gstreamer1.12/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp	2023-10-09 16:59:22.156624414 -0500
@@ -43,6 +43,7 @@
 #include <wtf/Scope.h>
 #include <wtf/glib/GUniquePtr.h>
 #include <wtf/glib/RunLoopSourcePriority.h>
+#include <wtf/PrintStream.h>
 
 #if USE(GSTREAMER_MPEGTS)
 #define GST_USE_UNSTABLE_API
@@ -911,12 +912,14 @@ PlatformVideoColorSpace videoColorSpaceF
     case GST_VIDEO_COLOR_PRIMARIES_SMPTE170M:
         colorSpace.primaries = PlatformVideoColorPrimaries::Smpte170m;
         break;
+#if GST_CHECK_VERSION(1, 16, 0)
     case GST_VIDEO_COLOR_PRIMARIES_SMPTERP431:
         colorSpace.primaries = PlatformVideoColorPrimaries::SmpteRp431;
         break;
     case GST_VIDEO_COLOR_PRIMARIES_SMPTEEG432:
         colorSpace.primaries = PlatformVideoColorPrimaries::SmpteEg432;
         break;
+#endif
     case GST_VIDEO_COLOR_PRIMARIES_FILM:
         colorSpace.primaries = PlatformVideoColorPrimaries::Film;
         break;
@@ -926,9 +929,11 @@ PlatformVideoColorSpace videoColorSpaceF
     case GST_VIDEO_COLOR_PRIMARIES_SMPTE240M:
         colorSpace.primaries = PlatformVideoColorPrimaries::Smpte240m;
         break;
+#if GST_CHECK_VERSION(1, 16, 0)
     case GST_VIDEO_COLOR_PRIMARIES_EBU3213:
         colorSpace.primaries = PlatformVideoColorPrimaries::JedecP22Phosphors;
         break;
+#endif
     case GST_VIDEO_COLOR_PRIMARIES_UNKNOWN:
         colorSpace.primaries = PlatformVideoColorPrimaries::Unspecified;
         break;
@@ -1043,12 +1048,14 @@ void fillVideoInfoColorimetryFromColorSp
         case PlatformVideoColorPrimaries::Smpte170m:
             GST_VIDEO_INFO_COLORIMETRY(info).primaries = GST_VIDEO_COLOR_PRIMARIES_SMPTE170M;
             break;
+#if GST_CHECK_VERSION(1, 16, 0)
         case PlatformVideoColorPrimaries::SmpteRp431:
             GST_VIDEO_INFO_COLORIMETRY(info).primaries = GST_VIDEO_COLOR_PRIMARIES_SMPTERP431;
             break;
         case PlatformVideoColorPrimaries::SmpteEg432:
             GST_VIDEO_INFO_COLORIMETRY(info).primaries = GST_VIDEO_COLOR_PRIMARIES_SMPTEEG432;
             break;
+#endif
         case PlatformVideoColorPrimaries::Film:
             GST_VIDEO_INFO_COLORIMETRY(info).primaries = GST_VIDEO_COLOR_PRIMARIES_FILM;
             break;
@@ -1058,9 +1065,11 @@ void fillVideoInfoColorimetryFromColorSp
         case PlatformVideoColorPrimaries::Smpte240m:
             GST_VIDEO_INFO_COLORIMETRY(info).primaries = GST_VIDEO_COLOR_PRIMARIES_SMPTE240M;
             break;
+#if GST_CHECK_VERSION(1, 16, 0)
         case PlatformVideoColorPrimaries::JedecP22Phosphors:
             GST_VIDEO_INFO_COLORIMETRY(info).primaries = GST_VIDEO_COLOR_PRIMARIES_EBU3213;
             break;
+#endif
         case PlatformVideoColorPrimaries::Unspecified:
             GST_VIDEO_INFO_COLORIMETRY(info).primaries = GST_VIDEO_COLOR_PRIMARIES_UNKNOWN;
             break;
diff -urp webkitgtk-2.42.1.gstreamer1.16/Source/WebCore/platform/graphics/gstreamer/ImageDecoderGStreamer.cpp webkitgtk-2.42.1.gstreamer1.12/Source/WebCore/platform/graphics/gstreamer/ImageDecoderGStreamer.cpp
--- webkitgtk-2.42.1.gstreamer1.16/Source/WebCore/platform/graphics/gstreamer/ImageDecoderGStreamer.cpp	2023-09-19 03:27:49.851692200 -0500
+++ webkitgtk-2.42.1.gstreamer1.12/Source/WebCore/platform/graphics/gstreamer/ImageDecoderGStreamer.cpp	2023-10-09 16:59:22.156624414 -0500
@@ -272,9 +272,11 @@ void ImageDecoderGStreamer::storeDecoded
 
 void ImageDecoderGStreamer::pushEncodedData(const FragmentedSharedBuffer& sharedBuffer)
 {
+    gsize size;
     auto data = sharedBuffer.makeContiguous();
     auto bytes = data->createGBytes();
-    auto buffer = adoptGRef(gst_buffer_new_wrapped_bytes(bytes.get()));
+  guint8 *bytes_data = (guint8 *) g_bytes_get_data (bytes.get(), &size);
+    auto buffer = adoptGRef(gst_buffer_new_wrapped_full(GST_MEMORY_FLAG_READONLY, bytes_data, size, 0, size, g_bytes_ref (bytes.get()), (GDestroyNotify) g_bytes_unref));
     m_eos = false;
     m_error = false;
 
diff -urp webkitgtk-2.42.1.gstreamer1.16/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp webkitgtk-2.42.1.gstreamer1.12/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
--- webkitgtk-2.42.1.gstreamer1.16/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp	2023-10-09 16:57:58.866182263 -0500
+++ webkitgtk-2.42.1.gstreamer1.12/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp	2023-10-09 16:59:22.156624414 -0500
@@ -52,7 +52,6 @@
 #include "InbandTextTrackPrivateGStreamer.h"
 #include "TextCombinerGStreamer.h"
 #include "TextSinkGStreamer.h"
-#include "VideoFrameMetadataGStreamer.h"
 #include "VideoTrackPrivateGStreamer.h"
 
 #if ENABLE(MEDIA_STREAM)
@@ -139,6 +138,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()));
+}
+
 MediaPlayerPrivateGStreamer::MediaPlayerPrivateGStreamer(MediaPlayer* player)
     : m_notifier(MainThreadNotifier<MainThreadNotification>::create())
     , m_player(player)
@@ -333,6 +340,7 @@ void MediaPlayerPrivateGStreamer::load(c
     m_readyState = MediaPlayer::ReadyState::HaveNothing;
     player->readyStateChanged();
     m_areVolumeAndMuteInitialized = false;
+    m_hasTaintedOrigin = std::nullopt;
 
     if (!m_isDelayingLoad)
         commitLoad();
@@ -854,6 +862,12 @@ unsigned long long MediaPlayerPrivateGSt
 
 std::optional<bool> MediaPlayerPrivateGStreamer::isCrossOrigin(const SecurityOrigin& origin) const
 {
+    // GStreamer < 1.12 has an incomplete uridownloader implementation so we
+    // can't use WebKitWebSrc for adaptive fragments downloading if this
+    // version is detected.
+    if (m_hasTaintedOrigin)
+        return true;
+
     if (WEBKIT_IS_WEB_SRC(m_source.get()))
         return webKitSrcIsCrossOrigin(WEBKIT_WEB_SRC(m_source.get()), origin);
     return false;
@@ -958,6 +972,7 @@ void MediaPlayerPrivateGStreamer::setPla
         cleanURLString = cleanURLString.left(url.pathEnd());
 
     m_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);
 }
@@ -1979,6 +1994,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 { String::fromLatin1(uri) };
+                convertToInternalProtocol(m_url);
 
                 if (url != m_url) {
                     GST_DEBUG_OBJECT(pipeline(), "Ignoring HTTP response headers for non-main URI.");
@@ -2017,6 +2033,11 @@ void MediaPlayerPrivateGStreamer::handle
             if (gst_structure_get(structure, "read-position", G_TYPE_UINT64, &m_networkReadPosition, "size", G_TYPE_UINT64, &m_httpResponseTotalSize, nullptr))
                 GST_LOG_OBJECT(pipeline(), "Updated network read position %" G_GUINT64_FORMAT ", size: %" G_GUINT64_FORMAT, m_networkReadPosition, m_httpResponseTotalSize);
         } else if (gst_structure_has_name(structure, "GstCacheDownloadComplete")) {
+        } 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 = webKitSrcIsCrossOrigin(WEBKIT_WEB_SRC_CAST(m_source.get()), SecurityOrigin::create(URL(URL(), String::fromLatin1(uri))));
+            }
             GST_INFO_OBJECT(pipeline(), "Stream is fully downloaded, stopping monitoring downloading progress.");
             m_fillTimer.stop();
             m_bufferingPercentage = 100;
@@ -2230,6 +2251,7 @@ void MediaPlayerPrivateGStreamer::proces
         processTableOfContentsEntry(static_cast<GstTocEntry*>(i->data));
 }
 
+#if 0
 void MediaPlayerPrivateGStreamer::configureElement(GstElement* element)
 {
 #if PLATFORM(BROADCOM) || USE(WESTEROS_SINK) || PLATFORM(AMLOGIC) || PLATFORM(REALTEK)
@@ -2272,6 +2294,7 @@ void MediaPlayerPrivateGStreamer::config
     if (!g_strcmp0(G_OBJECT_TYPE_NAME(G_OBJECT(element)), "GstQueue2"))
         g_object_set(G_OBJECT(element), "high-watermark", 0.10, nullptr);
 }
+#endif
 
 #if PLATFORM(BROADCOM) || USE(WESTEROS_SINK) || PLATFORM(AMLOGIC) || PLATFORM(REALTEK)
 void MediaPlayerPrivateGStreamer::configureElementPlatformQuirks(GstElement* element)
@@ -2975,8 +2998,34 @@ void MediaPlayerPrivateGStreamer::create
 
     g_object_set(m_pipeline.get(), "mute", static_cast<gboolean>(player->muted()), nullptr);
 
-    g_signal_connect(GST_BIN_CAST(m_pipeline.get()), "element-setup", G_CALLBACK(+[](GstBin*, GstElement* element, MediaPlayerPrivateGStreamer* player) {
-        player->configureElement(element);
+    g_signal_connect(GST_BIN_CAST(m_pipeline.get()), "deep-element-added", G_CALLBACK(+[](GstBin*, GstBin* subBin, GstElement* element, MediaPlayerPrivateGStreamer* player) {
+        GUniquePtr<char> binName(gst_element_get_name(GST_ELEMENT_CAST(subBin)));
+        GUniquePtr<char> elementName(gst_element_get_name(element));
+
+        if (g_str_has_prefix(elementName.get(), "downloadbuffer")) {
+            player->configureDownloadBuffer(element);
+            return;
+        }
+
+        if (g_str_has_prefix(elementName.get(), "uridecodebin")) {
+            // This will set the multiqueue size to the default value.
+            g_object_set(element, "buffer-size", 2 * MB, nullptr);
+            return;
+        }
+
+        if (!g_str_has_prefix(binName.get(), "decodebin"))
+            return;
+
+        if (g_str_has_prefix(elementName.get(), "v4l2"))
+            player->m_videoDecoderPlatform = GstVideoDecoderPlatform::Video4Linux;
+        else if (g_str_has_prefix(elementName.get(), "imxvpudec"))
+            player->m_videoDecoderPlatform = GstVideoDecoderPlatform::ImxVPU;
+        else if (g_str_has_prefix(elementName.get(), "omx"))
+            player->m_videoDecoderPlatform = GstVideoDecoderPlatform::OpenMAX;
+
+#if USE(TEXTURE_MAPPER_GL)
+        player->updateTextureMapperFlags();
+#endif
     }), this);
 
     g_signal_connect_swapped(m_pipeline.get(), "source-setup", G_CALLBACK(sourceSetupCallback), this);
@@ -3060,6 +3109,7 @@ void MediaPlayerPrivateGStreamer::config
     setupCodecProbe(decoder);
 }
 
+#if 0
 void MediaPlayerPrivateGStreamer::configureVideoDecoder(GstElement* decoder)
 {
     GUniquePtr<char> name(gst_element_get_name(decoder));
@@ -3123,6 +3173,7 @@ void MediaPlayerPrivateGStreamer::config
         return GST_PAD_PROBE_OK;
     }, this, nullptr);
 }
+#endif
 
 bool MediaPlayerPrivateGStreamer::didPassCORSAccessCheck() const
 {
@@ -3226,8 +3277,6 @@ void MediaPlayerPrivateGStreamer::pushTe
     if (!GST_IS_SAMPLE(m_sample.get()))
         return;
 
-    ++m_sampleCount;
-
     auto internalCompositingOperation = [this](TextureMapperPlatformLayerProxyGL& proxy, std::unique_ptr<GstVideoFrameHolder>&& frameHolder) {
         std::unique_ptr<TextureMapperPlatformLayerBuffer> layerBuffer;
         if (frameHolder->hasMappedTextures()) {
@@ -3352,8 +3401,6 @@ void MediaPlayerPrivateGStreamer::pushDM
         }
     }
 
-    ++m_sampleCount;
-
     auto& proxy = downcast<Nicosia::ContentLayerTextureMapperImpl>(m_nicosiaLayer->impl()).proxy();
     ASSERT(is<TextureMapperPlatformLayerProxyDMABuf>(proxy));
 
@@ -3775,7 +3822,7 @@ void MediaPlayerPrivateGStreamer::flushC
 {
     Locker sampleLocker { m_sampleMutex };
 
-    if (m_sample && gst_sample_get_buffer(m_sample.get())) {
+    if (m_sample) {
         // Allocate a new copy of the sample which has to be released. The copy is necessary so that
         // the video dimensions can still be fetched and also for canvas rendering. The release is
         // necessary because the sample might have been allocated by a hardware decoder and memory
@@ -4406,6 +4453,7 @@ WTFLogChannel& MediaPlayerPrivateGStream
 }
 #endif
 
+#if 0
 std::optional<VideoFrameMetadata> MediaPlayerPrivateGStreamer::videoFrameMetadata()
 {
     if (m_sampleCount == m_lastVideoFrameMetadataSampleCount)
@@ -4430,6 +4478,7 @@ std::optional<VideoFrameMetadata> MediaP
 
     return metadata;
 }
+#endif
 
 static bool areAllSinksPlayingForBin(GstBin* bin)
 {
diff -urp webkitgtk-2.42.1.gstreamer1.16/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h webkitgtk-2.42.1.gstreamer1.12/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h
--- webkitgtk-2.42.1.gstreamer1.16/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h	2023-10-09 16:57:58.869515615 -0500
+++ webkitgtk-2.42.1.gstreamer1.12/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h	2023-10-09 16:59:29.126661416 -0500
@@ -483,7 +483,6 @@ private:
     static void downloadBufferFileCreatedCallback(MediaPlayerPrivateGStreamer*);
 
     void configureAudioDecoder(GstElement*);
-    void configureVideoDecoder(GstElement*);
     void configureElement(GstElement*);
 #if PLATFORM(BROADCOM) || USE(WESTEROS_SINK) || PLATFORM(AMLOGIC) || PLATFORM(REALTEK)
     void configureElementPlatformQuirks(GstElement*);
@@ -578,6 +577,8 @@ private:
     uint64_t m_networkReadPosition { 0 };
     mutable uint64_t m_readPositionAtLastDidLoadingProgress { 0 };
 
+    std::optional<bool> m_hasTaintedOrigin { std::nullopt };
+
     GRefPtr<GstElement> m_fpsSink { nullptr };
     uint64_t m_totalVideoFrames { 0 };
     uint64_t m_droppedVideoFrames { 0 };
@@ -586,9 +587,6 @@ private:
     DataMutex<TaskAtMediaTimeScheduler> m_TaskAtMediaTimeSchedulerDataMutex;
 
 private:
-    std::optional<VideoFrameMetadata> videoFrameMetadata() final;
-    uint64_t m_sampleCount { 0 };
-    uint64_t m_lastVideoFrameMetadataSampleCount { 0 };
     mutable PlatformTimeRanges m_buffered;
 #if !RELEASE_LOG_DISABLED
     Ref<const Logger> m_logger;
diff -urp webkitgtk-2.42.1.gstreamer1.16/Source/WebCore/platform/graphics/gstreamer/PlatformDisplayGStreamer.cpp webkitgtk-2.42.1.gstreamer1.12/Source/WebCore/platform/graphics/gstreamer/PlatformDisplayGStreamer.cpp
--- webkitgtk-2.42.1.gstreamer1.16/Source/WebCore/platform/graphics/gstreamer/PlatformDisplayGStreamer.cpp	2023-09-19 03:27:49.855692100 -0500
+++ webkitgtk-2.42.1.gstreamer1.12/Source/WebCore/platform/graphics/gstreamer/PlatformDisplayGStreamer.cpp	2023-10-09 16:59:29.126661416 -0500
@@ -39,7 +39,7 @@ GstGLDisplay* PlatformDisplay::gstGLDisp
 {
 #if USE(EGL)
     if (!m_gstGLDisplay)
-        m_gstGLDisplay = adoptGRef(GST_GL_DISPLAY(gst_gl_display_egl_new_with_egl_display(eglDisplay())));
+        m_gstGLDisplay = GST_GL_DISPLAY(gst_gl_display_egl_new_with_egl_display(eglDisplay()));
 #endif
     return m_gstGLDisplay.get();
 }
@@ -58,7 +58,7 @@ GstGLContext* PlatformDisplay::gstGLCont
     if (!context)
         return nullptr;
 
-    m_gstGLContext = adoptGRef(gst_gl_context_new_wrapped(gstDisplay, reinterpret_cast<guintptr>(context->platformContext()), GST_GL_PLATFORM_EGL, GST_GL_API_GLES2));
+    m_gstGLContext = gst_gl_context_new_wrapped(gstDisplay, reinterpret_cast<guintptr>(context->platformContext()), GST_GL_PLATFORM_EGL, GST_GL_API_GLES2);
     {
         GLContext::ScopedGLContextCurrent scopedCurrent(*context);
         if (gst_gl_context_activate(m_gstGLContext.get(), TRUE)) {
diff -urp webkitgtk-2.42.1.gstreamer1.16/Source/WebCore/platform/graphics/gstreamer/WebKitAudioSinkGStreamer.cpp webkitgtk-2.42.1.gstreamer1.12/Source/WebCore/platform/graphics/gstreamer/WebKitAudioSinkGStreamer.cpp
--- webkitgtk-2.42.1.gstreamer1.16/Source/WebCore/platform/graphics/gstreamer/WebKitAudioSinkGStreamer.cpp	2023-09-19 03:27:49.855692100 -0500
+++ webkitgtk-2.42.1.gstreamer1.12/Source/WebCore/platform/graphics/gstreamer/WebKitAudioSinkGStreamer.cpp	2023-10-09 16:59:29.126661416 -0500
@@ -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 -urp webkitgtk-2.42.1.gstreamer1.16/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp webkitgtk-2.42.1.gstreamer1.12/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp
--- webkitgtk-2.42.1.gstreamer1.16/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp	2023-09-19 03:27:49.855692100 -0500
+++ webkitgtk-2.42.1.gstreamer1.12/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp	2023-10-09 16:59:29.126661416 -0500
@@ -467,7 +467,12 @@ static GstFlowReturn webKitWebSrcCreate(
     //    "source-setup" event. This doesn't work for additional WebKitWebSrc elements created by adaptivedemux.
     //
     // 2) A GstContext query made here.
-    if (!members->loader) {
+    // 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->loader) {
         members.runUnlocked([src, baseSrc]() {
             GRefPtr<GstQuery> query = adoptGRef(gst_query_new_context(WEBKIT_WEB_SRC_RESOURCE_LOADER_CONTEXT_TYPE_NAME));
             if (gst_pad_peer_query(GST_BASE_SRC_PAD(baseSrc), query.get())) {
@@ -866,16 +871,27 @@ 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;
 }
 
 static URL convertPlaybinURI(const char* uriString)
 {
-    return URL { String::fromLatin1(uriString) };
+    URL url { String::fromLatin1(uriString) };
+    if (!webkitGstCheckVersion(1, 12, 0)) {
+        ASSERT(url.protocol().substring(0, 7) == "webkit+");
+        url.setProtocol(url.protocol().substring(7).toString());
+    }
+     return url;
 }
 
 static gchar* webKitWebSrcGetUri(GstURIHandler* handler)
diff -urp webkitgtk-2.42.1.gstreamer1.16/Source/WebCore/platform/SourcesGStreamer.txt webkitgtk-2.42.1.gstreamer1.12/Source/WebCore/platform/SourcesGStreamer.txt
--- webkitgtk-2.42.1.gstreamer1.16/Source/WebCore/platform/SourcesGStreamer.txt	2023-09-19 03:27:49.751694200 -0500
+++ webkitgtk-2.42.1.gstreamer1.12/Source/WebCore/platform/SourcesGStreamer.txt	2023-10-09 16:59:29.126661416 -0500
@@ -61,7 +61,7 @@ platform/graphics/gstreamer/InbandTextTr
 platform/graphics/gstreamer/MediaEngineConfigurationFactoryGStreamer.cpp
 platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
 platform/graphics/gstreamer/MediaSampleGStreamer.cpp
-platform/graphics/gstreamer/PlatformDisplayGStreamer.cpp
+platform/graphics/gstreamer/PlatformDisplayGStreamer.cpp @no-unify
 platform/graphics/gstreamer/TextCombinerGStreamer.cpp @no-unify
 platform/graphics/gstreamer/TextCombinerPadGStreamer.cpp @no-unify
 platform/graphics/gstreamer/TextSinkGStreamer.cpp @no-unify
@@ -71,7 +71,7 @@ platform/graphics/gstreamer/VideoEncoder
 platform/graphics/gstreamer/VideoFrameGStreamer.cpp
 platform/graphics/gstreamer/VideoFrameMetadataGStreamer.cpp
 platform/graphics/gstreamer/VideoSinkGStreamer.cpp @no-unify
-platform/graphics/gstreamer/VideoTrackPrivateGStreamer.cpp
+platform/graphics/gstreamer/VideoTrackPrivateGStreamer.cpp @no-unify
 platform/graphics/gstreamer/WebKitAudioSinkGStreamer.cpp @no-unify
 platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp @no-unify
 
