Submitted By:            Zeckma <zeckma_DOT_tech_AT_gmail_DOT_com>
Date:                    2024-12-15
Initial Package Version: 2.46.4
Upstream Status:         Applied
Origin:                  Upstream (see link below)
Description:             This patch is for WebKitGTK-2.46.4 and fixes the build
                         for disabled GBM and release logs. This has been
                         commited in the main branch upstream at
                         https://github.com/WebKit/WebKit/commit/1cfbdd74e97ea29636ce442322b5399b43937401,
                         but has not made its way in 2.46.4.

diff --color -Naur webkitgtk-2.46.4.orig/Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp webkitgtk-2.46.4/Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp
--- webkitgtk-2.46.4.orig/Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp	2024-11-27 02:15:13.718765500 -0700
+++ webkitgtk-2.46.4/Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp	2024-12-15 02:35:46.969455605 -0700
@@ -165,6 +165,10 @@
         m_shouldFilterICECandidates = page->webRTCProvider().isSupportingMDNS();
 #endif
 
+#if RELEASE_LOG_DISABLED
+    m_logIdentifierString = makeString(hex(reinterpret_cast<uintptr_t>(this)));
+#endif
+
 #if !RELEASE_LOG_DISABLED && (PLATFORM(WPE) || PLATFORM(GTK))
     m_jsonFilePath = String::fromUTF8(getenv("WEBKIT_WEBRTC_JSON_EVENTS_FILE"));
     if (!m_jsonFilePath.isEmpty())
diff --color -Naur webkitgtk-2.46.4.orig/Source/WebCore/Modules/mediastream/PeerConnectionBackend.h webkitgtk-2.46.4/Source/WebCore/Modules/mediastream/PeerConnectionBackend.h
--- webkitgtk-2.46.4.orig/Source/WebCore/Modules/mediastream/PeerConnectionBackend.h	2024-11-27 02:15:13.718765500 -0700
+++ webkitgtk-2.46.4/Source/WebCore/Modules/mediastream/PeerConnectionBackend.h	2024-12-15 02:36:47.652461252 -0700
@@ -281,8 +281,8 @@
 #if !RELEASE_LOG_DISABLED
     Ref<const Logger> m_logger;
     const void* m_logIdentifier;
-    String m_logIdentifierString;
 #endif
+    String m_logIdentifierString;
     bool m_finishedGatheringCandidates { false };
     bool m_isProcessingLocalDescriptionAnswer { false };

diff --color -Naur webkitgtk-2.46.4.orig/Source/WebCore/Modules/mediastream/gstreamer/GStreamerMediaEndpoint.cpp webkitgtk-2.46.4/Source/WebCore/Modules/mediastream/gstreamer/GStreamerMediaEndpoint.cpp
--- webkitgtk-2.46.4.orig/Source/WebCore/Modules/mediastream/gstreamer/GStreamerMediaEndpoint.cpp	2024-11-27 02:15:13.718765500 -0700
+++ webkitgtk-2.46.4/Source/WebCore/Modules/mediastream/gstreamer/GStreamerMediaEndpoint.cpp	2024-12-15 02:38:01.178468095 -0700
@@ -2228,7 +2228,9 @@
 void GStreamerMediaEndpoint::startRTCLogs()
 {
     m_isGatheringRTCLogs = true;
+#if !RELEASE_LOG_DISABLED
     startLoggingStats();
+#endif
 }
 
 void GStreamerMediaEndpoint::stopRTCLogs()
diff --color -Naur webkitgtk-2.46.4.orig/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp webkitgtk-2.46.4/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp
--- webkitgtk-2.46.4.orig/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp	2024-11-27 02:15:13.722765400 -0700
+++ webkitgtk-2.46.4/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp	2024-12-15 02:41:24.312486998 -0700
@@ -1726,7 +1726,7 @@
 #endif
 }
 
-#if !GST_CHECK_VERSION(1, 24, 0)
+#if USE(GBM) && !GST_CHECK_VERSION(1, 24, 0)
 static GstVideoFormat drmFourccToGstVideoFormat(uint32_t fourcc)
 {
     switch (fourcc) {
@@ -1761,7 +1761,7 @@
     RELEASE_ASSERT_NOT_REACHED();
     return GST_VIDEO_FORMAT_UNKNOWN;
 }
-#endif // !GST_CHECK_VERSION(1, 24, 0)
+#endif // USE(GBM) && !GST_CHECK_VERSION(1, 24, 0)
 
 #if USE(GBM)
 GRefPtr<GstCaps> buildDMABufCaps()
@@ -1805,7 +1805,7 @@
                 gst_value_list_append_and_take_value(&supportedFormats, &value);
             }
         }
-#else
+#elif USE(GBM)
         GValue value = G_VALUE_INIT;
         g_value_init(&value, G_TYPE_STRING);
         g_value_set_string(&value, gst_video_format_to_string(drmFourccToGstVideoFormat(format.fourcc)));
@@ -1815,7 +1815,7 @@
 
 #if GST_CHECK_VERSION(1, 24, 0)
     gst_caps_set_value(caps.get(), "drm-format", &supportedFormats);
-#else
+#elif USE(GBM)
     gst_caps_set_value(caps.get(), "format", &supportedFormats);
 #endif
     g_value_unset(&supportedFormats);
diff --color -Naur webkitgtk-2.46.4.orig/Source/WebCore/platform/graphics/gstreamer/mse/MediaSourcePrivateGStreamer.h webkitgtk-2.46.4/Source/WebCore/platform/graphics/gstreamer/mse/MediaSourcePrivateGStreamer.h
--- webkitgtk-2.46.4.orig/Source/WebCore/platform/graphics/gstreamer/mse/MediaSourcePrivateGStreamer.h	2024-11-26 02:32:28.891127800 -0700
+++ webkitgtk-2.46.4/Source/WebCore/platform/graphics/gstreamer/mse/MediaSourcePrivateGStreamer.h	2024-12-15 02:42:40.578494095 -0700
@@ -93,13 +93,14 @@
 #if !RELEASE_LOG_DISABLED
     Ref<const Logger> m_logger;
     const void* m_logIdentifier;
+#endif
+
     uint64_t m_nextSourceBufferID { 0 };
 
     // Stores known track IDs, so we can work around ID collisions between multiple source buffers.
     // The registry is placed here to enforce ID uniqueness specifically by player, not by process,
     // since its not an issue if multiple players use the same ID, and we want to preserve IDs as much as possible.
     HashSet<TrackID, WTF::IntHash<TrackID>, WTF::UnsignedWithZeroKeyHashTraits<TrackID>> m_trackIdRegistry;
-#endif
 };
 
 } // namespace WebCore
