commit 1a5ba8d67318c2e5dd83348bfc9d1d35db8421b9
Author: Christoph Moench-Tegeder <cmt@FreeBSD.org>

    regenerate FreeBSD libwebrtc patch for Firefox 135

diff --git third_party/libwebrtc/api/adaptation/resource_adaptation_api_gn/moz.build third_party/libwebrtc/api/adaptation/resource_adaptation_api_gn/moz.build
index a80e5f32ade2..d5a2be24fcbe 100644
--- third_party/libwebrtc/api/adaptation/resource_adaptation_api_gn/moz.build
+++ third_party/libwebrtc/api/adaptation/resource_adaptation_api_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("resource_adaptation_api_gn")
diff --git third_party/libwebrtc/api/array_view_gn/moz.build third_party/libwebrtc/api/array_view_gn/moz.build
index 25221b2af745..dfc948eba91e 100644
--- third_party/libwebrtc/api/array_view_gn/moz.build
+++ third_party/libwebrtc/api/array_view_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,111 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -153,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("array_view_gn")
diff --git third_party/libwebrtc/api/async_dns_resolver_gn/moz.build third_party/libwebrtc/api/async_dns_resolver_gn/moz.build
index bf95db7b24ed..d4e55fe55732 100644
--- third_party/libwebrtc/api/async_dns_resolver_gn/moz.build
+++ third_party/libwebrtc/api/async_dns_resolver_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,119 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -161,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("async_dns_resolver_gn")
diff --git third_party/libwebrtc/api/audio/aec3_config_gn/moz.build third_party/libwebrtc/api/audio/aec3_config_gn/moz.build
index 2c964a4fd025..f6f8fff6e3bc 100644
--- third_party/libwebrtc/api/audio/aec3_config_gn/moz.build
+++ third_party/libwebrtc/api/audio/aec3_config_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("aec3_config_gn")
diff --git third_party/libwebrtc/api/audio/aec3_factory_gn/moz.build third_party/libwebrtc/api/audio/aec3_factory_gn/moz.build
index e02b226aca7f..744e4c8aa0de 100644
--- third_party/libwebrtc/api/audio/aec3_factory_gn/moz.build
+++ third_party/libwebrtc/api/audio/aec3_factory_gn/moz.build
@@ -12,12 +12,22 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
 DEFINES["WEBRTC_APM_DEBUG_DUMP"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -44,189 +54,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("aec3_factory_gn")
diff --git third_party/libwebrtc/api/audio/audio_device_gn/moz.build third_party/libwebrtc/api/audio/audio_device_gn/moz.build
index 0fc7d750796a..9f6439e12a20 100644
--- third_party/libwebrtc/api/audio/audio_device_gn/moz.build
+++ third_party/libwebrtc/api/audio/audio_device_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,111 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -153,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("audio_device_gn")
diff --git third_party/libwebrtc/api/audio/audio_frame_api_gn/moz.build third_party/libwebrtc/api/audio/audio_frame_api_gn/moz.build
index c0e06e7a7865..ca8fc7db5049 100644
--- third_party/libwebrtc/api/audio/audio_frame_api_gn/moz.build
+++ third_party/libwebrtc/api/audio/audio_frame_api_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -44,185 +54,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("audio_frame_api_gn")
diff --git third_party/libwebrtc/api/audio/audio_frame_processor_gn/moz.build third_party/libwebrtc/api/audio/audio_frame_processor_gn/moz.build
index bc6ea25161c1..d586a04ef2ba 100644
--- third_party/libwebrtc/api/audio/audio_frame_processor_gn/moz.build
+++ third_party/libwebrtc/api/audio/audio_frame_processor_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("audio_frame_processor_gn")
diff --git third_party/libwebrtc/api/audio/audio_mixer_api_gn/moz.build third_party/libwebrtc/api/audio/audio_mixer_api_gn/moz.build
index cedd56ac791e..7d5115f48657 100644
--- third_party/libwebrtc/api/audio/audio_mixer_api_gn/moz.build
+++ third_party/libwebrtc/api/audio/audio_mixer_api_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,118 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -160,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("audio_mixer_api_gn")
diff --git third_party/libwebrtc/api/audio/audio_processing_gn/moz.build third_party/libwebrtc/api/audio/audio_processing_gn/moz.build
index 10ae1f65fa9c..e4ababb74a87 100644
--- third_party/libwebrtc/api/audio/audio_processing_gn/moz.build
+++ third_party/libwebrtc/api/audio/audio_processing_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("audio_processing_gn")
diff --git third_party/libwebrtc/api/audio/audio_processing_statistics_gn/moz.build third_party/libwebrtc/api/audio/audio_processing_statistics_gn/moz.build
index 061ff48b8485..3ee36df68faa 100644
--- third_party/libwebrtc/api/audio/audio_processing_statistics_gn/moz.build
+++ third_party/libwebrtc/api/audio/audio_processing_statistics_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,174 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("audio_processing_statistics_gn")
diff --git third_party/libwebrtc/api/audio/echo_control_gn/moz.build third_party/libwebrtc/api/audio/echo_control_gn/moz.build
index f1cfe20bed12..a373bec2722f 100644
--- third_party/libwebrtc/api/audio/echo_control_gn/moz.build
+++ third_party/libwebrtc/api/audio/echo_control_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,111 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -153,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("echo_control_gn")
diff --git third_party/libwebrtc/api/audio_codecs/L16/audio_decoder_L16_gn/moz.build third_party/libwebrtc/api/audio_codecs/L16/audio_decoder_L16_gn/moz.build
index ff6ba51fed82..7c35bd52175d 100644
--- third_party/libwebrtc/api/audio_codecs/L16/audio_decoder_L16_gn/moz.build
+++ third_party/libwebrtc/api/audio_codecs/L16/audio_decoder_L16_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("audio_decoder_L16_gn")
diff --git third_party/libwebrtc/api/audio_codecs/L16/audio_encoder_L16_gn/moz.build third_party/libwebrtc/api/audio_codecs/L16/audio_encoder_L16_gn/moz.build
index 50f39677700f..2716e3c6cda0 100644
--- third_party/libwebrtc/api/audio_codecs/L16/audio_encoder_L16_gn/moz.build
+++ third_party/libwebrtc/api/audio_codecs/L16/audio_encoder_L16_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("audio_encoder_L16_gn")
diff --git third_party/libwebrtc/api/audio_codecs/audio_codecs_api_gn/moz.build third_party/libwebrtc/api/audio_codecs/audio_codecs_api_gn/moz.build
index 66899306c2b9..7016bab07db9 100644
--- third_party/libwebrtc/api/audio_codecs/audio_codecs_api_gn/moz.build
+++ third_party/libwebrtc/api/audio_codecs/audio_codecs_api_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -46,185 +56,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("audio_codecs_api_gn")
diff --git third_party/libwebrtc/api/audio_codecs/builtin_audio_decoder_factory_gn/moz.build third_party/libwebrtc/api/audio_codecs/builtin_audio_decoder_factory_gn/moz.build
index 235eb30debda..56c2a57b2191 100644
--- third_party/libwebrtc/api/audio_codecs/builtin_audio_decoder_factory_gn/moz.build
+++ third_party/libwebrtc/api/audio_codecs/builtin_audio_decoder_factory_gn/moz.build
@@ -12,13 +12,23 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
 DEFINES["WEBRTC_USE_BUILTIN_ILBC"] = "1"
 DEFINES["WEBRTC_USE_BUILTIN_OPUS"] = "1"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -45,189 +55,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("builtin_audio_decoder_factory_gn")
diff --git third_party/libwebrtc/api/audio_codecs/builtin_audio_encoder_factory_gn/moz.build third_party/libwebrtc/api/audio_codecs/builtin_audio_encoder_factory_gn/moz.build
index d6edc362eb2f..853f9ffd51f5 100644
--- third_party/libwebrtc/api/audio_codecs/builtin_audio_encoder_factory_gn/moz.build
+++ third_party/libwebrtc/api/audio_codecs/builtin_audio_encoder_factory_gn/moz.build
@@ -12,13 +12,23 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
 DEFINES["WEBRTC_USE_BUILTIN_ILBC"] = "1"
 DEFINES["WEBRTC_USE_BUILTIN_OPUS"] = "1"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -45,189 +55,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("builtin_audio_encoder_factory_gn")
diff --git third_party/libwebrtc/api/audio_codecs/g711/audio_decoder_g711_gn/moz.build third_party/libwebrtc/api/audio_codecs/g711/audio_decoder_g711_gn/moz.build
index cd6f3fcf496e..47a87bc850e2 100644
--- third_party/libwebrtc/api/audio_codecs/g711/audio_decoder_g711_gn/moz.build
+++ third_party/libwebrtc/api/audio_codecs/g711/audio_decoder_g711_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("audio_decoder_g711_gn")
diff --git third_party/libwebrtc/api/audio_codecs/g711/audio_encoder_g711_gn/moz.build third_party/libwebrtc/api/audio_codecs/g711/audio_encoder_g711_gn/moz.build
index 88ab3c83b6d4..0374f235d934 100644
--- third_party/libwebrtc/api/audio_codecs/g711/audio_encoder_g711_gn/moz.build
+++ third_party/libwebrtc/api/audio_codecs/g711/audio_encoder_g711_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("audio_encoder_g711_gn")
diff --git third_party/libwebrtc/api/audio_codecs/g722/audio_decoder_g722_gn/moz.build third_party/libwebrtc/api/audio_codecs/g722/audio_decoder_g722_gn/moz.build
index 033fdb4bb6e2..ce0b3b836f08 100644
--- third_party/libwebrtc/api/audio_codecs/g722/audio_decoder_g722_gn/moz.build
+++ third_party/libwebrtc/api/audio_codecs/g722/audio_decoder_g722_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("audio_decoder_g722_gn")
diff --git third_party/libwebrtc/api/audio_codecs/g722/audio_encoder_g722_config_gn/moz.build third_party/libwebrtc/api/audio_codecs/g722/audio_encoder_g722_config_gn/moz.build
index ecb9b406a256..9057ccf0945f 100644
--- third_party/libwebrtc/api/audio_codecs/g722/audio_encoder_g722_config_gn/moz.build
+++ third_party/libwebrtc/api/audio_codecs/g722/audio_encoder_g722_config_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,118 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -160,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("audio_encoder_g722_config_gn")
diff --git third_party/libwebrtc/api/audio_codecs/g722/audio_encoder_g722_gn/moz.build third_party/libwebrtc/api/audio_codecs/g722/audio_encoder_g722_gn/moz.build
index cd28eb346570..12e0041653f5 100644
--- third_party/libwebrtc/api/audio_codecs/g722/audio_encoder_g722_gn/moz.build
+++ third_party/libwebrtc/api/audio_codecs/g722/audio_encoder_g722_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("audio_encoder_g722_gn")
diff --git third_party/libwebrtc/api/audio_codecs/ilbc/audio_decoder_ilbc_gn/moz.build third_party/libwebrtc/api/audio_codecs/ilbc/audio_decoder_ilbc_gn/moz.build
index e259a3b72e60..94a1aa4045ad 100644
--- third_party/libwebrtc/api/audio_codecs/ilbc/audio_decoder_ilbc_gn/moz.build
+++ third_party/libwebrtc/api/audio_codecs/ilbc/audio_decoder_ilbc_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,189 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("audio_decoder_ilbc_gn")
diff --git third_party/libwebrtc/api/audio_codecs/ilbc/audio_encoder_ilbc_config_gn/moz.build third_party/libwebrtc/api/audio_codecs/ilbc/audio_encoder_ilbc_config_gn/moz.build
index cfa532092195..fe0de702eccb 100644
--- third_party/libwebrtc/api/audio_codecs/ilbc/audio_encoder_ilbc_config_gn/moz.build
+++ third_party/libwebrtc/api/audio_codecs/ilbc/audio_encoder_ilbc_config_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("audio_encoder_ilbc_config_gn")
diff --git third_party/libwebrtc/api/audio_codecs/ilbc/audio_encoder_ilbc_gn/moz.build third_party/libwebrtc/api/audio_codecs/ilbc/audio_encoder_ilbc_gn/moz.build
index 87b566eb9c63..1213d0c86e02 100644
--- third_party/libwebrtc/api/audio_codecs/ilbc/audio_encoder_ilbc_gn/moz.build
+++ third_party/libwebrtc/api/audio_codecs/ilbc/audio_encoder_ilbc_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,189 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("audio_encoder_ilbc_gn")
diff --git third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_multiopus_gn/moz.build third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_multiopus_gn/moz.build
index 728c782d1ad9..0d6256e50300 100644
--- third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_multiopus_gn/moz.build
+++ third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_multiopus_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -44,185 +54,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("audio_decoder_multiopus_gn")
diff --git third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_opus_config_gn/moz.build third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_opus_config_gn/moz.build
index c27e08d89ca7..09419763690d 100644
--- third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_opus_config_gn/moz.build
+++ third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_opus_config_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,118 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -160,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("audio_decoder_opus_config_gn")
diff --git third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_opus_gn/moz.build third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_opus_gn/moz.build
index d6fe84b97bcc..6c61258e2290 100644
--- third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_opus_gn/moz.build
+++ third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_opus_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -44,189 +54,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("audio_decoder_opus_gn")
diff --git third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_multiopus_gn/moz.build third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_multiopus_gn/moz.build
index 15d75c1a6da3..1961637772fd 100644
--- third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_multiopus_gn/moz.build
+++ third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_multiopus_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -44,185 +54,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("audio_encoder_multiopus_gn")
diff --git third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_opus_config_gn/moz.build third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_opus_config_gn/moz.build
index f0b9b2ddb3fe..c9b0fbf804e7 100644
--- third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_opus_config_gn/moz.build
+++ third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_opus_config_gn/moz.build
@@ -12,12 +12,22 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
 DEFINES["WEBRTC_OPUS_VARIABLE_COMPLEXITY"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -48,174 +58,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("audio_encoder_opus_config_gn")
diff --git third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_opus_gn/moz.build third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_opus_gn/moz.build
index e2fb4d316a84..5b65a29e09f3 100644
--- third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_opus_gn/moz.build
+++ third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_opus_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -44,189 +54,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("audio_encoder_opus_gn")
diff --git third_party/libwebrtc/api/audio_codecs/opus_audio_decoder_factory_gn/moz.build third_party/libwebrtc/api/audio_codecs/opus_audio_decoder_factory_gn/moz.build
index 7d52cca1b6f1..c65182bc4864 100644
--- third_party/libwebrtc/api/audio_codecs/opus_audio_decoder_factory_gn/moz.build
+++ third_party/libwebrtc/api/audio_codecs/opus_audio_decoder_factory_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,189 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("opus_audio_decoder_factory_gn")
diff --git third_party/libwebrtc/api/audio_options_api_gn/moz.build third_party/libwebrtc/api/audio_options_api_gn/moz.build
index 9cddf47802bc..77615a363884 100644
--- third_party/libwebrtc/api/audio_options_api_gn/moz.build
+++ third_party/libwebrtc/api/audio_options_api_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("audio_options_api_gn")
diff --git third_party/libwebrtc/api/bitrate_allocation_gn/moz.build third_party/libwebrtc/api/bitrate_allocation_gn/moz.build
index a5170774bd1c..4fa8cc90205e 100644
--- third_party/libwebrtc/api/bitrate_allocation_gn/moz.build
+++ third_party/libwebrtc/api/bitrate_allocation_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,111 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -153,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("bitrate_allocation_gn")
diff --git third_party/libwebrtc/api/call_api_gn/moz.build third_party/libwebrtc/api/call_api_gn/moz.build
index 439d2b44318b..bef49364775e 100644
--- third_party/libwebrtc/api/call_api_gn/moz.build
+++ third_party/libwebrtc/api/call_api_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("call_api_gn")
diff --git third_party/libwebrtc/api/crypto/frame_decryptor_interface_gn/moz.build third_party/libwebrtc/api/crypto/frame_decryptor_interface_gn/moz.build
index 8c4ad8dd1ec2..fd90602736ac 100644
--- third_party/libwebrtc/api/crypto/frame_decryptor_interface_gn/moz.build
+++ third_party/libwebrtc/api/crypto/frame_decryptor_interface_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,111 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -153,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("frame_decryptor_interface_gn")
diff --git third_party/libwebrtc/api/crypto/frame_encryptor_interface_gn/moz.build third_party/libwebrtc/api/crypto/frame_encryptor_interface_gn/moz.build
index b3d5fc80f2dc..494bb25a7ab9 100644
--- third_party/libwebrtc/api/crypto/frame_encryptor_interface_gn/moz.build
+++ third_party/libwebrtc/api/crypto/frame_encryptor_interface_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,111 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -153,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("frame_encryptor_interface_gn")
diff --git third_party/libwebrtc/api/crypto/options_gn/moz.build third_party/libwebrtc/api/crypto/options_gn/moz.build
index 5ce60513e9dd..02635946fe38 100644
--- third_party/libwebrtc/api/crypto/options_gn/moz.build
+++ third_party/libwebrtc/api/crypto/options_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("options_gn")
diff --git third_party/libwebrtc/api/environment/environment_factory_gn/moz.build third_party/libwebrtc/api/environment/environment_factory_gn/moz.build
index dfb310b07831..30fb8a32856a 100644
--- third_party/libwebrtc/api/environment/environment_factory_gn/moz.build
+++ third_party/libwebrtc/api/environment/environment_factory_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,189 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("environment_factory_gn")
diff --git third_party/libwebrtc/api/environment/environment_gn/moz.build third_party/libwebrtc/api/environment/environment_gn/moz.build
index 484b89746fa8..065021521a62 100644
--- third_party/libwebrtc/api/environment/environment_gn/moz.build
+++ third_party/libwebrtc/api/environment/environment_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("environment_gn")
diff --git third_party/libwebrtc/api/fec_controller_api_gn/moz.build third_party/libwebrtc/api/fec_controller_api_gn/moz.build
index e8caeb29b0b5..eb72c1303105 100644
--- third_party/libwebrtc/api/fec_controller_api_gn/moz.build
+++ third_party/libwebrtc/api/fec_controller_api_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,111 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -153,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("fec_controller_api_gn")
diff --git third_party/libwebrtc/api/field_trials_registry_gn/moz.build third_party/libwebrtc/api/field_trials_registry_gn/moz.build
index ee276a6abe37..f43eabe0f14f 100644
--- third_party/libwebrtc/api/field_trials_registry_gn/moz.build
+++ third_party/libwebrtc/api/field_trials_registry_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("field_trials_registry_gn")
diff --git third_party/libwebrtc/api/field_trials_view_gn/moz.build third_party/libwebrtc/api/field_trials_view_gn/moz.build
index 9dcf0f1332d4..adc359f7cb28 100644
--- third_party/libwebrtc/api/field_trials_view_gn/moz.build
+++ third_party/libwebrtc/api/field_trials_view_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("field_trials_view_gn")
diff --git third_party/libwebrtc/api/frame_transformer_interface_gn/moz.build third_party/libwebrtc/api/frame_transformer_interface_gn/moz.build
index b47d843d106d..e178baaec5de 100644
--- third_party/libwebrtc/api/frame_transformer_interface_gn/moz.build
+++ third_party/libwebrtc/api/frame_transformer_interface_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("frame_transformer_interface_gn")
diff --git third_party/libwebrtc/api/function_view_gn/moz.build third_party/libwebrtc/api/function_view_gn/moz.build
index 6eccd0a4fd32..7971643aae1a 100644
--- third_party/libwebrtc/api/function_view_gn/moz.build
+++ third_party/libwebrtc/api/function_view_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,111 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -153,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("function_view_gn")
diff --git third_party/libwebrtc/api/libjingle_logging_api_gn/moz.build third_party/libwebrtc/api/libjingle_logging_api_gn/moz.build
index 14951db5b9f2..56c1e1592ebb 100644
--- third_party/libwebrtc/api/libjingle_logging_api_gn/moz.build
+++ third_party/libwebrtc/api/libjingle_logging_api_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("jingle_logging_api_gn")
diff --git third_party/libwebrtc/api/libjingle_peerconnection_api_gn/moz.build third_party/libwebrtc/api/libjingle_peerconnection_api_gn/moz.build
index d75066b59596..270c9ba77c25 100644
--- third_party/libwebrtc/api/libjingle_peerconnection_api_gn/moz.build
+++ third_party/libwebrtc/api/libjingle_peerconnection_api_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("jingle_peerconnection_api_gn")
diff --git third_party/libwebrtc/api/location_gn/moz.build third_party/libwebrtc/api/location_gn/moz.build
index 87a58928611c..3f82d7befe43 100644
--- third_party/libwebrtc/api/location_gn/moz.build
+++ third_party/libwebrtc/api/location_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("location_gn")
diff --git third_party/libwebrtc/api/make_ref_counted_gn/moz.build third_party/libwebrtc/api/make_ref_counted_gn/moz.build
index 7f956665eda9..26c6bb690f73 100644
--- third_party/libwebrtc/api/make_ref_counted_gn/moz.build
+++ third_party/libwebrtc/api/make_ref_counted_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("make_ref_counted_gn")
diff --git third_party/libwebrtc/api/media_stream_interface_gn/moz.build third_party/libwebrtc/api/media_stream_interface_gn/moz.build
index fea8af2692d4..fa6313b4b8c4 100644
--- third_party/libwebrtc/api/media_stream_interface_gn/moz.build
+++ third_party/libwebrtc/api/media_stream_interface_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("media_stream_interface_gn")
diff --git third_party/libwebrtc/api/metronome/metronome_gn/moz.build third_party/libwebrtc/api/metronome/metronome_gn/moz.build
index 57a1e2ca464e..5974015ddef6 100644
--- third_party/libwebrtc/api/metronome/metronome_gn/moz.build
+++ third_party/libwebrtc/api/metronome/metronome_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,111 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -153,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("metronome_gn")
diff --git third_party/libwebrtc/api/neteq/default_neteq_controller_factory_gn/moz.build third_party/libwebrtc/api/neteq/default_neteq_controller_factory_gn/moz.build
index 10d65f922ebe..d27ef50a9725 100644
--- third_party/libwebrtc/api/neteq/default_neteq_controller_factory_gn/moz.build
+++ third_party/libwebrtc/api/neteq/default_neteq_controller_factory_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,189 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("default_neteq_controller_factory_gn")
diff --git third_party/libwebrtc/api/neteq/default_neteq_factory_gn/moz.build third_party/libwebrtc/api/neteq/default_neteq_factory_gn/moz.build
index a7d5369ee523..b4b5d4cc0b4f 100644
--- third_party/libwebrtc/api/neteq/default_neteq_factory_gn/moz.build
+++ third_party/libwebrtc/api/neteq/default_neteq_factory_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,189 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("default_neteq_factory_gn")
diff --git third_party/libwebrtc/api/neteq/neteq_api_gn/moz.build third_party/libwebrtc/api/neteq/neteq_api_gn/moz.build
index a4512f3c1f31..1adeffe9858a 100644
--- third_party/libwebrtc/api/neteq/neteq_api_gn/moz.build
+++ third_party/libwebrtc/api/neteq/neteq_api_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("neteq_api_gn")
diff --git third_party/libwebrtc/api/neteq/neteq_controller_api_gn/moz.build third_party/libwebrtc/api/neteq/neteq_controller_api_gn/moz.build
index 8ca00de79987..1ef35aa77b22 100644
--- third_party/libwebrtc/api/neteq/neteq_controller_api_gn/moz.build
+++ third_party/libwebrtc/api/neteq/neteq_controller_api_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,118 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -160,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("neteq_controller_api_gn")
diff --git third_party/libwebrtc/api/neteq/tick_timer_gn/moz.build third_party/libwebrtc/api/neteq/tick_timer_gn/moz.build
index 97f27314b014..537d954a8d2a 100644
--- third_party/libwebrtc/api/neteq/tick_timer_gn/moz.build
+++ third_party/libwebrtc/api/neteq/tick_timer_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("tick_timer_gn")
diff --git third_party/libwebrtc/api/network_state_predictor_api_gn/moz.build third_party/libwebrtc/api/network_state_predictor_api_gn/moz.build
index 27f989b8b230..b62ef76e23e2 100644
--- third_party/libwebrtc/api/network_state_predictor_api_gn/moz.build
+++ third_party/libwebrtc/api/network_state_predictor_api_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("network_state_predictor_api_gn")
diff --git third_party/libwebrtc/api/priority_gn/moz.build third_party/libwebrtc/api/priority_gn/moz.build
index f412b0d8fba4..2cef91d8eb1a 100644
--- third_party/libwebrtc/api/priority_gn/moz.build
+++ third_party/libwebrtc/api/priority_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,111 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -153,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("priority_gn")
diff --git third_party/libwebrtc/api/ref_count_gn/moz.build third_party/libwebrtc/api/ref_count_gn/moz.build
index 98c49cbfca5e..4bdb29aad6a8 100644
--- third_party/libwebrtc/api/ref_count_gn/moz.build
+++ third_party/libwebrtc/api/ref_count_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("ref_count_gn")
diff --git third_party/libwebrtc/api/refcountedbase_gn/moz.build third_party/libwebrtc/api/refcountedbase_gn/moz.build
index 7f6d1e6cf3a1..cfef69c83fc3 100644
--- third_party/libwebrtc/api/refcountedbase_gn/moz.build
+++ third_party/libwebrtc/api/refcountedbase_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("refcountedbase_gn")
diff --git third_party/libwebrtc/api/rtc_error_gn/moz.build third_party/libwebrtc/api/rtc_error_gn/moz.build
index fd4c614cf3ad..e1f3176d41bf 100644
--- third_party/libwebrtc/api/rtc_error_gn/moz.build
+++ third_party/libwebrtc/api/rtc_error_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("rtc_error_gn")
diff --git third_party/libwebrtc/api/rtc_event_log/rtc_event_log_gn/moz.build third_party/libwebrtc/api/rtc_event_log/rtc_event_log_gn/moz.build
index 2f1418300a0c..f617051daad9 100644
--- third_party/libwebrtc/api/rtc_event_log/rtc_event_log_gn/moz.build
+++ third_party/libwebrtc/api/rtc_event_log/rtc_event_log_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -44,185 +54,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("rtc_event_log_gn")
diff --git third_party/libwebrtc/api/rtp_headers_gn/moz.build third_party/libwebrtc/api/rtp_headers_gn/moz.build
index 033677891b16..a684eca109e1 100644
--- third_party/libwebrtc/api/rtp_headers_gn/moz.build
+++ third_party/libwebrtc/api/rtp_headers_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("rtp_headers_gn")
diff --git third_party/libwebrtc/api/rtp_packet_info_gn/moz.build third_party/libwebrtc/api/rtp_packet_info_gn/moz.build
index c75ba8f4c4db..9b2ce7b59fef 100644
--- third_party/libwebrtc/api/rtp_packet_info_gn/moz.build
+++ third_party/libwebrtc/api/rtp_packet_info_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("rtp_packet_info_gn")
diff --git third_party/libwebrtc/api/rtp_packet_sender_gn/moz.build third_party/libwebrtc/api/rtp_packet_sender_gn/moz.build
index 69412fc87e29..37c9f2066f28 100644
--- third_party/libwebrtc/api/rtp_packet_sender_gn/moz.build
+++ third_party/libwebrtc/api/rtp_packet_sender_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("rtp_packet_sender_gn")
diff --git third_party/libwebrtc/api/rtp_parameters_gn/moz.build third_party/libwebrtc/api/rtp_parameters_gn/moz.build
index b92b2259d02d..d69843293695 100644
--- third_party/libwebrtc/api/rtp_parameters_gn/moz.build
+++ third_party/libwebrtc/api/rtp_parameters_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -44,178 +54,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("rtp_parameters_gn")
diff --git third_party/libwebrtc/api/rtp_sender_interface_gn/moz.build third_party/libwebrtc/api/rtp_sender_interface_gn/moz.build
index fd0316a345b7..503fac0eb534 100644
--- third_party/libwebrtc/api/rtp_sender_interface_gn/moz.build
+++ third_party/libwebrtc/api/rtp_sender_interface_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("rtp_sender_interface_gn")
diff --git third_party/libwebrtc/api/rtp_sender_setparameters_callback_gn/moz.build third_party/libwebrtc/api/rtp_sender_setparameters_callback_gn/moz.build
index 2dbb1256e4ef..67f9290c80ec 100644
--- third_party/libwebrtc/api/rtp_sender_setparameters_callback_gn/moz.build
+++ third_party/libwebrtc/api/rtp_sender_setparameters_callback_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("rtp_sender_setparameters_callback_gn")
diff --git third_party/libwebrtc/api/rtp_transceiver_direction_gn/moz.build third_party/libwebrtc/api/rtp_transceiver_direction_gn/moz.build
index 154dc5391a56..cbf3c4679807 100644
--- third_party/libwebrtc/api/rtp_transceiver_direction_gn/moz.build
+++ third_party/libwebrtc/api/rtp_transceiver_direction_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("rtp_transceiver_direction_gn")
diff --git third_party/libwebrtc/api/scoped_refptr_gn/moz.build third_party/libwebrtc/api/scoped_refptr_gn/moz.build
index 5dc69d00eea3..5df7da191ed2 100644
--- third_party/libwebrtc/api/scoped_refptr_gn/moz.build
+++ third_party/libwebrtc/api/scoped_refptr_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("scoped_refptr_gn")
diff --git third_party/libwebrtc/api/sequence_checker_gn/moz.build third_party/libwebrtc/api/sequence_checker_gn/moz.build
index 649a16507f49..75f51d5cf5b5 100644
--- third_party/libwebrtc/api/sequence_checker_gn/moz.build
+++ third_party/libwebrtc/api/sequence_checker_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,111 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -153,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("sequence_checker_gn")
diff --git third_party/libwebrtc/api/simulated_network_api_gn/moz.build third_party/libwebrtc/api/simulated_network_api_gn/moz.build
index 654045dd91a1..bf4577cdad9b 100644
--- third_party/libwebrtc/api/simulated_network_api_gn/moz.build
+++ third_party/libwebrtc/api/simulated_network_api_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,111 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -153,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("simulated_network_api_gn")
diff --git third_party/libwebrtc/api/task_queue/default_task_queue_factory_gn/moz.build third_party/libwebrtc/api/task_queue/default_task_queue_factory_gn/moz.build
index a0b133fad759..c957b4aa5257 100644
--- third_party/libwebrtc/api/task_queue/default_task_queue_factory_gn/moz.build
+++ third_party/libwebrtc/api/task_queue/default_task_queue_factory_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("default_task_queue_factory_gn")
diff --git third_party/libwebrtc/api/task_queue/pending_task_safety_flag_gn/moz.build third_party/libwebrtc/api/task_queue/pending_task_safety_flag_gn/moz.build
index 00c89a68d1cb..967c696ae8f1 100644
--- third_party/libwebrtc/api/task_queue/pending_task_safety_flag_gn/moz.build
+++ third_party/libwebrtc/api/task_queue/pending_task_safety_flag_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("pending_task_safety_flag_gn")
diff --git third_party/libwebrtc/api/task_queue/task_queue_gn/moz.build third_party/libwebrtc/api/task_queue/task_queue_gn/moz.build
index fad8682ae701..bc1a3324cf7f 100644
--- third_party/libwebrtc/api/task_queue/task_queue_gn/moz.build
+++ third_party/libwebrtc/api/task_queue/task_queue_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("task_queue_gn")
diff --git third_party/libwebrtc/api/transport/bandwidth_estimation_settings_gn/moz.build third_party/libwebrtc/api/transport/bandwidth_estimation_settings_gn/moz.build
index 45a9e8326962..c54c4003e72e 100644
--- third_party/libwebrtc/api/transport/bandwidth_estimation_settings_gn/moz.build
+++ third_party/libwebrtc/api/transport/bandwidth_estimation_settings_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("bandwidth_estimation_settings_gn")
diff --git third_party/libwebrtc/api/transport/bandwidth_usage_gn/moz.build third_party/libwebrtc/api/transport/bandwidth_usage_gn/moz.build
index 0441698bcb75..280d320a8c36 100644
--- third_party/libwebrtc/api/transport/bandwidth_usage_gn/moz.build
+++ third_party/libwebrtc/api/transport/bandwidth_usage_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("bandwidth_usage_gn")
diff --git third_party/libwebrtc/api/transport/bitrate_settings_gn/moz.build third_party/libwebrtc/api/transport/bitrate_settings_gn/moz.build
index b66b9044f154..baafa648900b 100644
--- third_party/libwebrtc/api/transport/bitrate_settings_gn/moz.build
+++ third_party/libwebrtc/api/transport/bitrate_settings_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,174 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("bitrate_settings_gn")
diff --git third_party/libwebrtc/api/transport/datagram_transport_interface_gn/moz.build third_party/libwebrtc/api/transport/datagram_transport_interface_gn/moz.build
index 075109c58fea..a56ae7b53213 100644
--- third_party/libwebrtc/api/transport/datagram_transport_interface_gn/moz.build
+++ third_party/libwebrtc/api/transport/datagram_transport_interface_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,118 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -160,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("datagram_transport_interface_gn")
diff --git third_party/libwebrtc/api/transport/field_trial_based_config_gn/moz.build third_party/libwebrtc/api/transport/field_trial_based_config_gn/moz.build
index 3b970aee2e27..5824d2655751 100644
--- third_party/libwebrtc/api/transport/field_trial_based_config_gn/moz.build
+++ third_party/libwebrtc/api/transport/field_trial_based_config_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("field_trial_based_config_gn")
diff --git third_party/libwebrtc/api/transport/goog_cc_gn/moz.build third_party/libwebrtc/api/transport/goog_cc_gn/moz.build
index 8255eb921f79..f713906b4cd4 100644
--- third_party/libwebrtc/api/transport/goog_cc_gn/moz.build
+++ third_party/libwebrtc/api/transport/goog_cc_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,190 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("goog_cc_gn")
diff --git third_party/libwebrtc/api/transport/network_control_gn/moz.build third_party/libwebrtc/api/transport/network_control_gn/moz.build
index 561baff74f56..b3acce5ab46e 100644
--- third_party/libwebrtc/api/transport/network_control_gn/moz.build
+++ third_party/libwebrtc/api/transport/network_control_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("network_control_gn")
diff --git third_party/libwebrtc/api/transport/rtp/dependency_descriptor_gn/moz.build third_party/libwebrtc/api/transport/rtp/dependency_descriptor_gn/moz.build
index 5df8c9603ac6..4ea1d123bf64 100644
--- third_party/libwebrtc/api/transport/rtp/dependency_descriptor_gn/moz.build
+++ third_party/libwebrtc/api/transport/rtp/dependency_descriptor_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("dependency_descriptor_gn")
diff --git third_party/libwebrtc/api/transport/rtp/rtp_source_gn/moz.build third_party/libwebrtc/api/transport/rtp/rtp_source_gn/moz.build
index cd6ffae7d73f..bb4cb862d8ab 100644
--- third_party/libwebrtc/api/transport/rtp/rtp_source_gn/moz.build
+++ third_party/libwebrtc/api/transport/rtp/rtp_source_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,118 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -160,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("rtp_source_gn")
diff --git third_party/libwebrtc/api/transport/stun_types_gn/moz.build third_party/libwebrtc/api/transport/stun_types_gn/moz.build
index 098eb72eb9ac..8bace3d4370c 100644
--- third_party/libwebrtc/api/transport/stun_types_gn/moz.build
+++ third_party/libwebrtc/api/transport/stun_types_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("stun_types_gn")
diff --git third_party/libwebrtc/api/transport_api_gn/moz.build third_party/libwebrtc/api/transport_api_gn/moz.build
index 3f5d0852a58e..b172533f8690 100644
--- third_party/libwebrtc/api/transport_api_gn/moz.build
+++ third_party/libwebrtc/api/transport_api_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("transport_api_gn")
diff --git third_party/libwebrtc/api/units/data_rate_gn/moz.build third_party/libwebrtc/api/units/data_rate_gn/moz.build
index 19e412ef718c..6ef287808300 100644
--- third_party/libwebrtc/api/units/data_rate_gn/moz.build
+++ third_party/libwebrtc/api/units/data_rate_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("data_rate_gn")
diff --git third_party/libwebrtc/api/units/data_size_gn/moz.build third_party/libwebrtc/api/units/data_size_gn/moz.build
index d78fda4aa54c..9f96a446f15e 100644
--- third_party/libwebrtc/api/units/data_size_gn/moz.build
+++ third_party/libwebrtc/api/units/data_size_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("data_size_gn")
diff --git third_party/libwebrtc/api/units/frequency_gn/moz.build third_party/libwebrtc/api/units/frequency_gn/moz.build
index ff1a8c54034e..0f609929a4e6 100644
--- third_party/libwebrtc/api/units/frequency_gn/moz.build
+++ third_party/libwebrtc/api/units/frequency_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("frequency_gn")
diff --git third_party/libwebrtc/api/units/time_delta_gn/moz.build third_party/libwebrtc/api/units/time_delta_gn/moz.build
index 43f43d80d89a..501d9b8a6af3 100644
--- third_party/libwebrtc/api/units/time_delta_gn/moz.build
+++ third_party/libwebrtc/api/units/time_delta_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("time_delta_gn")
diff --git third_party/libwebrtc/api/units/timestamp_gn/moz.build third_party/libwebrtc/api/units/timestamp_gn/moz.build
index d4a9959eae2b..e606fbd1f708 100644
--- third_party/libwebrtc/api/units/timestamp_gn/moz.build
+++ third_party/libwebrtc/api/units/timestamp_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("timestamp_gn")
diff --git third_party/libwebrtc/api/video/builtin_video_bitrate_allocator_factory_gn/moz.build third_party/libwebrtc/api/video/builtin_video_bitrate_allocator_factory_gn/moz.build
index fb5c3b325059..6861ef59f17b 100644
--- third_party/libwebrtc/api/video/builtin_video_bitrate_allocator_factory_gn/moz.build
+++ third_party/libwebrtc/api/video/builtin_video_bitrate_allocator_factory_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,190 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("builtin_video_bitrate_allocator_factory_gn")
diff --git third_party/libwebrtc/api/video/encoded_frame_gn/moz.build third_party/libwebrtc/api/video/encoded_frame_gn/moz.build
index c935e1128449..bff7d83848ad 100644
--- third_party/libwebrtc/api/video/encoded_frame_gn/moz.build
+++ third_party/libwebrtc/api/video/encoded_frame_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("encoded_frame_gn")
diff --git third_party/libwebrtc/api/video/encoded_image_gn/moz.build third_party/libwebrtc/api/video/encoded_image_gn/moz.build
index 4c2d4cd0ccbf..e6095826bd91 100644
--- third_party/libwebrtc/api/video/encoded_image_gn/moz.build
+++ third_party/libwebrtc/api/video/encoded_image_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("encoded_image_gn")
diff --git third_party/libwebrtc/api/video/frame_buffer_gn/moz.build third_party/libwebrtc/api/video/frame_buffer_gn/moz.build
index 8b0f07346188..dde6da5fd6bd 100644
--- third_party/libwebrtc/api/video/frame_buffer_gn/moz.build
+++ third_party/libwebrtc/api/video/frame_buffer_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,190 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("frame_buffer_gn")
diff --git third_party/libwebrtc/api/video/recordable_encoded_frame_gn/moz.build third_party/libwebrtc/api/video/recordable_encoded_frame_gn/moz.build
index e23a66634e87..4b49c7916ff8 100644
--- third_party/libwebrtc/api/video/recordable_encoded_frame_gn/moz.build
+++ third_party/libwebrtc/api/video/recordable_encoded_frame_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,118 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -160,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("recordable_encoded_frame_gn")
diff --git third_party/libwebrtc/api/video/render_resolution_gn/moz.build third_party/libwebrtc/api/video/render_resolution_gn/moz.build
index 37131d1328f7..9e9a6ad7ae17 100644
--- third_party/libwebrtc/api/video/render_resolution_gn/moz.build
+++ third_party/libwebrtc/api/video/render_resolution_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("render_resolution_gn")
diff --git third_party/libwebrtc/api/video/resolution_gn/moz.build third_party/libwebrtc/api/video/resolution_gn/moz.build
index 2d00ea929f01..77caba34b370 100644
--- third_party/libwebrtc/api/video/resolution_gn/moz.build
+++ third_party/libwebrtc/api/video/resolution_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("resolution_gn")
diff --git third_party/libwebrtc/api/video/video_adaptation_gn/moz.build third_party/libwebrtc/api/video/video_adaptation_gn/moz.build
index 8b89c69dc003..e79522c0abbb 100644
--- third_party/libwebrtc/api/video/video_adaptation_gn/moz.build
+++ third_party/libwebrtc/api/video/video_adaptation_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("video_adaptation_gn")
diff --git third_party/libwebrtc/api/video/video_bitrate_allocation_gn/moz.build third_party/libwebrtc/api/video/video_bitrate_allocation_gn/moz.build
index cd607967c486..32b23ac53c39 100644
--- third_party/libwebrtc/api/video/video_bitrate_allocation_gn/moz.build
+++ third_party/libwebrtc/api/video/video_bitrate_allocation_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("video_bitrate_allocation_gn")
diff --git third_party/libwebrtc/api/video/video_bitrate_allocator_factory_gn/moz.build third_party/libwebrtc/api/video/video_bitrate_allocator_factory_gn/moz.build
index a0531d267a2d..9c94ef9067c6 100644
--- third_party/libwebrtc/api/video/video_bitrate_allocator_factory_gn/moz.build
+++ third_party/libwebrtc/api/video/video_bitrate_allocator_factory_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,118 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -160,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("video_bitrate_allocator_factory_gn")
diff --git third_party/libwebrtc/api/video/video_bitrate_allocator_gn/moz.build third_party/libwebrtc/api/video/video_bitrate_allocator_gn/moz.build
index b731f61ae62e..ff055e370669 100644
--- third_party/libwebrtc/api/video/video_bitrate_allocator_gn/moz.build
+++ third_party/libwebrtc/api/video/video_bitrate_allocator_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("video_bitrate_allocator_gn")
diff --git third_party/libwebrtc/api/video/video_codec_constants_gn/moz.build third_party/libwebrtc/api/video/video_codec_constants_gn/moz.build
index 3ac5b9efc87e..513d9c80447f 100644
--- third_party/libwebrtc/api/video/video_codec_constants_gn/moz.build
+++ third_party/libwebrtc/api/video/video_codec_constants_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("video_codec_constants_gn")
diff --git third_party/libwebrtc/api/video/video_frame_gn/moz.build third_party/libwebrtc/api/video/video_frame_gn/moz.build
index 4704e8482b97..998f6b26349c 100644
--- third_party/libwebrtc/api/video/video_frame_gn/moz.build
+++ third_party/libwebrtc/api/video/video_frame_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -54,185 +64,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("video_frame_gn")
diff --git third_party/libwebrtc/api/video/video_frame_i010_gn/moz.build third_party/libwebrtc/api/video/video_frame_i010_gn/moz.build
index 5534a976cf12..7dc99b73f151 100644
--- third_party/libwebrtc/api/video/video_frame_i010_gn/moz.build
+++ third_party/libwebrtc/api/video/video_frame_i010_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -50,185 +60,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("video_frame_i010_gn")
diff --git third_party/libwebrtc/api/video/video_frame_metadata_gn/moz.build third_party/libwebrtc/api/video/video_frame_metadata_gn/moz.build
index e129b5b4f7b4..a35c051cbede 100644
--- third_party/libwebrtc/api/video/video_frame_metadata_gn/moz.build
+++ third_party/libwebrtc/api/video/video_frame_metadata_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("video_frame_metadata_gn")
diff --git third_party/libwebrtc/api/video/video_frame_type_gn/moz.build third_party/libwebrtc/api/video/video_frame_type_gn/moz.build
index d1402be61ac5..4b903646992f 100644
--- third_party/libwebrtc/api/video/video_frame_type_gn/moz.build
+++ third_party/libwebrtc/api/video/video_frame_type_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,111 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -153,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("video_frame_type_gn")
diff --git third_party/libwebrtc/api/video/video_layers_allocation_gn/moz.build third_party/libwebrtc/api/video/video_layers_allocation_gn/moz.build
index d6bb07ec8c87..2c20b0276d46 100644
--- third_party/libwebrtc/api/video/video_layers_allocation_gn/moz.build
+++ third_party/libwebrtc/api/video/video_layers_allocation_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,111 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -153,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("video_layers_allocation_gn")
diff --git third_party/libwebrtc/api/video/video_rtp_headers_gn/moz.build third_party/libwebrtc/api/video/video_rtp_headers_gn/moz.build
index 3ce253a3e8cc..bfdaacf2f399 100644
--- third_party/libwebrtc/api/video/video_rtp_headers_gn/moz.build
+++ third_party/libwebrtc/api/video/video_rtp_headers_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -46,185 +56,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("video_rtp_headers_gn")
diff --git third_party/libwebrtc/api/video/video_stream_encoder_gn/moz.build third_party/libwebrtc/api/video/video_stream_encoder_gn/moz.build
index d3ada0cf1d14..80d3314f94e3 100644
--- third_party/libwebrtc/api/video/video_stream_encoder_gn/moz.build
+++ third_party/libwebrtc/api/video/video_stream_encoder_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,118 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -160,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("video_stream_encoder_gn")
diff --git third_party/libwebrtc/api/video_codecs/bitstream_parser_api_gn/moz.build third_party/libwebrtc/api/video_codecs/bitstream_parser_api_gn/moz.build
index 30278b672f20..57f08bd2aed8 100644
--- third_party/libwebrtc/api/video_codecs/bitstream_parser_api_gn/moz.build
+++ third_party/libwebrtc/api/video_codecs/bitstream_parser_api_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,111 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -153,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("bitstream_parser_api_gn")
diff --git third_party/libwebrtc/api/video_codecs/builtin_video_decoder_factory_gn/moz.build third_party/libwebrtc/api/video_codecs/builtin_video_decoder_factory_gn/moz.build
index 4334202f11b5..70504aa2ddcb 100644
--- third_party/libwebrtc/api/video_codecs/builtin_video_decoder_factory_gn/moz.build
+++ third_party/libwebrtc/api/video_codecs/builtin_video_decoder_factory_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,190 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("builtin_video_decoder_factory_gn")
diff --git third_party/libwebrtc/api/video_codecs/rtc_software_fallback_wrappers_gn/moz.build third_party/libwebrtc/api/video_codecs/rtc_software_fallback_wrappers_gn/moz.build
index 723ee880f3c1..33bec021ef3c 100644
--- third_party/libwebrtc/api/video_codecs/rtc_software_fallback_wrappers_gn/moz.build
+++ third_party/libwebrtc/api/video_codecs/rtc_software_fallback_wrappers_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -44,190 +54,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("rtc_software_fallback_wrappers_gn")
diff --git third_party/libwebrtc/api/video_codecs/scalability_mode_gn/moz.build third_party/libwebrtc/api/video_codecs/scalability_mode_gn/moz.build
index aca8affe6867..f16f4f72c69f 100644
--- third_party/libwebrtc/api/video_codecs/scalability_mode_gn/moz.build
+++ third_party/libwebrtc/api/video_codecs/scalability_mode_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("scalability_mode_gn")
diff --git third_party/libwebrtc/api/video_codecs/video_codecs_api_gn/moz.build third_party/libwebrtc/api/video_codecs/video_codecs_api_gn/moz.build
index df8d151dd497..4134dfb41549 100644
--- third_party/libwebrtc/api/video_codecs/video_codecs_api_gn/moz.build
+++ third_party/libwebrtc/api/video_codecs/video_codecs_api_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -53,185 +63,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("video_codecs_api_gn")
diff --git third_party/libwebrtc/api/video_codecs/video_encoder_factory_template_gn/moz.build third_party/libwebrtc/api/video_codecs/video_encoder_factory_template_gn/moz.build
index 2a469a56b0b1..fae685811732 100644
--- third_party/libwebrtc/api/video_codecs/video_encoder_factory_template_gn/moz.build
+++ third_party/libwebrtc/api/video_codecs/video_encoder_factory_template_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,118 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -160,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("video_encoder_factory_template_gn")
diff --git third_party/libwebrtc/api/video_codecs/video_encoder_factory_template_libaom_av1_adapter_gn/moz.build third_party/libwebrtc/api/video_codecs/video_encoder_factory_template_libaom_av1_adapter_gn/moz.build
index 1fbefd3e1b1b..28873cb4a203 100644
--- third_party/libwebrtc/api/video_codecs/video_encoder_factory_template_libaom_av1_adapter_gn/moz.build
+++ third_party/libwebrtc/api/video_codecs/video_encoder_factory_template_libaom_av1_adapter_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,122 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -164,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("video_encoder_factory_template_libaom_av1_adapter_gn")
diff --git third_party/libwebrtc/api/video_codecs/video_encoder_factory_template_libvpx_vp8_adapter_gn/moz.build third_party/libwebrtc/api/video_codecs/video_encoder_factory_template_libvpx_vp8_adapter_gn/moz.build
index f285414fc561..d483e4f3cf9c 100644
--- third_party/libwebrtc/api/video_codecs/video_encoder_factory_template_libvpx_vp8_adapter_gn/moz.build
+++ third_party/libwebrtc/api/video_codecs/video_encoder_factory_template_libvpx_vp8_adapter_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,123 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -165,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("video_encoder_factory_template_libvpx_vp8_adapter_gn")
diff --git third_party/libwebrtc/api/video_codecs/video_encoder_factory_template_libvpx_vp9_adapter_gn/moz.build third_party/libwebrtc/api/video_codecs/video_encoder_factory_template_libvpx_vp9_adapter_gn/moz.build
index a618ccac0a1e..94c966467e42 100644
--- third_party/libwebrtc/api/video_codecs/video_encoder_factory_template_libvpx_vp9_adapter_gn/moz.build
+++ third_party/libwebrtc/api/video_codecs/video_encoder_factory_template_libvpx_vp9_adapter_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,123 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -165,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("video_encoder_factory_template_libvpx_vp9_adapter_gn")
diff --git third_party/libwebrtc/api/video_codecs/video_encoder_factory_template_open_h264_adapter_gn/moz.build third_party/libwebrtc/api/video_codecs/video_encoder_factory_template_open_h264_adapter_gn/moz.build
index 846208e9f33b..b83e5b1af1fb 100644
--- third_party/libwebrtc/api/video_codecs/video_encoder_factory_template_open_h264_adapter_gn/moz.build
+++ third_party/libwebrtc/api/video_codecs/video_encoder_factory_template_open_h264_adapter_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,123 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -165,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("video_encoder_factory_template_open_h264_adapter_gn")
diff --git third_party/libwebrtc/api/video_codecs/vp8_temporal_layers_factory_gn/moz.build third_party/libwebrtc/api/video_codecs/vp8_temporal_layers_factory_gn/moz.build
index a197fc9fdcc5..92b38446400e 100644
--- third_party/libwebrtc/api/video_codecs/vp8_temporal_layers_factory_gn/moz.build
+++ third_party/libwebrtc/api/video_codecs/vp8_temporal_layers_factory_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,190 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("vp8_temporal_layers_factory_gn")
diff --git third_party/libwebrtc/api/video_track_source_constraints_gn/moz.build third_party/libwebrtc/api/video_track_source_constraints_gn/moz.build
index f6456b10c949..3ebe854e0841 100644
--- third_party/libwebrtc/api/video_track_source_constraints_gn/moz.build
+++ third_party/libwebrtc/api/video_track_source_constraints_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("video_track_source_constraints_gn")
diff --git third_party/libwebrtc/audio/audio_gn/moz.build third_party/libwebrtc/audio/audio_gn/moz.build
index 7e907152932a..26e74709eca4 100644
--- third_party/libwebrtc/audio/audio_gn/moz.build
+++ third_party/libwebrtc/audio/audio_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -55,190 +65,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("audio_gn")
diff --git third_party/libwebrtc/audio/utility/audio_frame_operations_gn/moz.build third_party/libwebrtc/audio/utility/audio_frame_operations_gn/moz.build
index 513ee2df29a4..6e04ad3c6c6c 100644
--- third_party/libwebrtc/audio/utility/audio_frame_operations_gn/moz.build
+++ third_party/libwebrtc/audio/utility/audio_frame_operations_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -45,189 +55,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("audio_frame_operations_gn")
diff --git third_party/libwebrtc/call/adaptation/resource_adaptation_gn/moz.build third_party/libwebrtc/call/adaptation/resource_adaptation_gn/moz.build
index 9731da555bb5..4ddc49602b5a 100644
--- third_party/libwebrtc/call/adaptation/resource_adaptation_gn/moz.build
+++ third_party/libwebrtc/call/adaptation/resource_adaptation_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -52,190 +62,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("resource_adaptation_gn")
diff --git third_party/libwebrtc/call/audio_sender_interface_gn/moz.build third_party/libwebrtc/call/audio_sender_interface_gn/moz.build
index af23788409d9..586442905686 100644
--- third_party/libwebrtc/call/audio_sender_interface_gn/moz.build
+++ third_party/libwebrtc/call/audio_sender_interface_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,118 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -160,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("audio_sender_interface_gn")
diff --git third_party/libwebrtc/call/bitrate_allocator_gn/moz.build third_party/libwebrtc/call/bitrate_allocator_gn/moz.build
index eb39b9ced731..27d78e6d3192 100644
--- third_party/libwebrtc/call/bitrate_allocator_gn/moz.build
+++ third_party/libwebrtc/call/bitrate_allocator_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,189 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("bitrate_allocator_gn")
diff --git third_party/libwebrtc/call/bitrate_configurator_gn/moz.build third_party/libwebrtc/call/bitrate_configurator_gn/moz.build
index e73d8889769d..b48c2a9cd42e 100644
--- third_party/libwebrtc/call/bitrate_configurator_gn/moz.build
+++ third_party/libwebrtc/call/bitrate_configurator_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,189 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("bitrate_configurator_gn")
diff --git third_party/libwebrtc/call/call_gn/moz.build third_party/libwebrtc/call/call_gn/moz.build
index b00caf858186..f97d55dde006 100644
--- third_party/libwebrtc/call/call_gn/moz.build
+++ third_party/libwebrtc/call/call_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -45,190 +55,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("call_gn")
diff --git third_party/libwebrtc/call/call_interfaces_gn/moz.build third_party/libwebrtc/call/call_interfaces_gn/moz.build
index c5d22abe424a..11749d75f42d 100644
--- third_party/libwebrtc/call/call_interfaces_gn/moz.build
+++ third_party/libwebrtc/call/call_interfaces_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -49,190 +59,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("call_interfaces_gn")
diff --git third_party/libwebrtc/call/payload_type_gn/moz.build third_party/libwebrtc/call/payload_type_gn/moz.build
index 3947d7c4c2f6..c9ec738cf8a3 100644
--- third_party/libwebrtc/call/payload_type_gn/moz.build
+++ third_party/libwebrtc/call/payload_type_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,118 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -160,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("payload_type_gn")
diff --git third_party/libwebrtc/call/payload_type_picker_gn/moz.build third_party/libwebrtc/call/payload_type_picker_gn/moz.build
index e49308c312a8..ac567f73c3b9 100644
--- third_party/libwebrtc/call/payload_type_picker_gn/moz.build
+++ third_party/libwebrtc/call/payload_type_picker_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("payload_type_picker_gn")
diff --git third_party/libwebrtc/call/receive_stream_interface_gn/moz.build third_party/libwebrtc/call/receive_stream_interface_gn/moz.build
index 15e5be29d320..a813e9d71a69 100644
--- third_party/libwebrtc/call/receive_stream_interface_gn/moz.build
+++ third_party/libwebrtc/call/receive_stream_interface_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,122 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -164,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("receive_stream_interface_gn")
diff --git third_party/libwebrtc/call/rtp_interfaces_gn/moz.build third_party/libwebrtc/call/rtp_interfaces_gn/moz.build
index 29e7a8d99609..0b41486895d4 100644
--- third_party/libwebrtc/call/rtp_interfaces_gn/moz.build
+++ third_party/libwebrtc/call/rtp_interfaces_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,189 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("rtp_interfaces_gn")
diff --git third_party/libwebrtc/call/rtp_receiver_gn/moz.build third_party/libwebrtc/call/rtp_receiver_gn/moz.build
index b1a295a56ae2..8d459d1d711e 100644
--- third_party/libwebrtc/call/rtp_receiver_gn/moz.build
+++ third_party/libwebrtc/call/rtp_receiver_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -45,190 +55,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("rtp_receiver_gn")
diff --git third_party/libwebrtc/call/rtp_sender_gn/moz.build third_party/libwebrtc/call/rtp_sender_gn/moz.build
index f488ad07c25a..aeba0134575e 100644
--- third_party/libwebrtc/call/rtp_sender_gn/moz.build
+++ third_party/libwebrtc/call/rtp_sender_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -45,190 +55,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("rtp_sender_gn")
diff --git third_party/libwebrtc/call/version_gn/moz.build third_party/libwebrtc/call/version_gn/moz.build
index 485833ee2beb..bfccfe4b4400 100644
--- third_party/libwebrtc/call/version_gn/moz.build
+++ third_party/libwebrtc/call/version_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,174 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("version_gn")
diff --git third_party/libwebrtc/call/video_stream_api_gn/moz.build third_party/libwebrtc/call/video_stream_api_gn/moz.build
index 3d0b6a488cb3..271e176d5f75 100644
--- third_party/libwebrtc/call/video_stream_api_gn/moz.build
+++ third_party/libwebrtc/call/video_stream_api_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -44,189 +54,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("video_stream_api_gn")
diff --git third_party/libwebrtc/common_audio/common_audio_avx2_gn/moz.build third_party/libwebrtc/common_audio/common_audio_avx2_gn/moz.build
index 1b4cea6e47ec..84c4d1e1ca79 100644
--- third_party/libwebrtc/common_audio/common_audio_avx2_gn/moz.build
+++ third_party/libwebrtc/common_audio/common_audio_avx2_gn/moz.build
@@ -17,12 +17,22 @@ CXXFLAGS += [
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
 DEFINES["WEBRTC_ENABLE_AVX2"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -50,137 +60,16 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
     DEFINES["_DEBUG"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
+if CONFIG["TARGET_CPU"] == "x86":
 
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+    DEFINES["USE_X11"] = "1"
 
 Library("common_audio_avx2_gn")
diff --git third_party/libwebrtc/common_audio/common_audio_c_arm_asm_gn/moz.build third_party/libwebrtc/common_audio/common_audio_c_arm_asm_gn/moz.build
index f87719576dfa..3351f5581617 100644
--- third_party/libwebrtc/common_audio/common_audio_c_arm_asm_gn/moz.build
+++ third_party/libwebrtc/common_audio/common_audio_c_arm_asm_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,112 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
-    SOURCES += [
-        "/third_party/libwebrtc/common_audio/signal_processing/complex_bit_reverse_arm.S",
-        "/third_party/libwebrtc/common_audio/signal_processing/filter_ar_fast_q12_armv7.S"
-    ]
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -154,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("common_audio_c_arm_asm_gn")
diff --git third_party/libwebrtc/common_audio/common_audio_c_gn/moz.build third_party/libwebrtc/common_audio/common_audio_c_gn/moz.build
index 07660c8bb56b..df29659eeb4e 100644
--- third_party/libwebrtc/common_audio/common_audio_c_gn/moz.build
+++ third_party/libwebrtc/common_audio/common_audio_c_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -80,117 +90,12 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
+    DEFINES["_DEBUG"] = True
 
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-    UNIFIED_SOURCES += [
-        "/third_party/libwebrtc/common_audio/signal_processing/complex_fft.c"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    UNIFIED_SOURCES += [
-        "/third_party/libwebrtc/common_audio/signal_processing/complex_bit_reverse.c",
-        "/third_party/libwebrtc/common_audio/signal_processing/complex_fft.c",
-        "/third_party/libwebrtc/common_audio/signal_processing/filter_ar_fast_q12.c"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    UNIFIED_SOURCES += [
-        "/third_party/libwebrtc/common_audio/signal_processing/complex_bit_reverse.c",
-        "/third_party/libwebrtc/common_audio/signal_processing/complex_fft.c",
-        "/third_party/libwebrtc/common_audio/signal_processing/filter_ar_fast_q12.c"
-    ]
+if CONFIG["TARGET_CPU"] == "aarch64":
 
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["WEBRTC_ARCH_ARM64"] = True
+    DEFINES["WEBRTC_HAS_NEON"] = True
 
     UNIFIED_SOURCES += [
         "/third_party/libwebrtc/common_audio/signal_processing/complex_bit_reverse.c",
@@ -198,26 +103,10 @@ if CONFIG["OS_TARGET"] == "WINNT":
         "/third_party/libwebrtc/common_audio/signal_processing/filter_ar_fast_q12.c"
     ]
 
-if CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["WEBRTC_ARCH_ARM64"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
 
     SOURCES += [
         "/third_party/libwebrtc/common_audio/signal_processing/resample_by_2_mips.c"
@@ -234,8 +123,6 @@ if CONFIG["TARGET_CPU"] == "mips32":
 
 if CONFIG["TARGET_CPU"] == "mips64":
 
-    DEFINES["_GNU_SOURCE"] = True
-
     UNIFIED_SOURCES += [
         "/third_party/libwebrtc/common_audio/signal_processing/complex_bit_reverse.c",
         "/third_party/libwebrtc/common_audio/signal_processing/complex_fft.c",
@@ -250,88 +137,21 @@ if CONFIG["TARGET_CPU"] == "ppc64":
         "/third_party/libwebrtc/common_audio/signal_processing/filter_ar_fast_q12.c"
     ]
 
-if CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "aarch64":
+if CONFIG["TARGET_CPU"] == "riscv64":
 
     UNIFIED_SOURCES += [
         "/third_party/libwebrtc/common_audio/signal_processing/complex_bit_reverse.c",
+        "/third_party/libwebrtc/common_audio/signal_processing/complex_fft.c",
         "/third_party/libwebrtc/common_audio/signal_processing/filter_ar_fast_q12.c"
     ]
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
+if CONFIG["TARGET_CPU"] == "x86":
 
     CFLAGS += [
         "-msse2"
     ]
 
-    UNIFIED_SOURCES += [
-        "/third_party/libwebrtc/common_audio/signal_processing/complex_bit_reverse.c",
-        "/third_party/libwebrtc/common_audio/signal_processing/filter_ar_fast_q12.c"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    UNIFIED_SOURCES += [
-        "/third_party/libwebrtc/common_audio/signal_processing/complex_bit_reverse.c",
-        "/third_party/libwebrtc/common_audio/signal_processing/filter_ar_fast_q12.c"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-    UNIFIED_SOURCES += [
-        "/third_party/libwebrtc/common_audio/signal_processing/complex_bit_reverse.c",
-        "/third_party/libwebrtc/common_audio/signal_processing/complex_fft.c",
-        "/third_party/libwebrtc/common_audio/signal_processing/filter_ar_fast_q12.c"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-    UNIFIED_SOURCES += [
-        "/third_party/libwebrtc/common_audio/signal_processing/complex_fft.c"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "riscv64":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
     UNIFIED_SOURCES += [
         "/third_party/libwebrtc/common_audio/signal_processing/complex_bit_reverse.c",
@@ -339,13 +159,9 @@ if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "riscv64":
         "/third_party/libwebrtc/common_audio/signal_processing/filter_ar_fast_q12.c"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    CFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
     UNIFIED_SOURCES += [
         "/third_party/libwebrtc/common_audio/signal_processing/complex_bit_reverse.c",
@@ -353,14 +169,8 @@ if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
         "/third_party/libwebrtc/common_audio/signal_processing/filter_ar_fast_q12.c"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    UNIFIED_SOURCES += [
-        "/third_party/libwebrtc/common_audio/signal_processing/complex_bit_reverse.c",
-        "/third_party/libwebrtc/common_audio/signal_processing/complex_fft.c",
-        "/third_party/libwebrtc/common_audio/signal_processing/filter_ar_fast_q12.c"
-    ]
+    DEFINES["USE_X11"] = "1"
 
 Library("common_audio_c_gn")
diff --git third_party/libwebrtc/common_audio/common_audio_cc_gn/moz.build third_party/libwebrtc/common_audio/common_audio_cc_gn/moz.build
index 63d72e183fb0..914aafb6fd0c 100644
--- third_party/libwebrtc/common_audio/common_audio_cc_gn/moz.build
+++ third_party/libwebrtc/common_audio/common_audio_cc_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,189 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("common_audio_cc_gn")
diff --git third_party/libwebrtc/common_audio/common_audio_gn/moz.build third_party/libwebrtc/common_audio/common_audio_gn/moz.build
index 6ee67860188c..e3335f95e262 100644
--- third_party/libwebrtc/common_audio/common_audio_gn/moz.build
+++ third_party/libwebrtc/common_audio/common_audio_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -56,189 +66,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("common_audio_gn")
diff --git third_party/libwebrtc/common_audio/common_audio_neon_c_gn/moz.build third_party/libwebrtc/common_audio/common_audio_neon_c_gn/moz.build
index b00937b48f1a..a44e4ef14c20 100644
--- third_party/libwebrtc/common_audio/common_audio_neon_c_gn/moz.build
+++ third_party/libwebrtc/common_audio/common_audio_neon_c_gn/moz.build
@@ -12,12 +12,23 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_ARCH_ARM64"] = True
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_HAS_NEON"] = True
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -46,151 +57,10 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_ARCH_ARM64"] = True
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_ARCH_ARM64"] = True
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_ARCH_ARM64"] = True
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
-
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
     DEFINES["_DEBUG"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["WEBRTC_ARCH_ARM64"] = True
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["WEBRTC_ARCH_ARM64"] = True
-
 Library("common_audio_neon_c_gn")
diff --git third_party/libwebrtc/common_audio/common_audio_neon_gn/moz.build third_party/libwebrtc/common_audio/common_audio_neon_gn/moz.build
index 3af7e03d43f4..e8d3a8489e99 100644
--- third_party/libwebrtc/common_audio/common_audio_neon_gn/moz.build
+++ third_party/libwebrtc/common_audio/common_audio_neon_gn/moz.build
@@ -12,12 +12,23 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_ARCH_ARM64"] = True
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_HAS_NEON"] = True
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -45,151 +56,10 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_ARCH_ARM64"] = True
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_ARCH_ARM64"] = True
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_ARCH_ARM64"] = True
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
-
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
     DEFINES["_DEBUG"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["WEBRTC_ARCH_ARM64"] = True
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["WEBRTC_ARCH_ARM64"] = True
-
 Library("common_audio_neon_gn")
diff --git third_party/libwebrtc/common_audio/common_audio_sse2_gn/moz.build third_party/libwebrtc/common_audio/common_audio_sse2_gn/moz.build
index 074abd829083..eec558688bef 100644
--- third_party/libwebrtc/common_audio/common_audio_sse2_gn/moz.build
+++ third_party/libwebrtc/common_audio/common_audio_sse2_gn/moz.build
@@ -12,12 +12,22 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
 DEFINES["WEBRTC_ENABLE_AVX2"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -45,159 +55,23 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    CXXFLAGS += [
-        "-msse2"
-    ]
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    CXXFLAGS += [
-        "-msse2"
-    ]
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
     DEFINES["_DEBUG"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
+if CONFIG["TARGET_CPU"] == "x86":
 
     CXXFLAGS += [
         "-msse2",
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["TARGET_CPU"] == "x86_64":
 
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    CXXFLAGS += [
-        "-msse2",
-        "-msse2"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    CXXFLAGS += [
-        "-msse2"
-    ]
+    DEFINES["USE_X11"] = "1"
 
 Library("common_audio_sse2_gn")
diff --git third_party/libwebrtc/common_audio/fir_filter_factory_gn/moz.build third_party/libwebrtc/common_audio/fir_filter_factory_gn/moz.build
index 8e5b54e61d96..79b65cf27906 100644
--- third_party/libwebrtc/common_audio/fir_filter_factory_gn/moz.build
+++ third_party/libwebrtc/common_audio/fir_filter_factory_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -44,189 +54,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("fir_filter_factory_gn")
diff --git third_party/libwebrtc/common_audio/fir_filter_gn/moz.build third_party/libwebrtc/common_audio/fir_filter_gn/moz.build
index 067128609c1d..cdd143bb0930 100644
--- third_party/libwebrtc/common_audio/fir_filter_gn/moz.build
+++ third_party/libwebrtc/common_audio/fir_filter_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("fir_filter_gn")
diff --git third_party/libwebrtc/common_audio/sinc_resampler_gn/moz.build third_party/libwebrtc/common_audio/sinc_resampler_gn/moz.build
index 8649a26e7f60..42f1f8e5b55b 100644
--- third_party/libwebrtc/common_audio/sinc_resampler_gn/moz.build
+++ third_party/libwebrtc/common_audio/sinc_resampler_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,122 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -164,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("sinc_resampler_gn")
diff --git third_party/libwebrtc/common_audio/third_party/ooura/fft_size_128_gn/moz.build third_party/libwebrtc/common_audio/third_party/ooura/fft_size_128_gn/moz.build
index daeab1ffae94..df178bf850cf 100644
--- third_party/libwebrtc/common_audio/third_party/ooura/fft_size_128_gn/moz.build
+++ third_party/libwebrtc/common_audio/third_party/ooura/fft_size_128_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,101 +53,7 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
@@ -148,128 +64,42 @@ if CONFIG["TARGET_CPU"] == "aarch64":
         "/third_party/libwebrtc/common_audio/third_party/ooura/fft_size_128/ooura_fft_neon.cc"
     ]
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
-    UNIFIED_SOURCES += [
-        "/third_party/libwebrtc/common_audio/third_party/ooura/fft_size_128/ooura_fft_neon.cc"
-    ]
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
 
     UNIFIED_SOURCES += [
         "/third_party/libwebrtc/common_audio/third_party/ooura/fft_size_128/ooura_fft_mips.cc"
     ]
 
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-    UNIFIED_SOURCES += [
-        "/third_party/libwebrtc/common_audio/third_party/ooura/fft_size_128/ooura_fft_sse2.cc"
-    ]
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-    UNIFIED_SOURCES += [
-        "/third_party/libwebrtc/common_audio/third_party/ooura/fft_size_128/ooura_fft_sse2.cc"
-    ]
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2",
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    CXXFLAGS += [
-        "-msse2"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin" and CONFIG["TARGET_CPU"] == "x86_64":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
+    UNIFIED_SOURCES += [
+        "/third_party/libwebrtc/common_audio/third_party/ooura/fft_size_128/ooura_fft_sse2.cc"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+if CONFIG["TARGET_CPU"] == "x86_64":
 
     CXXFLAGS += [
-        "-msse2",
         "-msse2"
     ]
 
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
+    UNIFIED_SOURCES += [
+        "/third_party/libwebrtc/common_audio/third_party/ooura/fft_size_128/ooura_fft_sse2.cc"
     ]
 
-    DEFINES["_GNU_SOURCE"] = True
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-if CONFIG["OS_TARGET"] == "OpenBSD" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    CXXFLAGS += [
-        "-msse2"
-    ]
+    DEFINES["USE_X11"] = "1"
 
 Library("fft_size_128_gn")
diff --git third_party/libwebrtc/common_audio/third_party/ooura/fft_size_256_gn/moz.build third_party/libwebrtc/common_audio/third_party/ooura/fft_size_256_gn/moz.build
index 157b77da7490..5d769a1bf8ce 100644
--- third_party/libwebrtc/common_audio/third_party/ooura/fft_size_256_gn/moz.build
+++ third_party/libwebrtc/common_audio/third_party/ooura/fft_size_256_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,174 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("fft_size_256_gn")
diff --git third_party/libwebrtc/common_audio/third_party/spl_sqrt_floor/spl_sqrt_floor_gn/moz.build third_party/libwebrtc/common_audio/third_party/spl_sqrt_floor/spl_sqrt_floor_gn/moz.build
index 3acc048e7b55..7a1a664ccd76 100644
--- third_party/libwebrtc/common_audio/third_party/spl_sqrt_floor/spl_sqrt_floor_gn/moz.build
+++ third_party/libwebrtc/common_audio/third_party/spl_sqrt_floor/spl_sqrt_floor_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,119 +49,21 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    UNIFIED_SOURCES += [
-        "/third_party/libwebrtc/common_audio/third_party/spl_sqrt_floor/spl_sqrt_floor.c"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    UNIFIED_SOURCES += [
-        "/third_party/libwebrtc/common_audio/third_party/spl_sqrt_floor/spl_sqrt_floor.c"
-    ]
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    UNIFIED_SOURCES += [
-        "/third_party/libwebrtc/common_audio/third_party/spl_sqrt_floor/spl_sqrt_floor.c"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
-    SOURCES += [
-        "/third_party/libwebrtc/common_audio/third_party/spl_sqrt_floor/spl_sqrt_floor_arm.S"
+    UNIFIED_SOURCES += [
+        "/third_party/libwebrtc/common_audio/third_party/spl_sqrt_floor/spl_sqrt_floor.c"
     ]
 
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
 
     UNIFIED_SOURCES += [
         "/third_party/libwebrtc/common_audio/third_party/spl_sqrt_floor/spl_sqrt_floor_mips.c"
@@ -159,8 +71,6 @@ if CONFIG["TARGET_CPU"] == "mips32":
 
 if CONFIG["TARGET_CPU"] == "mips64":
 
-    DEFINES["_GNU_SOURCE"] = True
-
     UNIFIED_SOURCES += [
         "/third_party/libwebrtc/common_audio/third_party/spl_sqrt_floor/spl_sqrt_floor.c"
     ]
@@ -171,102 +81,34 @@ if CONFIG["TARGET_CPU"] == "ppc64":
         "/third_party/libwebrtc/common_audio/third_party/spl_sqrt_floor/spl_sqrt_floor.c"
     ]
 
-if CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "aarch64":
+if CONFIG["TARGET_CPU"] == "riscv64":
 
     UNIFIED_SOURCES += [
         "/third_party/libwebrtc/common_audio/third_party/spl_sqrt_floor/spl_sqrt_floor.c"
     ]
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
+if CONFIG["TARGET_CPU"] == "x86":
 
     CFLAGS += [
         "-msse2"
     ]
 
-    UNIFIED_SOURCES += [
-        "/third_party/libwebrtc/common_audio/third_party/spl_sqrt_floor/spl_sqrt_floor.c"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    UNIFIED_SOURCES += [
-        "/third_party/libwebrtc/common_audio/third_party/spl_sqrt_floor/spl_sqrt_floor.c"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-    UNIFIED_SOURCES += [
-        "/third_party/libwebrtc/common_audio/third_party/spl_sqrt_floor/spl_sqrt_floor.c"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "riscv64":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
     UNIFIED_SOURCES += [
         "/third_party/libwebrtc/common_audio/third_party/spl_sqrt_floor/spl_sqrt_floor.c"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    CFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
     UNIFIED_SOURCES += [
         "/third_party/libwebrtc/common_audio/third_party/spl_sqrt_floor/spl_sqrt_floor.c"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
-
-    UNIFIED_SOURCES += [
-        "/third_party/libwebrtc/common_audio/third_party/spl_sqrt_floor/spl_sqrt_floor.c"
-    ]
+    DEFINES["USE_X11"] = "1"
 
 Library("spl_sqrt_floor_gn")
diff --git third_party/libwebrtc/common_video/common_video_gn/moz.build third_party/libwebrtc/common_video/common_video_gn/moz.build
index e1d4464ae3bc..e671bcd86cbb 100644
--- third_party/libwebrtc/common_video/common_video_gn/moz.build
+++ third_party/libwebrtc/common_video/common_video_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -55,185 +65,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("common_video_gn")
diff --git third_party/libwebrtc/common_video/corruption_detection_converters_gn/moz.build third_party/libwebrtc/common_video/corruption_detection_converters_gn/moz.build
index 7903c24d64fc..dbdf5ba50bdb 100644
--- third_party/libwebrtc/common_video/corruption_detection_converters_gn/moz.build
+++ third_party/libwebrtc/common_video/corruption_detection_converters_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("corruption_detection_converters_gn")
diff --git third_party/libwebrtc/common_video/corruption_detection_message_gn/moz.build third_party/libwebrtc/common_video/corruption_detection_message_gn/moz.build
index 686c5ffbad4a..07df7c46df63 100644
--- third_party/libwebrtc/common_video/corruption_detection_message_gn/moz.build
+++ third_party/libwebrtc/common_video/corruption_detection_message_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,111 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -153,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("corruption_detection_message_gn")
diff --git third_party/libwebrtc/common_video/corruption_score_calculator_gn/moz.build third_party/libwebrtc/common_video/corruption_score_calculator_gn/moz.build
index 324373cedded..2a57b7d1373e 100644
--- third_party/libwebrtc/common_video/corruption_score_calculator_gn/moz.build
+++ third_party/libwebrtc/common_video/corruption_score_calculator_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,118 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -160,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("corruption_score_calculator_gn")
diff --git third_party/libwebrtc/common_video/frame_counts_gn/moz.build third_party/libwebrtc/common_video/frame_counts_gn/moz.build
index f840eae9028e..8fa780c107a2 100644
--- third_party/libwebrtc/common_video/frame_counts_gn/moz.build
+++ third_party/libwebrtc/common_video/frame_counts_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("frame_counts_gn")
diff --git third_party/libwebrtc/common_video/frame_instrumentation_data_gn/moz.build third_party/libwebrtc/common_video/frame_instrumentation_data_gn/moz.build
index 19cf51b9b1d8..c397211c2bc0 100644
--- third_party/libwebrtc/common_video/frame_instrumentation_data_gn/moz.build
+++ third_party/libwebrtc/common_video/frame_instrumentation_data_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("frame_instrumentation_data_gn")
diff --git third_party/libwebrtc/common_video/generic_frame_descriptor/generic_frame_descriptor_gn/moz.build third_party/libwebrtc/common_video/generic_frame_descriptor/generic_frame_descriptor_gn/moz.build
index a5877debe7a8..9ca4b22bfc80 100644
--- third_party/libwebrtc/common_video/generic_frame_descriptor/generic_frame_descriptor_gn/moz.build
+++ third_party/libwebrtc/common_video/generic_frame_descriptor/generic_frame_descriptor_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("generic_frame_descriptor_gn")
diff --git third_party/libwebrtc/dcsctp_gn/moz.build third_party/libwebrtc/dcsctp_gn/moz.build
index 81c5b82f4dcd..f23bf1262cee 100644
--- third_party/libwebrtc/dcsctp_gn/moz.build
+++ third_party/libwebrtc/dcsctp_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,118 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -160,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("dcsctp_gn")
diff --git third_party/libwebrtc/experiments/registered_field_trials_gn/moz.build third_party/libwebrtc/experiments/registered_field_trials_gn/moz.build
index 9392f8ab7ce1..2fe7c39ca455 100644
--- third_party/libwebrtc/experiments/registered_field_trials_gn/moz.build
+++ third_party/libwebrtc/experiments/registered_field_trials_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("registered_field_trials_gn")
diff --git third_party/libwebrtc/experiments/registered_field_trials_header_gn/moz.build third_party/libwebrtc/experiments/registered_field_trials_header_gn/moz.build
index 6c29dea76a50..3ae54a950c46 100644
--- third_party/libwebrtc/experiments/registered_field_trials_header_gn/moz.build
+++ third_party/libwebrtc/experiments/registered_field_trials_header_gn/moz.build
@@ -31,9 +31,4 @@ LOCAL_INCLUDES += [
     "/tools/profiler/public"
 ]
 
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["UNICODE"] = True
-    DEFINES["_UNICODE"] = True
-
 Library("registered_field_trials_header_gn")
diff --git third_party/libwebrtc/logging/rtc_event_audio_gn/moz.build third_party/libwebrtc/logging/rtc_event_audio_gn/moz.build
index 10e20ecba098..dfcd49a1aa57 100644
--- third_party/libwebrtc/logging/rtc_event_audio_gn/moz.build
+++ third_party/libwebrtc/logging/rtc_event_audio_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -47,185 +57,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("rtc_event_audio_gn")
diff --git third_party/libwebrtc/logging/rtc_event_bwe_gn/moz.build third_party/libwebrtc/logging/rtc_event_bwe_gn/moz.build
index 8f8c1c86a14c..fd638a0aef5e 100644
--- third_party/libwebrtc/logging/rtc_event_bwe_gn/moz.build
+++ third_party/libwebrtc/logging/rtc_event_bwe_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -48,185 +58,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("rtc_event_bwe_gn")
diff --git third_party/libwebrtc/logging/rtc_event_field_gn/moz.build third_party/libwebrtc/logging/rtc_event_field_gn/moz.build
index db8a0c7723d9..ad874c3b3c02 100644
--- third_party/libwebrtc/logging/rtc_event_field_gn/moz.build
+++ third_party/libwebrtc/logging/rtc_event_field_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -46,185 +56,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("rtc_event_field_gn")
diff --git third_party/libwebrtc/logging/rtc_event_log_parse_status_gn/moz.build third_party/libwebrtc/logging/rtc_event_log_parse_status_gn/moz.build
index c5f090ad669f..ec19d27b98d3 100644
--- third_party/libwebrtc/logging/rtc_event_log_parse_status_gn/moz.build
+++ third_party/libwebrtc/logging/rtc_event_log_parse_status_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,111 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -153,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("rtc_event_log_parse_status_gn")
diff --git third_party/libwebrtc/logging/rtc_event_number_encodings_gn/moz.build third_party/libwebrtc/logging/rtc_event_number_encodings_gn/moz.build
index ae770cf7c778..8d6d58d64f21 100644
--- third_party/libwebrtc/logging/rtc_event_number_encodings_gn/moz.build
+++ third_party/libwebrtc/logging/rtc_event_number_encodings_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -45,178 +55,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("rtc_event_number_encodings_gn")
diff --git third_party/libwebrtc/logging/rtc_event_pacing_gn/moz.build third_party/libwebrtc/logging/rtc_event_pacing_gn/moz.build
index 080549171c71..610ffce77e9d 100644
--- third_party/libwebrtc/logging/rtc_event_pacing_gn/moz.build
+++ third_party/libwebrtc/logging/rtc_event_pacing_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("rtc_event_pacing_gn")
diff --git third_party/libwebrtc/logging/rtc_event_rtp_rtcp_gn/moz.build third_party/libwebrtc/logging/rtc_event_rtp_rtcp_gn/moz.build
index 953ae5151ce4..0d639a2aa189 100644
--- third_party/libwebrtc/logging/rtc_event_rtp_rtcp_gn/moz.build
+++ third_party/libwebrtc/logging/rtc_event_rtp_rtcp_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -46,189 +56,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("rtc_event_rtp_rtcp_gn")
diff --git third_party/libwebrtc/logging/rtc_event_video_gn/moz.build third_party/libwebrtc/logging/rtc_event_video_gn/moz.build
index 0c31614317c2..69e0987881f7 100644
--- third_party/libwebrtc/logging/rtc_event_video_gn/moz.build
+++ third_party/libwebrtc/logging/rtc_event_video_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -44,185 +54,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("rtc_event_video_gn")
diff --git third_party/libwebrtc/logging/rtc_stream_config_gn/moz.build third_party/libwebrtc/logging/rtc_stream_config_gn/moz.build
index dbe85beeb123..7275caccfcea 100644
--- third_party/libwebrtc/logging/rtc_stream_config_gn/moz.build
+++ third_party/libwebrtc/logging/rtc_stream_config_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("rtc_stream_config_gn")
diff --git third_party/libwebrtc/media/adapted_video_track_source_gn/moz.build third_party/libwebrtc/media/adapted_video_track_source_gn/moz.build
index 84ff9891679e..5b015ab1c46f 100644
--- third_party/libwebrtc/media/adapted_video_track_source_gn/moz.build
+++ third_party/libwebrtc/media/adapted_video_track_source_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,118 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -160,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("adapted_video_track_source_gn")
diff --git third_party/libwebrtc/media/audio_source_gn/moz.build third_party/libwebrtc/media/audio_source_gn/moz.build
index 15a7fff97cb4..b87ac1d96da7 100644
--- third_party/libwebrtc/media/audio_source_gn/moz.build
+++ third_party/libwebrtc/media/audio_source_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("audio_source_gn")
diff --git third_party/libwebrtc/media/codec_gn/moz.build third_party/libwebrtc/media/codec_gn/moz.build
index 1d9dcc538de5..7dbf25e2eebc 100644
--- third_party/libwebrtc/media/codec_gn/moz.build
+++ third_party/libwebrtc/media/codec_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -44,185 +54,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("codec_gn")
diff --git third_party/libwebrtc/media/media_channel_gn/moz.build third_party/libwebrtc/media/media_channel_gn/moz.build
index 9a8b4ded79f2..4ed55e34a9cc 100644
--- third_party/libwebrtc/media/media_channel_gn/moz.build
+++ third_party/libwebrtc/media/media_channel_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,123 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -165,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("media_channel_gn")
diff --git third_party/libwebrtc/media/media_channel_impl_gn/moz.build third_party/libwebrtc/media/media_channel_impl_gn/moz.build
index c42d7c65492f..c5ecc3fe88f5 100644
--- third_party/libwebrtc/media/media_channel_impl_gn/moz.build
+++ third_party/libwebrtc/media/media_channel_impl_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("media_channel_impl_gn")
diff --git third_party/libwebrtc/media/media_constants_gn/moz.build third_party/libwebrtc/media/media_constants_gn/moz.build
index 9338f3c0f5d3..42b815c8f371 100644
--- third_party/libwebrtc/media/media_constants_gn/moz.build
+++ third_party/libwebrtc/media/media_constants_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,174 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("media_constants_gn")
diff --git third_party/libwebrtc/media/media_engine_gn/moz.build third_party/libwebrtc/media/media_engine_gn/moz.build
index d043267dbae5..49a627162740 100644
--- third_party/libwebrtc/media/media_engine_gn/moz.build
+++ third_party/libwebrtc/media/media_engine_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,123 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -165,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("media_engine_gn")
diff --git third_party/libwebrtc/media/rid_description_gn/moz.build third_party/libwebrtc/media/rid_description_gn/moz.build
index d564fc86c266..0d0f8a0800d6 100644
--- third_party/libwebrtc/media/rid_description_gn/moz.build
+++ third_party/libwebrtc/media/rid_description_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,174 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("rid_description_gn")
diff --git third_party/libwebrtc/media/rtc_audio_video_gn/moz.build third_party/libwebrtc/media/rtc_audio_video_gn/moz.build
index e13dc1a441ad..92aaee0e9b21 100644
--- third_party/libwebrtc/media/rtc_audio_video_gn/moz.build
+++ third_party/libwebrtc/media/rtc_audio_video_gn/moz.build
@@ -13,11 +13,21 @@ DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["HAVE_WEBRTC_VIDEO"] = True
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -45,128 +55,23 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "ole32",
-        "oleaut32",
-        "secur32",
-        "strmiids",
-        "user32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
+    DEFINES["WEBRTC_USE_PIPEWIRE"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
+    LOCAL_INCLUDES += [
+        "/third_party/pipewire/"
     ]
 
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
     DEFINES["WEBRTC_USE_PIPEWIRE"] = True
-    DEFINES["_GNU_SOURCE"] = True
 
     LOCAL_INCLUDES += [
         "/third_party/pipewire/"
@@ -175,7 +80,6 @@ if CONFIG["TARGET_CPU"] == "mips32":
 if CONFIG["TARGET_CPU"] == "mips64":
 
     DEFINES["WEBRTC_USE_PIPEWIRE"] = True
-    DEFINES["_GNU_SOURCE"] = True
 
     LOCAL_INCLUDES += [
         "/third_party/pipewire/"
@@ -183,86 +87,28 @@ if CONFIG["TARGET_CPU"] == "mips64":
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["WEBRTC_USE_PIPEWIRE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-    LOCAL_INCLUDES += [
-        "/third_party/pipewire/"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
     DEFINES["WEBRTC_USE_PIPEWIRE"] = True
-    DEFINES["_GNU_SOURCE"] = True
 
     LOCAL_INCLUDES += [
         "/third_party/pipewire/"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
     DEFINES["WEBRTC_USE_PIPEWIRE"] = True
-    DEFINES["_GNU_SOURCE"] = True
 
     LOCAL_INCLUDES += [
         "/third_party/pipewire/"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_USE_PIPEWIRE"] = True
-    DEFINES["_GNU_SOURCE"] = True
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    LOCAL_INCLUDES += [
-        "/third_party/pipewire/"
-    ]
+    DEFINES["USE_X11"] = "1"
 
 Library("rtc_audio_video_gn")
diff --git third_party/libwebrtc/media/rtc_internal_video_codecs_gn/moz.build third_party/libwebrtc/media/rtc_internal_video_codecs_gn/moz.build
index ba17a19c4b04..305dbf9d0b33 100644
--- third_party/libwebrtc/media/rtc_internal_video_codecs_gn/moz.build
+++ third_party/libwebrtc/media/rtc_internal_video_codecs_gn/moz.build
@@ -13,11 +13,21 @@ DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
 DEFINES["RTC_USE_LIBAOM_AV1_ENCODER"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -44,190 +54,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("rtc_internal_video_codecs_gn")
diff --git third_party/libwebrtc/media/rtc_media_base_gn/moz.build third_party/libwebrtc/media/rtc_media_base_gn/moz.build
index 58997370b876..d2aa6d298666 100644
--- third_party/libwebrtc/media/rtc_media_base_gn/moz.build
+++ third_party/libwebrtc/media/rtc_media_base_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,123 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -165,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("rtc_media_base_gn")
diff --git third_party/libwebrtc/media/rtc_media_config_gn/moz.build third_party/libwebrtc/media/rtc_media_config_gn/moz.build
index 2cfb8f933687..b6fc3bc4a277 100644
--- third_party/libwebrtc/media/rtc_media_config_gn/moz.build
+++ third_party/libwebrtc/media/rtc_media_config_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("rtc_media_config_gn")
diff --git third_party/libwebrtc/media/rtc_media_gn/moz.build third_party/libwebrtc/media/rtc_media_gn/moz.build
index 5805e451299b..330f44f0cd37 100644
--- third_party/libwebrtc/media/rtc_media_gn/moz.build
+++ third_party/libwebrtc/media/rtc_media_gn/moz.build
@@ -13,11 +13,21 @@ DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["HAVE_WEBRTC_VIDEO"] = True
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -40,127 +50,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "ole32",
-        "oleaut32",
-        "secur32",
-        "strmiids",
-        "user32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -170,50 +70,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("rtc_media_gn")
diff --git third_party/libwebrtc/media/rtc_sdp_video_format_utils_gn/moz.build third_party/libwebrtc/media/rtc_sdp_video_format_utils_gn/moz.build
index db2cc89a041f..c8c81bc3717c 100644
--- third_party/libwebrtc/media/rtc_sdp_video_format_utils_gn/moz.build
+++ third_party/libwebrtc/media/rtc_sdp_video_format_utils_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("rtc_sdp_video_format_utils_gn")
diff --git third_party/libwebrtc/media/rtc_simulcast_encoder_adapter_gn/moz.build third_party/libwebrtc/media/rtc_simulcast_encoder_adapter_gn/moz.build
index 4fe267a97b64..a3e9fb2c96da 100644
--- third_party/libwebrtc/media/rtc_simulcast_encoder_adapter_gn/moz.build
+++ third_party/libwebrtc/media/rtc_simulcast_encoder_adapter_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,190 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("rtc_simulcast_encoder_adapter_gn")
diff --git third_party/libwebrtc/media/rtp_utils_gn/moz.build third_party/libwebrtc/media/rtp_utils_gn/moz.build
index 852af5860851..4f59eac0f2d3 100644
--- third_party/libwebrtc/media/rtp_utils_gn/moz.build
+++ third_party/libwebrtc/media/rtp_utils_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("rtp_utils_gn")
diff --git third_party/libwebrtc/media/stream_params_gn/moz.build third_party/libwebrtc/media/stream_params_gn/moz.build
index 19a47f719a09..258453ae0a51 100644
--- third_party/libwebrtc/media/stream_params_gn/moz.build
+++ third_party/libwebrtc/media/stream_params_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("stream_params_gn")
diff --git third_party/libwebrtc/media/video_adapter_gn/moz.build third_party/libwebrtc/media/video_adapter_gn/moz.build
index c64baa9d03cc..aa452bca0c66 100644
--- third_party/libwebrtc/media/video_adapter_gn/moz.build
+++ third_party/libwebrtc/media/video_adapter_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("video_adapter_gn")
diff --git third_party/libwebrtc/media/video_broadcaster_gn/moz.build third_party/libwebrtc/media/video_broadcaster_gn/moz.build
index 680eace5143b..02012646651c 100644
--- third_party/libwebrtc/media/video_broadcaster_gn/moz.build
+++ third_party/libwebrtc/media/video_broadcaster_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("video_broadcaster_gn")
diff --git third_party/libwebrtc/media/video_common_gn/moz.build third_party/libwebrtc/media/video_common_gn/moz.build
index c25c1a0db303..f5610153289e 100644
--- third_party/libwebrtc/media/video_common_gn/moz.build
+++ third_party/libwebrtc/media/video_common_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("video_common_gn")
diff --git third_party/libwebrtc/media/video_source_base_gn/moz.build third_party/libwebrtc/media/video_source_base_gn/moz.build
index cd9c32d0b0f0..92b6e63987e1 100644
--- third_party/libwebrtc/media/video_source_base_gn/moz.build
+++ third_party/libwebrtc/media/video_source_base_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("video_source_base_gn")
diff --git third_party/libwebrtc/modules/async_audio_processing/async_audio_processing_gn/moz.build third_party/libwebrtc/modules/async_audio_processing/async_audio_processing_gn/moz.build
index fb495956fbeb..7c9e29ac867d 100644
--- third_party/libwebrtc/modules/async_audio_processing/async_audio_processing_gn/moz.build
+++ third_party/libwebrtc/modules/async_audio_processing/async_audio_processing_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("async_audio_processing_gn")
diff --git third_party/libwebrtc/modules/audio_coding/audio_coding_gn/moz.build third_party/libwebrtc/modules/audio_coding/audio_coding_gn/moz.build
index aa9ce2702b25..92a43b68ff69 100644
--- third_party/libwebrtc/modules/audio_coding/audio_coding_gn/moz.build
+++ third_party/libwebrtc/modules/audio_coding/audio_coding_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -46,189 +56,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("audio_coding_gn")
diff --git third_party/libwebrtc/modules/audio_coding/audio_coding_module_typedefs_gn/moz.build third_party/libwebrtc/modules/audio_coding/audio_coding_module_typedefs_gn/moz.build
index f907a7321765..8117aba2db95 100644
--- third_party/libwebrtc/modules/audio_coding/audio_coding_module_typedefs_gn/moz.build
+++ third_party/libwebrtc/modules/audio_coding/audio_coding_module_typedefs_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("audio_coding_module_typedefs_gn")
diff --git third_party/libwebrtc/modules/audio_coding/audio_coding_opus_common_gn/moz.build third_party/libwebrtc/modules/audio_coding/audio_coding_opus_common_gn/moz.build
index 0fba540a063d..553c271980fd 100644
--- third_party/libwebrtc/modules/audio_coding/audio_coding_opus_common_gn/moz.build
+++ third_party/libwebrtc/modules/audio_coding/audio_coding_opus_common_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("audio_coding_opus_common_gn")
diff --git third_party/libwebrtc/modules/audio_coding/audio_encoder_cng_gn/moz.build third_party/libwebrtc/modules/audio_coding/audio_encoder_cng_gn/moz.build
index 1626d8cd6f64..8c252434b483 100644
--- third_party/libwebrtc/modules/audio_coding/audio_encoder_cng_gn/moz.build
+++ third_party/libwebrtc/modules/audio_coding/audio_encoder_cng_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,189 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("audio_encoder_cng_gn")
diff --git third_party/libwebrtc/modules/audio_coding/audio_network_adaptor_config_gn/moz.build third_party/libwebrtc/modules/audio_coding/audio_network_adaptor_config_gn/moz.build
index cd665a5454ac..ae2f6016b493 100644
--- third_party/libwebrtc/modules/audio_coding/audio_network_adaptor_config_gn/moz.build
+++ third_party/libwebrtc/modules/audio_coding/audio_network_adaptor_config_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,174 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("audio_network_adaptor_config_gn")
diff --git third_party/libwebrtc/modules/audio_coding/audio_network_adaptor_gn/moz.build third_party/libwebrtc/modules/audio_coding/audio_network_adaptor_gn/moz.build
index 735a5e0b91de..1e6a3e530957 100644
--- third_party/libwebrtc/modules/audio_coding/audio_network_adaptor_gn/moz.build
+++ third_party/libwebrtc/modules/audio_coding/audio_network_adaptor_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -53,189 +63,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("audio_network_adaptor_gn")
diff --git third_party/libwebrtc/modules/audio_coding/g711_c_gn/moz.build third_party/libwebrtc/modules/audio_coding/g711_c_gn/moz.build
index a207fdcb944c..462a299829d6 100644
--- third_party/libwebrtc/modules/audio_coding/g711_c_gn/moz.build
+++ third_party/libwebrtc/modules/audio_coding/g711_c_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,174 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("g711_c_gn")
diff --git third_party/libwebrtc/modules/audio_coding/g711_gn/moz.build third_party/libwebrtc/modules/audio_coding/g711_gn/moz.build
index f58ae048413e..66d68a72b99e 100644
--- third_party/libwebrtc/modules/audio_coding/g711_gn/moz.build
+++ third_party/libwebrtc/modules/audio_coding/g711_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -44,185 +54,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("g711_gn")
diff --git third_party/libwebrtc/modules/audio_coding/g722_c_gn/moz.build third_party/libwebrtc/modules/audio_coding/g722_c_gn/moz.build
index aec0fb9b5e2d..6750be70458a 100644
--- third_party/libwebrtc/modules/audio_coding/g722_c_gn/moz.build
+++ third_party/libwebrtc/modules/audio_coding/g722_c_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,174 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("g722_c_gn")
diff --git third_party/libwebrtc/modules/audio_coding/g722_gn/moz.build third_party/libwebrtc/modules/audio_coding/g722_gn/moz.build
index 7e6c4fa154fd..d3e60d5fe33f 100644
--- third_party/libwebrtc/modules/audio_coding/g722_gn/moz.build
+++ third_party/libwebrtc/modules/audio_coding/g722_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -44,185 +54,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("g722_gn")
diff --git third_party/libwebrtc/modules/audio_coding/ilbc_c_gn/moz.build third_party/libwebrtc/modules/audio_coding/ilbc_c_gn/moz.build
index f49ac18199ce..e60bb823350b 100644
--- third_party/libwebrtc/modules/audio_coding/ilbc_c_gn/moz.build
+++ third_party/libwebrtc/modules/audio_coding/ilbc_c_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -111,189 +121,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("ilbc_c_gn")
diff --git third_party/libwebrtc/modules/audio_coding/ilbc_gn/moz.build third_party/libwebrtc/modules/audio_coding/ilbc_gn/moz.build
index 269e69826899..6de0b38256a6 100644
--- third_party/libwebrtc/modules/audio_coding/ilbc_gn/moz.build
+++ third_party/libwebrtc/modules/audio_coding/ilbc_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -44,189 +54,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("ilbc_gn")
diff --git third_party/libwebrtc/modules/audio_coding/isac_bwinfo_gn/moz.build third_party/libwebrtc/modules/audio_coding/isac_bwinfo_gn/moz.build
index de83c14d7e82..79521f4db7b0 100644
--- third_party/libwebrtc/modules/audio_coding/isac_bwinfo_gn/moz.build
+++ third_party/libwebrtc/modules/audio_coding/isac_bwinfo_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("isac_bwinfo_gn")
diff --git third_party/libwebrtc/modules/audio_coding/isac_vad_gn/moz.build third_party/libwebrtc/modules/audio_coding/isac_vad_gn/moz.build
index 5fbc721158ac..b400fdf60066 100644
--- third_party/libwebrtc/modules/audio_coding/isac_vad_gn/moz.build
+++ third_party/libwebrtc/modules/audio_coding/isac_vad_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -46,174 +56,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("isac_vad_gn")
diff --git third_party/libwebrtc/modules/audio_coding/legacy_encoded_audio_frame_gn/moz.build third_party/libwebrtc/modules/audio_coding/legacy_encoded_audio_frame_gn/moz.build
index e4f0ed753ecd..8bd6903a7d66 100644
--- third_party/libwebrtc/modules/audio_coding/legacy_encoded_audio_frame_gn/moz.build
+++ third_party/libwebrtc/modules/audio_coding/legacy_encoded_audio_frame_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("legacy_encoded_audio_frame_gn")
diff --git third_party/libwebrtc/modules/audio_coding/neteq_gn/moz.build third_party/libwebrtc/modules/audio_coding/neteq_gn/moz.build
index 1044a2bde98e..782793ab5d60 100644
--- third_party/libwebrtc/modules/audio_coding/neteq_gn/moz.build
+++ third_party/libwebrtc/modules/audio_coding/neteq_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -78,189 +88,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("neteq_gn")
diff --git third_party/libwebrtc/modules/audio_coding/pcm16b_c_gn/moz.build third_party/libwebrtc/modules/audio_coding/pcm16b_c_gn/moz.build
index 790032c65ac6..7806fd65a153 100644
--- third_party/libwebrtc/modules/audio_coding/pcm16b_c_gn/moz.build
+++ third_party/libwebrtc/modules/audio_coding/pcm16b_c_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,174 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("pcm16b_c_gn")
diff --git third_party/libwebrtc/modules/audio_coding/pcm16b_gn/moz.build third_party/libwebrtc/modules/audio_coding/pcm16b_gn/moz.build
index 0bdd6ed6ba90..8d125a0cabdf 100644
--- third_party/libwebrtc/modules/audio_coding/pcm16b_gn/moz.build
+++ third_party/libwebrtc/modules/audio_coding/pcm16b_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -45,185 +55,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("pcm16b_gn")
diff --git third_party/libwebrtc/modules/audio_coding/red_gn/moz.build third_party/libwebrtc/modules/audio_coding/red_gn/moz.build
index d20eee83656c..714817b11aee 100644
--- third_party/libwebrtc/modules/audio_coding/red_gn/moz.build
+++ third_party/libwebrtc/modules/audio_coding/red_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,189 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("red_gn")
diff --git third_party/libwebrtc/modules/audio_coding/webrtc_cng_gn/moz.build third_party/libwebrtc/modules/audio_coding/webrtc_cng_gn/moz.build
index 0e2616b2a0a1..4ceb89920847 100644
--- third_party/libwebrtc/modules/audio_coding/webrtc_cng_gn/moz.build
+++ third_party/libwebrtc/modules/audio_coding/webrtc_cng_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,189 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("webrtc_cng_gn")
diff --git third_party/libwebrtc/modules/audio_coding/webrtc_multiopus_gn/moz.build third_party/libwebrtc/modules/audio_coding/webrtc_multiopus_gn/moz.build
index 34a982b76282..ddb346e675c4 100644
--- third_party/libwebrtc/modules/audio_coding/webrtc_multiopus_gn/moz.build
+++ third_party/libwebrtc/modules/audio_coding/webrtc_multiopus_gn/moz.build
@@ -12,14 +12,24 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
 DEFINES["WEBRTC_CODEC_ILBC"] = True
 DEFINES["WEBRTC_CODEC_OPUS"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
 DEFINES["WEBRTC_OPUS_SUPPORT_120MS_PTIME"] = "1"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -48,185 +58,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("webrtc_multiopus_gn")
diff --git third_party/libwebrtc/modules/audio_coding/webrtc_opus_gn/moz.build third_party/libwebrtc/modules/audio_coding/webrtc_opus_gn/moz.build
index 33f8d93af1be..a20d37b1ba53 100644
--- third_party/libwebrtc/modules/audio_coding/webrtc_opus_gn/moz.build
+++ third_party/libwebrtc/modules/audio_coding/webrtc_opus_gn/moz.build
@@ -12,14 +12,24 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
 DEFINES["WEBRTC_CODEC_ILBC"] = True
 DEFINES["WEBRTC_CODEC_OPUS"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
 DEFINES["WEBRTC_OPUS_SUPPORT_120MS_PTIME"] = "1"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -48,189 +58,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("webrtc_opus_gn")
diff --git third_party/libwebrtc/modules/audio_coding/webrtc_opus_wrapper_gn/moz.build third_party/libwebrtc/modules/audio_coding/webrtc_opus_wrapper_gn/moz.build
index 45ce2083a15b..91550740ea5f 100644
--- third_party/libwebrtc/modules/audio_coding/webrtc_opus_wrapper_gn/moz.build
+++ third_party/libwebrtc/modules/audio_coding/webrtc_opus_wrapper_gn/moz.build
@@ -12,14 +12,24 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
 DEFINES["WEBRTC_CODEC_ILBC"] = True
 DEFINES["WEBRTC_CODEC_OPUS"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
 DEFINES["WEBRTC_OPUS_SUPPORT_120MS_PTIME"] = "1"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -47,178 +57,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("webrtc_opus_wrapper_gn")
diff --git third_party/libwebrtc/modules/audio_device/audio_device_gn/moz.build third_party/libwebrtc/modules/audio_device/audio_device_gn/moz.build
index 6c2c91b00478..9f6439e12a20 100644
--- third_party/libwebrtc/modules/audio_device/audio_device_gn/moz.build
+++ third_party/libwebrtc/modules/audio_device/audio_device_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("audio_device_gn")
diff --git third_party/libwebrtc/modules/audio_device/audio_device_impl_gn/moz.build third_party/libwebrtc/modules/audio_device/audio_device_impl_gn/moz.build
index a482ce72de83..4c18f0f1626b 100644
--- third_party/libwebrtc/modules/audio_device/audio_device_impl_gn/moz.build
+++ third_party/libwebrtc/modules/audio_device/audio_device_impl_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("audio_device_impl_gn")
diff --git third_party/libwebrtc/modules/audio_mixer/audio_frame_manipulator_gn/moz.build third_party/libwebrtc/modules/audio_mixer/audio_frame_manipulator_gn/moz.build
index f26b5858d6a0..fdba74a45225 100644
--- third_party/libwebrtc/modules/audio_mixer/audio_frame_manipulator_gn/moz.build
+++ third_party/libwebrtc/modules/audio_mixer/audio_frame_manipulator_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,189 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("audio_frame_manipulator_gn")
diff --git third_party/libwebrtc/modules/audio_mixer/audio_mixer_impl_gn/moz.build third_party/libwebrtc/modules/audio_mixer/audio_mixer_impl_gn/moz.build
index b998e5cf3e3b..59099dd15033 100644
--- third_party/libwebrtc/modules/audio_mixer/audio_mixer_impl_gn/moz.build
+++ third_party/libwebrtc/modules/audio_mixer/audio_mixer_impl_gn/moz.build
@@ -12,12 +12,22 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
 DEFINES["WEBRTC_APM_DEBUG_DUMP"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -46,189 +56,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("audio_mixer_impl_gn")
diff --git third_party/libwebrtc/modules/audio_processing/aec3/adaptive_fir_filter_erl_gn/moz.build third_party/libwebrtc/modules/audio_processing/aec3/adaptive_fir_filter_erl_gn/moz.build
index 3643adf3d9cd..7c2636f7557e 100644
--- third_party/libwebrtc/modules/audio_processing/aec3/adaptive_fir_filter_erl_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/aec3/adaptive_fir_filter_erl_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,111 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -153,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("adaptive_fir_filter_erl_gn")
diff --git third_party/libwebrtc/modules/audio_processing/aec3/adaptive_fir_filter_gn/moz.build third_party/libwebrtc/modules/audio_processing/aec3/adaptive_fir_filter_gn/moz.build
index cac619740bc3..515d332ff43c 100644
--- third_party/libwebrtc/modules/audio_processing/aec3/adaptive_fir_filter_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/aec3/adaptive_fir_filter_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,122 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -164,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("adaptive_fir_filter_gn")
diff --git third_party/libwebrtc/modules/audio_processing/aec3/aec3_avx2_gn/moz.build third_party/libwebrtc/modules/audio_processing/aec3/aec3_avx2_gn/moz.build
index d66a64d70a82..39583fda02e7 100644
--- third_party/libwebrtc/modules/audio_processing/aec3/aec3_avx2_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/aec3/aec3_avx2_gn/moz.build
@@ -17,13 +17,23 @@ CXXFLAGS += [
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
 DEFINES["WEBRTC_APM_DEBUG_DUMP"] = "1"
+DEFINES["WEBRTC_BSD"] = True
 DEFINES["WEBRTC_ENABLE_AVX2"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -54,137 +64,16 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
     DEFINES["_DEBUG"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
+if CONFIG["TARGET_CPU"] == "x86":
 
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+    DEFINES["USE_X11"] = "1"
 
 Library("aec3_avx2_gn")
diff --git third_party/libwebrtc/modules/audio_processing/aec3/aec3_common_gn/moz.build third_party/libwebrtc/modules/audio_processing/aec3/aec3_common_gn/moz.build
index c5ec3c1cd9b6..0f5ce6b89859 100644
--- third_party/libwebrtc/modules/audio_processing/aec3/aec3_common_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/aec3/aec3_common_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("aec3_common_gn")
diff --git third_party/libwebrtc/modules/audio_processing/aec3/aec3_fft_gn/moz.build third_party/libwebrtc/modules/audio_processing/aec3/aec3_fft_gn/moz.build
index a92b7893981e..a2fb0ebe9dd6 100644
--- third_party/libwebrtc/modules/audio_processing/aec3/aec3_fft_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/aec3/aec3_fft_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,122 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -164,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("aec3_fft_gn")
diff --git third_party/libwebrtc/modules/audio_processing/aec3/aec3_gn/moz.build third_party/libwebrtc/modules/audio_processing/aec3/aec3_gn/moz.build
index 76eb9b374afd..b163dd25704f 100644
--- third_party/libwebrtc/modules/audio_processing/aec3/aec3_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/aec3/aec3_gn/moz.build
@@ -12,12 +12,22 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
 DEFINES["WEBRTC_APM_DEBUG_DUMP"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -100,189 +110,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("aec3_gn")
diff --git third_party/libwebrtc/modules/audio_processing/aec3/fft_data_gn/moz.build third_party/libwebrtc/modules/audio_processing/aec3/fft_data_gn/moz.build
index bf6f884d4657..a382baf22973 100644
--- third_party/libwebrtc/modules/audio_processing/aec3/fft_data_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/aec3/fft_data_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,111 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -153,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("fft_data_gn")
diff --git third_party/libwebrtc/modules/audio_processing/aec3/matched_filter_gn/moz.build third_party/libwebrtc/modules/audio_processing/aec3/matched_filter_gn/moz.build
index 3e0c262d8943..a8f024d8b966 100644
--- third_party/libwebrtc/modules/audio_processing/aec3/matched_filter_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/aec3/matched_filter_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,111 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -153,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("matched_filter_gn")
diff --git third_party/libwebrtc/modules/audio_processing/aec3/render_buffer_gn/moz.build third_party/libwebrtc/modules/audio_processing/aec3/render_buffer_gn/moz.build
index 5cbc1135eb3f..6e7a8c273a3a 100644
--- third_party/libwebrtc/modules/audio_processing/aec3/render_buffer_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/aec3/render_buffer_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,111 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -153,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("render_buffer_gn")
diff --git third_party/libwebrtc/modules/audio_processing/aec3/vector_math_gn/moz.build third_party/libwebrtc/modules/audio_processing/aec3/vector_math_gn/moz.build
index c12496c562d4..871969c6d25b 100644
--- third_party/libwebrtc/modules/audio_processing/aec3/vector_math_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/aec3/vector_math_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,111 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -153,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("vector_math_gn")
diff --git third_party/libwebrtc/modules/audio_processing/aec_dump/aec_dump_gn/moz.build third_party/libwebrtc/modules/audio_processing/aec_dump/aec_dump_gn/moz.build
index 454823f408ba..2655562bb5cf 100644
--- third_party/libwebrtc/modules/audio_processing/aec_dump/aec_dump_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/aec_dump/aec_dump_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,118 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -160,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("aec_dump_gn")
diff --git third_party/libwebrtc/modules/audio_processing/aec_dump/null_aec_dump_factory_gn/moz.build third_party/libwebrtc/modules/audio_processing/aec_dump/null_aec_dump_factory_gn/moz.build
index 79c47a87bc96..573146ff0679 100644
--- third_party/libwebrtc/modules/audio_processing/aec_dump/null_aec_dump_factory_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/aec_dump/null_aec_dump_factory_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("null_aec_dump_factory_gn")
diff --git third_party/libwebrtc/modules/audio_processing/aec_dump_interface_gn/moz.build third_party/libwebrtc/modules/audio_processing/aec_dump_interface_gn/moz.build
index ba900c1f0128..9149108c4595 100644
--- third_party/libwebrtc/modules/audio_processing/aec_dump_interface_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/aec_dump_interface_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("aec_dump_interface_gn")
diff --git third_party/libwebrtc/modules/audio_processing/aecm/aecm_core_gn/moz.build third_party/libwebrtc/modules/audio_processing/aecm/aecm_core_gn/moz.build
index 576db07795fa..755e9b03e8de 100644
--- third_party/libwebrtc/modules/audio_processing/aecm/aecm_core_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/aecm/aecm_core_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -44,117 +54,7 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-    SOURCES += [
-        "/third_party/libwebrtc/modules/audio_processing/aecm/aecm_core_c.cc"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    SOURCES += [
-        "/third_party/libwebrtc/modules/audio_processing/aecm/aecm_core_c.cc"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    SOURCES += [
-        "/third_party/libwebrtc/modules/audio_processing/aecm/aecm_core_c.cc"
-    ]
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
-
-    SOURCES += [
-        "/third_party/libwebrtc/modules/audio_processing/aecm/aecm_core_c.cc"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
@@ -162,20 +62,7 @@ if CONFIG["TARGET_CPU"] == "aarch64":
     DEFINES["WEBRTC_HAS_NEON"] = True
 
     SOURCES += [
-        "/third_party/libwebrtc/modules/audio_processing/aecm/aecm_core_neon.cc"
-    ]
-
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
-    SOURCES += [
+        "/third_party/libwebrtc/modules/audio_processing/aecm/aecm_core_c.cc",
         "/third_party/libwebrtc/modules/audio_processing/aecm/aecm_core_neon.cc"
     ]
 
@@ -183,7 +70,6 @@ if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
 
     SOURCES += [
         "/third_party/libwebrtc/modules/audio_processing/aecm/aecm_core_mips.cc"
@@ -191,8 +77,6 @@ if CONFIG["TARGET_CPU"] == "mips32":
 
 if CONFIG["TARGET_CPU"] == "mips64":
 
-    DEFINES["_GNU_SOURCE"] = True
-
     SOURCES += [
         "/third_party/libwebrtc/modules/audio_processing/aecm/aecm_core_c.cc"
     ]
@@ -203,90 +87,34 @@ if CONFIG["TARGET_CPU"] == "ppc64":
         "/third_party/libwebrtc/modules/audio_processing/aecm/aecm_core_c.cc"
     ]
 
-if CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
-    CXXFLAGS += [
-        "-msse2"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-    SOURCES += [
-        "/third_party/libwebrtc/modules/audio_processing/aecm/aecm_core_c.cc"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-    SOURCES += [
-        "/third_party/libwebrtc/modules/audio_processing/aecm/aecm_core_c.cc"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "riscv64":
+if CONFIG["TARGET_CPU"] == "riscv64":
 
     SOURCES += [
         "/third_party/libwebrtc/modules/audio_processing/aecm/aecm_core_c.cc"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+if CONFIG["TARGET_CPU"] == "x86":
 
     CXXFLAGS += [
         "-msse2"
     ]
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
     SOURCES += [
         "/third_party/libwebrtc/modules/audio_processing/aecm/aecm_core_c.cc"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
     SOURCES += [
         "/third_party/libwebrtc/modules/audio_processing/aecm/aecm_core_c.cc"
     ]
 
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
+
+    DEFINES["USE_X11"] = "1"
+
 Library("aecm_core_gn")
diff --git third_party/libwebrtc/modules/audio_processing/agc/agc_gn/moz.build third_party/libwebrtc/modules/audio_processing/agc/agc_gn/moz.build
index e7becea28955..4c78e5c2960d 100644
--- third_party/libwebrtc/modules/audio_processing/agc/agc_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/agc/agc_gn/moz.build
@@ -12,12 +12,22 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
 DEFINES["WEBRTC_APM_DEBUG_DUMP"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -44,189 +54,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("agc_gn")
diff --git third_party/libwebrtc/modules/audio_processing/agc/gain_control_interface_gn/moz.build third_party/libwebrtc/modules/audio_processing/agc/gain_control_interface_gn/moz.build
index 53e1886cef10..f06860c00a16 100644
--- third_party/libwebrtc/modules/audio_processing/agc/gain_control_interface_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/agc/gain_control_interface_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("gain_control_interface_gn")
diff --git third_party/libwebrtc/modules/audio_processing/agc/legacy_agc_gn/moz.build third_party/libwebrtc/modules/audio_processing/agc/legacy_agc_gn/moz.build
index 887cc343cc7d..2793d66766bd 100644
--- third_party/libwebrtc/modules/audio_processing/agc/legacy_agc_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/agc/legacy_agc_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -44,189 +54,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("legacy_agc_gn")
diff --git third_party/libwebrtc/modules/audio_processing/agc/level_estimation_gn/moz.build third_party/libwebrtc/modules/audio_processing/agc/level_estimation_gn/moz.build
index 068bd7f772b6..046c4070fa47 100644
--- third_party/libwebrtc/modules/audio_processing/agc/level_estimation_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/agc/level_estimation_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -45,189 +55,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("level_estimation_gn")
diff --git third_party/libwebrtc/modules/audio_processing/agc2/adaptive_digital_gain_controller_gn/moz.build third_party/libwebrtc/modules/audio_processing/agc2/adaptive_digital_gain_controller_gn/moz.build
index a9128bc171d6..eb460b00414d 100644
--- third_party/libwebrtc/modules/audio_processing/agc2/adaptive_digital_gain_controller_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/agc2/adaptive_digital_gain_controller_gn/moz.build
@@ -12,12 +12,22 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
 DEFINES["WEBRTC_APM_DEBUG_DUMP"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -44,189 +54,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("adaptive_digital_gain_controller_gn")
diff --git third_party/libwebrtc/modules/audio_processing/agc2/biquad_filter_gn/moz.build third_party/libwebrtc/modules/audio_processing/agc2/biquad_filter_gn/moz.build
index b414bac082d8..bd88eec7a07a 100644
--- third_party/libwebrtc/modules/audio_processing/agc2/biquad_filter_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/agc2/biquad_filter_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("biquad_filter_gn")
diff --git third_party/libwebrtc/modules/audio_processing/agc2/clipping_predictor_gn/moz.build third_party/libwebrtc/modules/audio_processing/agc2/clipping_predictor_gn/moz.build
index 14b87b5cac6f..4d20e6b03b8e 100644
--- third_party/libwebrtc/modules/audio_processing/agc2/clipping_predictor_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/agc2/clipping_predictor_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -44,189 +54,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("clipping_predictor_gn")
diff --git third_party/libwebrtc/modules/audio_processing/agc2/common_gn/moz.build third_party/libwebrtc/modules/audio_processing/agc2/common_gn/moz.build
index 79ab80ab68a8..05ae05298254 100644
--- third_party/libwebrtc/modules/audio_processing/agc2/common_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/agc2/common_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("common_gn")
diff --git third_party/libwebrtc/modules/audio_processing/agc2/cpu_features_gn/moz.build third_party/libwebrtc/modules/audio_processing/agc2/cpu_features_gn/moz.build
index 15a4901cc9ea..39f104ad9b69 100644
--- third_party/libwebrtc/modules/audio_processing/agc2/cpu_features_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/agc2/cpu_features_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,189 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("cpu_features_gn")
diff --git third_party/libwebrtc/modules/audio_processing/agc2/fixed_digital_gn/moz.build third_party/libwebrtc/modules/audio_processing/agc2/fixed_digital_gn/moz.build
index dd306f3bb513..1fae78ba14c1 100644
--- third_party/libwebrtc/modules/audio_processing/agc2/fixed_digital_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/agc2/fixed_digital_gn/moz.build
@@ -12,12 +12,22 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
 DEFINES["WEBRTC_APM_DEBUG_DUMP"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -46,189 +56,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("fixed_digital_gn")
diff --git third_party/libwebrtc/modules/audio_processing/agc2/gain_applier_gn/moz.build third_party/libwebrtc/modules/audio_processing/agc2/gain_applier_gn/moz.build
index 9f49e828dd7b..8f2b17adb293 100644
--- third_party/libwebrtc/modules/audio_processing/agc2/gain_applier_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/agc2/gain_applier_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("gain_applier_gn")
diff --git third_party/libwebrtc/modules/audio_processing/agc2/gain_map_gn/moz.build third_party/libwebrtc/modules/audio_processing/agc2/gain_map_gn/moz.build
index fb4b57fed2bc..ba83eeafabc1 100644
--- third_party/libwebrtc/modules/audio_processing/agc2/gain_map_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/agc2/gain_map_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("gain_map_gn")
diff --git third_party/libwebrtc/modules/audio_processing/agc2/input_volume_controller_gn/moz.build third_party/libwebrtc/modules/audio_processing/agc2/input_volume_controller_gn/moz.build
index 1d885a88ee30..093b875ff189 100644
--- third_party/libwebrtc/modules/audio_processing/agc2/input_volume_controller_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/agc2/input_volume_controller_gn/moz.build
@@ -12,12 +12,22 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
 DEFINES["WEBRTC_APM_DEBUG_DUMP"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -45,189 +55,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("input_volume_controller_gn")
diff --git third_party/libwebrtc/modules/audio_processing/agc2/input_volume_stats_reporter_gn/moz.build third_party/libwebrtc/modules/audio_processing/agc2/input_volume_stats_reporter_gn/moz.build
index 5825d2c670b1..eb6e7f8d51b5 100644
--- third_party/libwebrtc/modules/audio_processing/agc2/input_volume_stats_reporter_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/agc2/input_volume_stats_reporter_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("input_volume_stats_reporter_gn")
diff --git third_party/libwebrtc/modules/audio_processing/agc2/noise_level_estimator_gn/moz.build third_party/libwebrtc/modules/audio_processing/agc2/noise_level_estimator_gn/moz.build
index c18a6769d7b3..a925b2e75863 100644
--- third_party/libwebrtc/modules/audio_processing/agc2/noise_level_estimator_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/agc2/noise_level_estimator_gn/moz.build
@@ -12,12 +12,22 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
 DEFINES["WEBRTC_APM_DEBUG_DUMP"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -44,189 +54,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("noise_level_estimator_gn")
diff --git third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_auto_correlation_gn/moz.build third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_auto_correlation_gn/moz.build
index 81389ceafa17..9087c6fb5602 100644
--- third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_auto_correlation_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_auto_correlation_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,189 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("rnn_vad_auto_correlation_gn")
diff --git third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_common_gn/moz.build third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_common_gn/moz.build
index 97a069e402f5..4d9a5646f72a 100644
--- third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_common_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_common_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,122 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -164,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("rnn_vad_common_gn")
diff --git third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_gn/moz.build third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_gn/moz.build
index 671e7abff297..9a40aa458651 100644
--- third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -44,189 +54,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("rnn_vad_gn")
diff --git third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_layers_gn/moz.build third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_layers_gn/moz.build
index 271469362fbd..88197b192f27 100644
--- third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_layers_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_layers_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -44,189 +54,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("rnn_vad_layers_gn")
diff --git third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_lp_residual_gn/moz.build third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_lp_residual_gn/moz.build
index ca0bed615c59..ad8dee8dce4b 100644
--- third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_lp_residual_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_lp_residual_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("rnn_vad_lp_residual_gn")
diff --git third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_pitch_gn/moz.build third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_pitch_gn/moz.build
index 5820353de9d1..94fa15002d81 100644
--- third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_pitch_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_pitch_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -44,189 +54,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("rnn_vad_pitch_gn")
diff --git third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_ring_buffer_gn/moz.build third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_ring_buffer_gn/moz.build
index 27fdd04949df..84916e6e5230 100644
--- third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_ring_buffer_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_ring_buffer_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,111 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -153,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("rnn_vad_ring_buffer_gn")
diff --git third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_sequence_buffer_gn/moz.build third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_sequence_buffer_gn/moz.build
index e42a389e6a3f..9cf2e39ee87a 100644
--- third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_sequence_buffer_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_sequence_buffer_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,111 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -153,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("rnn_vad_sequence_buffer_gn")
diff --git third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_spectral_features_gn/moz.build third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_spectral_features_gn/moz.build
index 0ff9b98abd77..78bc65830c8f 100644
--- third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_spectral_features_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_spectral_features_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -44,189 +54,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("rnn_vad_spectral_features_gn")
diff --git third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_symmetric_matrix_buffer_gn/moz.build third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_symmetric_matrix_buffer_gn/moz.build
index 9f5bb53ec07a..bb81f6000f01 100644
--- third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_symmetric_matrix_buffer_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_symmetric_matrix_buffer_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,111 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -153,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("rnn_vad_symmetric_matrix_buffer_gn")
diff --git third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/vector_math_avx2_gn/moz.build third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/vector_math_avx2_gn/moz.build
index 6495a53a3b70..50772fa28280 100644
--- third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/vector_math_avx2_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/vector_math_avx2_gn/moz.build
@@ -17,12 +17,22 @@ CXXFLAGS += [
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
 DEFINES["WEBRTC_ENABLE_AVX2"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -49,137 +59,16 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
     DEFINES["_DEBUG"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
+if CONFIG["TARGET_CPU"] == "x86":
 
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+    DEFINES["USE_X11"] = "1"
 
 Library("vector_math_avx2_gn")
diff --git third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/vector_math_gn/moz.build third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/vector_math_gn/moz.build
index 79d73bb0e3fa..871969c6d25b 100644
--- third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/vector_math_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/vector_math_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,122 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -164,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("vector_math_gn")
diff --git third_party/libwebrtc/modules/audio_processing/agc2/saturation_protector_gn/moz.build third_party/libwebrtc/modules/audio_processing/agc2/saturation_protector_gn/moz.build
index fd27a27da1f1..577ce4433f5a 100644
--- third_party/libwebrtc/modules/audio_processing/agc2/saturation_protector_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/agc2/saturation_protector_gn/moz.build
@@ -12,12 +12,22 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
 DEFINES["WEBRTC_APM_DEBUG_DUMP"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -45,189 +55,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("saturation_protector_gn")
diff --git third_party/libwebrtc/modules/audio_processing/agc2/speech_level_estimator_gn/moz.build third_party/libwebrtc/modules/audio_processing/agc2/speech_level_estimator_gn/moz.build
index aedae110fd46..efc1473dd2ef 100644
--- third_party/libwebrtc/modules/audio_processing/agc2/speech_level_estimator_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/agc2/speech_level_estimator_gn/moz.build
@@ -12,12 +12,22 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
 DEFINES["WEBRTC_APM_DEBUG_DUMP"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -44,189 +54,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("speech_level_estimator_gn")
diff --git third_party/libwebrtc/modules/audio_processing/agc2/vad_wrapper_gn/moz.build third_party/libwebrtc/modules/audio_processing/agc2/vad_wrapper_gn/moz.build
index 9b40d9ff9463..f0c63ec5b948 100644
--- third_party/libwebrtc/modules/audio_processing/agc2/vad_wrapper_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/agc2/vad_wrapper_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,189 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("vad_wrapper_gn")
diff --git third_party/libwebrtc/modules/audio_processing/apm_logging_gn/moz.build third_party/libwebrtc/modules/audio_processing/apm_logging_gn/moz.build
index 30453ba62793..69e323aa956b 100644
--- third_party/libwebrtc/modules/audio_processing/apm_logging_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/apm_logging_gn/moz.build
@@ -12,12 +12,22 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
 DEFINES["WEBRTC_APM_DEBUG_DUMP"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -44,189 +54,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("apm_logging_gn")
diff --git third_party/libwebrtc/modules/audio_processing/audio_buffer_gn/moz.build third_party/libwebrtc/modules/audio_processing/audio_buffer_gn/moz.build
index 2fce4639d9e3..beeb48f23ea0 100644
--- third_party/libwebrtc/modules/audio_processing/audio_buffer_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/audio_buffer_gn/moz.build
@@ -12,12 +12,22 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
 DEFINES["WEBRTC_APM_DEBUG_DUMP"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -46,189 +56,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("audio_buffer_gn")
diff --git third_party/libwebrtc/modules/audio_processing/audio_frame_proxies_gn/moz.build third_party/libwebrtc/modules/audio_processing/audio_frame_proxies_gn/moz.build
index 231bdb8f4175..44821c58cfde 100644
--- third_party/libwebrtc/modules/audio_processing/audio_frame_proxies_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/audio_frame_proxies_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("audio_frame_proxies_gn")
diff --git third_party/libwebrtc/modules/audio_processing/audio_frame_view_gn/moz.build third_party/libwebrtc/modules/audio_processing/audio_frame_view_gn/moz.build
index 43ffbc502d81..aee63b94bf74 100644
--- third_party/libwebrtc/modules/audio_processing/audio_frame_view_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/audio_frame_view_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,118 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -160,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("audio_frame_view_gn")
diff --git third_party/libwebrtc/modules/audio_processing/audio_processing_gn/moz.build third_party/libwebrtc/modules/audio_processing/audio_processing_gn/moz.build
index c34635a34775..3533acc5c5d2 100644
--- third_party/libwebrtc/modules/audio_processing/audio_processing_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/audio_processing_gn/moz.build
@@ -12,12 +12,22 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
 DEFINES["WEBRTC_APM_DEBUG_DUMP"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -50,189 +60,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("audio_processing_gn")
diff --git third_party/libwebrtc/modules/audio_processing/capture_levels_adjuster/capture_levels_adjuster_gn/moz.build third_party/libwebrtc/modules/audio_processing/capture_levels_adjuster/capture_levels_adjuster_gn/moz.build
index bcc0e359d23d..d574412d6e3f 100644
--- third_party/libwebrtc/modules/audio_processing/capture_levels_adjuster/capture_levels_adjuster_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/capture_levels_adjuster/capture_levels_adjuster_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -44,189 +54,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("capture_levels_adjuster_gn")
diff --git third_party/libwebrtc/modules/audio_processing/gain_controller2_gn/moz.build third_party/libwebrtc/modules/audio_processing/gain_controller2_gn/moz.build
index 901a593d4e99..a8253e5675c5 100644
--- third_party/libwebrtc/modules/audio_processing/gain_controller2_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/gain_controller2_gn/moz.build
@@ -12,12 +12,22 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
 DEFINES["WEBRTC_APM_DEBUG_DUMP"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -44,189 +54,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("gain_controller2_gn")
diff --git third_party/libwebrtc/modules/audio_processing/high_pass_filter_gn/moz.build third_party/libwebrtc/modules/audio_processing/high_pass_filter_gn/moz.build
index 767aac52bbba..91b346bccbe6 100644
--- third_party/libwebrtc/modules/audio_processing/high_pass_filter_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/high_pass_filter_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,189 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("high_pass_filter_gn")
diff --git third_party/libwebrtc/modules/audio_processing/ns/ns_gn/moz.build third_party/libwebrtc/modules/audio_processing/ns/ns_gn/moz.build
index 2880f10c6dcc..fb02ef3557c4 100644
--- third_party/libwebrtc/modules/audio_processing/ns/ns_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/ns/ns_gn/moz.build
@@ -12,12 +12,22 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
 DEFINES["WEBRTC_APM_DEBUG_DUMP"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -56,189 +66,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("ns_gn")
diff --git third_party/libwebrtc/modules/audio_processing/rms_level_gn/moz.build third_party/libwebrtc/modules/audio_processing/rms_level_gn/moz.build
index 6deed14b7fdf..50d785c79e15 100644
--- third_party/libwebrtc/modules/audio_processing/rms_level_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/rms_level_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("rms_level_gn")
diff --git third_party/libwebrtc/modules/audio_processing/utility/cascaded_biquad_filter_gn/moz.build third_party/libwebrtc/modules/audio_processing/utility/cascaded_biquad_filter_gn/moz.build
index ec295a9840b4..f38e1186781b 100644
--- third_party/libwebrtc/modules/audio_processing/utility/cascaded_biquad_filter_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/utility/cascaded_biquad_filter_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("cascaded_biquad_filter_gn")
diff --git third_party/libwebrtc/modules/audio_processing/utility/legacy_delay_estimator_gn/moz.build third_party/libwebrtc/modules/audio_processing/utility/legacy_delay_estimator_gn/moz.build
index beca78d13434..bac6527ab3aa 100644
--- third_party/libwebrtc/modules/audio_processing/utility/legacy_delay_estimator_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/utility/legacy_delay_estimator_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -44,178 +54,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("legacy_delay_estimator_gn")
diff --git third_party/libwebrtc/modules/audio_processing/utility/pffft_wrapper_gn/moz.build third_party/libwebrtc/modules/audio_processing/utility/pffft_wrapper_gn/moz.build
index d118284e2c2d..a0d7aee58047 100644
--- third_party/libwebrtc/modules/audio_processing/utility/pffft_wrapper_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/utility/pffft_wrapper_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("pffft_wrapper_gn")
diff --git third_party/libwebrtc/modules/audio_processing/vad/vad_gn/moz.build third_party/libwebrtc/modules/audio_processing/vad/vad_gn/moz.build
index b2ff5b479858..173fe69d2caf 100644
--- third_party/libwebrtc/modules/audio_processing/vad/vad_gn/moz.build
+++ third_party/libwebrtc/modules/audio_processing/vad/vad_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -50,189 +60,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("vad_gn")
diff --git third_party/libwebrtc/modules/congestion_controller/congestion_controller_gn/moz.build third_party/libwebrtc/modules/congestion_controller/congestion_controller_gn/moz.build
index 1f355f493b19..939b49256e00 100644
--- third_party/libwebrtc/modules/congestion_controller/congestion_controller_gn/moz.build
+++ third_party/libwebrtc/modules/congestion_controller/congestion_controller_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -44,190 +54,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("congestion_controller_gn")
diff --git third_party/libwebrtc/modules/congestion_controller/goog_cc/alr_detector_gn/moz.build third_party/libwebrtc/modules/congestion_controller/goog_cc/alr_detector_gn/moz.build
index d846e19c0b4a..63c39c877298 100644
--- third_party/libwebrtc/modules/congestion_controller/goog_cc/alr_detector_gn/moz.build
+++ third_party/libwebrtc/modules/congestion_controller/goog_cc/alr_detector_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("alr_detector_gn")
diff --git third_party/libwebrtc/modules/congestion_controller/goog_cc/delay_based_bwe_gn/moz.build third_party/libwebrtc/modules/congestion_controller/goog_cc/delay_based_bwe_gn/moz.build
index 7668240917b8..cca1be60d88f 100644
--- third_party/libwebrtc/modules/congestion_controller/goog_cc/delay_based_bwe_gn/moz.build
+++ third_party/libwebrtc/modules/congestion_controller/goog_cc/delay_based_bwe_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -44,190 +54,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("delay_based_bwe_gn")
diff --git third_party/libwebrtc/modules/congestion_controller/goog_cc/estimators_gn/moz.build third_party/libwebrtc/modules/congestion_controller/goog_cc/estimators_gn/moz.build
index 8c9acee0293a..c517088ee11f 100644
--- third_party/libwebrtc/modules/congestion_controller/goog_cc/estimators_gn/moz.build
+++ third_party/libwebrtc/modules/congestion_controller/goog_cc/estimators_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -48,189 +58,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("estimators_gn")
diff --git third_party/libwebrtc/modules/congestion_controller/goog_cc/goog_cc_gn/moz.build third_party/libwebrtc/modules/congestion_controller/goog_cc/goog_cc_gn/moz.build
index b63d8b6e6fe4..4e778fdce344 100644
--- third_party/libwebrtc/modules/congestion_controller/goog_cc/goog_cc_gn/moz.build
+++ third_party/libwebrtc/modules/congestion_controller/goog_cc/goog_cc_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,190 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("goog_cc_gn")
diff --git third_party/libwebrtc/modules/congestion_controller/goog_cc/link_capacity_estimator_gn/moz.build third_party/libwebrtc/modules/congestion_controller/goog_cc/link_capacity_estimator_gn/moz.build
index 6480b5f7867a..e8ad187ddf34 100644
--- third_party/libwebrtc/modules/congestion_controller/goog_cc/link_capacity_estimator_gn/moz.build
+++ third_party/libwebrtc/modules/congestion_controller/goog_cc/link_capacity_estimator_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("link_capacity_estimator_gn")
diff --git third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v1_gn/moz.build third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v1_gn/moz.build
index a1dae5bfec71..a86d75fb666f 100644
--- third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v1_gn/moz.build
+++ third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v1_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("loss_based_bwe_v1_gn")
diff --git third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v2_gn/moz.build third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v2_gn/moz.build
index fb157ec2ad6f..6643254bd2fd 100644
--- third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v2_gn/moz.build
+++ third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v2_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,189 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("loss_based_bwe_v2_gn")
diff --git third_party/libwebrtc/modules/congestion_controller/goog_cc/probe_controller_gn/moz.build third_party/libwebrtc/modules/congestion_controller/goog_cc/probe_controller_gn/moz.build
index c098912b760f..2f113b89318e 100644
--- third_party/libwebrtc/modules/congestion_controller/goog_cc/probe_controller_gn/moz.build
+++ third_party/libwebrtc/modules/congestion_controller/goog_cc/probe_controller_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("probe_controller_gn")
diff --git third_party/libwebrtc/modules/congestion_controller/goog_cc/pushback_controller_gn/moz.build third_party/libwebrtc/modules/congestion_controller/goog_cc/pushback_controller_gn/moz.build
index 46255c32429f..b40ba7585db4 100644
--- third_party/libwebrtc/modules/congestion_controller/goog_cc/pushback_controller_gn/moz.build
+++ third_party/libwebrtc/modules/congestion_controller/goog_cc/pushback_controller_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("pushback_controller_gn")
diff --git third_party/libwebrtc/modules/congestion_controller/goog_cc/send_side_bwe_gn/moz.build third_party/libwebrtc/modules/congestion_controller/goog_cc/send_side_bwe_gn/moz.build
index 3c3f10e984a0..f6d82bf15035 100644
--- third_party/libwebrtc/modules/congestion_controller/goog_cc/send_side_bwe_gn/moz.build
+++ third_party/libwebrtc/modules/congestion_controller/goog_cc/send_side_bwe_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,189 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("send_side_bwe_gn")
diff --git third_party/libwebrtc/modules/congestion_controller/rtp/control_handler_gn/moz.build third_party/libwebrtc/modules/congestion_controller/rtp/control_handler_gn/moz.build
index 51a296016ada..df644e918611 100644
--- third_party/libwebrtc/modules/congestion_controller/rtp/control_handler_gn/moz.build
+++ third_party/libwebrtc/modules/congestion_controller/rtp/control_handler_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,190 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("control_handler_gn")
diff --git third_party/libwebrtc/modules/congestion_controller/rtp/transport_feedback_gn/moz.build third_party/libwebrtc/modules/congestion_controller/rtp/transport_feedback_gn/moz.build
index f1c4138f12f8..b19153fe1086 100644
--- third_party/libwebrtc/modules/congestion_controller/rtp/transport_feedback_gn/moz.build
+++ third_party/libwebrtc/modules/congestion_controller/rtp/transport_feedback_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -44,189 +54,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("transport_feedback_gn")
diff --git third_party/libwebrtc/modules/desktop_capture/desktop_capture_differ_sse2_gn/moz.build third_party/libwebrtc/modules/desktop_capture/desktop_capture_differ_sse2_gn/moz.build
index 53433ae4de27..4531ffd0c2be 100644
--- third_party/libwebrtc/modules/desktop_capture/desktop_capture_differ_sse2_gn/moz.build
+++ third_party/libwebrtc/modules/desktop_capture/desktop_capture_differ_sse2_gn/moz.build
@@ -12,12 +12,22 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
 DEFINES["WEBRTC_ENABLE_AVX2"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -44,113 +54,23 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
+    DEFINES["_DEBUG"] = True
 
-if CONFIG["OS_TARGET"] == "Darwin":
+if CONFIG["TARGET_CPU"] == "x86":
 
     CXXFLAGS += [
+        "-msse2",
         "-msse2"
     ]
 
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
+if CONFIG["TARGET_CPU"] == "x86_64":
 
     CXXFLAGS += [
         "-msse2"
     ]
 
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    CXXFLAGS += [
-        "-msse2",
-        "-msse2"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    CXXFLAGS += [
-        "-msse2"
-    ]
-
 Library("desktop_capture_differ_sse2_gn")
diff --git third_party/libwebrtc/modules/desktop_capture/desktop_capture_gn/moz.build third_party/libwebrtc/modules/desktop_capture/desktop_capture_gn/moz.build
index 442f60843dcb..4fc9c1ca6af7 100644
--- third_party/libwebrtc/modules/desktop_capture/desktop_capture_gn/moz.build
+++ third_party/libwebrtc/modules/desktop_capture/desktop_capture_gn/moz.build
@@ -14,11 +14,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -70,188 +80,13 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    UNIFIED_SOURCES += [
-        "/third_party/libwebrtc/modules/desktop_capture/mac/desktop_configuration_monitor.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/mac/desktop_frame_utils.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/mac/full_screen_mac_application_handler.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/mac/window_list_utils.cc"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-    SOURCES += [
-        "/third_party/libwebrtc/modules/desktop_capture/mouse_cursor_monitor_linux.cc"
-    ]
-
-    UNIFIED_SOURCES += [
-        "/third_party/libwebrtc/modules/desktop_capture/screen_capturer_linux.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/window_capturer_linux.cc"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["WEBRTC_USE_X11"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "X11",
-        "Xcomposite",
-        "Xdamage",
-        "Xext",
-        "Xfixes",
-        "Xrandr",
-        "Xrender"
-    ]
-
-    SOURCES += [
-        "/third_party/libwebrtc/modules/desktop_capture/mouse_cursor_monitor_linux.cc"
-    ]
-
-    UNIFIED_SOURCES += [
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/mouse_cursor_monitor_x11.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/screen_capturer_x11.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/shared_x_display.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/window_capturer_x11.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/window_finder_x11.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/window_list_utils.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/x_atom_cache.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/x_error_trap.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/x_server_pixel_buffer.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/x_window_property.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/screen_capturer_linux.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/window_capturer_linux.cc"
-    ]
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "d3d11",
-        "dwmapi",
-        "dxgi",
-        "iphlpapi",
-        "secur32",
-        "shcore",
-        "winmm"
-    ]
-
-    SOURCES += [
-        "/third_party/libwebrtc/modules/desktop_capture/win/screen_capturer_win_gdi.cc"
-    ]
-
-    UNIFIED_SOURCES += [
-        "/third_party/libwebrtc/modules/desktop_capture/cropping_window_capturer_win.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/desktop_frame_win.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/mouse_cursor_monitor_win.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/screen_capturer_win.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/win/cursor.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/win/d3d_device.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/win/desktop.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/win/desktop_capture_utils.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/win/display_configuration_monitor.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/win/dxgi_adapter_duplicator.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/win/dxgi_context.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/win/dxgi_duplicator_controller.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/win/dxgi_frame.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/win/dxgi_output_duplicator.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/win/dxgi_texture.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/win/dxgi_texture_mapping.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/win/dxgi_texture_staging.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/win/full_screen_win_application_handler.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/win/scoped_thread_desktop.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/win/screen_capture_utils.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/win/screen_capturer_win_directx.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/win/screen_capturer_win_magnifier.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/win/selected_window_context.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/win/wgc_capture_session.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/win/wgc_capture_source.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/win/wgc_capturer_win.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/win/wgc_desktop_frame.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/win/window_capture_utils.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/win/window_capturer_win_gdi.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/window_capturer_win.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/window_finder_win.cc"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
-
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
     DEFINES["WEBRTC_USE_PIPEWIRE"] = True
-    DEFINES["_GNU_SOURCE"] = True
 
     LOCAL_INCLUDES += [
         "/gfx/angle/checkout/include/",
@@ -264,7 +99,8 @@ if CONFIG["TARGET_CPU"] == "arm":
     ]
 
     SOURCES += [
-        "/third_party/libwebrtc/modules/desktop_capture/linux/wayland/base_capturer_pipewire.cc"
+        "/third_party/libwebrtc/modules/desktop_capture/linux/wayland/base_capturer_pipewire.cc",
+        "/third_party/libwebrtc/modules/desktop_capture/mouse_cursor_monitor_linux.cc"
     ]
 
     UNIFIED_SOURCES += [
@@ -274,7 +110,9 @@ if CONFIG["TARGET_CPU"] == "arm":
         "/third_party/libwebrtc/modules/desktop_capture/linux/wayland/screen_capture_portal_interface.cc",
         "/third_party/libwebrtc/modules/desktop_capture/linux/wayland/screencast_portal.cc",
         "/third_party/libwebrtc/modules/desktop_capture/linux/wayland/screencast_stream_utils.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc"
+        "/third_party/libwebrtc/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc",
+        "/third_party/libwebrtc/modules/desktop_capture/screen_capturer_linux.cc",
+        "/third_party/libwebrtc/modules/desktop_capture/window_capturer_linux.cc"
     ]
 
 if CONFIG["TARGET_CPU"] == "mips32":
@@ -282,7 +120,6 @@ if CONFIG["TARGET_CPU"] == "mips32":
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
     DEFINES["WEBRTC_USE_PIPEWIRE"] = True
-    DEFINES["_GNU_SOURCE"] = True
 
     LOCAL_INCLUDES += [
         "/gfx/angle/checkout/include/",
@@ -295,7 +132,8 @@ if CONFIG["TARGET_CPU"] == "mips32":
     ]
 
     SOURCES += [
-        "/third_party/libwebrtc/modules/desktop_capture/linux/wayland/base_capturer_pipewire.cc"
+        "/third_party/libwebrtc/modules/desktop_capture/linux/wayland/base_capturer_pipewire.cc",
+        "/third_party/libwebrtc/modules/desktop_capture/mouse_cursor_monitor_linux.cc"
     ]
 
     UNIFIED_SOURCES += [
@@ -305,13 +143,14 @@ if CONFIG["TARGET_CPU"] == "mips32":
         "/third_party/libwebrtc/modules/desktop_capture/linux/wayland/screen_capture_portal_interface.cc",
         "/third_party/libwebrtc/modules/desktop_capture/linux/wayland/screencast_portal.cc",
         "/third_party/libwebrtc/modules/desktop_capture/linux/wayland/screencast_stream_utils.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc"
+        "/third_party/libwebrtc/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc",
+        "/third_party/libwebrtc/modules/desktop_capture/screen_capturer_linux.cc",
+        "/third_party/libwebrtc/modules/desktop_capture/window_capturer_linux.cc"
     ]
 
 if CONFIG["TARGET_CPU"] == "mips64":
 
     DEFINES["WEBRTC_USE_PIPEWIRE"] = True
-    DEFINES["_GNU_SOURCE"] = True
 
     LOCAL_INCLUDES += [
         "/gfx/angle/checkout/include/",
@@ -324,7 +163,8 @@ if CONFIG["TARGET_CPU"] == "mips64":
     ]
 
     SOURCES += [
-        "/third_party/libwebrtc/modules/desktop_capture/linux/wayland/base_capturer_pipewire.cc"
+        "/third_party/libwebrtc/modules/desktop_capture/linux/wayland/base_capturer_pipewire.cc",
+        "/third_party/libwebrtc/modules/desktop_capture/mouse_cursor_monitor_linux.cc"
     ]
 
     UNIFIED_SOURCES += [
@@ -334,126 +174,19 @@ if CONFIG["TARGET_CPU"] == "mips64":
         "/third_party/libwebrtc/modules/desktop_capture/linux/wayland/screen_capture_portal_interface.cc",
         "/third_party/libwebrtc/modules/desktop_capture/linux/wayland/screencast_portal.cc",
         "/third_party/libwebrtc/modules/desktop_capture/linux/wayland/screencast_stream_utils.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc"
-    ]
-
-if CONFIG["TARGET_CPU"] == "ppc64":
-
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_USE_X11"] = True
-
-    OS_LIBS += [
-        "X11",
-        "Xcomposite",
-        "Xdamage",
-        "Xext",
-        "Xfixes",
-        "Xrandr",
-        "Xrender"
-    ]
-
-    UNIFIED_SOURCES += [
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/mouse_cursor_monitor_x11.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/screen_capturer_x11.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/shared_x_display.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/window_capturer_x11.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/window_finder_x11.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/window_list_utils.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/x_atom_cache.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/x_error_trap.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/x_server_pixel_buffer.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/x_window_property.cc"
+        "/third_party/libwebrtc/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc",
+        "/third_party/libwebrtc/modules/desktop_capture/screen_capturer_linux.cc",
+        "/third_party/libwebrtc/modules/desktop_capture/window_capturer_linux.cc"
     ]
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["WEBRTC_USE_PIPEWIRE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-    LOCAL_INCLUDES += [
-        "/gfx/angle/checkout/include/",
-        "/third_party/drm/drm/",
-        "/third_party/drm/drm/include/",
-        "/third_party/drm/drm/include/libdrm/",
-        "/third_party/gbm/gbm/",
-        "/third_party/libepoxy/libepoxy/include/",
-        "/third_party/pipewire/"
-    ]
-
-    SOURCES += [
-        "/third_party/libwebrtc/modules/desktop_capture/linux/wayland/base_capturer_pipewire.cc"
-    ]
-
-    UNIFIED_SOURCES += [
-        "/third_party/libwebrtc/modules/desktop_capture/linux/wayland/egl_dmabuf.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/wayland/mouse_cursor_monitor_pipewire.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/wayland/restore_token_manager.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/wayland/screen_capture_portal_interface.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/wayland/screencast_portal.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/wayland/screencast_stream_utils.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "riscv64":
-
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_USE_X11"] = True
-
-    OS_LIBS += [
-        "X11",
-        "Xcomposite",
-        "Xdamage",
-        "Xext",
-        "Xfixes",
-        "Xrandr",
-        "Xrender"
-    ]
-
-    UNIFIED_SOURCES += [
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/mouse_cursor_monitor_x11.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/screen_capturer_x11.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/shared_x_display.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/window_capturer_x11.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/window_finder_x11.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/window_list_utils.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/x_atom_cache.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/x_error_trap.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/x_server_pixel_buffer.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/x_window_property.cc"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
     DEFINES["WEBRTC_USE_PIPEWIRE"] = True
-    DEFINES["_GNU_SOURCE"] = True
 
     LOCAL_INCLUDES += [
         "/gfx/angle/checkout/include/",
@@ -466,7 +199,8 @@ if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
     ]
 
     SOURCES += [
-        "/third_party/libwebrtc/modules/desktop_capture/linux/wayland/base_capturer_pipewire.cc"
+        "/third_party/libwebrtc/modules/desktop_capture/linux/wayland/base_capturer_pipewire.cc",
+        "/third_party/libwebrtc/modules/desktop_capture/mouse_cursor_monitor_linux.cc"
     ]
 
     UNIFIED_SOURCES += [
@@ -476,13 +210,15 @@ if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
         "/third_party/libwebrtc/modules/desktop_capture/linux/wayland/screen_capture_portal_interface.cc",
         "/third_party/libwebrtc/modules/desktop_capture/linux/wayland/screencast_portal.cc",
         "/third_party/libwebrtc/modules/desktop_capture/linux/wayland/screencast_stream_utils.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc"
+        "/third_party/libwebrtc/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc",
+        "/third_party/libwebrtc/modules/desktop_capture/screen_capturer_linux.cc",
+        "/third_party/libwebrtc/modules/desktop_capture/window_capturer_linux.cc"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["TARGET_CPU"] == "x86_64":
 
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
     DEFINES["WEBRTC_USE_PIPEWIRE"] = True
-    DEFINES["_GNU_SOURCE"] = True
 
     LOCAL_INCLUDES += [
         "/gfx/angle/checkout/include/",
@@ -495,7 +231,8 @@ if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
     ]
 
     SOURCES += [
-        "/third_party/libwebrtc/modules/desktop_capture/linux/wayland/base_capturer_pipewire.cc"
+        "/third_party/libwebrtc/modules/desktop_capture/linux/wayland/base_capturer_pipewire.cc",
+        "/third_party/libwebrtc/modules/desktop_capture/mouse_cursor_monitor_linux.cc"
     ]
 
     UNIFIED_SOURCES += [
@@ -505,38 +242,12 @@ if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
         "/third_party/libwebrtc/modules/desktop_capture/linux/wayland/screen_capture_portal_interface.cc",
         "/third_party/libwebrtc/modules/desktop_capture/linux/wayland/screencast_portal.cc",
         "/third_party/libwebrtc/modules/desktop_capture/linux/wayland/screencast_stream_utils.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc"
-    ]
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_USE_X11"] = True
-
-    OS_LIBS += [
-        "X11",
-        "Xcomposite",
-        "Xdamage",
-        "Xext",
-        "Xfixes",
-        "Xrandr",
-        "Xrender"
-    ]
-
-    UNIFIED_SOURCES += [
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/mouse_cursor_monitor_x11.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/screen_capturer_x11.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/shared_x_display.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/window_capturer_x11.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/window_finder_x11.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/window_list_utils.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/x_atom_cache.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/x_error_trap.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/x_server_pixel_buffer.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/x_window_property.cc"
+        "/third_party/libwebrtc/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc",
+        "/third_party/libwebrtc/modules/desktop_capture/screen_capturer_linux.cc",
+        "/third_party/libwebrtc/modules/desktop_capture/window_capturer_linux.cc"
     ]
 
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
     DEFINES["WEBRTC_USE_X11"] = True
@@ -564,116 +275,42 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGE
         "/third_party/libwebrtc/modules/desktop_capture/linux/x11/x_window_property.cc"
     ]
 
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "mips32":
-
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_USE_X11"] = True
-
-    OS_LIBS += [
-        "X11",
-        "Xcomposite",
-        "Xdamage",
-        "Xext",
-        "Xfixes",
-        "Xrandr",
-        "Xrender"
-    ]
+if not CONFIG["MOZ_X11"] and CONFIG["OS_TARGET"] == "FreeBSD" and CONFIG["TARGET_CPU"] == "ppc64":
 
     UNIFIED_SOURCES += [
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/mouse_cursor_monitor_x11.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/screen_capturer_x11.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/shared_x_display.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/window_capturer_x11.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/window_finder_x11.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/window_list_utils.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/x_atom_cache.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/x_error_trap.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/x_server_pixel_buffer.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/x_window_property.cc"
+        "/third_party/libwebrtc/modules/desktop_capture/mouse_cursor_monitor_null.cc",
+        "/third_party/libwebrtc/modules/desktop_capture/screen_capturer_null.cc",
+        "/third_party/libwebrtc/modules/desktop_capture/window_capturer_null.cc"
     ]
 
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_USE_X11"] = True
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD" and CONFIG["TARGET_CPU"] == "ppc64":
 
-    OS_LIBS += [
-        "X11",
-        "Xcomposite",
-        "Xdamage",
-        "Xext",
-        "Xfixes",
-        "Xrandr",
-        "Xrender"
+    SOURCES += [
+        "/third_party/libwebrtc/modules/desktop_capture/mouse_cursor_monitor_linux.cc"
     ]
 
     UNIFIED_SOURCES += [
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/mouse_cursor_monitor_x11.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/screen_capturer_x11.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/shared_x_display.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/window_capturer_x11.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/window_finder_x11.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/window_list_utils.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/x_atom_cache.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/x_error_trap.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/x_server_pixel_buffer.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/x_window_property.cc"
+        "/third_party/libwebrtc/modules/desktop_capture/screen_capturer_linux.cc",
+        "/third_party/libwebrtc/modules/desktop_capture/window_capturer_linux.cc"
     ]
 
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_USE_X11"] = True
-
-    OS_LIBS += [
-        "X11",
-        "Xcomposite",
-        "Xdamage",
-        "Xext",
-        "Xfixes",
-        "Xrandr",
-        "Xrender"
-    ]
+if not CONFIG["MOZ_X11"] and CONFIG["OS_TARGET"] == "FreeBSD" and CONFIG["TARGET_CPU"] == "riscv64":
 
     UNIFIED_SOURCES += [
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/mouse_cursor_monitor_x11.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/screen_capturer_x11.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/shared_x_display.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/window_capturer_x11.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/window_finder_x11.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/window_list_utils.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/x_atom_cache.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/x_error_trap.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/x_server_pixel_buffer.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/x_window_property.cc"
+        "/third_party/libwebrtc/modules/desktop_capture/mouse_cursor_monitor_null.cc",
+        "/third_party/libwebrtc/modules/desktop_capture/screen_capturer_null.cc",
+        "/third_party/libwebrtc/modules/desktop_capture/window_capturer_null.cc"
     ]
 
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD" and CONFIG["TARGET_CPU"] == "riscv64":
 
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_USE_X11"] = True
-
-    OS_LIBS += [
-        "X11",
-        "Xcomposite",
-        "Xdamage",
-        "Xext",
-        "Xfixes",
-        "Xrandr",
-        "Xrender"
+    SOURCES += [
+        "/third_party/libwebrtc/modules/desktop_capture/mouse_cursor_monitor_linux.cc"
     ]
 
     UNIFIED_SOURCES += [
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/mouse_cursor_monitor_x11.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/screen_capturer_x11.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/shared_x_display.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/window_capturer_x11.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/window_finder_x11.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/window_list_utils.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/x_atom_cache.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/x_error_trap.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/x_server_pixel_buffer.cc",
-        "/third_party/libwebrtc/modules/desktop_capture/linux/x11/x_window_property.cc"
+        "/third_party/libwebrtc/modules/desktop_capture/screen_capturer_linux.cc",
+        "/third_party/libwebrtc/modules/desktop_capture/window_capturer_linux.cc"
     ]
 
 Library("desktop_capture_gn")
diff --git third_party/libwebrtc/modules/desktop_capture/desktop_capture_objc_gn/moz.build third_party/libwebrtc/modules/desktop_capture/desktop_capture_objc_gn/moz.build
deleted file mode 100644
index a8051a1743d1..000000000000
--- third_party/libwebrtc/modules/desktop_capture/desktop_capture_objc_gn/moz.build
+++ /dev/null
@@ -1,79 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-
-  ### This moz.build was AUTOMATICALLY GENERATED from a GN config,  ###
-  ### DO NOT edit it by hand.                                       ###
-
-CMMFLAGS += [
-    "-fobjc-arc"
-]
-
-COMPILE_FLAGS["OS_INCLUDES"] = []
-AllowCompilerWarnings()
-
-DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
-DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
-DEFINES["RTC_ENABLE_VP9"] = True
-DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
-DEFINES["WEBRTC_LIBRARY_IMPL"] = True
-DEFINES["WEBRTC_MAC"] = True
-DEFINES["WEBRTC_MOZILLA_BUILD"] = True
-DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
-DEFINES["WEBRTC_POSIX"] = True
-DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
-DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-DEFINES["__STDC_CONSTANT_MACROS"] = True
-DEFINES["__STDC_FORMAT_MACROS"] = True
-
-FINAL_LIBRARY = "xul"
-
-
-LOCAL_INCLUDES += [
-    "!/ipc/ipdl/_ipdlheaders",
-    "!/third_party/libwebrtc/gen",
-    "/ipc/chromium/src",
-    "/third_party/abseil-cpp/",
-    "/third_party/libwebrtc/",
-    "/third_party/libwebrtc/sdk/objc/",
-    "/third_party/libwebrtc/sdk/objc/base/",
-    "/tools/profiler/public"
-]
-
-UNIFIED_SOURCES += [
-    "/third_party/libwebrtc/modules/desktop_capture/mac/desktop_configuration.mm",
-    "/third_party/libwebrtc/modules/desktop_capture/mac/desktop_frame_cgimage.mm",
-    "/third_party/libwebrtc/modules/desktop_capture/mac/desktop_frame_iosurface.mm",
-    "/third_party/libwebrtc/modules/desktop_capture/mac/desktop_frame_provider.mm",
-    "/third_party/libwebrtc/modules/desktop_capture/mac/sck_picker_handle.mm",
-    "/third_party/libwebrtc/modules/desktop_capture/mac/screen_capturer_mac.mm",
-    "/third_party/libwebrtc/modules/desktop_capture/mac/screen_capturer_sck.mm",
-    "/third_party/libwebrtc/modules/desktop_capture/mouse_cursor_monitor_mac.mm",
-    "/third_party/libwebrtc/modules/desktop_capture/screen_capturer_darwin.mm",
-    "/third_party/libwebrtc/modules/desktop_capture/window_capturer_mac.mm",
-    "/third_party/libwebrtc/modules/desktop_capture/window_finder_mac.mm"
-]
-
-if not CONFIG["MOZ_DEBUG"]:
-
-    DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "0"
-    DEFINES["NDEBUG"] = True
-    DEFINES["NVALGRIND"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1":
-
-    DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["WEBRTC_ARCH_ARM64"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-Library("desktop_capture_objc_gn")
diff --git third_party/libwebrtc/modules/desktop_capture/primitives_gn/moz.build third_party/libwebrtc/modules/desktop_capture/primitives_gn/moz.build
index 4414259d7ed7..2771d0e13e8e 100644
--- third_party/libwebrtc/modules/desktop_capture/primitives_gn/moz.build
+++ third_party/libwebrtc/modules/desktop_capture/primitives_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -49,168 +59,31 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "ppc64":
-
-    DEFINES["USE_X11"] = "1"
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "riscv64":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "mips32":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["USE_X11"] = "1"
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["USE_X11"] = "1"
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
diff --git third_party/libwebrtc/modules/module_api_gn/moz.build third_party/libwebrtc/modules/module_api_gn/moz.build
index 5d16a3e7e5e3..315cc9a4744b 100644
--- third_party/libwebrtc/modules/module_api_gn/moz.build
+++ third_party/libwebrtc/modules/module_api_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("module_api_gn")
diff --git third_party/libwebrtc/modules/module_api_public_gn/moz.build third_party/libwebrtc/modules/module_api_public_gn/moz.build
index 38f4c929ebff..168eb7351127 100644
--- third_party/libwebrtc/modules/module_api_public_gn/moz.build
+++ third_party/libwebrtc/modules/module_api_public_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("module_api_public_gn")
diff --git third_party/libwebrtc/modules/module_fec_api_gn/moz.build third_party/libwebrtc/modules/module_fec_api_gn/moz.build
index 2c8d429c9230..2bde83c69b9b 100644
--- third_party/libwebrtc/modules/module_fec_api_gn/moz.build
+++ third_party/libwebrtc/modules/module_fec_api_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("module_fec_api_gn")
diff --git third_party/libwebrtc/modules/pacing/interval_budget_gn/moz.build third_party/libwebrtc/modules/pacing/interval_budget_gn/moz.build
index 4b4e2e1bf40e..29813cdd4a0a 100644
--- third_party/libwebrtc/modules/pacing/interval_budget_gn/moz.build
+++ third_party/libwebrtc/modules/pacing/interval_budget_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("interval_budget_gn")
diff --git third_party/libwebrtc/modules/pacing/pacing_gn/moz.build third_party/libwebrtc/modules/pacing/pacing_gn/moz.build
index f713d0737f63..d6ad3940e48c 100644
--- third_party/libwebrtc/modules/pacing/pacing_gn/moz.build
+++ third_party/libwebrtc/modules/pacing/pacing_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -50,190 +60,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("pacing_gn")
diff --git third_party/libwebrtc/modules/portal/portal_gn/moz.build third_party/libwebrtc/modules/portal/portal_gn/moz.build
index 9223eed155e0..e7bc6ef35536 100644
--- third_party/libwebrtc/modules/portal/portal_gn/moz.build
+++ third_party/libwebrtc/modules/portal/portal_gn/moz.build
@@ -14,22 +14,18 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
-DEFINES["USE_AURA"] = "1"
 DEFINES["USE_GLIB"] = "1"
-DEFINES["USE_NSS_CERTS"] = "1"
 DEFINES["USE_OZONE"] = "1"
-DEFINES["USE_UDEV"] = True
+DEFINES["WEBRTC_BSD"] = True
 DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
-DEFINES["WEBRTC_LINUX"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
 DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
 DEFINES["WEBRTC_USE_PIPEWIRE"] = True
 DEFINES["_FILE_OFFSET_BITS"] = "64"
-DEFINES["_GNU_SOURCE"] = True
 DEFINES["_LARGEFILE64_SOURCE"] = True
 DEFINES["_LARGEFILE_SOURCE"] = True
 DEFINES["__STDC_CONSTANT_MACROS"] = True
@@ -76,16 +72,6 @@ if CONFIG["TARGET_CPU"] == "aarch64":
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
@@ -103,7 +89,7 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
diff --git third_party/libwebrtc/modules/remote_bitrate_estimator/congestion_control_feedback_generator_gn/moz.build third_party/libwebrtc/modules/remote_bitrate_estimator/congestion_control_feedback_generator_gn/moz.build
index 2f721caab1e2..25140607e5bc 100644
--- third_party/libwebrtc/modules/remote_bitrate_estimator/congestion_control_feedback_generator_gn/moz.build
+++ third_party/libwebrtc/modules/remote_bitrate_estimator/congestion_control_feedback_generator_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,189 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("congestion_control_feedback_generator_gn")
diff --git third_party/libwebrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_gn/moz.build third_party/libwebrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_gn/moz.build
index 70b2e3fe3590..a71d5913ebff 100644
--- third_party/libwebrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_gn/moz.build
+++ third_party/libwebrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -52,189 +62,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("remote_bitrate_estimator_gn")
diff --git third_party/libwebrtc/modules/remote_bitrate_estimator/rtp_transport_feedback_generator_gn/moz.build third_party/libwebrtc/modules/remote_bitrate_estimator/rtp_transport_feedback_generator_gn/moz.build
index a0d7d7e0ac3e..bc541e8676ac 100644
--- third_party/libwebrtc/modules/remote_bitrate_estimator/rtp_transport_feedback_generator_gn/moz.build
+++ third_party/libwebrtc/modules/remote_bitrate_estimator/rtp_transport_feedback_generator_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,122 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -164,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("rtp_transport_feedback_generator_gn")
diff --git third_party/libwebrtc/modules/remote_bitrate_estimator/transport_sequence_number_feedback_generator_gn/moz.build third_party/libwebrtc/modules/remote_bitrate_estimator/transport_sequence_number_feedback_generator_gn/moz.build
index 3cdc29623f2c..e30dd2e3927c 100644
--- third_party/libwebrtc/modules/remote_bitrate_estimator/transport_sequence_number_feedback_generator_gn/moz.build
+++ third_party/libwebrtc/modules/remote_bitrate_estimator/transport_sequence_number_feedback_generator_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -44,189 +54,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("transport_sequence_number_feedback_generator_gn")
diff --git third_party/libwebrtc/modules/rtp_rtcp/leb128_gn/moz.build third_party/libwebrtc/modules/rtp_rtcp/leb128_gn/moz.build
index db194c628d2d..a2430c8c2d4a 100644
--- third_party/libwebrtc/modules/rtp_rtcp/leb128_gn/moz.build
+++ third_party/libwebrtc/modules/rtp_rtcp/leb128_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,174 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("leb128_gn")
diff --git third_party/libwebrtc/modules/rtp_rtcp/ntp_time_util_gn/moz.build third_party/libwebrtc/modules/rtp_rtcp/ntp_time_util_gn/moz.build
index 82edd9452695..72027e714057 100644
--- third_party/libwebrtc/modules/rtp_rtcp/ntp_time_util_gn/moz.build
+++ third_party/libwebrtc/modules/rtp_rtcp/ntp_time_util_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,189 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("ntp_time_util_gn")
diff --git third_party/libwebrtc/modules/rtp_rtcp/rtp_rtcp_format_gn/moz.build third_party/libwebrtc/modules/rtp_rtcp/rtp_rtcp_format_gn/moz.build
index 335232a62bbe..46c7826dc574 100644
--- third_party/libwebrtc/modules/rtp_rtcp/rtp_rtcp_format_gn/moz.build
+++ third_party/libwebrtc/modules/rtp_rtcp/rtp_rtcp_format_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -87,189 +97,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("rtp_rtcp_format_gn")
diff --git third_party/libwebrtc/modules/rtp_rtcp/rtp_rtcp_gn/moz.build third_party/libwebrtc/modules/rtp_rtcp/rtp_rtcp_gn/moz.build
index 91531e0c5ff8..bc8d83a926fc 100644
--- third_party/libwebrtc/modules/rtp_rtcp/rtp_rtcp_gn/moz.build
+++ third_party/libwebrtc/modules/rtp_rtcp/rtp_rtcp_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -97,190 +107,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("rtp_rtcp_gn")
diff --git third_party/libwebrtc/modules/rtp_rtcp/rtp_video_header_gn/moz.build third_party/libwebrtc/modules/rtp_rtcp/rtp_video_header_gn/moz.build
index 2c4f89592394..77640b3fd28f 100644
--- third_party/libwebrtc/modules/rtp_rtcp/rtp_video_header_gn/moz.build
+++ third_party/libwebrtc/modules/rtp_rtcp/rtp_video_header_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("rtp_video_header_gn")
diff --git third_party/libwebrtc/modules/third_party/fft/fft_gn/moz.build third_party/libwebrtc/modules/third_party/fft/fft_gn/moz.build
index 855a7c640e94..b6feb3008fb9 100644
--- third_party/libwebrtc/modules/third_party/fft/fft_gn/moz.build
+++ third_party/libwebrtc/modules/third_party/fft/fft_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,174 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("fft_gn")
diff --git third_party/libwebrtc/modules/third_party/g711/g711_3p_gn/moz.build third_party/libwebrtc/modules/third_party/g711/g711_3p_gn/moz.build
index e49c5be29664..00ffb0ed1510 100644
--- third_party/libwebrtc/modules/third_party/g711/g711_3p_gn/moz.build
+++ third_party/libwebrtc/modules/third_party/g711/g711_3p_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,174 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("g711_3p_gn")
diff --git third_party/libwebrtc/modules/third_party/g722/g722_3p_gn/moz.build third_party/libwebrtc/modules/third_party/g722/g722_3p_gn/moz.build
index 35318f094ae1..a9c333b6f5c3 100644
--- third_party/libwebrtc/modules/third_party/g722/g722_3p_gn/moz.build
+++ third_party/libwebrtc/modules/third_party/g722/g722_3p_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -47,174 +57,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("g722_3p_gn")
diff --git third_party/libwebrtc/modules/utility/utility_gn/moz.build third_party/libwebrtc/modules/utility/utility_gn/moz.build
index 08951c311a33..c62a0644df9e 100644
--- third_party/libwebrtc/modules/utility/utility_gn/moz.build
+++ third_party/libwebrtc/modules/utility/utility_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,115 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-    UNIFIED_SOURCES += [
-        "/third_party/libwebrtc/modules/utility/source/helpers_android.cc"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -157,60 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
-    CXXFLAGS += [
-        "-msse2"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("utility_gn")
diff --git third_party/libwebrtc/modules/video_capture/video_capture_internal_impl_gn/moz.build third_party/libwebrtc/modules/video_capture/video_capture_internal_impl_gn/moz.build
index ce9b51191cb9..6555d80c5d30 100644
--- third_party/libwebrtc/modules/video_capture/video_capture_internal_impl_gn/moz.build
+++ third_party/libwebrtc/modules/video_capture/video_capture_internal_impl_gn/moz.build
@@ -14,11 +14,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -33,6 +43,10 @@ LOCAL_INCLUDES += [
 ]
 
 UNIFIED_SOURCES += [
+    "/third_party/libwebrtc/modules/video_capture/linux/device_info_linux.cc",
+    "/third_party/libwebrtc/modules/video_capture/linux/device_info_v4l2.cc",
+    "/third_party/libwebrtc/modules/video_capture/linux/video_capture_linux.cc",
+    "/third_party/libwebrtc/modules/video_capture/linux/video_capture_v4l2.cc",
     "/third_party/libwebrtc/modules/video_capture/video_capture_options.cc"
 ]
 
@@ -45,152 +59,13 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-    UNIFIED_SOURCES += [
-        "/third_party/libwebrtc/modules/video_capture/linux/device_info_linux.cc",
-        "/third_party/libwebrtc/modules/video_capture/linux/device_info_v4l2.cc",
-        "/third_party/libwebrtc/modules/video_capture/linux/video_capture_linux.cc",
-        "/third_party/libwebrtc/modules/video_capture/linux/video_capture_v4l2.cc"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    UNIFIED_SOURCES += [
-        "/third_party/libwebrtc/modules/video_capture/linux/device_info_linux.cc",
-        "/third_party/libwebrtc/modules/video_capture/linux/device_info_v4l2.cc",
-        "/third_party/libwebrtc/modules/video_capture/linux/video_capture_linux.cc",
-        "/third_party/libwebrtc/modules/video_capture/linux/video_capture_v4l2.cc"
-    ]
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "ole32",
-        "oleaut32",
-        "secur32",
-        "strmiids",
-        "user32",
-        "winmm"
-    ]
-
-    SOURCES += [
-        "/third_party/libwebrtc/modules/video_capture/windows/device_info_ds.cc",
-        "/third_party/libwebrtc/modules/video_capture/windows/help_functions_ds.cc",
-        "/third_party/libwebrtc/modules/video_capture/windows/sink_filter_ds.cc"
-    ]
-
-    UNIFIED_SOURCES += [
-        "/third_party/libwebrtc/modules/video_capture/windows/video_capture_ds.cc",
-        "/third_party/libwebrtc/modules/video_capture/windows/video_capture_factory_windows.cc"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
-
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
-if CONFIG["TARGET_CPU"] == "mips32":
-
-    DEFINES["MIPS32_LE"] = True
-    DEFINES["MIPS_FPU_LE"] = True
     DEFINES["WEBRTC_USE_PIPEWIRE"] = True
-    DEFINES["_GNU_SOURCE"] = True
 
     LOCAL_INCLUDES += [
         "/gfx/angle/checkout/include/",
@@ -209,76 +84,11 @@ if CONFIG["TARGET_CPU"] == "mips32":
         "/third_party/libwebrtc/modules/video_capture/linux/video_capture_pipewire.cc"
     ]
 
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["WEBRTC_USE_PIPEWIRE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-    LOCAL_INCLUDES += [
-        "/gfx/angle/checkout/include/",
-        "/third_party/drm/drm/",
-        "/third_party/drm/drm/include/",
-        "/third_party/drm/drm/include/libdrm/",
-        "/third_party/gbm/gbm/",
-        "/third_party/libepoxy/libepoxy/include/",
-        "/third_party/pipewire/"
-    ]
-
-    UNIFIED_SOURCES += [
-        "/third_party/libwebrtc/modules/video_capture/linux/camera_portal.cc",
-        "/third_party/libwebrtc/modules/video_capture/linux/device_info_pipewire.cc",
-        "/third_party/libwebrtc/modules/video_capture/linux/pipewire_session.cc",
-        "/third_party/libwebrtc/modules/video_capture/linux/video_capture_pipewire.cc"
-    ]
-
-if CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
-    CXXFLAGS += [
-        "-msse2"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
+if CONFIG["TARGET_CPU"] == "mips32":
 
+    DEFINES["MIPS32_LE"] = True
+    DEFINES["MIPS_FPU_LE"] = True
     DEFINES["WEBRTC_USE_PIPEWIRE"] = True
-    DEFINES["_GNU_SOURCE"] = True
 
     LOCAL_INCLUDES += [
         "/gfx/angle/checkout/include/",
@@ -297,10 +107,9 @@ if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
         "/third_party/libwebrtc/modules/video_capture/linux/video_capture_pipewire.cc"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
+if CONFIG["TARGET_CPU"] == "mips64":
 
     DEFINES["WEBRTC_USE_PIPEWIRE"] = True
-    DEFINES["_GNU_SOURCE"] = True
 
     LOCAL_INCLUDES += [
         "/gfx/angle/checkout/include/",
@@ -319,14 +128,14 @@ if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
         "/third_party/libwebrtc/modules/video_capture/linux/video_capture_pipewire.cc"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+if CONFIG["TARGET_CPU"] == "x86":
 
     CXXFLAGS += [
         "-msse2"
     ]
 
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
     DEFINES["WEBRTC_USE_PIPEWIRE"] = True
-    DEFINES["_GNU_SOURCE"] = True
 
     LOCAL_INCLUDES += [
         "/gfx/angle/checkout/include/",
@@ -345,10 +154,10 @@ if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
         "/third_party/libwebrtc/modules/video_capture/linux/video_capture_pipewire.cc"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["TARGET_CPU"] == "x86_64":
 
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
     DEFINES["WEBRTC_USE_PIPEWIRE"] = True
-    DEFINES["_GNU_SOURCE"] = True
 
     LOCAL_INCLUDES += [
         "/gfx/angle/checkout/include/",
@@ -367,4 +176,8 @@ if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
         "/third_party/libwebrtc/modules/video_capture/linux/video_capture_pipewire.cc"
     ]
 
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
+
+    DEFINES["USE_X11"] = "1"
+
 Library("video_capture_internal_impl_gn")
diff --git third_party/libwebrtc/modules/video_capture/video_capture_module_gn/moz.build third_party/libwebrtc/modules/video_capture/video_capture_module_gn/moz.build
index c0bac4064793..4eb71efbc14c 100644
--- third_party/libwebrtc/modules/video_capture/video_capture_module_gn/moz.build
+++ third_party/libwebrtc/modules/video_capture/video_capture_module_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -47,189 +57,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("video_capture_module_gn")
diff --git third_party/libwebrtc/modules/video_coding/chain_diff_calculator_gn/moz.build third_party/libwebrtc/modules/video_coding/chain_diff_calculator_gn/moz.build
index 4d13e69f7bff..b8464560a1ad 100644
--- third_party/libwebrtc/modules/video_coding/chain_diff_calculator_gn/moz.build
+++ third_party/libwebrtc/modules/video_coding/chain_diff_calculator_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("chain_diff_calculator_gn")
diff --git third_party/libwebrtc/modules/video_coding/codec_globals_headers_gn/moz.build third_party/libwebrtc/modules/video_coding/codec_globals_headers_gn/moz.build
index 7fd4ec68f2ef..487bebc3649e 100644
--- third_party/libwebrtc/modules/video_coding/codec_globals_headers_gn/moz.build
+++ third_party/libwebrtc/modules/video_coding/codec_globals_headers_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,111 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -153,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("codec_globals_headers_gn")
diff --git third_party/libwebrtc/modules/video_coding/codecs/av1/av1_svc_config_gn/moz.build third_party/libwebrtc/modules/video_coding/codecs/av1/av1_svc_config_gn/moz.build
index 68e07db4ea7b..a8e1a60ea02f 100644
--- third_party/libwebrtc/modules/video_coding/codecs/av1/av1_svc_config_gn/moz.build
+++ third_party/libwebrtc/modules/video_coding/codecs/av1/av1_svc_config_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("av1_svc_config_gn")
diff --git third_party/libwebrtc/modules/video_coding/codecs/av1/dav1d_decoder_gn/moz.build third_party/libwebrtc/modules/video_coding/codecs/av1/dav1d_decoder_gn/moz.build
index d7062ced7f53..6505a3c7ed4a 100644
--- third_party/libwebrtc/modules/video_coding/codecs/av1/dav1d_decoder_gn/moz.build
+++ third_party/libwebrtc/modules/video_coding/codecs/av1/dav1d_decoder_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -47,185 +57,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("dav1d_decoder_gn")
diff --git third_party/libwebrtc/modules/video_coding/codecs/av1/libaom_av1_encoder_gn/moz.build third_party/libwebrtc/modules/video_coding/codecs/av1/libaom_av1_encoder_gn/moz.build
index 13e676095f98..686a56220b86 100644
--- third_party/libwebrtc/modules/video_coding/codecs/av1/libaom_av1_encoder_gn/moz.build
+++ third_party/libwebrtc/modules/video_coding/codecs/av1/libaom_av1_encoder_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,189 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("aom_av1_encoder_gn")
diff --git third_party/libwebrtc/modules/video_coding/encoded_frame_gn/moz.build third_party/libwebrtc/modules/video_coding/encoded_frame_gn/moz.build
index ff8f03e9900d..0e1fb2879b0d 100644
--- third_party/libwebrtc/modules/video_coding/encoded_frame_gn/moz.build
+++ third_party/libwebrtc/modules/video_coding/encoded_frame_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,189 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("encoded_frame_gn")
diff --git third_party/libwebrtc/modules/video_coding/frame_dependencies_calculator_gn/moz.build third_party/libwebrtc/modules/video_coding/frame_dependencies_calculator_gn/moz.build
index a353fa0c1a55..92c1f6a29021 100644
--- third_party/libwebrtc/modules/video_coding/frame_dependencies_calculator_gn/moz.build
+++ third_party/libwebrtc/modules/video_coding/frame_dependencies_calculator_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("frame_dependencies_calculator_gn")
diff --git third_party/libwebrtc/modules/video_coding/frame_helpers_gn/moz.build third_party/libwebrtc/modules/video_coding/frame_helpers_gn/moz.build
index 23f3426af9e8..22403ec92671 100644
--- third_party/libwebrtc/modules/video_coding/frame_helpers_gn/moz.build
+++ third_party/libwebrtc/modules/video_coding/frame_helpers_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("frame_helpers_gn")
diff --git third_party/libwebrtc/modules/video_coding/h264_sprop_parameter_sets_gn/moz.build third_party/libwebrtc/modules/video_coding/h264_sprop_parameter_sets_gn/moz.build
index 293c5a94474f..62c22e5056b2 100644
--- third_party/libwebrtc/modules/video_coding/h264_sprop_parameter_sets_gn/moz.build
+++ third_party/libwebrtc/modules/video_coding/h264_sprop_parameter_sets_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("h264_sprop_parameter_sets_gn")
diff --git third_party/libwebrtc/modules/video_coding/h26x_packet_buffer_gn/moz.build third_party/libwebrtc/modules/video_coding/h26x_packet_buffer_gn/moz.build
index 61b529cd9a1d..b355a983b2d8 100644
--- third_party/libwebrtc/modules/video_coding/h26x_packet_buffer_gn/moz.build
+++ third_party/libwebrtc/modules/video_coding/h26x_packet_buffer_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,189 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("h26x_packet_buffer_gn")
diff --git third_party/libwebrtc/modules/video_coding/nack_requester_gn/moz.build third_party/libwebrtc/modules/video_coding/nack_requester_gn/moz.build
index 81bf962b0588..8f93120e2188 100644
--- third_party/libwebrtc/modules/video_coding/nack_requester_gn/moz.build
+++ third_party/libwebrtc/modules/video_coding/nack_requester_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -44,189 +54,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("nack_requester_gn")
diff --git third_party/libwebrtc/modules/video_coding/packet_buffer_gn/moz.build third_party/libwebrtc/modules/video_coding/packet_buffer_gn/moz.build
index deb0e75d02d7..db30a57d3619 100644
--- third_party/libwebrtc/modules/video_coding/packet_buffer_gn/moz.build
+++ third_party/libwebrtc/modules/video_coding/packet_buffer_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,189 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("packet_buffer_gn")
diff --git third_party/libwebrtc/modules/video_coding/svc/scalability_mode_util_gn/moz.build third_party/libwebrtc/modules/video_coding/svc/scalability_mode_util_gn/moz.build
index a927c852333b..b397b36748b0 100644
--- third_party/libwebrtc/modules/video_coding/svc/scalability_mode_util_gn/moz.build
+++ third_party/libwebrtc/modules/video_coding/svc/scalability_mode_util_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("scalability_mode_util_gn")
diff --git third_party/libwebrtc/modules/video_coding/svc/scalability_structures_gn/moz.build third_party/libwebrtc/modules/video_coding/svc/scalability_structures_gn/moz.build
index 7d99ca631f7f..027e9e9fcecf 100644
--- third_party/libwebrtc/modules/video_coding/svc/scalability_structures_gn/moz.build
+++ third_party/libwebrtc/modules/video_coding/svc/scalability_structures_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -50,185 +60,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("scalability_structures_gn")
diff --git third_party/libwebrtc/modules/video_coding/svc/scalable_video_controller_gn/moz.build third_party/libwebrtc/modules/video_coding/svc/scalable_video_controller_gn/moz.build
index de65ae6081b2..c29bf99a9498 100644
--- third_party/libwebrtc/modules/video_coding/svc/scalable_video_controller_gn/moz.build
+++ third_party/libwebrtc/modules/video_coding/svc/scalable_video_controller_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("scalable_video_controller_gn")
diff --git third_party/libwebrtc/modules/video_coding/svc/simulcast_to_svc_converter_gn/moz.build third_party/libwebrtc/modules/video_coding/svc/simulcast_to_svc_converter_gn/moz.build
index 74ed12f1d08e..d96b59c45f2c 100644
--- third_party/libwebrtc/modules/video_coding/svc/simulcast_to_svc_converter_gn/moz.build
+++ third_party/libwebrtc/modules/video_coding/svc/simulcast_to_svc_converter_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("simulcast_to_svc_converter_gn")
diff --git third_party/libwebrtc/modules/video_coding/svc/svc_rate_allocator_gn/moz.build third_party/libwebrtc/modules/video_coding/svc/svc_rate_allocator_gn/moz.build
index 9ac42accf0a2..5dafc0fe81fb 100644
--- third_party/libwebrtc/modules/video_coding/svc/svc_rate_allocator_gn/moz.build
+++ third_party/libwebrtc/modules/video_coding/svc/svc_rate_allocator_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("svc_rate_allocator_gn")
diff --git third_party/libwebrtc/modules/video_coding/timing/decode_time_percentile_filter_gn/moz.build third_party/libwebrtc/modules/video_coding/timing/decode_time_percentile_filter_gn/moz.build
index edf94ba576b4..8a9cc2f130a3 100644
--- third_party/libwebrtc/modules/video_coding/timing/decode_time_percentile_filter_gn/moz.build
+++ third_party/libwebrtc/modules/video_coding/timing/decode_time_percentile_filter_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("decode_time_percentile_filter_gn")
diff --git third_party/libwebrtc/modules/video_coding/timing/frame_delay_variation_kalman_filter_gn/moz.build third_party/libwebrtc/modules/video_coding/timing/frame_delay_variation_kalman_filter_gn/moz.build
index 33b768c83d9b..d78cb90bc9fb 100644
--- third_party/libwebrtc/modules/video_coding/timing/frame_delay_variation_kalman_filter_gn/moz.build
+++ third_party/libwebrtc/modules/video_coding/timing/frame_delay_variation_kalman_filter_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("frame_delay_variation_kalman_filter_gn")
diff --git third_party/libwebrtc/modules/video_coding/timing/inter_frame_delay_variation_calculator_gn/moz.build third_party/libwebrtc/modules/video_coding/timing/inter_frame_delay_variation_calculator_gn/moz.build
index 2e60885cc8ad..8067370152f8 100644
--- third_party/libwebrtc/modules/video_coding/timing/inter_frame_delay_variation_calculator_gn/moz.build
+++ third_party/libwebrtc/modules/video_coding/timing/inter_frame_delay_variation_calculator_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("inter_frame_delay_variation_calculator_gn")
diff --git third_party/libwebrtc/modules/video_coding/timing/jitter_estimator_gn/moz.build third_party/libwebrtc/modules/video_coding/timing/jitter_estimator_gn/moz.build
index 93e4dc45ce3b..31f81ae96c73 100644
--- third_party/libwebrtc/modules/video_coding/timing/jitter_estimator_gn/moz.build
+++ third_party/libwebrtc/modules/video_coding/timing/jitter_estimator_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,189 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("jitter_estimator_gn")
diff --git third_party/libwebrtc/modules/video_coding/timing/rtt_filter_gn/moz.build third_party/libwebrtc/modules/video_coding/timing/rtt_filter_gn/moz.build
index 38d5005afb1d..59039b3cb5bb 100644
--- third_party/libwebrtc/modules/video_coding/timing/rtt_filter_gn/moz.build
+++ third_party/libwebrtc/modules/video_coding/timing/rtt_filter_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("rtt_filter_gn")
diff --git third_party/libwebrtc/modules/video_coding/timing/timestamp_extrapolator_gn/moz.build third_party/libwebrtc/modules/video_coding/timing/timestamp_extrapolator_gn/moz.build
index f8c4616bcda2..d3036cbe8185 100644
--- third_party/libwebrtc/modules/video_coding/timing/timestamp_extrapolator_gn/moz.build
+++ third_party/libwebrtc/modules/video_coding/timing/timestamp_extrapolator_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("timestamp_extrapolator_gn")
diff --git third_party/libwebrtc/modules/video_coding/timing/timing_module_gn/moz.build third_party/libwebrtc/modules/video_coding/timing/timing_module_gn/moz.build
index d517c26f4ee2..e6bb2e193cad 100644
--- third_party/libwebrtc/modules/video_coding/timing/timing_module_gn/moz.build
+++ third_party/libwebrtc/modules/video_coding/timing/timing_module_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,189 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("timing_module_gn")
diff --git third_party/libwebrtc/modules/video_coding/video_codec_interface_gn/moz.build third_party/libwebrtc/modules/video_coding/video_codec_interface_gn/moz.build
index dfd036b7704b..e4e3248b0090 100644
--- third_party/libwebrtc/modules/video_coding/video_codec_interface_gn/moz.build
+++ third_party/libwebrtc/modules/video_coding/video_codec_interface_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -45,185 +55,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("video_codec_interface_gn")
diff --git third_party/libwebrtc/modules/video_coding/video_coding_gn/moz.build third_party/libwebrtc/modules/video_coding/video_coding_gn/moz.build
index 35788afdc052..d43548f8655e 100644
--- third_party/libwebrtc/modules/video_coding/video_coding_gn/moz.build
+++ third_party/libwebrtc/modules/video_coding/video_coding_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -56,190 +66,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("video_coding_gn")
diff --git third_party/libwebrtc/modules/video_coding/video_coding_utility_gn/moz.build third_party/libwebrtc/modules/video_coding/video_coding_utility_gn/moz.build
index 73901879e767..8b8fa78c72ef 100644
--- third_party/libwebrtc/modules/video_coding/video_coding_utility_gn/moz.build
+++ third_party/libwebrtc/modules/video_coding/video_coding_utility_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -54,190 +64,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("video_coding_utility_gn")
diff --git third_party/libwebrtc/modules/video_coding/webrtc_h264_gn/moz.build third_party/libwebrtc/modules/video_coding/webrtc_h264_gn/moz.build
index 2ee1d4db7581..61dc3d2d514d 100644
--- third_party/libwebrtc/modules/video_coding/webrtc_h264_gn/moz.build
+++ third_party/libwebrtc/modules/video_coding/webrtc_h264_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -48,190 +58,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("webrtc_h264_gn")
diff --git third_party/libwebrtc/modules/video_coding/webrtc_libvpx_interface_gn/moz.build third_party/libwebrtc/modules/video_coding/webrtc_libvpx_interface_gn/moz.build
index e94a117cf5ae..590a98e740ab 100644
--- third_party/libwebrtc/modules/video_coding/webrtc_libvpx_interface_gn/moz.build
+++ third_party/libwebrtc/modules/video_coding/webrtc_libvpx_interface_gn/moz.build
@@ -15,11 +15,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -46,178 +56,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("webrtc_libvpx_interface_gn")
diff --git third_party/libwebrtc/modules/video_coding/webrtc_vp8_gn/moz.build third_party/libwebrtc/modules/video_coding/webrtc_vp8_gn/moz.build
index a0a827f8c662..4527fc66f0aa 100644
--- third_party/libwebrtc/modules/video_coding/webrtc_vp8_gn/moz.build
+++ third_party/libwebrtc/modules/video_coding/webrtc_vp8_gn/moz.build
@@ -15,11 +15,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -49,190 +59,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("webrtc_vp8_gn")
diff --git third_party/libwebrtc/modules/video_coding/webrtc_vp8_scalability_gn/moz.build third_party/libwebrtc/modules/video_coding/webrtc_vp8_scalability_gn/moz.build
index c6c24c5e660a..937c21caa208 100644
--- third_party/libwebrtc/modules/video_coding/webrtc_vp8_scalability_gn/moz.build
+++ third_party/libwebrtc/modules/video_coding/webrtc_vp8_scalability_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("webrtc_vp8_scalability_gn")
diff --git third_party/libwebrtc/modules/video_coding/webrtc_vp8_temporal_layers_gn/moz.build third_party/libwebrtc/modules/video_coding/webrtc_vp8_temporal_layers_gn/moz.build
index 9e4b59514b55..dac11fbcb08f 100644
--- third_party/libwebrtc/modules/video_coding/webrtc_vp8_temporal_layers_gn/moz.build
+++ third_party/libwebrtc/modules/video_coding/webrtc_vp8_temporal_layers_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -48,190 +58,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("webrtc_vp8_temporal_layers_gn")
diff --git third_party/libwebrtc/modules/video_coding/webrtc_vp9_gn/moz.build third_party/libwebrtc/modules/video_coding/webrtc_vp9_gn/moz.build
index 79230cbf3497..29e952cba05b 100644
--- third_party/libwebrtc/modules/video_coding/webrtc_vp9_gn/moz.build
+++ third_party/libwebrtc/modules/video_coding/webrtc_vp9_gn/moz.build
@@ -15,11 +15,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -51,190 +61,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("webrtc_vp9_gn")
diff --git third_party/libwebrtc/modules/video_coding/webrtc_vp9_helpers_gn/moz.build third_party/libwebrtc/modules/video_coding/webrtc_vp9_helpers_gn/moz.build
index 2c74ca51d93a..3a3dc9df3751 100644
--- third_party/libwebrtc/modules/video_coding/webrtc_vp9_helpers_gn/moz.build
+++ third_party/libwebrtc/modules/video_coding/webrtc_vp9_helpers_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("webrtc_vp9_helpers_gn")
diff --git third_party/libwebrtc/moz.build third_party/libwebrtc/moz.build
index 55f24e7c5f25..e7dda49da0e5 100644
--- third_party/libwebrtc/moz.build
+++ third_party/libwebrtc/moz.build
@@ -292,6 +292,8 @@ DIRS += [
     "/third_party/libwebrtc/modules/congestion_controller/goog_cc/send_side_bwe_gn",
     "/third_party/libwebrtc/modules/congestion_controller/rtp/control_handler_gn",
     "/third_party/libwebrtc/modules/congestion_controller/rtp/transport_feedback_gn",
+    "/third_party/libwebrtc/modules/desktop_capture/desktop_capture_gn",
+    "/third_party/libwebrtc/modules/desktop_capture/primitives_gn",
     "/third_party/libwebrtc/modules/module_api_gn",
     "/third_party/libwebrtc/modules/module_api_public_gn",
     "/third_party/libwebrtc/modules/module_fec_api_gn",
@@ -518,102 +520,11 @@ DIRS += [
     "/third_party/libwebrtc/webrtc_gn"
 ]
 
-if CONFIG["OS_TARGET"] == "Android":
-
-    DIRS += [
-        "/third_party/libwebrtc/rtc_base/ifaddrs_android_gn"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DIRS += [
-        "/third_party/libwebrtc/modules/desktop_capture/desktop_capture_gn",
-        "/third_party/libwebrtc/modules/desktop_capture/desktop_capture_objc_gn",
-        "/third_party/libwebrtc/modules/desktop_capture/primitives_gn",
-        "/third_party/libwebrtc/rtc_base/system/cocoa_threading_gn",
-        "/third_party/libwebrtc/rtc_base/system/gcd_helpers_gn",
-        "/third_party/libwebrtc/sdk/base_objc_gn",
-        "/third_party/libwebrtc/sdk/helpers_objc_gn",
-        "/third_party/libwebrtc/sdk/videocapture_objc_gn",
-        "/third_party/libwebrtc/sdk/videoframebuffer_objc_gn"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DIRS += [
-        "/third_party/libwebrtc/modules/desktop_capture/desktop_capture_gn",
-        "/third_party/libwebrtc/modules/desktop_capture/primitives_gn"
-    ]
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DIRS += [
-        "/third_party/libwebrtc/modules/desktop_capture/desktop_capture_gn",
-        "/third_party/libwebrtc/modules/desktop_capture/primitives_gn",
-        "/third_party/libwebrtc/rtc_base/win/create_direct3d_device_gn",
-        "/third_party/libwebrtc/rtc_base/win/get_activation_factory_gn",
-        "/third_party/libwebrtc/rtc_base/win/hstring_gn",
-        "/third_party/libwebrtc/rtc_base/win/windows_version_gn",
-        "/third_party/libwebrtc/rtc_base/win32_gn"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DIRS += [
-        "/third_party/libwebrtc/common_audio/common_audio_neon_c_gn",
-        "/third_party/libwebrtc/common_audio/common_audio_neon_gn"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    DIRS += [
-        "/third_party/libwebrtc/common_audio/common_audio_neon_c_gn",
-        "/third_party/libwebrtc/common_audio/common_audio_neon_gn",
-        "/third_party/libwebrtc/rtc_base/system/asm_defines_gn"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
-    DIRS += [
-        "/third_party/libwebrtc/common_audio/common_audio_avx2_gn",
-        "/third_party/libwebrtc/common_audio/common_audio_sse2_gn",
-        "/third_party/libwebrtc/modules/audio_processing/aec3/aec3_avx2_gn",
-        "/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/vector_math_avx2_gn"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DIRS += [
-        "/third_party/libwebrtc/common_audio/common_audio_avx2_gn",
-        "/third_party/libwebrtc/common_audio/common_audio_sse2_gn",
-        "/third_party/libwebrtc/modules/audio_processing/aec3/aec3_avx2_gn",
-        "/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/vector_math_avx2_gn"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DIRS += [
-        "/third_party/libwebrtc/common_audio/common_audio_neon_c_gn",
-        "/third_party/libwebrtc/common_audio/common_audio_neon_gn"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DIRS += [
-        "/third_party/libwebrtc/common_audio/common_audio_avx2_gn",
-        "/third_party/libwebrtc/common_audio/common_audio_sse2_gn",
-        "/third_party/libwebrtc/modules/audio_processing/aec3/aec3_avx2_gn",
-        "/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/vector_math_avx2_gn",
-        "/third_party/libwebrtc/modules/desktop_capture/desktop_capture_differ_sse2_gn"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
+if CONFIG["OS_TARGET"] == "FreeBSD" and CONFIG["TARGET_CPU"] == "aarch64":
 
     DIRS += [
         "/third_party/libwebrtc/common_audio/common_audio_neon_c_gn",
         "/third_party/libwebrtc/common_audio/common_audio_neon_gn",
-        "/third_party/libwebrtc/modules/desktop_capture/desktop_capture_gn",
-        "/third_party/libwebrtc/modules/desktop_capture/primitives_gn",
         "/third_party/libwebrtc/modules/portal/portal_gn",
         "/third_party/libwebrtc/third_party/drm/drm_gn",
         "/third_party/libwebrtc/third_party/gbm/gbm_gn",
@@ -621,26 +532,9 @@ if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
         "/third_party/libwebrtc/third_party/pipewire/pipewire_gn"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
+if CONFIG["OS_TARGET"] == "FreeBSD" and CONFIG["TARGET_CPU"] == "mips32":
 
     DIRS += [
-        "/third_party/libwebrtc/common_audio/common_audio_neon_c_gn",
-        "/third_party/libwebrtc/common_audio/common_audio_neon_gn",
-        "/third_party/libwebrtc/modules/desktop_capture/desktop_capture_gn",
-        "/third_party/libwebrtc/modules/desktop_capture/primitives_gn",
-        "/third_party/libwebrtc/modules/portal/portal_gn",
-        "/third_party/libwebrtc/rtc_base/system/asm_defines_gn",
-        "/third_party/libwebrtc/third_party/drm/drm_gn",
-        "/third_party/libwebrtc/third_party/gbm/gbm_gn",
-        "/third_party/libwebrtc/third_party/libepoxy/libepoxy_gn",
-        "/third_party/libwebrtc/third_party/pipewire/pipewire_gn"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "mips32":
-
-    DIRS += [
-        "/third_party/libwebrtc/modules/desktop_capture/desktop_capture_gn",
-        "/third_party/libwebrtc/modules/desktop_capture/primitives_gn",
         "/third_party/libwebrtc/modules/portal/portal_gn",
         "/third_party/libwebrtc/third_party/drm/drm_gn",
         "/third_party/libwebrtc/third_party/gbm/gbm_gn",
@@ -648,11 +542,9 @@ if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "mips32":
         "/third_party/libwebrtc/third_party/pipewire/pipewire_gn"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "mips64":
+if CONFIG["OS_TARGET"] == "FreeBSD" and CONFIG["TARGET_CPU"] == "mips64":
 
     DIRS += [
-        "/third_party/libwebrtc/modules/desktop_capture/desktop_capture_gn",
-        "/third_party/libwebrtc/modules/desktop_capture/primitives_gn",
         "/third_party/libwebrtc/modules/portal/portal_gn",
         "/third_party/libwebrtc/third_party/drm/drm_gn",
         "/third_party/libwebrtc/third_party/gbm/gbm_gn",
@@ -660,7 +552,7 @@ if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "mips64":
         "/third_party/libwebrtc/third_party/pipewire/pipewire_gn"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+if CONFIG["OS_TARGET"] == "FreeBSD" and CONFIG["TARGET_CPU"] == "x86":
 
     DIRS += [
         "/third_party/libwebrtc/common_audio/common_audio_avx2_gn",
@@ -668,8 +560,6 @@ if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
         "/third_party/libwebrtc/modules/audio_processing/aec3/aec3_avx2_gn",
         "/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/vector_math_avx2_gn",
         "/third_party/libwebrtc/modules/desktop_capture/desktop_capture_differ_sse2_gn",
-        "/third_party/libwebrtc/modules/desktop_capture/desktop_capture_gn",
-        "/third_party/libwebrtc/modules/desktop_capture/primitives_gn",
         "/third_party/libwebrtc/modules/portal/portal_gn",
         "/third_party/libwebrtc/third_party/drm/drm_gn",
         "/third_party/libwebrtc/third_party/gbm/gbm_gn",
@@ -677,7 +567,7 @@ if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
         "/third_party/libwebrtc/third_party/pipewire/pipewire_gn"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["OS_TARGET"] == "FreeBSD" and CONFIG["TARGET_CPU"] == "x86_64":
 
     DIRS += [
         "/third_party/libwebrtc/common_audio/common_audio_avx2_gn",
@@ -685,69 +575,9 @@ if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
         "/third_party/libwebrtc/modules/audio_processing/aec3/aec3_avx2_gn",
         "/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/vector_math_avx2_gn",
         "/third_party/libwebrtc/modules/desktop_capture/desktop_capture_differ_sse2_gn",
-        "/third_party/libwebrtc/modules/desktop_capture/desktop_capture_gn",
-        "/third_party/libwebrtc/modules/desktop_capture/primitives_gn",
         "/third_party/libwebrtc/modules/portal/portal_gn",
         "/third_party/libwebrtc/third_party/drm/drm_gn",
         "/third_party/libwebrtc/third_party/gbm/gbm_gn",
         "/third_party/libwebrtc/third_party/libepoxy/libepoxy_gn",
         "/third_party/libwebrtc/third_party/pipewire/pipewire_gn"
     ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DIRS += [
-        "/third_party/libwebrtc/common_audio/common_audio_neon_c_gn",
-        "/third_party/libwebrtc/common_audio/common_audio_neon_gn"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DIRS += [
-        "/third_party/libwebrtc/common_audio/common_audio_avx2_gn",
-        "/third_party/libwebrtc/common_audio/common_audio_sse2_gn",
-        "/third_party/libwebrtc/modules/audio_processing/aec3/aec3_avx2_gn",
-        "/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/vector_math_avx2_gn",
-        "/third_party/libwebrtc/modules/desktop_capture/desktop_capture_differ_sse2_gn"
-    ]
-
-if CONFIG["OS_TARGET"] == "WINNT" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DIRS += [
-        "/third_party/libwebrtc/common_audio/common_audio_neon_c_gn",
-        "/third_party/libwebrtc/common_audio/common_audio_neon_gn"
-    ]
-
-if CONFIG["OS_TARGET"] == "WINNT" and CONFIG["TARGET_CPU"] == "x86":
-
-    DIRS += [
-        "/third_party/libwebrtc/common_audio/common_audio_avx2_gn",
-        "/third_party/libwebrtc/common_audio/common_audio_sse2_gn",
-        "/third_party/libwebrtc/modules/audio_processing/aec3/aec3_avx2_gn",
-        "/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/vector_math_avx2_gn",
-        "/third_party/libwebrtc/modules/desktop_capture/desktop_capture_differ_sse2_gn"
-    ]
-
-if CONFIG["OS_TARGET"] == "WINNT" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DIRS += [
-        "/third_party/libwebrtc/common_audio/common_audio_avx2_gn",
-        "/third_party/libwebrtc/common_audio/common_audio_sse2_gn",
-        "/third_party/libwebrtc/modules/audio_processing/aec3/aec3_avx2_gn",
-        "/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/vector_math_avx2_gn",
-        "/third_party/libwebrtc/modules/desktop_capture/desktop_capture_differ_sse2_gn"
-    ]
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "ppc64":
-
-    DIRS += [
-        "/third_party/libwebrtc/modules/desktop_capture/desktop_capture_gn",
-        "/third_party/libwebrtc/modules/desktop_capture/primitives_gn"
-    ]
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "riscv64":
-
-    DIRS += [
-        "/third_party/libwebrtc/modules/desktop_capture/desktop_capture_gn",
-        "/third_party/libwebrtc/modules/desktop_capture/primitives_gn"
-    ]
diff --git third_party/libwebrtc/net/dcsctp/common/internal_types_gn/moz.build third_party/libwebrtc/net/dcsctp/common/internal_types_gn/moz.build
index c44b45ccb28a..50bc9dd138b1 100644
--- third_party/libwebrtc/net/dcsctp/common/internal_types_gn/moz.build
+++ third_party/libwebrtc/net/dcsctp/common/internal_types_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,111 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -153,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("internal_types_gn")
diff --git third_party/libwebrtc/net/dcsctp/common/math_gn/moz.build third_party/libwebrtc/net/dcsctp/common/math_gn/moz.build
index 2012ad67b93c..f2b6c6f8dd34 100644
--- third_party/libwebrtc/net/dcsctp/common/math_gn/moz.build
+++ third_party/libwebrtc/net/dcsctp/common/math_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("math_gn")
diff --git third_party/libwebrtc/net/dcsctp/common/sequence_numbers_gn/moz.build third_party/libwebrtc/net/dcsctp/common/sequence_numbers_gn/moz.build
index 4b98db30759e..5113dad22f0e 100644
--- third_party/libwebrtc/net/dcsctp/common/sequence_numbers_gn/moz.build
+++ third_party/libwebrtc/net/dcsctp/common/sequence_numbers_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,111 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -153,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("sequence_numbers_gn")
diff --git third_party/libwebrtc/net/dcsctp/packet/bounded_io_gn/moz.build third_party/libwebrtc/net/dcsctp/packet/bounded_io_gn/moz.build
index 9b807caa2fca..777d99d02e76 100644
--- third_party/libwebrtc/net/dcsctp/packet/bounded_io_gn/moz.build
+++ third_party/libwebrtc/net/dcsctp/packet/bounded_io_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,111 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -153,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("bounded_io_gn")
diff --git third_party/libwebrtc/net/dcsctp/packet/chunk_gn/moz.build third_party/libwebrtc/net/dcsctp/packet/chunk_gn/moz.build
index 5c409ce50e73..6cfbaa05eff0 100644
--- third_party/libwebrtc/net/dcsctp/packet/chunk_gn/moz.build
+++ third_party/libwebrtc/net/dcsctp/packet/chunk_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -60,185 +70,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("chunk_gn")
diff --git third_party/libwebrtc/net/dcsctp/packet/chunk_validators_gn/moz.build third_party/libwebrtc/net/dcsctp/packet/chunk_validators_gn/moz.build
index b37e5b698771..660fd5b70fe4 100644
--- third_party/libwebrtc/net/dcsctp/packet/chunk_validators_gn/moz.build
+++ third_party/libwebrtc/net/dcsctp/packet/chunk_validators_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("chunk_validators_gn")
diff --git third_party/libwebrtc/net/dcsctp/packet/crc32c_gn/moz.build third_party/libwebrtc/net/dcsctp/packet/crc32c_gn/moz.build
index 1f688d936217..75f9e4101bc7 100644
--- third_party/libwebrtc/net/dcsctp/packet/crc32c_gn/moz.build
+++ third_party/libwebrtc/net/dcsctp/packet/crc32c_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("crc32c_gn")
diff --git third_party/libwebrtc/net/dcsctp/packet/data_gn/moz.build third_party/libwebrtc/net/dcsctp/packet/data_gn/moz.build
index 645a199eddb8..74ded9e4288e 100644
--- third_party/libwebrtc/net/dcsctp/packet/data_gn/moz.build
+++ third_party/libwebrtc/net/dcsctp/packet/data_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,111 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -153,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("data_gn")
diff --git third_party/libwebrtc/net/dcsctp/packet/error_cause_gn/moz.build third_party/libwebrtc/net/dcsctp/packet/error_cause_gn/moz.build
index e1234461a818..4dfd207d96ad 100644
--- third_party/libwebrtc/net/dcsctp/packet/error_cause_gn/moz.build
+++ third_party/libwebrtc/net/dcsctp/packet/error_cause_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -56,185 +66,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("error_cause_gn")
diff --git third_party/libwebrtc/net/dcsctp/packet/parameter_gn/moz.build third_party/libwebrtc/net/dcsctp/packet/parameter_gn/moz.build
index 33e73bd7e304..fdc446b8d615 100644
--- third_party/libwebrtc/net/dcsctp/packet/parameter_gn/moz.build
+++ third_party/libwebrtc/net/dcsctp/packet/parameter_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -54,185 +64,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("parameter_gn")
diff --git third_party/libwebrtc/net/dcsctp/packet/sctp_packet_gn/moz.build third_party/libwebrtc/net/dcsctp/packet/sctp_packet_gn/moz.build
index 32dbd9f477fa..c8cae0f58ea6 100644
--- third_party/libwebrtc/net/dcsctp/packet/sctp_packet_gn/moz.build
+++ third_party/libwebrtc/net/dcsctp/packet/sctp_packet_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("sctp_packet_gn")
diff --git third_party/libwebrtc/net/dcsctp/packet/tlv_trait_gn/moz.build third_party/libwebrtc/net/dcsctp/packet/tlv_trait_gn/moz.build
index 81fa5732fee0..c85b7fcb9ee9 100644
--- third_party/libwebrtc/net/dcsctp/packet/tlv_trait_gn/moz.build
+++ third_party/libwebrtc/net/dcsctp/packet/tlv_trait_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("tlv_trait_gn")
diff --git third_party/libwebrtc/net/dcsctp/public/factory_gn/moz.build third_party/libwebrtc/net/dcsctp/public/factory_gn/moz.build
index c862859b1251..c7680875af0b 100644
--- third_party/libwebrtc/net/dcsctp/public/factory_gn/moz.build
+++ third_party/libwebrtc/net/dcsctp/public/factory_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("factory_gn")
diff --git third_party/libwebrtc/net/dcsctp/public/socket_gn/moz.build third_party/libwebrtc/net/dcsctp/public/socket_gn/moz.build
index adb35e438ffc..4be3f7feae7f 100644
--- third_party/libwebrtc/net/dcsctp/public/socket_gn/moz.build
+++ third_party/libwebrtc/net/dcsctp/public/socket_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("socket_gn")
diff --git third_party/libwebrtc/net/dcsctp/public/types_gn/moz.build third_party/libwebrtc/net/dcsctp/public/types_gn/moz.build
index 013fabe0fce2..f1c2ea4ce834 100644
--- third_party/libwebrtc/net/dcsctp/public/types_gn/moz.build
+++ third_party/libwebrtc/net/dcsctp/public/types_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,111 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -153,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("types_gn")
diff --git third_party/libwebrtc/net/dcsctp/rx/data_tracker_gn/moz.build third_party/libwebrtc/net/dcsctp/rx/data_tracker_gn/moz.build
index 4ee544f64806..c59c4b3a5cac 100644
--- third_party/libwebrtc/net/dcsctp/rx/data_tracker_gn/moz.build
+++ third_party/libwebrtc/net/dcsctp/rx/data_tracker_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("data_tracker_gn")
diff --git third_party/libwebrtc/net/dcsctp/rx/interleaved_reassembly_streams_gn/moz.build third_party/libwebrtc/net/dcsctp/rx/interleaved_reassembly_streams_gn/moz.build
index b97e2da228a9..d70be2b39e04 100644
--- third_party/libwebrtc/net/dcsctp/rx/interleaved_reassembly_streams_gn/moz.build
+++ third_party/libwebrtc/net/dcsctp/rx/interleaved_reassembly_streams_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("interleaved_reassembly_streams_gn")
diff --git third_party/libwebrtc/net/dcsctp/rx/reassembly_queue_gn/moz.build third_party/libwebrtc/net/dcsctp/rx/reassembly_queue_gn/moz.build
index b43d1dd3c99d..6f682f824c9a 100644
--- third_party/libwebrtc/net/dcsctp/rx/reassembly_queue_gn/moz.build
+++ third_party/libwebrtc/net/dcsctp/rx/reassembly_queue_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("reassembly_queue_gn")
diff --git third_party/libwebrtc/net/dcsctp/rx/reassembly_streams_gn/moz.build third_party/libwebrtc/net/dcsctp/rx/reassembly_streams_gn/moz.build
index b5635c5866b6..3e92f31e7d26 100644
--- third_party/libwebrtc/net/dcsctp/rx/reassembly_streams_gn/moz.build
+++ third_party/libwebrtc/net/dcsctp/rx/reassembly_streams_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,118 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -160,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("reassembly_streams_gn")
diff --git third_party/libwebrtc/net/dcsctp/rx/traditional_reassembly_streams_gn/moz.build third_party/libwebrtc/net/dcsctp/rx/traditional_reassembly_streams_gn/moz.build
index e864f3b4e47a..5e4e3989043d 100644
--- third_party/libwebrtc/net/dcsctp/rx/traditional_reassembly_streams_gn/moz.build
+++ third_party/libwebrtc/net/dcsctp/rx/traditional_reassembly_streams_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("traditional_reassembly_streams_gn")
diff --git third_party/libwebrtc/net/dcsctp/socket/context_gn/moz.build third_party/libwebrtc/net/dcsctp/socket/context_gn/moz.build
index ea8183fb378f..843a0c7b78b1 100644
--- third_party/libwebrtc/net/dcsctp/socket/context_gn/moz.build
+++ third_party/libwebrtc/net/dcsctp/socket/context_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,118 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -160,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("context_gn")
diff --git third_party/libwebrtc/net/dcsctp/socket/dcsctp_socket_gn/moz.build third_party/libwebrtc/net/dcsctp/socket/dcsctp_socket_gn/moz.build
index 4476e9e314fc..460dba07cdeb 100644
--- third_party/libwebrtc/net/dcsctp/socket/dcsctp_socket_gn/moz.build
+++ third_party/libwebrtc/net/dcsctp/socket/dcsctp_socket_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -45,185 +55,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("dcsctp_socket_gn")
diff --git third_party/libwebrtc/net/dcsctp/socket/heartbeat_handler_gn/moz.build third_party/libwebrtc/net/dcsctp/socket/heartbeat_handler_gn/moz.build
index d5c531c8e762..38d9532e7f9e 100644
--- third_party/libwebrtc/net/dcsctp/socket/heartbeat_handler_gn/moz.build
+++ third_party/libwebrtc/net/dcsctp/socket/heartbeat_handler_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("heartbeat_handler_gn")
diff --git third_party/libwebrtc/net/dcsctp/socket/packet_sender_gn/moz.build third_party/libwebrtc/net/dcsctp/socket/packet_sender_gn/moz.build
index e2bd90bdbbcf..ea7e09d7a7f5 100644
--- third_party/libwebrtc/net/dcsctp/socket/packet_sender_gn/moz.build
+++ third_party/libwebrtc/net/dcsctp/socket/packet_sender_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("packet_sender_gn")
diff --git third_party/libwebrtc/net/dcsctp/socket/stream_reset_handler_gn/moz.build third_party/libwebrtc/net/dcsctp/socket/stream_reset_handler_gn/moz.build
index b544f83bf97b..ac695b3f8139 100644
--- third_party/libwebrtc/net/dcsctp/socket/stream_reset_handler_gn/moz.build
+++ third_party/libwebrtc/net/dcsctp/socket/stream_reset_handler_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("stream_reset_handler_gn")
diff --git third_party/libwebrtc/net/dcsctp/socket/transmission_control_block_gn/moz.build third_party/libwebrtc/net/dcsctp/socket/transmission_control_block_gn/moz.build
index 52c581990d3e..8fef42ff1bd5 100644
--- third_party/libwebrtc/net/dcsctp/socket/transmission_control_block_gn/moz.build
+++ third_party/libwebrtc/net/dcsctp/socket/transmission_control_block_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("transmission_control_block_gn")
diff --git third_party/libwebrtc/net/dcsctp/timer/task_queue_timeout_gn/moz.build third_party/libwebrtc/net/dcsctp/timer/task_queue_timeout_gn/moz.build
index 66892eaf4f26..f900d22e218f 100644
--- third_party/libwebrtc/net/dcsctp/timer/task_queue_timeout_gn/moz.build
+++ third_party/libwebrtc/net/dcsctp/timer/task_queue_timeout_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("task_queue_timeout_gn")
diff --git third_party/libwebrtc/net/dcsctp/timer/timer_gn/moz.build third_party/libwebrtc/net/dcsctp/timer/timer_gn/moz.build
index 4c41a69cdbcc..1b2b8a09eab5 100644
--- third_party/libwebrtc/net/dcsctp/timer/timer_gn/moz.build
+++ third_party/libwebrtc/net/dcsctp/timer/timer_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("timer_gn")
diff --git third_party/libwebrtc/net/dcsctp/tx/outstanding_data_gn/moz.build third_party/libwebrtc/net/dcsctp/tx/outstanding_data_gn/moz.build
index 904f67126944..a8bd51b1b21f 100644
--- third_party/libwebrtc/net/dcsctp/tx/outstanding_data_gn/moz.build
+++ third_party/libwebrtc/net/dcsctp/tx/outstanding_data_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("outstanding_data_gn")
diff --git third_party/libwebrtc/net/dcsctp/tx/retransmission_error_counter_gn/moz.build third_party/libwebrtc/net/dcsctp/tx/retransmission_error_counter_gn/moz.build
index 6c6318286173..a78b7689e278 100644
--- third_party/libwebrtc/net/dcsctp/tx/retransmission_error_counter_gn/moz.build
+++ third_party/libwebrtc/net/dcsctp/tx/retransmission_error_counter_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("retransmission_error_counter_gn")
diff --git third_party/libwebrtc/net/dcsctp/tx/retransmission_queue_gn/moz.build third_party/libwebrtc/net/dcsctp/tx/retransmission_queue_gn/moz.build
index 9b5c6d8cf564..23ee3b6935e8 100644
--- third_party/libwebrtc/net/dcsctp/tx/retransmission_queue_gn/moz.build
+++ third_party/libwebrtc/net/dcsctp/tx/retransmission_queue_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("retransmission_queue_gn")
diff --git third_party/libwebrtc/net/dcsctp/tx/retransmission_timeout_gn/moz.build third_party/libwebrtc/net/dcsctp/tx/retransmission_timeout_gn/moz.build
index bb2190262099..97ac7b74ad7e 100644
--- third_party/libwebrtc/net/dcsctp/tx/retransmission_timeout_gn/moz.build
+++ third_party/libwebrtc/net/dcsctp/tx/retransmission_timeout_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("retransmission_timeout_gn")
diff --git third_party/libwebrtc/net/dcsctp/tx/rr_send_queue_gn/moz.build third_party/libwebrtc/net/dcsctp/tx/rr_send_queue_gn/moz.build
index 1c21c9910d53..606d2124121c 100644
--- third_party/libwebrtc/net/dcsctp/tx/rr_send_queue_gn/moz.build
+++ third_party/libwebrtc/net/dcsctp/tx/rr_send_queue_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("rr_send_queue_gn")
diff --git third_party/libwebrtc/net/dcsctp/tx/send_queue_gn/moz.build third_party/libwebrtc/net/dcsctp/tx/send_queue_gn/moz.build
index 23426721dc1a..69c26faf6bbf 100644
--- third_party/libwebrtc/net/dcsctp/tx/send_queue_gn/moz.build
+++ third_party/libwebrtc/net/dcsctp/tx/send_queue_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,118 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -160,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("send_queue_gn")
diff --git third_party/libwebrtc/net/dcsctp/tx/stream_scheduler_gn/moz.build third_party/libwebrtc/net/dcsctp/tx/stream_scheduler_gn/moz.build
index eed261218f86..e35e30f2660a 100644
--- third_party/libwebrtc/net/dcsctp/tx/stream_scheduler_gn/moz.build
+++ third_party/libwebrtc/net/dcsctp/tx/stream_scheduler_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("stream_scheduler_gn")
diff --git third_party/libwebrtc/rtc_base/async_dns_resolver_gn/moz.build third_party/libwebrtc/rtc_base/async_dns_resolver_gn/moz.build
index 04a6adf96394..88b861565869 100644
--- third_party/libwebrtc/rtc_base/async_dns_resolver_gn/moz.build
+++ third_party/libwebrtc/rtc_base/async_dns_resolver_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,186 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("async_dns_resolver_gn")
diff --git third_party/libwebrtc/rtc_base/async_packet_socket_gn/moz.build third_party/libwebrtc/rtc_base/async_packet_socket_gn/moz.build
index 9337d72a6bc5..4a1391f2f165 100644
--- third_party/libwebrtc/rtc_base/async_packet_socket_gn/moz.build
+++ third_party/libwebrtc/rtc_base/async_packet_socket_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("async_packet_socket_gn")
diff --git third_party/libwebrtc/rtc_base/audio_format_to_string_gn/moz.build third_party/libwebrtc/rtc_base/audio_format_to_string_gn/moz.build
index 6d057c77d749..b47f3bd09377 100644
--- third_party/libwebrtc/rtc_base/audio_format_to_string_gn/moz.build
+++ third_party/libwebrtc/rtc_base/audio_format_to_string_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("audio_format_to_string_gn")
diff --git third_party/libwebrtc/rtc_base/bit_buffer_gn/moz.build third_party/libwebrtc/rtc_base/bit_buffer_gn/moz.build
index b9848a28795a..1d5ffe5e020b 100644
--- third_party/libwebrtc/rtc_base/bit_buffer_gn/moz.build
+++ third_party/libwebrtc/rtc_base/bit_buffer_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("bit_buffer_gn")
diff --git third_party/libwebrtc/rtc_base/bitrate_tracker_gn/moz.build third_party/libwebrtc/rtc_base/bitrate_tracker_gn/moz.build
index 3019986ef2ea..5d90cb6ec00f 100644
--- third_party/libwebrtc/rtc_base/bitrate_tracker_gn/moz.build
+++ third_party/libwebrtc/rtc_base/bitrate_tracker_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("bitrate_tracker_gn")
diff --git third_party/libwebrtc/rtc_base/bitstream_reader_gn/moz.build third_party/libwebrtc/rtc_base/bitstream_reader_gn/moz.build
index 08b85e88db60..446ec6fc995d 100644
--- third_party/libwebrtc/rtc_base/bitstream_reader_gn/moz.build
+++ third_party/libwebrtc/rtc_base/bitstream_reader_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("bitstream_reader_gn")
diff --git third_party/libwebrtc/rtc_base/buffer_gn/moz.build third_party/libwebrtc/rtc_base/buffer_gn/moz.build
index ca6f8408cdc8..f15920a7cf12 100644
--- third_party/libwebrtc/rtc_base/buffer_gn/moz.build
+++ third_party/libwebrtc/rtc_base/buffer_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,111 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -153,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("buffer_gn")
diff --git third_party/libwebrtc/rtc_base/byte_buffer_gn/moz.build third_party/libwebrtc/rtc_base/byte_buffer_gn/moz.build
index 925b6e4218f3..d5f124885e6a 100644
--- third_party/libwebrtc/rtc_base/byte_buffer_gn/moz.build
+++ third_party/libwebrtc/rtc_base/byte_buffer_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("byte_buffer_gn")
diff --git third_party/libwebrtc/rtc_base/byte_order_gn/moz.build third_party/libwebrtc/rtc_base/byte_order_gn/moz.build
index 44c220a2f709..6711c3416489 100644
--- third_party/libwebrtc/rtc_base/byte_order_gn/moz.build
+++ third_party/libwebrtc/rtc_base/byte_order_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("byte_order_gn")
diff --git third_party/libwebrtc/rtc_base/checks_gn/moz.build third_party/libwebrtc/rtc_base/checks_gn/moz.build
index ea191d0a1620..16bfbb3bb54b 100644
--- third_party/libwebrtc/rtc_base/checks_gn/moz.build
+++ third_party/libwebrtc/rtc_base/checks_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("checks_gn")
diff --git third_party/libwebrtc/rtc_base/compile_assert_c_gn/moz.build third_party/libwebrtc/rtc_base/compile_assert_c_gn/moz.build
index 29b7e50f59de..23e0ab489558 100644
--- third_party/libwebrtc/rtc_base/compile_assert_c_gn/moz.build
+++ third_party/libwebrtc/rtc_base/compile_assert_c_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("compile_assert_c_gn")
diff --git third_party/libwebrtc/rtc_base/containers/flat_containers_internal_gn/moz.build third_party/libwebrtc/rtc_base/containers/flat_containers_internal_gn/moz.build
index 3cf4d58b7080..ef23a514029f 100644
--- third_party/libwebrtc/rtc_base/containers/flat_containers_internal_gn/moz.build
+++ third_party/libwebrtc/rtc_base/containers/flat_containers_internal_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("flat_containers_internal_gn")
diff --git third_party/libwebrtc/rtc_base/containers/flat_map_gn/moz.build third_party/libwebrtc/rtc_base/containers/flat_map_gn/moz.build
index 7dbec6779333..0e9d882980cd 100644
--- third_party/libwebrtc/rtc_base/containers/flat_map_gn/moz.build
+++ third_party/libwebrtc/rtc_base/containers/flat_map_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,111 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -153,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("flat_map_gn")
diff --git third_party/libwebrtc/rtc_base/containers/flat_set_gn/moz.build third_party/libwebrtc/rtc_base/containers/flat_set_gn/moz.build
index ad3fa6725577..c727277850d9 100644
--- third_party/libwebrtc/rtc_base/containers/flat_set_gn/moz.build
+++ third_party/libwebrtc/rtc_base/containers/flat_set_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,111 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -153,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("flat_set_gn")
diff --git third_party/libwebrtc/rtc_base/copy_on_write_buffer_gn/moz.build third_party/libwebrtc/rtc_base/copy_on_write_buffer_gn/moz.build
index 9e422ff63e7c..f2aef4b56160 100644
--- third_party/libwebrtc/rtc_base/copy_on_write_buffer_gn/moz.build
+++ third_party/libwebrtc/rtc_base/copy_on_write_buffer_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("copy_on_write_buffer_gn")
diff --git third_party/libwebrtc/rtc_base/criticalsection_gn/moz.build third_party/libwebrtc/rtc_base/criticalsection_gn/moz.build
index 82b460295383..84ae29b05824 100644
--- third_party/libwebrtc/rtc_base/criticalsection_gn/moz.build
+++ third_party/libwebrtc/rtc_base/criticalsection_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("criticalsection_gn")
diff --git third_party/libwebrtc/rtc_base/divide_round_gn/moz.build third_party/libwebrtc/rtc_base/divide_round_gn/moz.build
index bcbc3682adb0..d570fc975f7e 100644
--- third_party/libwebrtc/rtc_base/divide_round_gn/moz.build
+++ third_party/libwebrtc/rtc_base/divide_round_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,111 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -153,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("divide_round_gn")
diff --git third_party/libwebrtc/rtc_base/dscp_gn/moz.build third_party/libwebrtc/rtc_base/dscp_gn/moz.build
index 90110683589b..e64459ac9342 100644
--- third_party/libwebrtc/rtc_base/dscp_gn/moz.build
+++ third_party/libwebrtc/rtc_base/dscp_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("dscp_gn")
diff --git third_party/libwebrtc/rtc_base/event_tracer_gn/moz.build third_party/libwebrtc/rtc_base/event_tracer_gn/moz.build
index 4c4181482928..45269272694b 100644
--- third_party/libwebrtc/rtc_base/event_tracer_gn/moz.build
+++ third_party/libwebrtc/rtc_base/event_tracer_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("event_tracer_gn")
diff --git third_party/libwebrtc/rtc_base/experiments/alr_experiment_gn/moz.build third_party/libwebrtc/rtc_base/experiments/alr_experiment_gn/moz.build
index 4e53a89a0562..b8c7071256f8 100644
--- third_party/libwebrtc/rtc_base/experiments/alr_experiment_gn/moz.build
+++ third_party/libwebrtc/rtc_base/experiments/alr_experiment_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("alr_experiment_gn")
diff --git third_party/libwebrtc/rtc_base/experiments/balanced_degradation_settings_gn/moz.build third_party/libwebrtc/rtc_base/experiments/balanced_degradation_settings_gn/moz.build
index 3ddc28da45c3..eba8ea19a441 100644
--- third_party/libwebrtc/rtc_base/experiments/balanced_degradation_settings_gn/moz.build
+++ third_party/libwebrtc/rtc_base/experiments/balanced_degradation_settings_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("balanced_degradation_settings_gn")
diff --git third_party/libwebrtc/rtc_base/experiments/encoder_info_settings_gn/moz.build third_party/libwebrtc/rtc_base/experiments/encoder_info_settings_gn/moz.build
index 8ab7b59f9ac5..06e2533c9c80 100644
--- third_party/libwebrtc/rtc_base/experiments/encoder_info_settings_gn/moz.build
+++ third_party/libwebrtc/rtc_base/experiments/encoder_info_settings_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("encoder_info_settings_gn")
diff --git third_party/libwebrtc/rtc_base/experiments/field_trial_parser_gn/moz.build third_party/libwebrtc/rtc_base/experiments/field_trial_parser_gn/moz.build
index 7c2115ee42eb..25df1c876186 100644
--- third_party/libwebrtc/rtc_base/experiments/field_trial_parser_gn/moz.build
+++ third_party/libwebrtc/rtc_base/experiments/field_trial_parser_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -46,185 +56,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("field_trial_parser_gn")
diff --git third_party/libwebrtc/rtc_base/experiments/keyframe_interval_settings_experiment_gn/moz.build third_party/libwebrtc/rtc_base/experiments/keyframe_interval_settings_experiment_gn/moz.build
index 80ee96a36692..8aed2262fa3a 100644
--- third_party/libwebrtc/rtc_base/experiments/keyframe_interval_settings_experiment_gn/moz.build
+++ third_party/libwebrtc/rtc_base/experiments/keyframe_interval_settings_experiment_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("keyframe_interval_settings_experiment_gn")
diff --git third_party/libwebrtc/rtc_base/experiments/min_video_bitrate_experiment_gn/moz.build third_party/libwebrtc/rtc_base/experiments/min_video_bitrate_experiment_gn/moz.build
index 237ee94c876c..3d2ad771efb1 100644
--- third_party/libwebrtc/rtc_base/experiments/min_video_bitrate_experiment_gn/moz.build
+++ third_party/libwebrtc/rtc_base/experiments/min_video_bitrate_experiment_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("min_video_bitrate_experiment_gn")
diff --git third_party/libwebrtc/rtc_base/experiments/normalize_simulcast_size_experiment_gn/moz.build third_party/libwebrtc/rtc_base/experiments/normalize_simulcast_size_experiment_gn/moz.build
index 4f2adbf257e3..1443386f65f6 100644
--- third_party/libwebrtc/rtc_base/experiments/normalize_simulcast_size_experiment_gn/moz.build
+++ third_party/libwebrtc/rtc_base/experiments/normalize_simulcast_size_experiment_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("normalize_simulcast_size_experiment_gn")
diff --git third_party/libwebrtc/rtc_base/experiments/quality_scaler_settings_gn/moz.build third_party/libwebrtc/rtc_base/experiments/quality_scaler_settings_gn/moz.build
index 0d309eb7e460..a6981acc4b34 100644
--- third_party/libwebrtc/rtc_base/experiments/quality_scaler_settings_gn/moz.build
+++ third_party/libwebrtc/rtc_base/experiments/quality_scaler_settings_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("quality_scaler_settings_gn")
diff --git third_party/libwebrtc/rtc_base/experiments/quality_scaling_experiment_gn/moz.build third_party/libwebrtc/rtc_base/experiments/quality_scaling_experiment_gn/moz.build
index 59d541e6a005..291cb10ff7b1 100644
--- third_party/libwebrtc/rtc_base/experiments/quality_scaling_experiment_gn/moz.build
+++ third_party/libwebrtc/rtc_base/experiments/quality_scaling_experiment_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("quality_scaling_experiment_gn")
diff --git third_party/libwebrtc/rtc_base/experiments/rate_control_settings_gn/moz.build third_party/libwebrtc/rtc_base/experiments/rate_control_settings_gn/moz.build
index 34a32a0e0d68..2fd714931789 100644
--- third_party/libwebrtc/rtc_base/experiments/rate_control_settings_gn/moz.build
+++ third_party/libwebrtc/rtc_base/experiments/rate_control_settings_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("rate_control_settings_gn")
diff --git third_party/libwebrtc/rtc_base/experiments/stable_target_rate_experiment_gn/moz.build third_party/libwebrtc/rtc_base/experiments/stable_target_rate_experiment_gn/moz.build
index 90de4c0afe60..0f16c03dadfc 100644
--- third_party/libwebrtc/rtc_base/experiments/stable_target_rate_experiment_gn/moz.build
+++ third_party/libwebrtc/rtc_base/experiments/stable_target_rate_experiment_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("stable_target_rate_experiment_gn")
diff --git third_party/libwebrtc/rtc_base/frequency_tracker_gn/moz.build third_party/libwebrtc/rtc_base/frequency_tracker_gn/moz.build
index d73e4f6d7f93..37564838b7da 100644
--- third_party/libwebrtc/rtc_base/frequency_tracker_gn/moz.build
+++ third_party/libwebrtc/rtc_base/frequency_tracker_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("frequency_tracker_gn")
diff --git third_party/libwebrtc/rtc_base/gtest_prod_gn/moz.build third_party/libwebrtc/rtc_base/gtest_prod_gn/moz.build
index 39f95b2ec843..bbd991488a12 100644
--- third_party/libwebrtc/rtc_base/gtest_prod_gn/moz.build
+++ third_party/libwebrtc/rtc_base/gtest_prod_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("gtest_prod_gn")
diff --git third_party/libwebrtc/rtc_base/histogram_percentile_counter_gn/moz.build third_party/libwebrtc/rtc_base/histogram_percentile_counter_gn/moz.build
index a9e54dfe82c8..71f8d55f43eb 100644
--- third_party/libwebrtc/rtc_base/histogram_percentile_counter_gn/moz.build
+++ third_party/libwebrtc/rtc_base/histogram_percentile_counter_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("histogram_percentile_counter_gn")
diff --git third_party/libwebrtc/rtc_base/ifaddrs_android_gn/moz.build third_party/libwebrtc/rtc_base/ifaddrs_android_gn/moz.build
deleted file mode 100644
index c4452691d690..000000000000
--- third_party/libwebrtc/rtc_base/ifaddrs_android_gn/moz.build
+++ /dev/null
@@ -1,95 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-
-  ### This moz.build was AUTOMATICALLY GENERATED from a GN config,  ###
-  ### DO NOT edit it by hand.                                       ###
-
-COMPILE_FLAGS["OS_INCLUDES"] = []
-AllowCompilerWarnings()
-
-DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
-DEFINES["ANDROID"] = True
-DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-DEFINES["HAVE_SYS_UIO_H"] = True
-DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
-DEFINES["RTC_ENABLE_VP9"] = True
-DEFINES["WEBRTC_ANDROID"] = True
-DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
-DEFINES["WEBRTC_LIBRARY_IMPL"] = True
-DEFINES["WEBRTC_LINUX"] = True
-DEFINES["WEBRTC_MOZILLA_BUILD"] = True
-DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
-DEFINES["WEBRTC_POSIX"] = True
-DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
-DEFINES["_GNU_SOURCE"] = True
-DEFINES["__STDC_CONSTANT_MACROS"] = True
-DEFINES["__STDC_FORMAT_MACROS"] = True
-
-FINAL_LIBRARY = "xul"
-
-
-LOCAL_INCLUDES += [
-    "!/ipc/ipdl/_ipdlheaders",
-    "!/third_party/libwebrtc/gen",
-    "/ipc/chromium/src",
-    "/third_party/abseil-cpp/",
-    "/third_party/libwebrtc/",
-    "/tools/profiler/public"
-]
-
-OS_LIBS += [
-    "GLESv2",
-    "log"
-]
-
-UNIFIED_SOURCES += [
-    "/third_party/libwebrtc/rtc_base/ifaddrs_android.cc"
-]
-
-if not CONFIG["MOZ_DEBUG"]:
-
-    DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "0"
-    DEFINES["NDEBUG"] = True
-    DEFINES["NVALGRIND"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1":
-
-    DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["WEBRTC_ARCH_ARM64"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["TARGET_CPU"] == "x86":
-
-    CXXFLAGS += [
-        "-msse2"
-    ]
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-Library("ifaddrs_android_gn")
diff --git third_party/libwebrtc/rtc_base/ignore_wundef_gn/moz.build third_party/libwebrtc/rtc_base/ignore_wundef_gn/moz.build
index c50706007bf3..10301c3a59c3 100644
--- third_party/libwebrtc/rtc_base/ignore_wundef_gn/moz.build
+++ third_party/libwebrtc/rtc_base/ignore_wundef_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("ignore_wundef_gn")
diff --git third_party/libwebrtc/rtc_base/ip_address_gn/moz.build third_party/libwebrtc/rtc_base/ip_address_gn/moz.build
index d7e6c9f293db..6b9a73dc693a 100644
--- third_party/libwebrtc/rtc_base/ip_address_gn/moz.build
+++ third_party/libwebrtc/rtc_base/ip_address_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("ip_address_gn")
diff --git third_party/libwebrtc/rtc_base/logging_gn/moz.build third_party/libwebrtc/rtc_base/logging_gn/moz.build
index 56ed104e2002..c7896a36c136 100644
--- third_party/libwebrtc/rtc_base/logging_gn/moz.build
+++ third_party/libwebrtc/rtc_base/logging_gn/moz.build
@@ -12,12 +12,22 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
 DEFINES["WEBRTC_APM_DEBUG_DUMP"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -44,185 +54,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("logging_gn")
diff --git third_party/libwebrtc/rtc_base/macromagic_gn/moz.build third_party/libwebrtc/rtc_base/macromagic_gn/moz.build
index 359df288f2c1..2c34f5c36858 100644
--- third_party/libwebrtc/rtc_base/macromagic_gn/moz.build
+++ third_party/libwebrtc/rtc_base/macromagic_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("macromagic_gn")
diff --git third_party/libwebrtc/rtc_base/memory/aligned_malloc_gn/moz.build third_party/libwebrtc/rtc_base/memory/aligned_malloc_gn/moz.build
index d09905b69892..8d65543a25ae 100644
--- third_party/libwebrtc/rtc_base/memory/aligned_malloc_gn/moz.build
+++ third_party/libwebrtc/rtc_base/memory/aligned_malloc_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("aligned_malloc_gn")
diff --git third_party/libwebrtc/rtc_base/mod_ops_gn/moz.build third_party/libwebrtc/rtc_base/mod_ops_gn/moz.build
index b65e15c66b17..66702507ea4f 100644
--- third_party/libwebrtc/rtc_base/mod_ops_gn/moz.build
+++ third_party/libwebrtc/rtc_base/mod_ops_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,111 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -153,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("mod_ops_gn")
diff --git third_party/libwebrtc/rtc_base/moving_max_counter_gn/moz.build third_party/libwebrtc/rtc_base/moving_max_counter_gn/moz.build
index f04b67d19d4f..b40ca1e737db 100644
--- third_party/libwebrtc/rtc_base/moving_max_counter_gn/moz.build
+++ third_party/libwebrtc/rtc_base/moving_max_counter_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,111 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -153,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("moving_max_counter_gn")
diff --git third_party/libwebrtc/rtc_base/net_helpers_gn/moz.build third_party/libwebrtc/rtc_base/net_helpers_gn/moz.build
index db5cf7eda3e1..a0bb9924d1c9 100644
--- third_party/libwebrtc/rtc_base/net_helpers_gn/moz.build
+++ third_party/libwebrtc/rtc_base/net_helpers_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("net_helpers_gn")
diff --git third_party/libwebrtc/rtc_base/network/ecn_marking_gn/moz.build third_party/libwebrtc/rtc_base/network/ecn_marking_gn/moz.build
index 51dafd65f729..ac8a6db64809 100644
--- third_party/libwebrtc/rtc_base/network/ecn_marking_gn/moz.build
+++ third_party/libwebrtc/rtc_base/network/ecn_marking_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("ecn_marking_gn")
diff --git third_party/libwebrtc/rtc_base/network/sent_packet_gn/moz.build third_party/libwebrtc/rtc_base/network/sent_packet_gn/moz.build
index 3871a5742f23..5d6eea6ab93e 100644
--- third_party/libwebrtc/rtc_base/network/sent_packet_gn/moz.build
+++ third_party/libwebrtc/rtc_base/network/sent_packet_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,174 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("sent_packet_gn")
diff --git third_party/libwebrtc/rtc_base/network_constants_gn/moz.build third_party/libwebrtc/rtc_base/network_constants_gn/moz.build
index e016c6ebf353..7a9faee8edd4 100644
--- third_party/libwebrtc/rtc_base/network_constants_gn/moz.build
+++ third_party/libwebrtc/rtc_base/network_constants_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("network_constants_gn")
diff --git third_party/libwebrtc/rtc_base/network_route_gn/moz.build third_party/libwebrtc/rtc_base/network_route_gn/moz.build
index d36384ccc5e4..b09cda2e8318 100644
--- third_party/libwebrtc/rtc_base/network_route_gn/moz.build
+++ third_party/libwebrtc/rtc_base/network_route_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("network_route_gn")
diff --git third_party/libwebrtc/rtc_base/null_socket_server_gn/moz.build third_party/libwebrtc/rtc_base/null_socket_server_gn/moz.build
index 2d3797324776..b2beb103f324 100644
--- third_party/libwebrtc/rtc_base/null_socket_server_gn/moz.build
+++ third_party/libwebrtc/rtc_base/null_socket_server_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,186 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("null_socket_server_gn")
diff --git third_party/libwebrtc/rtc_base/one_time_event_gn/moz.build third_party/libwebrtc/rtc_base/one_time_event_gn/moz.build
index e12f306d6159..41e22676df3e 100644
--- third_party/libwebrtc/rtc_base/one_time_event_gn/moz.build
+++ third_party/libwebrtc/rtc_base/one_time_event_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,111 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -153,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("one_time_event_gn")
diff --git third_party/libwebrtc/rtc_base/platform_thread_gn/moz.build third_party/libwebrtc/rtc_base/platform_thread_gn/moz.build
index de9df4d78af5..a2158f92f387 100644
--- third_party/libwebrtc/rtc_base/platform_thread_gn/moz.build
+++ third_party/libwebrtc/rtc_base/platform_thread_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("platform_thread_gn")
diff --git third_party/libwebrtc/rtc_base/platform_thread_types_gn/moz.build third_party/libwebrtc/rtc_base/platform_thread_types_gn/moz.build
index fa305fd318ba..c2a316b35e10 100644
--- third_party/libwebrtc/rtc_base/platform_thread_types_gn/moz.build
+++ third_party/libwebrtc/rtc_base/platform_thread_types_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("platform_thread_types_gn")
diff --git third_party/libwebrtc/rtc_base/protobuf_utils_gn/moz.build third_party/libwebrtc/rtc_base/protobuf_utils_gn/moz.build
index 89ac56a987e5..a841f3c9d9d2 100644
--- third_party/libwebrtc/rtc_base/protobuf_utils_gn/moz.build
+++ third_party/libwebrtc/rtc_base/protobuf_utils_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("protobuf_utils_gn")
diff --git third_party/libwebrtc/rtc_base/race_checker_gn/moz.build third_party/libwebrtc/rtc_base/race_checker_gn/moz.build
index 8fe24e9ea339..d3c399736dda 100644
--- third_party/libwebrtc/rtc_base/race_checker_gn/moz.build
+++ third_party/libwebrtc/rtc_base/race_checker_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("race_checker_gn")
diff --git third_party/libwebrtc/rtc_base/random_gn/moz.build third_party/libwebrtc/rtc_base/random_gn/moz.build
index 3790744893dc..57d892e7235d 100644
--- third_party/libwebrtc/rtc_base/random_gn/moz.build
+++ third_party/libwebrtc/rtc_base/random_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("random_gn")
diff --git third_party/libwebrtc/rtc_base/rate_limiter_gn/moz.build third_party/libwebrtc/rtc_base/rate_limiter_gn/moz.build
index 5329a3ecff3d..517eb779f5e9 100644
--- third_party/libwebrtc/rtc_base/rate_limiter_gn/moz.build
+++ third_party/libwebrtc/rtc_base/rate_limiter_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,189 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("rate_limiter_gn")
diff --git third_party/libwebrtc/rtc_base/rate_statistics_gn/moz.build third_party/libwebrtc/rtc_base/rate_statistics_gn/moz.build
index dcf729ffe8ed..648ca137ca30 100644
--- third_party/libwebrtc/rtc_base/rate_statistics_gn/moz.build
+++ third_party/libwebrtc/rtc_base/rate_statistics_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("rate_statistics_gn")
diff --git third_party/libwebrtc/rtc_base/rate_tracker_gn/moz.build third_party/libwebrtc/rtc_base/rate_tracker_gn/moz.build
index 0c54b37a137f..4cdd20074653 100644
--- third_party/libwebrtc/rtc_base/rate_tracker_gn/moz.build
+++ third_party/libwebrtc/rtc_base/rate_tracker_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("rate_tracker_gn")
diff --git third_party/libwebrtc/rtc_base/refcount_gn/moz.build third_party/libwebrtc/rtc_base/refcount_gn/moz.build
index 9f5c572f202c..b59156b9ccc7 100644
--- third_party/libwebrtc/rtc_base/refcount_gn/moz.build
+++ third_party/libwebrtc/rtc_base/refcount_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("refcount_gn")
diff --git third_party/libwebrtc/rtc_base/rolling_accumulator_gn/moz.build third_party/libwebrtc/rtc_base/rolling_accumulator_gn/moz.build
index 879a61c33625..c18fcf730b81 100644
--- third_party/libwebrtc/rtc_base/rolling_accumulator_gn/moz.build
+++ third_party/libwebrtc/rtc_base/rolling_accumulator_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,111 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -153,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("rolling_accumulator_gn")
diff --git third_party/libwebrtc/rtc_base/rtc_event_gn/moz.build third_party/libwebrtc/rtc_base/rtc_event_gn/moz.build
index 28da0c698193..d983fa9a5f55 100644
--- third_party/libwebrtc/rtc_base/rtc_event_gn/moz.build
+++ third_party/libwebrtc/rtc_base/rtc_event_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("rtc_event_gn")
diff --git third_party/libwebrtc/rtc_base/rtc_numerics_gn/moz.build third_party/libwebrtc/rtc_base/rtc_numerics_gn/moz.build
index dc606f8e631b..b22128cee619 100644
--- third_party/libwebrtc/rtc_base/rtc_numerics_gn/moz.build
+++ third_party/libwebrtc/rtc_base/rtc_numerics_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -45,178 +55,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("rtc_numerics_gn")
diff --git third_party/libwebrtc/rtc_base/safe_compare_gn/moz.build third_party/libwebrtc/rtc_base/safe_compare_gn/moz.build
index 6bd90aff9d21..93e8d7ca347d 100644
--- third_party/libwebrtc/rtc_base/safe_compare_gn/moz.build
+++ third_party/libwebrtc/rtc_base/safe_compare_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("safe_compare_gn")
diff --git third_party/libwebrtc/rtc_base/safe_conversions_gn/moz.build third_party/libwebrtc/rtc_base/safe_conversions_gn/moz.build
index 728f9986f5bb..a50766d20e54 100644
--- third_party/libwebrtc/rtc_base/safe_conversions_gn/moz.build
+++ third_party/libwebrtc/rtc_base/safe_conversions_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,111 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -153,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("safe_conversions_gn")
diff --git third_party/libwebrtc/rtc_base/safe_minmax_gn/moz.build third_party/libwebrtc/rtc_base/safe_minmax_gn/moz.build
index 08d6ed5a08e3..7a9dc1e1e62d 100644
--- third_party/libwebrtc/rtc_base/safe_minmax_gn/moz.build
+++ third_party/libwebrtc/rtc_base/safe_minmax_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,111 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -153,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("safe_minmax_gn")
diff --git third_party/libwebrtc/rtc_base/sample_counter_gn/moz.build third_party/libwebrtc/rtc_base/sample_counter_gn/moz.build
index bf6a8ed2ea36..df72ddace4dc 100644
--- third_party/libwebrtc/rtc_base/sample_counter_gn/moz.build
+++ third_party/libwebrtc/rtc_base/sample_counter_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("sample_counter_gn")
diff --git third_party/libwebrtc/rtc_base/sanitizer_gn/moz.build third_party/libwebrtc/rtc_base/sanitizer_gn/moz.build
index 10412ea91e8b..be2a4ecea3ea 100644
--- third_party/libwebrtc/rtc_base/sanitizer_gn/moz.build
+++ third_party/libwebrtc/rtc_base/sanitizer_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("sanitizer_gn")
diff --git third_party/libwebrtc/rtc_base/socket_address_gn/moz.build third_party/libwebrtc/rtc_base/socket_address_gn/moz.build
index a519752955ba..b92e05c8cf11 100644
--- third_party/libwebrtc/rtc_base/socket_address_gn/moz.build
+++ third_party/libwebrtc/rtc_base/socket_address_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,186 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("socket_address_gn")
diff --git third_party/libwebrtc/rtc_base/socket_factory_gn/moz.build third_party/libwebrtc/rtc_base/socket_factory_gn/moz.build
index a7ffe7659d0d..f1b8575eb212 100644
--- third_party/libwebrtc/rtc_base/socket_factory_gn/moz.build
+++ third_party/libwebrtc/rtc_base/socket_factory_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,119 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -161,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("socket_factory_gn")
diff --git third_party/libwebrtc/rtc_base/socket_gn/moz.build third_party/libwebrtc/rtc_base/socket_gn/moz.build
index 25090bb71acd..917bf97aa0d1 100644
--- third_party/libwebrtc/rtc_base/socket_gn/moz.build
+++ third_party/libwebrtc/rtc_base/socket_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,186 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("socket_gn")
diff --git third_party/libwebrtc/rtc_base/socket_server_gn/moz.build third_party/libwebrtc/rtc_base/socket_server_gn/moz.build
index c8422272d86d..c487a6a1a9c3 100644
--- third_party/libwebrtc/rtc_base/socket_server_gn/moz.build
+++ third_party/libwebrtc/rtc_base/socket_server_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,119 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -161,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("socket_server_gn")
diff --git third_party/libwebrtc/rtc_base/ssl_adapter_gn/moz.build third_party/libwebrtc/rtc_base/ssl_adapter_gn/moz.build
index 5918111073da..dffbff477eb4 100644
--- third_party/libwebrtc/rtc_base/ssl_adapter_gn/moz.build
+++ third_party/libwebrtc/rtc_base/ssl_adapter_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("ssl_adapter_gn")
diff --git third_party/libwebrtc/rtc_base/ssl_gn/moz.build third_party/libwebrtc/rtc_base/ssl_gn/moz.build
index bfe661ea4787..300330129fe1 100644
--- third_party/libwebrtc/rtc_base/ssl_gn/moz.build
+++ third_party/libwebrtc/rtc_base/ssl_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("ssl_gn")
diff --git third_party/libwebrtc/rtc_base/stringutils_gn/moz.build third_party/libwebrtc/rtc_base/stringutils_gn/moz.build
index 75921a43ab56..d47eb321a37c 100644
--- third_party/libwebrtc/rtc_base/stringutils_gn/moz.build
+++ third_party/libwebrtc/rtc_base/stringutils_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -47,178 +57,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("stringutils_gn")
diff --git third_party/libwebrtc/rtc_base/strong_alias_gn/moz.build third_party/libwebrtc/rtc_base/strong_alias_gn/moz.build
index 04a9115ab9ef..bc03fb306863 100644
--- third_party/libwebrtc/rtc_base/strong_alias_gn/moz.build
+++ third_party/libwebrtc/rtc_base/strong_alias_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("strong_alias_gn")
diff --git third_party/libwebrtc/rtc_base/swap_queue_gn/moz.build third_party/libwebrtc/rtc_base/swap_queue_gn/moz.build
index ca2c7814e857..9d5e20f05cd1 100644
--- third_party/libwebrtc/rtc_base/swap_queue_gn/moz.build
+++ third_party/libwebrtc/rtc_base/swap_queue_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,111 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -153,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("swap_queue_gn")
diff --git third_party/libwebrtc/rtc_base/synchronization/mutex_gn/moz.build third_party/libwebrtc/rtc_base/synchronization/mutex_gn/moz.build
index b643fe459c81..5e1c1cd358d7 100644
--- third_party/libwebrtc/rtc_base/synchronization/mutex_gn/moz.build
+++ third_party/libwebrtc/rtc_base/synchronization/mutex_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,111 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -153,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("mutex_gn")
diff --git third_party/libwebrtc/rtc_base/synchronization/sequence_checker_internal_gn/moz.build third_party/libwebrtc/rtc_base/synchronization/sequence_checker_internal_gn/moz.build
index bb5927b75df3..1367d09cbfd7 100644
--- third_party/libwebrtc/rtc_base/synchronization/sequence_checker_internal_gn/moz.build
+++ third_party/libwebrtc/rtc_base/synchronization/sequence_checker_internal_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("sequence_checker_internal_gn")
diff --git third_party/libwebrtc/rtc_base/synchronization/yield_gn/moz.build third_party/libwebrtc/rtc_base/synchronization/yield_gn/moz.build
index 395ae6db1d66..649b24818cda 100644
--- third_party/libwebrtc/rtc_base/synchronization/yield_gn/moz.build
+++ third_party/libwebrtc/rtc_base/synchronization/yield_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,174 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("yield_gn")
diff --git third_party/libwebrtc/rtc_base/synchronization/yield_policy_gn/moz.build third_party/libwebrtc/rtc_base/synchronization/yield_policy_gn/moz.build
index 9b3743827556..6cce225200a7 100644
--- third_party/libwebrtc/rtc_base/synchronization/yield_policy_gn/moz.build
+++ third_party/libwebrtc/rtc_base/synchronization/yield_policy_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("yield_policy_gn")
diff --git third_party/libwebrtc/rtc_base/system/arch_gn/moz.build third_party/libwebrtc/rtc_base/system/arch_gn/moz.build
index eab84dd33140..cc9898059b47 100644
--- third_party/libwebrtc/rtc_base/system/arch_gn/moz.build
+++ third_party/libwebrtc/rtc_base/system/arch_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("arch_gn")
diff --git third_party/libwebrtc/rtc_base/system/asm_defines_gn/moz.build third_party/libwebrtc/rtc_base/system/asm_defines_gn/moz.build
deleted file mode 100644
index aef882dd21c6..000000000000
--- third_party/libwebrtc/rtc_base/system/asm_defines_gn/moz.build
+++ /dev/null
@@ -1,80 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-
-  ### This moz.build was AUTOMATICALLY GENERATED from a GN config,  ###
-  ### DO NOT edit it by hand.                                       ###
-
-COMPILE_FLAGS["OS_INCLUDES"] = []
-AllowCompilerWarnings()
-
-DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
-DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
-DEFINES["RTC_ENABLE_VP9"] = True
-DEFINES["WEBRTC_ARCH_ARM"] = True
-DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
-DEFINES["WEBRTC_HAS_NEON"] = True
-DEFINES["WEBRTC_LIBRARY_IMPL"] = True
-DEFINES["WEBRTC_LINUX"] = True
-DEFINES["WEBRTC_MOZILLA_BUILD"] = True
-DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
-DEFINES["WEBRTC_POSIX"] = True
-DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
-DEFINES["_GNU_SOURCE"] = True
-DEFINES["__STDC_CONSTANT_MACROS"] = True
-DEFINES["__STDC_FORMAT_MACROS"] = True
-
-FINAL_LIBRARY = "xul"
-
-
-LOCAL_INCLUDES += [
-    "!/ipc/ipdl/_ipdlheaders",
-    "!/third_party/libwebrtc/gen",
-    "/ipc/chromium/src",
-    "/third_party/abseil-cpp/",
-    "/third_party/libwebrtc/",
-    "/tools/profiler/public"
-]
-
-if not CONFIG["MOZ_DEBUG"]:
-
-    DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "0"
-    DEFINES["NDEBUG"] = True
-    DEFINES["NVALGRIND"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1":
-
-    DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-Library("asm_defines_gn")
diff --git third_party/libwebrtc/rtc_base/system/cocoa_threading_gn/moz.build third_party/libwebrtc/rtc_base/system/cocoa_threading_gn/moz.build
deleted file mode 100644
index 558f19324d33..000000000000
--- third_party/libwebrtc/rtc_base/system/cocoa_threading_gn/moz.build
+++ /dev/null
@@ -1,67 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-
-  ### This moz.build was AUTOMATICALLY GENERATED from a GN config,  ###
-  ### DO NOT edit it by hand.                                       ###
-
-CMMFLAGS += [
-    "-fobjc-arc"
-]
-
-COMPILE_FLAGS["OS_INCLUDES"] = []
-AllowCompilerWarnings()
-
-DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
-DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
-DEFINES["RTC_ENABLE_VP9"] = True
-DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
-DEFINES["WEBRTC_LIBRARY_IMPL"] = True
-DEFINES["WEBRTC_MAC"] = True
-DEFINES["WEBRTC_MOZILLA_BUILD"] = True
-DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
-DEFINES["WEBRTC_POSIX"] = True
-DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
-DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-DEFINES["__STDC_CONSTANT_MACROS"] = True
-DEFINES["__STDC_FORMAT_MACROS"] = True
-
-FINAL_LIBRARY = "xul"
-
-
-LOCAL_INCLUDES += [
-    "!/ipc/ipdl/_ipdlheaders",
-    "!/third_party/libwebrtc/gen",
-    "/ipc/chromium/src",
-    "/third_party/abseil-cpp/",
-    "/third_party/libwebrtc/",
-    "/tools/profiler/public"
-]
-
-UNIFIED_SOURCES += [
-    "/third_party/libwebrtc/rtc_base/system/cocoa_threading.mm"
-]
-
-if not CONFIG["MOZ_DEBUG"]:
-
-    DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "0"
-    DEFINES["NDEBUG"] = True
-    DEFINES["NVALGRIND"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1":
-
-    DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["WEBRTC_ARCH_ARM64"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-Library("cocoa_threading_gn")
diff --git third_party/libwebrtc/rtc_base/system/file_wrapper_gn/moz.build third_party/libwebrtc/rtc_base/system/file_wrapper_gn/moz.build
index 4fa2a3995855..b24a234a8441 100644
--- third_party/libwebrtc/rtc_base/system/file_wrapper_gn/moz.build
+++ third_party/libwebrtc/rtc_base/system/file_wrapper_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("file_wrapper_gn")
diff --git third_party/libwebrtc/rtc_base/system/gcd_helpers_gn/moz.build third_party/libwebrtc/rtc_base/system/gcd_helpers_gn/moz.build
deleted file mode 100644
index ebb3552a5504..000000000000
--- third_party/libwebrtc/rtc_base/system/gcd_helpers_gn/moz.build
+++ /dev/null
@@ -1,67 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-
-  ### This moz.build was AUTOMATICALLY GENERATED from a GN config,  ###
-  ### DO NOT edit it by hand.                                       ###
-
-CMFLAGS += [
-    "-fobjc-arc"
-]
-
-COMPILE_FLAGS["OS_INCLUDES"] = []
-AllowCompilerWarnings()
-
-DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
-DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
-DEFINES["RTC_ENABLE_VP9"] = True
-DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
-DEFINES["WEBRTC_LIBRARY_IMPL"] = True
-DEFINES["WEBRTC_MAC"] = True
-DEFINES["WEBRTC_MOZILLA_BUILD"] = True
-DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
-DEFINES["WEBRTC_POSIX"] = True
-DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
-DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-DEFINES["__STDC_CONSTANT_MACROS"] = True
-DEFINES["__STDC_FORMAT_MACROS"] = True
-
-FINAL_LIBRARY = "xul"
-
-
-LOCAL_INCLUDES += [
-    "!/ipc/ipdl/_ipdlheaders",
-    "!/third_party/libwebrtc/gen",
-    "/ipc/chromium/src",
-    "/third_party/abseil-cpp/",
-    "/third_party/libwebrtc/",
-    "/tools/profiler/public"
-]
-
-UNIFIED_SOURCES += [
-    "/third_party/libwebrtc/rtc_base/system/gcd_helpers.m"
-]
-
-if not CONFIG["MOZ_DEBUG"]:
-
-    DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "0"
-    DEFINES["NDEBUG"] = True
-    DEFINES["NVALGRIND"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1":
-
-    DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["WEBRTC_ARCH_ARM64"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-Library("gcd_helpers_gn")
diff --git third_party/libwebrtc/rtc_base/system/ignore_warnings_gn/moz.build third_party/libwebrtc/rtc_base/system/ignore_warnings_gn/moz.build
index d807d9e45d42..b6f7d1224f89 100644
--- third_party/libwebrtc/rtc_base/system/ignore_warnings_gn/moz.build
+++ third_party/libwebrtc/rtc_base/system/ignore_warnings_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("ignore_warnings_gn")
diff --git third_party/libwebrtc/rtc_base/system/inline_gn/moz.build third_party/libwebrtc/rtc_base/system/inline_gn/moz.build
index e427abf5700d..7b1087757005 100644
--- third_party/libwebrtc/rtc_base/system/inline_gn/moz.build
+++ third_party/libwebrtc/rtc_base/system/inline_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("inline_gn")
diff --git third_party/libwebrtc/rtc_base/system/no_unique_address_gn/moz.build third_party/libwebrtc/rtc_base/system/no_unique_address_gn/moz.build
index 8003a8f5e6ff..fa1723ca2198 100644
--- third_party/libwebrtc/rtc_base/system/no_unique_address_gn/moz.build
+++ third_party/libwebrtc/rtc_base/system/no_unique_address_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("no_unique_address_gn")
diff --git third_party/libwebrtc/rtc_base/system/rtc_export_gn/moz.build third_party/libwebrtc/rtc_base/system/rtc_export_gn/moz.build
index d58855bc2c57..85f76cc47513 100644
--- third_party/libwebrtc/rtc_base/system/rtc_export_gn/moz.build
+++ third_party/libwebrtc/rtc_base/system/rtc_export_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("rtc_export_gn")
diff --git third_party/libwebrtc/rtc_base/system/unused_gn/moz.build third_party/libwebrtc/rtc_base/system/unused_gn/moz.build
index 14c87f46cf75..2e2d1ccdc9f2 100644
--- third_party/libwebrtc/rtc_base/system/unused_gn/moz.build
+++ third_party/libwebrtc/rtc_base/system/unused_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("unused_gn")
diff --git third_party/libwebrtc/rtc_base/system/warn_current_thread_is_deadlocked_gn/moz.build third_party/libwebrtc/rtc_base/system/warn_current_thread_is_deadlocked_gn/moz.build
index 639589a8525d..9f50e33f1bd5 100644
--- third_party/libwebrtc/rtc_base/system/warn_current_thread_is_deadlocked_gn/moz.build
+++ third_party/libwebrtc/rtc_base/system/warn_current_thread_is_deadlocked_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("warn_current_thread_is_deadlocked_gn")
diff --git third_party/libwebrtc/rtc_base/task_utils/repeating_task_gn/moz.build third_party/libwebrtc/rtc_base/task_utils/repeating_task_gn/moz.build
index 330b87a2f876..2cecca8682c7 100644
--- third_party/libwebrtc/rtc_base/task_utils/repeating_task_gn/moz.build
+++ third_party/libwebrtc/rtc_base/task_utils/repeating_task_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,189 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("repeating_task_gn")
diff --git third_party/libwebrtc/rtc_base/third_party/base64/base64_gn/moz.build third_party/libwebrtc/rtc_base/third_party/base64/base64_gn/moz.build
index 813e85ca2e2a..90c22496578a 100644
--- third_party/libwebrtc/rtc_base/third_party/base64/base64_gn/moz.build
+++ third_party/libwebrtc/rtc_base/third_party/base64/base64_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("base64_gn")
diff --git third_party/libwebrtc/rtc_base/third_party/sigslot/sigslot_gn/moz.build third_party/libwebrtc/rtc_base/third_party/sigslot/sigslot_gn/moz.build
index dc375810b3f0..4bc36c2f4d30 100644
--- third_party/libwebrtc/rtc_base/third_party/sigslot/sigslot_gn/moz.build
+++ third_party/libwebrtc/rtc_base/third_party/sigslot/sigslot_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,174 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("sigslot_gn")
diff --git third_party/libwebrtc/rtc_base/threading_gn/moz.build third_party/libwebrtc/rtc_base/threading_gn/moz.build
index 56cbe529d143..efec4f148ca9 100644
--- third_party/libwebrtc/rtc_base/threading_gn/moz.build
+++ third_party/libwebrtc/rtc_base/threading_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -46,202 +56,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-    UNIFIED_SOURCES += [
-        "/third_party/libwebrtc/rtc_base/physical_socket_server.cc"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    UNIFIED_SOURCES += [
-        "/third_party/libwebrtc/rtc_base/physical_socket_server.cc"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    UNIFIED_SOURCES += [
-        "/third_party/libwebrtc/rtc_base/physical_socket_server.cc"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
-
-    UNIFIED_SOURCES += [
-        "/third_party/libwebrtc/rtc_base/physical_socket_server.cc"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("threading_gn")
diff --git third_party/libwebrtc/rtc_base/timeutils_gn/moz.build third_party/libwebrtc/rtc_base/timeutils_gn/moz.build
index bb37032aff82..3cce4edd523d 100644
--- third_party/libwebrtc/rtc_base/timeutils_gn/moz.build
+++ third_party/libwebrtc/rtc_base/timeutils_gn/moz.build
@@ -12,12 +12,22 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_EXCLUDE_SYSTEM_TIME"] = True
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -45,185 +55,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("timeutils_gn")
diff --git third_party/libwebrtc/rtc_base/type_traits_gn/moz.build third_party/libwebrtc/rtc_base/type_traits_gn/moz.build
index 1236cdcdc0ef..f8427d18b1f6 100644
--- third_party/libwebrtc/rtc_base/type_traits_gn/moz.build
+++ third_party/libwebrtc/rtc_base/type_traits_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("type_traits_gn")
diff --git third_party/libwebrtc/rtc_base/unique_id_generator_gn/moz.build third_party/libwebrtc/rtc_base/unique_id_generator_gn/moz.build
index a3b15450a5d8..2833f41808a1 100644
--- third_party/libwebrtc/rtc_base/unique_id_generator_gn/moz.build
+++ third_party/libwebrtc/rtc_base/unique_id_generator_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("unique_id_generator_gn")
diff --git third_party/libwebrtc/rtc_base/units/unit_base_gn/moz.build third_party/libwebrtc/rtc_base/units/unit_base_gn/moz.build
index 4bf43cc48410..c8ff69d62f0f 100644
--- third_party/libwebrtc/rtc_base/units/unit_base_gn/moz.build
+++ third_party/libwebrtc/rtc_base/units/unit_base_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,111 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -153,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("unit_base_gn")
diff --git third_party/libwebrtc/rtc_base/weak_ptr_gn/moz.build third_party/libwebrtc/rtc_base/weak_ptr_gn/moz.build
index cd3c1db313a2..0a0f133cae3e 100644
--- third_party/libwebrtc/rtc_base/weak_ptr_gn/moz.build
+++ third_party/libwebrtc/rtc_base/weak_ptr_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("weak_ptr_gn")
diff --git third_party/libwebrtc/rtc_base/win/create_direct3d_device_gn/moz.build third_party/libwebrtc/rtc_base/win/create_direct3d_device_gn/moz.build
deleted file mode 100644
index 6782a6918724..000000000000
--- third_party/libwebrtc/rtc_base/win/create_direct3d_device_gn/moz.build
+++ /dev/null
@@ -1,85 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-
-  ### This moz.build was AUTOMATICALLY GENERATED from a GN config,  ###
-  ### DO NOT edit it by hand.                                       ###
-
-COMPILE_FLAGS["OS_INCLUDES"] = []
-AllowCompilerWarnings()
-
-DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
-DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-DEFINES["NOMINMAX"] = True
-DEFINES["NTDDI_VERSION"] = "0x0A000000"
-DEFINES["PSAPI_VERSION"] = "2"
-DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
-DEFINES["RTC_ENABLE_VP9"] = True
-DEFINES["RTC_ENABLE_WIN_WGC"] = True
-DEFINES["UNICODE"] = True
-DEFINES["USE_AURA"] = "1"
-DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
-DEFINES["WEBRTC_LIBRARY_IMPL"] = True
-DEFINES["WEBRTC_MOZILLA_BUILD"] = True
-DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
-DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
-DEFINES["WEBRTC_WIN"] = True
-DEFINES["WIN32"] = True
-DEFINES["WIN32_LEAN_AND_MEAN"] = True
-DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-DEFINES["WINVER"] = "0x0A00"
-DEFINES["_ATL_NO_OPENGL"] = True
-DEFINES["_CRT_RAND_S"] = True
-DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-DEFINES["_HAS_EXCEPTIONS"] = "0"
-DEFINES["_HAS_NODISCARD"] = True
-DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-DEFINES["_SECURE_ATL"] = True
-DEFINES["_UNICODE"] = True
-DEFINES["_WIN32_WINNT"] = "0x0A00"
-DEFINES["_WINDOWS"] = True
-DEFINES["__STD_C"] = True
-
-FINAL_LIBRARY = "xul"
-
-
-LOCAL_INCLUDES += [
-    "!/ipc/ipdl/_ipdlheaders",
-    "!/third_party/libwebrtc/gen",
-    "/ipc/chromium/src",
-    "/third_party/abseil-cpp/",
-    "/third_party/libwebrtc/",
-    "/tools/profiler/public"
-]
-
-UNIFIED_SOURCES += [
-    "/third_party/libwebrtc/rtc_base/win/create_direct3d_device.cc"
-]
-
-if not CONFIG["MOZ_DEBUG"]:
-
-    DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "0"
-    DEFINES["NDEBUG"] = True
-    DEFINES["NVALGRIND"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1":
-
-    DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["WEBRTC_ARCH_ARM64"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
-if CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-Library("create_direct3d_device_gn")
diff --git third_party/libwebrtc/rtc_base/win/get_activation_factory_gn/moz.build third_party/libwebrtc/rtc_base/win/get_activation_factory_gn/moz.build
deleted file mode 100644
index f2ad41ae9f27..000000000000
--- third_party/libwebrtc/rtc_base/win/get_activation_factory_gn/moz.build
+++ /dev/null
@@ -1,85 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-
-  ### This moz.build was AUTOMATICALLY GENERATED from a GN config,  ###
-  ### DO NOT edit it by hand.                                       ###
-
-COMPILE_FLAGS["OS_INCLUDES"] = []
-AllowCompilerWarnings()
-
-DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
-DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-DEFINES["NOMINMAX"] = True
-DEFINES["NTDDI_VERSION"] = "0x0A000000"
-DEFINES["PSAPI_VERSION"] = "2"
-DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
-DEFINES["RTC_ENABLE_VP9"] = True
-DEFINES["RTC_ENABLE_WIN_WGC"] = True
-DEFINES["UNICODE"] = True
-DEFINES["USE_AURA"] = "1"
-DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
-DEFINES["WEBRTC_LIBRARY_IMPL"] = True
-DEFINES["WEBRTC_MOZILLA_BUILD"] = True
-DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
-DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
-DEFINES["WEBRTC_WIN"] = True
-DEFINES["WIN32"] = True
-DEFINES["WIN32_LEAN_AND_MEAN"] = True
-DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-DEFINES["WINVER"] = "0x0A00"
-DEFINES["_ATL_NO_OPENGL"] = True
-DEFINES["_CRT_RAND_S"] = True
-DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-DEFINES["_HAS_EXCEPTIONS"] = "0"
-DEFINES["_HAS_NODISCARD"] = True
-DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-DEFINES["_SECURE_ATL"] = True
-DEFINES["_UNICODE"] = True
-DEFINES["_WIN32_WINNT"] = "0x0A00"
-DEFINES["_WINDOWS"] = True
-DEFINES["__STD_C"] = True
-
-FINAL_LIBRARY = "xul"
-
-
-LOCAL_INCLUDES += [
-    "!/ipc/ipdl/_ipdlheaders",
-    "!/third_party/libwebrtc/gen",
-    "/ipc/chromium/src",
-    "/third_party/abseil-cpp/",
-    "/third_party/libwebrtc/",
-    "/tools/profiler/public"
-]
-
-UNIFIED_SOURCES += [
-    "/third_party/libwebrtc/rtc_base/win/get_activation_factory.cc"
-]
-
-if not CONFIG["MOZ_DEBUG"]:
-
-    DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "0"
-    DEFINES["NDEBUG"] = True
-    DEFINES["NVALGRIND"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1":
-
-    DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["WEBRTC_ARCH_ARM64"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
-if CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-Library("get_activation_factory_gn")
diff --git third_party/libwebrtc/rtc_base/win/hstring_gn/moz.build third_party/libwebrtc/rtc_base/win/hstring_gn/moz.build
deleted file mode 100644
index ba15ff2b3c18..000000000000
--- third_party/libwebrtc/rtc_base/win/hstring_gn/moz.build
+++ /dev/null
@@ -1,85 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-
-  ### This moz.build was AUTOMATICALLY GENERATED from a GN config,  ###
-  ### DO NOT edit it by hand.                                       ###
-
-COMPILE_FLAGS["OS_INCLUDES"] = []
-AllowCompilerWarnings()
-
-DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
-DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-DEFINES["NOMINMAX"] = True
-DEFINES["NTDDI_VERSION"] = "0x0A000000"
-DEFINES["PSAPI_VERSION"] = "2"
-DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
-DEFINES["RTC_ENABLE_VP9"] = True
-DEFINES["RTC_ENABLE_WIN_WGC"] = True
-DEFINES["UNICODE"] = True
-DEFINES["USE_AURA"] = "1"
-DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
-DEFINES["WEBRTC_LIBRARY_IMPL"] = True
-DEFINES["WEBRTC_MOZILLA_BUILD"] = True
-DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
-DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
-DEFINES["WEBRTC_WIN"] = True
-DEFINES["WIN32"] = True
-DEFINES["WIN32_LEAN_AND_MEAN"] = True
-DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-DEFINES["WINVER"] = "0x0A00"
-DEFINES["_ATL_NO_OPENGL"] = True
-DEFINES["_CRT_RAND_S"] = True
-DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-DEFINES["_HAS_EXCEPTIONS"] = "0"
-DEFINES["_HAS_NODISCARD"] = True
-DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-DEFINES["_SECURE_ATL"] = True
-DEFINES["_UNICODE"] = True
-DEFINES["_WIN32_WINNT"] = "0x0A00"
-DEFINES["_WINDOWS"] = True
-DEFINES["__STD_C"] = True
-
-FINAL_LIBRARY = "xul"
-
-
-LOCAL_INCLUDES += [
-    "!/ipc/ipdl/_ipdlheaders",
-    "!/third_party/libwebrtc/gen",
-    "/ipc/chromium/src",
-    "/third_party/abseil-cpp/",
-    "/third_party/libwebrtc/",
-    "/tools/profiler/public"
-]
-
-SOURCES += [
-    "/third_party/libwebrtc/rtc_base/win/hstring.cc"
-]
-
-if not CONFIG["MOZ_DEBUG"]:
-
-    DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "0"
-    DEFINES["NDEBUG"] = True
-    DEFINES["NVALGRIND"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1":
-
-    DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["WEBRTC_ARCH_ARM64"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
-if CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-Library("hstring_gn")
diff --git third_party/libwebrtc/rtc_base/win/windows_version_gn/moz.build third_party/libwebrtc/rtc_base/win/windows_version_gn/moz.build
deleted file mode 100644
index 8720108cc441..000000000000
--- third_party/libwebrtc/rtc_base/win/windows_version_gn/moz.build
+++ /dev/null
@@ -1,85 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-
-  ### This moz.build was AUTOMATICALLY GENERATED from a GN config,  ###
-  ### DO NOT edit it by hand.                                       ###
-
-COMPILE_FLAGS["OS_INCLUDES"] = []
-AllowCompilerWarnings()
-
-DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
-DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-DEFINES["NOMINMAX"] = True
-DEFINES["NTDDI_VERSION"] = "0x0A000000"
-DEFINES["PSAPI_VERSION"] = "2"
-DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
-DEFINES["RTC_ENABLE_VP9"] = True
-DEFINES["RTC_ENABLE_WIN_WGC"] = True
-DEFINES["UNICODE"] = True
-DEFINES["USE_AURA"] = "1"
-DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
-DEFINES["WEBRTC_LIBRARY_IMPL"] = True
-DEFINES["WEBRTC_MOZILLA_BUILD"] = True
-DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
-DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
-DEFINES["WEBRTC_WIN"] = True
-DEFINES["WIN32"] = True
-DEFINES["WIN32_LEAN_AND_MEAN"] = True
-DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-DEFINES["WINVER"] = "0x0A00"
-DEFINES["_ATL_NO_OPENGL"] = True
-DEFINES["_CRT_RAND_S"] = True
-DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-DEFINES["_HAS_EXCEPTIONS"] = "0"
-DEFINES["_HAS_NODISCARD"] = True
-DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-DEFINES["_SECURE_ATL"] = True
-DEFINES["_UNICODE"] = True
-DEFINES["_WIN32_WINNT"] = "0x0A00"
-DEFINES["_WINDOWS"] = True
-DEFINES["__STD_C"] = True
-
-FINAL_LIBRARY = "xul"
-
-
-LOCAL_INCLUDES += [
-    "!/ipc/ipdl/_ipdlheaders",
-    "!/third_party/libwebrtc/gen",
-    "/ipc/chromium/src",
-    "/third_party/abseil-cpp/",
-    "/third_party/libwebrtc/",
-    "/tools/profiler/public"
-]
-
-UNIFIED_SOURCES += [
-    "/third_party/libwebrtc/rtc_base/win/windows_version.cc"
-]
-
-if not CONFIG["MOZ_DEBUG"]:
-
-    DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "0"
-    DEFINES["NDEBUG"] = True
-    DEFINES["NVALGRIND"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1":
-
-    DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["WEBRTC_ARCH_ARM64"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
-if CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-Library("windows_version_gn")
diff --git third_party/libwebrtc/rtc_base/win32_gn/moz.build third_party/libwebrtc/rtc_base/win32_gn/moz.build
deleted file mode 100644
index 0c72f4850db5..000000000000
--- third_party/libwebrtc/rtc_base/win32_gn/moz.build
+++ /dev/null
@@ -1,92 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-
-  ### This moz.build was AUTOMATICALLY GENERATED from a GN config,  ###
-  ### DO NOT edit it by hand.                                       ###
-
-COMPILE_FLAGS["OS_INCLUDES"] = []
-AllowCompilerWarnings()
-
-DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
-DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-DEFINES["NOMINMAX"] = True
-DEFINES["NTDDI_VERSION"] = "0x0A000000"
-DEFINES["PSAPI_VERSION"] = "2"
-DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
-DEFINES["RTC_ENABLE_VP9"] = True
-DEFINES["RTC_ENABLE_WIN_WGC"] = True
-DEFINES["UNICODE"] = True
-DEFINES["USE_AURA"] = "1"
-DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
-DEFINES["WEBRTC_LIBRARY_IMPL"] = True
-DEFINES["WEBRTC_MOZILLA_BUILD"] = True
-DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
-DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
-DEFINES["WEBRTC_WIN"] = True
-DEFINES["WIN32"] = True
-DEFINES["WIN32_LEAN_AND_MEAN"] = True
-DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-DEFINES["WINVER"] = "0x0A00"
-DEFINES["_ATL_NO_OPENGL"] = True
-DEFINES["_CRT_NONSTDC_NO_DEPRECATE"] = True
-DEFINES["_CRT_RAND_S"] = True
-DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-DEFINES["_HAS_EXCEPTIONS"] = "0"
-DEFINES["_HAS_NODISCARD"] = True
-DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-DEFINES["_SECURE_ATL"] = True
-DEFINES["_UNICODE"] = True
-DEFINES["_WIN32_WINNT"] = "0x0A00"
-DEFINES["_WINDOWS"] = True
-DEFINES["__STD_C"] = True
-
-FINAL_LIBRARY = "xul"
-
-
-LOCAL_INCLUDES += [
-    "!/ipc/ipdl/_ipdlheaders",
-    "!/third_party/libwebrtc/gen",
-    "/ipc/chromium/src",
-    "/third_party/abseil-cpp/",
-    "/third_party/libwebrtc/",
-    "/tools/profiler/public"
-]
-
-OS_LIBS += [
-    "crypt32",
-    "iphlpapi",
-    "secur32"
-]
-
-UNIFIED_SOURCES += [
-    "/third_party/libwebrtc/rtc_base/win32.cc"
-]
-
-if not CONFIG["MOZ_DEBUG"]:
-
-    DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "0"
-    DEFINES["NDEBUG"] = True
-    DEFINES["NVALGRIND"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1":
-
-    DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["WEBRTC_ARCH_ARM64"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
-if CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-Library("win32_gn")
diff --git third_party/libwebrtc/rtc_base/zero_memory_gn/moz.build third_party/libwebrtc/rtc_base/zero_memory_gn/moz.build
index bfff36ec02ab..b9a6295e770c 100644
--- third_party/libwebrtc/rtc_base/zero_memory_gn/moz.build
+++ third_party/libwebrtc/rtc_base/zero_memory_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("zero_memory_gn")
diff --git third_party/libwebrtc/sdk/base_objc_gn/moz.build third_party/libwebrtc/sdk/base_objc_gn/moz.build
deleted file mode 100644
index aa939b4394b7..000000000000
--- third_party/libwebrtc/sdk/base_objc_gn/moz.build
+++ /dev/null
@@ -1,80 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-
-  ### This moz.build was AUTOMATICALLY GENERATED from a GN config,  ###
-  ### DO NOT edit it by hand.                                       ###
-
-CMFLAGS += [
-    "-fobjc-arc"
-]
-
-CMMFLAGS += [
-    "-fobjc-arc"
-]
-
-COMPILE_FLAGS["OS_INCLUDES"] = []
-AllowCompilerWarnings()
-
-DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
-DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
-DEFINES["RTC_ENABLE_VP9"] = True
-DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
-DEFINES["WEBRTC_LIBRARY_IMPL"] = True
-DEFINES["WEBRTC_MAC"] = True
-DEFINES["WEBRTC_MOZILLA_BUILD"] = True
-DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
-DEFINES["WEBRTC_POSIX"] = True
-DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
-DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-DEFINES["__STDC_CONSTANT_MACROS"] = True
-DEFINES["__STDC_FORMAT_MACROS"] = True
-
-FINAL_LIBRARY = "xul"
-
-
-LOCAL_INCLUDES += [
-    "!/ipc/ipdl/_ipdlheaders",
-    "!/third_party/libwebrtc/gen",
-    "/ipc/chromium/src",
-    "/third_party/abseil-cpp/",
-    "/third_party/libwebrtc/",
-    "/third_party/libwebrtc/sdk/objc/",
-    "/third_party/libwebrtc/sdk/objc/base/",
-    "/tools/profiler/public"
-]
-
-UNIFIED_SOURCES += [
-    "/third_party/libwebrtc/sdk/objc/base/RTCEncodedImage.m",
-    "/third_party/libwebrtc/sdk/objc/base/RTCLogging.mm",
-    "/third_party/libwebrtc/sdk/objc/base/RTCVideoCapturer.m",
-    "/third_party/libwebrtc/sdk/objc/base/RTCVideoCodecInfo.m",
-    "/third_party/libwebrtc/sdk/objc/base/RTCVideoEncoderFactory.mm",
-    "/third_party/libwebrtc/sdk/objc/base/RTCVideoEncoderQpThresholds.m",
-    "/third_party/libwebrtc/sdk/objc/base/RTCVideoEncoderSettings.m",
-    "/third_party/libwebrtc/sdk/objc/base/RTCVideoFrame.mm"
-]
-
-if not CONFIG["MOZ_DEBUG"]:
-
-    DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "0"
-    DEFINES["NDEBUG"] = True
-    DEFINES["NVALGRIND"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1":
-
-    DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["WEBRTC_ARCH_ARM64"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-Library("base_objc_gn")
diff --git third_party/libwebrtc/sdk/helpers_objc_gn/moz.build third_party/libwebrtc/sdk/helpers_objc_gn/moz.build
deleted file mode 100644
index 161ce60f39a6..000000000000
--- third_party/libwebrtc/sdk/helpers_objc_gn/moz.build
+++ /dev/null
@@ -1,75 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-
-  ### This moz.build was AUTOMATICALLY GENERATED from a GN config,  ###
-  ### DO NOT edit it by hand.                                       ###
-
-CMFLAGS += [
-    "-fobjc-arc"
-]
-
-CMMFLAGS += [
-    "-fobjc-arc"
-]
-
-COMPILE_FLAGS["OS_INCLUDES"] = []
-AllowCompilerWarnings()
-
-DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
-DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
-DEFINES["RTC_ENABLE_VP9"] = True
-DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
-DEFINES["WEBRTC_LIBRARY_IMPL"] = True
-DEFINES["WEBRTC_MAC"] = True
-DEFINES["WEBRTC_MOZILLA_BUILD"] = True
-DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
-DEFINES["WEBRTC_POSIX"] = True
-DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
-DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-DEFINES["__STDC_CONSTANT_MACROS"] = True
-DEFINES["__STDC_FORMAT_MACROS"] = True
-
-FINAL_LIBRARY = "xul"
-
-
-LOCAL_INCLUDES += [
-    "!/ipc/ipdl/_ipdlheaders",
-    "!/third_party/libwebrtc/gen",
-    "/ipc/chromium/src",
-    "/third_party/abseil-cpp/",
-    "/third_party/libwebrtc/",
-    "/third_party/libwebrtc/sdk/objc/",
-    "/third_party/libwebrtc/sdk/objc/base/",
-    "/tools/profiler/public"
-]
-
-UNIFIED_SOURCES += [
-    "/third_party/libwebrtc/sdk/objc/helpers/AVCaptureSession+DevicePosition.mm",
-    "/third_party/libwebrtc/sdk/objc/helpers/NSString+StdString.mm",
-    "/third_party/libwebrtc/sdk/objc/helpers/RTCDispatcher.m"
-]
-
-if not CONFIG["MOZ_DEBUG"]:
-
-    DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "0"
-    DEFINES["NDEBUG"] = True
-    DEFINES["NVALGRIND"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1":
-
-    DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["WEBRTC_ARCH_ARM64"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-Library("helpers_objc_gn")
diff --git third_party/libwebrtc/sdk/videocapture_objc_gn/moz.build third_party/libwebrtc/sdk/videocapture_objc_gn/moz.build
deleted file mode 100644
index db4fdfb6b108..000000000000
--- third_party/libwebrtc/sdk/videocapture_objc_gn/moz.build
+++ /dev/null
@@ -1,70 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-
-  ### This moz.build was AUTOMATICALLY GENERATED from a GN config,  ###
-  ### DO NOT edit it by hand.                                       ###
-
-CMFLAGS += [
-    "-fobjc-arc"
-]
-
-COMPILE_FLAGS["OS_INCLUDES"] = []
-AllowCompilerWarnings()
-
-DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
-DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
-DEFINES["RTC_ENABLE_VP9"] = True
-DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
-DEFINES["WEBRTC_LIBRARY_IMPL"] = True
-DEFINES["WEBRTC_MAC"] = True
-DEFINES["WEBRTC_MOZILLA_BUILD"] = True
-DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
-DEFINES["WEBRTC_POSIX"] = True
-DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
-DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-DEFINES["__STDC_CONSTANT_MACROS"] = True
-DEFINES["__STDC_FORMAT_MACROS"] = True
-
-FINAL_LIBRARY = "xul"
-
-
-LOCAL_INCLUDES += [
-    "!/ipc/ipdl/_ipdlheaders",
-    "!/third_party/libwebrtc/gen",
-    "/ipc/chromium/src",
-    "/third_party/abseil-cpp/",
-    "/third_party/libwebrtc/",
-    "/third_party/libwebrtc/sdk/objc/",
-    "/third_party/libwebrtc/sdk/objc/base/",
-    "/tools/profiler/public"
-]
-
-UNIFIED_SOURCES += [
-    "/third_party/libwebrtc/sdk/objc/components/capturer/RTCCameraVideoCapturer.m",
-    "/third_party/libwebrtc/sdk/objc/components/capturer/RTCFileVideoCapturer.m"
-]
-
-if not CONFIG["MOZ_DEBUG"]:
-
-    DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "0"
-    DEFINES["NDEBUG"] = True
-    DEFINES["NVALGRIND"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1":
-
-    DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["WEBRTC_ARCH_ARM64"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-Library("videocapture_objc_gn")
diff --git third_party/libwebrtc/sdk/videoframebuffer_objc_gn/moz.build third_party/libwebrtc/sdk/videoframebuffer_objc_gn/moz.build
deleted file mode 100644
index f705e220de43..000000000000
--- third_party/libwebrtc/sdk/videoframebuffer_objc_gn/moz.build
+++ /dev/null
@@ -1,73 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-
-  ### This moz.build was AUTOMATICALLY GENERATED from a GN config,  ###
-  ### DO NOT edit it by hand.                                       ###
-
-CMMFLAGS += [
-    "-fobjc-arc"
-]
-
-COMPILE_FLAGS["OS_INCLUDES"] = []
-AllowCompilerWarnings()
-
-DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
-DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
-DEFINES["RTC_ENABLE_VP9"] = True
-DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
-DEFINES["WEBRTC_LIBRARY_IMPL"] = True
-DEFINES["WEBRTC_MAC"] = True
-DEFINES["WEBRTC_MOZILLA_BUILD"] = True
-DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
-DEFINES["WEBRTC_POSIX"] = True
-DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
-DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-DEFINES["__STDC_CONSTANT_MACROS"] = True
-DEFINES["__STDC_FORMAT_MACROS"] = True
-
-FINAL_LIBRARY = "xul"
-
-
-LOCAL_INCLUDES += [
-    "!/ipc/ipdl/_ipdlheaders",
-    "!/third_party/libwebrtc/gen",
-    "/ipc/chromium/src",
-    "/media/libyuv/",
-    "/media/libyuv/libyuv/include/",
-    "/third_party/abseil-cpp/",
-    "/third_party/libwebrtc/",
-    "/third_party/libwebrtc/sdk/objc/",
-    "/third_party/libwebrtc/sdk/objc/base/",
-    "/tools/profiler/public"
-]
-
-UNIFIED_SOURCES += [
-    "/third_party/libwebrtc/sdk/objc/api/video_frame_buffer/RTCNativeI420Buffer.mm",
-    "/third_party/libwebrtc/sdk/objc/api/video_frame_buffer/RTCNativeMutableI420Buffer.mm",
-    "/third_party/libwebrtc/sdk/objc/components/video_frame_buffer/RTCCVPixelBuffer.mm"
-]
-
-if not CONFIG["MOZ_DEBUG"]:
-
-    DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "0"
-    DEFINES["NDEBUG"] = True
-    DEFINES["NVALGRIND"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1":
-
-    DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["WEBRTC_ARCH_ARM64"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-Library("videoframebuffer_objc_gn")
diff --git third_party/libwebrtc/system_wrappers/denormal_disabler_gn/moz.build third_party/libwebrtc/system_wrappers/denormal_disabler_gn/moz.build
index e112c4874c1f..518c1df32127 100644
--- third_party/libwebrtc/system_wrappers/denormal_disabler_gn/moz.build
+++ third_party/libwebrtc/system_wrappers/denormal_disabler_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("denormal_disabler_gn")
diff --git third_party/libwebrtc/system_wrappers/field_trial_gn/moz.build third_party/libwebrtc/system_wrappers/field_trial_gn/moz.build
index 460a3a113757..d40812159ee8 100644
--- third_party/libwebrtc/system_wrappers/field_trial_gn/moz.build
+++ third_party/libwebrtc/system_wrappers/field_trial_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("field_trial_gn")
diff --git third_party/libwebrtc/system_wrappers/metrics_gn/moz.build third_party/libwebrtc/system_wrappers/metrics_gn/moz.build
index 29156ca2193e..7a01c486865b 100644
--- third_party/libwebrtc/system_wrappers/metrics_gn/moz.build
+++ third_party/libwebrtc/system_wrappers/metrics_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("metrics_gn")
diff --git third_party/libwebrtc/system_wrappers/system_wrappers_gn/moz.build third_party/libwebrtc/system_wrappers/system_wrappers_gn/moz.build
index 02d7c603b974..2bc033f65974 100644
--- third_party/libwebrtc/system_wrappers/system_wrappers_gn/moz.build
+++ third_party/libwebrtc/system_wrappers/system_wrappers_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -47,199 +57,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    LOCAL_INCLUDES += [
-        "/config/external/nspr/",
-        "/nsprpub/lib/ds/",
-        "/nsprpub/pr/include/"
-    ]
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-    UNIFIED_SOURCES += [
-        "/third_party/libwebrtc/system_wrappers/source/cpu_features_linux.cc"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("system_wrappers_gn")
diff --git third_party/libwebrtc/test/network/simulated_network_gn/moz.build third_party/libwebrtc/test/network/simulated_network_gn/moz.build
index bedfa0c56dbe..6ac0bb28a3f8 100644
--- third_party/libwebrtc/test/network/simulated_network_gn/moz.build
+++ third_party/libwebrtc/test/network/simulated_network_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("simulated_network_gn")
diff --git third_party/libwebrtc/test/rtp_test_utils_gn/moz.build third_party/libwebrtc/test/rtp_test_utils_gn/moz.build
index 8ce02c0e89e8..eb6407536eab 100644
--- third_party/libwebrtc/test/rtp_test_utils_gn/moz.build
+++ third_party/libwebrtc/test/rtp_test_utils_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,123 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -165,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("rtp_test_utils_gn")
diff --git third_party/libwebrtc/third_party/crc32c/crc32c_arm64_gn/moz.build third_party/libwebrtc/third_party/crc32c/crc32c_arm64_gn/moz.build
index 0da83a9219f4..97b58e494521 100644
--- third_party/libwebrtc/third_party/crc32c/crc32c_arm64_gn/moz.build
+++ third_party/libwebrtc/third_party/crc32c/crc32c_arm64_gn/moz.build
@@ -14,6 +14,15 @@ DEFINES["CRC32C_TESTS_BUILT_WITH_GLOG"] = "0"
 DEFINES["HAVE_ARM64_CRC32C"] = "0"
 DEFINES["HAVE_BUILTIN_PREFETCH"] = "1"
 DEFINES["HAVE_SSE42"] = "0"
+DEFINES["HAVE_STRONG_GETAUXVAL"] = "0"
+DEFINES["HAVE_WEAK_GETAUXVAL"] = "0"
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -41,102 +50,19 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_STRONG_GETAUXVAL"] = "1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["HAVE_WEAK_GETAUXVAL"] = "1"
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["HAVE_STRONG_GETAUXVAL"] = "0"
-    DEFINES["HAVE_WEAK_GETAUXVAL"] = "0"
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["HAVE_STRONG_GETAUXVAL"] = "1"
-    DEFINES["HAVE_WEAK_GETAUXVAL"] = "1"
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["HAVE_STRONG_GETAUXVAL"] = "0"
-    DEFINES["HAVE_WEAK_GETAUXVAL"] = "0"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["HAVE_STRONG_GETAUXVAL"] = "0"
-    DEFINES["HAVE_WEAK_GETAUXVAL"] = "0"
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["HAVE_MM_PREFETCH"] = "0"
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["HAVE_MM_PREFETCH"] = "0"
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["HAVE_MM_PREFETCH"] = "0"
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "mips64":
 
     DEFINES["HAVE_MM_PREFETCH"] = "0"
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "ppc64":
 
@@ -148,66 +74,18 @@ if CONFIG["TARGET_CPU"] == "riscv64":
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["HAVE_MM_PREFETCH"] = "1"
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["HAVE_MM_PREFETCH"] = "1"
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["HAVE_MM_PREFETCH"] = "1"
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["HAVE_MM_PREFETCH"] = "1"
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("crc32c_arm64_gn")
diff --git third_party/libwebrtc/third_party/crc32c/crc32c_gn/moz.build third_party/libwebrtc/third_party/crc32c/crc32c_gn/moz.build
index 02bd56fbd454..4be91cd5ce24 100644
--- third_party/libwebrtc/third_party/crc32c/crc32c_gn/moz.build
+++ third_party/libwebrtc/third_party/crc32c/crc32c_gn/moz.build
@@ -14,6 +14,15 @@ DEFINES["CRC32C_TESTS_BUILT_WITH_GLOG"] = "0"
 DEFINES["HAVE_ARM64_CRC32C"] = "0"
 DEFINES["HAVE_BUILTIN_PREFETCH"] = "1"
 DEFINES["HAVE_SSE42"] = "0"
+DEFINES["HAVE_STRONG_GETAUXVAL"] = "0"
+DEFINES["HAVE_WEAK_GETAUXVAL"] = "0"
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -42,102 +51,19 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_STRONG_GETAUXVAL"] = "1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["HAVE_WEAK_GETAUXVAL"] = "1"
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["HAVE_STRONG_GETAUXVAL"] = "0"
-    DEFINES["HAVE_WEAK_GETAUXVAL"] = "0"
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["HAVE_STRONG_GETAUXVAL"] = "1"
-    DEFINES["HAVE_WEAK_GETAUXVAL"] = "1"
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["HAVE_STRONG_GETAUXVAL"] = "0"
-    DEFINES["HAVE_WEAK_GETAUXVAL"] = "0"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["HAVE_STRONG_GETAUXVAL"] = "0"
-    DEFINES["HAVE_WEAK_GETAUXVAL"] = "0"
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["HAVE_MM_PREFETCH"] = "0"
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["HAVE_MM_PREFETCH"] = "0"
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["HAVE_MM_PREFETCH"] = "0"
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "mips64":
 
     DEFINES["HAVE_MM_PREFETCH"] = "0"
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "ppc64":
 
@@ -149,66 +75,18 @@ if CONFIG["TARGET_CPU"] == "riscv64":
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["HAVE_MM_PREFETCH"] = "1"
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["HAVE_MM_PREFETCH"] = "1"
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["HAVE_MM_PREFETCH"] = "1"
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["HAVE_MM_PREFETCH"] = "1"
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("crc32c_gn")
diff --git third_party/libwebrtc/third_party/crc32c/crc32c_internal_headers_gn/moz.build third_party/libwebrtc/third_party/crc32c/crc32c_internal_headers_gn/moz.build
index 86c319ca059d..f7a92bd53658 100644
--- third_party/libwebrtc/third_party/crc32c/crc32c_internal_headers_gn/moz.build
+++ third_party/libwebrtc/third_party/crc32c/crc32c_internal_headers_gn/moz.build
@@ -9,6 +9,14 @@
 COMPILE_FLAGS["OS_INCLUDES"] = []
 AllowCompilerWarnings()
 
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
+
 FINAL_LIBRARY = "xul"
 
 
@@ -29,123 +37,10 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-if CONFIG["TARGET_CPU"] == "mips32":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
     DEFINES["_DEBUG"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("crc32c_internal_headers_gn")
diff --git third_party/libwebrtc/third_party/crc32c/crc32c_sse42_gn/moz.build third_party/libwebrtc/third_party/crc32c/crc32c_sse42_gn/moz.build
index 6d124a37625c..603361341c04 100644
--- third_party/libwebrtc/third_party/crc32c/crc32c_sse42_gn/moz.build
+++ third_party/libwebrtc/third_party/crc32c/crc32c_sse42_gn/moz.build
@@ -14,6 +14,15 @@ DEFINES["CRC32C_TESTS_BUILT_WITH_GLOG"] = "0"
 DEFINES["HAVE_ARM64_CRC32C"] = "0"
 DEFINES["HAVE_BUILTIN_PREFETCH"] = "1"
 DEFINES["HAVE_SSE42"] = "0"
+DEFINES["HAVE_STRONG_GETAUXVAL"] = "0"
+DEFINES["HAVE_WEAK_GETAUXVAL"] = "0"
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -41,102 +50,19 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_STRONG_GETAUXVAL"] = "1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["HAVE_WEAK_GETAUXVAL"] = "1"
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["HAVE_STRONG_GETAUXVAL"] = "0"
-    DEFINES["HAVE_WEAK_GETAUXVAL"] = "0"
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["HAVE_STRONG_GETAUXVAL"] = "1"
-    DEFINES["HAVE_WEAK_GETAUXVAL"] = "1"
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["HAVE_STRONG_GETAUXVAL"] = "0"
-    DEFINES["HAVE_WEAK_GETAUXVAL"] = "0"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["HAVE_STRONG_GETAUXVAL"] = "0"
-    DEFINES["HAVE_WEAK_GETAUXVAL"] = "0"
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["HAVE_MM_PREFETCH"] = "0"
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["HAVE_MM_PREFETCH"] = "0"
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["HAVE_MM_PREFETCH"] = "0"
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "mips64":
 
     DEFINES["HAVE_MM_PREFETCH"] = "0"
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "ppc64":
 
@@ -148,66 +74,18 @@ if CONFIG["TARGET_CPU"] == "riscv64":
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["HAVE_MM_PREFETCH"] = "1"
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["HAVE_MM_PREFETCH"] = "1"
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["HAVE_MM_PREFETCH"] = "1"
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["HAVE_MM_PREFETCH"] = "1"
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("crc32c_sse42_gn")
diff --git third_party/libwebrtc/third_party/dav1d/dav1d_gn/moz.build third_party/libwebrtc/third_party/dav1d/dav1d_gn/moz.build
index 59c7f92814b7..5d9b917f598f 100644
--- third_party/libwebrtc/third_party/dav1d/dav1d_gn/moz.build
+++ third_party/libwebrtc/third_party/dav1d/dav1d_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -41,107 +51,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -151,50 +71,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("dav1d_gn")
diff --git third_party/libwebrtc/third_party/drm/drm_gn/moz.build third_party/libwebrtc/third_party/drm/drm_gn/moz.build
index 7c425a25708f..e24de7a7f5ed 100644
--- third_party/libwebrtc/third_party/drm/drm_gn/moz.build
+++ third_party/libwebrtc/third_party/drm/drm_gn/moz.build
@@ -12,21 +12,17 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
-DEFINES["USE_AURA"] = "1"
 DEFINES["USE_GLIB"] = "1"
-DEFINES["USE_NSS_CERTS"] = "1"
 DEFINES["USE_OZONE"] = "1"
-DEFINES["USE_UDEV"] = True
+DEFINES["WEBRTC_BSD"] = True
 DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
-DEFINES["WEBRTC_LINUX"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
 DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
 DEFINES["_FILE_OFFSET_BITS"] = "64"
-DEFINES["_GNU_SOURCE"] = True
 DEFINES["_LARGEFILE64_SOURCE"] = True
 DEFINES["_LARGEFILE_SOURCE"] = True
 DEFINES["__STDC_CONSTANT_MACROS"] = True
@@ -63,12 +59,6 @@ if CONFIG["TARGET_CPU"] == "aarch64":
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
@@ -82,7 +72,7 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
diff --git third_party/libwebrtc/third_party/gbm/gbm_gn/moz.build third_party/libwebrtc/third_party/gbm/gbm_gn/moz.build
index 7c126d82542b..42eb6521079f 100644
--- third_party/libwebrtc/third_party/gbm/gbm_gn/moz.build
+++ third_party/libwebrtc/third_party/gbm/gbm_gn/moz.build
@@ -12,21 +12,17 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
-DEFINES["USE_AURA"] = "1"
 DEFINES["USE_GLIB"] = "1"
-DEFINES["USE_NSS_CERTS"] = "1"
 DEFINES["USE_OZONE"] = "1"
-DEFINES["USE_UDEV"] = True
+DEFINES["WEBRTC_BSD"] = True
 DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
-DEFINES["WEBRTC_LINUX"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
 DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
 DEFINES["_FILE_OFFSET_BITS"] = "64"
-DEFINES["_GNU_SOURCE"] = True
 DEFINES["_LARGEFILE64_SOURCE"] = True
 DEFINES["_LARGEFILE_SOURCE"] = True
 DEFINES["__STDC_CONSTANT_MACROS"] = True
@@ -61,12 +57,6 @@ if CONFIG["TARGET_CPU"] == "aarch64":
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
@@ -80,7 +70,7 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
diff --git third_party/libwebrtc/third_party/libaom/libaom_gn/moz.build third_party/libwebrtc/third_party/libaom/libaom_gn/moz.build
index 96e7af57553e..3a8de699dd29 100644
--- third_party/libwebrtc/third_party/libaom/libaom_gn/moz.build
+++ third_party/libwebrtc/third_party/libaom/libaom_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,107 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -149,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("aom_gn")
diff --git third_party/libwebrtc/third_party/libepoxy/libepoxy_gn/moz.build third_party/libwebrtc/third_party/libepoxy/libepoxy_gn/moz.build
index 0c2874eb73a8..032d3c12aa30 100644
--- third_party/libwebrtc/third_party/libepoxy/libepoxy_gn/moz.build
+++ third_party/libwebrtc/third_party/libepoxy/libepoxy_gn/moz.build
@@ -12,21 +12,17 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
-DEFINES["USE_AURA"] = "1"
 DEFINES["USE_GLIB"] = "1"
-DEFINES["USE_NSS_CERTS"] = "1"
 DEFINES["USE_OZONE"] = "1"
-DEFINES["USE_UDEV"] = True
+DEFINES["WEBRTC_BSD"] = True
 DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
-DEFINES["WEBRTC_LINUX"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
 DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
 DEFINES["_FILE_OFFSET_BITS"] = "64"
-DEFINES["_GNU_SOURCE"] = True
 DEFINES["_LARGEFILE64_SOURCE"] = True
 DEFINES["_LARGEFILE_SOURCE"] = True
 DEFINES["__STDC_CONSTANT_MACROS"] = True
@@ -62,12 +58,6 @@ if CONFIG["TARGET_CPU"] == "aarch64":
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
@@ -81,7 +71,7 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
diff --git third_party/libwebrtc/third_party/libyuv/libyuv_gn/moz.build third_party/libwebrtc/third_party/libyuv/libyuv_gn/moz.build
index 32e84e422d97..9bf6973ec982 100644
--- third_party/libwebrtc/third_party/libyuv/libyuv_gn/moz.build
+++ third_party/libwebrtc/third_party/libyuv/libyuv_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -41,107 +51,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -151,50 +71,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("yuv_gn")
diff --git third_party/libwebrtc/third_party/pffft/pffft_gn/moz.build third_party/libwebrtc/third_party/pffft/pffft_gn/moz.build
index 836a04a7c723..4adcdaca807c 100644
--- third_party/libwebrtc/third_party/pffft/pffft_gn/moz.build
+++ third_party/libwebrtc/third_party/pffft/pffft_gn/moz.build
@@ -9,6 +9,14 @@
 COMPILE_FLAGS["OS_INCLUDES"] = []
 AllowCompilerWarnings()
 
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
+
 FINAL_LIBRARY = "xul"
 
 
@@ -33,87 +41,15 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_USE_MATH_DEFINES"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CFLAGS += [
-        "-mfpu=neon"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["PFFFT_SIMD_DISABLE"] = True
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "mips64":
 
     DEFINES["PFFFT_SIMD_DISABLE"] = True
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "ppc64":
 
@@ -123,60 +59,14 @@ if CONFIG["TARGET_CPU"] == "riscv64":
 
     DEFINES["PFFFT_SIMD_DISABLE"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
+if CONFIG["TARGET_CPU"] == "x86":
 
     CFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    CFLAGS += [
-        "-msse2"
-    ]
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("pffft_gn")
diff --git third_party/libwebrtc/third_party/pipewire/pipewire_gn/moz.build third_party/libwebrtc/third_party/pipewire/pipewire_gn/moz.build
index 77bfb16a9df6..35ba3bbe70b8 100644
--- third_party/libwebrtc/third_party/pipewire/pipewire_gn/moz.build
+++ third_party/libwebrtc/third_party/pipewire/pipewire_gn/moz.build
@@ -12,22 +12,18 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
-DEFINES["USE_AURA"] = "1"
 DEFINES["USE_GLIB"] = "1"
-DEFINES["USE_NSS_CERTS"] = "1"
 DEFINES["USE_OZONE"] = "1"
-DEFINES["USE_UDEV"] = True
+DEFINES["WEBRTC_BSD"] = True
 DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
-DEFINES["WEBRTC_LINUX"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
 DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
 DEFINES["WEBRTC_USE_PIPEWIRE"] = True
 DEFINES["_FILE_OFFSET_BITS"] = "64"
-DEFINES["_GNU_SOURCE"] = True
 DEFINES["_LARGEFILE64_SOURCE"] = True
 DEFINES["_LARGEFILE_SOURCE"] = True
 DEFINES["__STDC_CONSTANT_MACROS"] = True
@@ -62,12 +58,6 @@ if CONFIG["TARGET_CPU"] == "aarch64":
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
@@ -81,7 +71,7 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
diff --git third_party/libwebrtc/third_party/rnnoise/rnn_vad_gn/moz.build third_party/libwebrtc/third_party/rnnoise/rnn_vad_gn/moz.build
index b10b4c330ef8..3703f7ef3366 100644
--- third_party/libwebrtc/third_party/rnnoise/rnn_vad_gn/moz.build
+++ third_party/libwebrtc/third_party/rnnoise/rnn_vad_gn/moz.build
@@ -9,6 +9,14 @@
 COMPILE_FLAGS["OS_INCLUDES"] = []
 AllowCompilerWarnings()
 
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
+
 FINAL_LIBRARY = "xul"
 
 
@@ -33,139 +41,16 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-if CONFIG["TARGET_CPU"] == "mips32":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
     DEFINES["_DEBUG"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
+if CONFIG["TARGET_CPU"] == "x86":
 
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    CXXFLAGS += [
-        "-msse2"
-    ]
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("rnn_vad_gn")
diff --git third_party/libwebrtc/video/adaptation/video_adaptation_gn/moz.build third_party/libwebrtc/video/adaptation/video_adaptation_gn/moz.build
index 92db0ecf14f2..ed55e8e83f49 100644
--- third_party/libwebrtc/video/adaptation/video_adaptation_gn/moz.build
+++ third_party/libwebrtc/video/adaptation/video_adaptation_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -51,190 +61,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("video_adaptation_gn")
diff --git third_party/libwebrtc/video/config/encoder_config_gn/moz.build third_party/libwebrtc/video/config/encoder_config_gn/moz.build
index 25d4e52bc234..7902174e756b 100644
--- third_party/libwebrtc/video/config/encoder_config_gn/moz.build
+++ third_party/libwebrtc/video/config/encoder_config_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("encoder_config_gn")
diff --git third_party/libwebrtc/video/config/streams_config_gn/moz.build third_party/libwebrtc/video/config/streams_config_gn/moz.build
index 84750d67a3fd..4c28f43e2fe1 100644
--- third_party/libwebrtc/video/config/streams_config_gn/moz.build
+++ third_party/libwebrtc/video/config/streams_config_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -44,190 +54,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("streams_config_gn")
diff --git third_party/libwebrtc/video/corruption_detection/corruption_classifier_gn/moz.build third_party/libwebrtc/video/corruption_detection/corruption_classifier_gn/moz.build
index 3291ea4c6d8b..9bc7808e56be 100644
--- third_party/libwebrtc/video/corruption_detection/corruption_classifier_gn/moz.build
+++ third_party/libwebrtc/video/corruption_detection/corruption_classifier_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("corruption_classifier_gn")
diff --git third_party/libwebrtc/video/corruption_detection/frame_instrumentation_evaluation_gn/moz.build third_party/libwebrtc/video/corruption_detection/frame_instrumentation_evaluation_gn/moz.build
index 0dd7587c61cc..5ac74dca65e0 100644
--- third_party/libwebrtc/video/corruption_detection/frame_instrumentation_evaluation_gn/moz.build
+++ third_party/libwebrtc/video/corruption_detection/frame_instrumentation_evaluation_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("frame_instrumentation_evaluation_gn")
diff --git third_party/libwebrtc/video/corruption_detection/frame_instrumentation_generator_gn/moz.build third_party/libwebrtc/video/corruption_detection/frame_instrumentation_generator_gn/moz.build
index b45a5c22582b..75ac08c5b8c4 100644
--- third_party/libwebrtc/video/corruption_detection/frame_instrumentation_generator_gn/moz.build
+++ third_party/libwebrtc/video/corruption_detection/frame_instrumentation_generator_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,190 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("frame_instrumentation_generator_gn")
diff --git third_party/libwebrtc/video/corruption_detection/generic_mapping_functions_gn/moz.build third_party/libwebrtc/video/corruption_detection/generic_mapping_functions_gn/moz.build
index 6904634583c3..c61f382d5883 100644
--- third_party/libwebrtc/video/corruption_detection/generic_mapping_functions_gn/moz.build
+++ third_party/libwebrtc/video/corruption_detection/generic_mapping_functions_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("generic_mapping_functions_gn")
diff --git third_party/libwebrtc/video/corruption_detection/halton_frame_sampler_gn/moz.build third_party/libwebrtc/video/corruption_detection/halton_frame_sampler_gn/moz.build
index e0c0942ce6ab..a05ea05a7cd4 100644
--- third_party/libwebrtc/video/corruption_detection/halton_frame_sampler_gn/moz.build
+++ third_party/libwebrtc/video/corruption_detection/halton_frame_sampler_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("halton_frame_sampler_gn")
diff --git third_party/libwebrtc/video/corruption_detection/halton_sequence_gn/moz.build third_party/libwebrtc/video/corruption_detection/halton_sequence_gn/moz.build
index 5ffff21e8df2..907391dba932 100644
--- third_party/libwebrtc/video/corruption_detection/halton_sequence_gn/moz.build
+++ third_party/libwebrtc/video/corruption_detection/halton_sequence_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,178 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("halton_sequence_gn")
diff --git third_party/libwebrtc/video/decode_synchronizer_gn/moz.build third_party/libwebrtc/video/decode_synchronizer_gn/moz.build
index e5b92baba40f..b234e7808436 100644
--- third_party/libwebrtc/video/decode_synchronizer_gn/moz.build
+++ third_party/libwebrtc/video/decode_synchronizer_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,189 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("decode_synchronizer_gn")
diff --git third_party/libwebrtc/video/frame_cadence_adapter_gn/moz.build third_party/libwebrtc/video/frame_cadence_adapter_gn/moz.build
index 5817a5b68a3c..a49f2342f96d 100644
--- third_party/libwebrtc/video/frame_cadence_adapter_gn/moz.build
+++ third_party/libwebrtc/video/frame_cadence_adapter_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,189 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("frame_cadence_adapter_gn")
diff --git third_party/libwebrtc/video/frame_decode_scheduler_gn/moz.build third_party/libwebrtc/video/frame_decode_scheduler_gn/moz.build
index ae358f548924..60e58b4d3e94 100644
--- third_party/libwebrtc/video/frame_decode_scheduler_gn/moz.build
+++ third_party/libwebrtc/video/frame_decode_scheduler_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,122 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -164,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("frame_decode_scheduler_gn")
diff --git third_party/libwebrtc/video/frame_decode_timing_gn/moz.build third_party/libwebrtc/video/frame_decode_timing_gn/moz.build
index 0deade49e8f6..7048ad94cbe8 100644
--- third_party/libwebrtc/video/frame_decode_timing_gn/moz.build
+++ third_party/libwebrtc/video/frame_decode_timing_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,189 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("frame_decode_timing_gn")
diff --git third_party/libwebrtc/video/frame_dumping_decoder_gn/moz.build third_party/libwebrtc/video/frame_dumping_decoder_gn/moz.build
index 8129c6209e6b..6e16a191239c 100644
--- third_party/libwebrtc/video/frame_dumping_decoder_gn/moz.build
+++ third_party/libwebrtc/video/frame_dumping_decoder_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,190 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("frame_dumping_decoder_gn")
diff --git third_party/libwebrtc/video/frame_dumping_encoder_gn/moz.build third_party/libwebrtc/video/frame_dumping_encoder_gn/moz.build
index 25b047e3798f..6e35ea00b773 100644
--- third_party/libwebrtc/video/frame_dumping_encoder_gn/moz.build
+++ third_party/libwebrtc/video/frame_dumping_encoder_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,190 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("frame_dumping_encoder_gn")
diff --git third_party/libwebrtc/video/render/incoming_video_stream_gn/moz.build third_party/libwebrtc/video/render/incoming_video_stream_gn/moz.build
index 166999051875..117ca8774fd0 100644
--- third_party/libwebrtc/video/render/incoming_video_stream_gn/moz.build
+++ third_party/libwebrtc/video/render/incoming_video_stream_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("incoming_video_stream_gn")
diff --git third_party/libwebrtc/video/render/video_render_frames_gn/moz.build third_party/libwebrtc/video/render/video_render_frames_gn/moz.build
index 6a9ad8451a57..e561cf8d21b6 100644
--- third_party/libwebrtc/video/render/video_render_frames_gn/moz.build
+++ third_party/libwebrtc/video/render/video_render_frames_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,185 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("video_render_frames_gn")
diff --git third_party/libwebrtc/video/task_queue_frame_decode_scheduler_gn/moz.build third_party/libwebrtc/video/task_queue_frame_decode_scheduler_gn/moz.build
index b2df93f20386..022d5aab0b07 100644
--- third_party/libwebrtc/video/task_queue_frame_decode_scheduler_gn/moz.build
+++ third_party/libwebrtc/video/task_queue_frame_decode_scheduler_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,189 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("task_queue_frame_decode_scheduler_gn")
diff --git third_party/libwebrtc/video/unique_timestamp_counter_gn/moz.build third_party/libwebrtc/video/unique_timestamp_counter_gn/moz.build
index edd42aa502c4..2edcc433f13c 100644
--- third_party/libwebrtc/video/unique_timestamp_counter_gn/moz.build
+++ third_party/libwebrtc/video/unique_timestamp_counter_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,174 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("unique_timestamp_counter_gn")
diff --git third_party/libwebrtc/video/video_gn/moz.build third_party/libwebrtc/video/video_gn/moz.build
index 73a0749f2926..e28cf052d5a2 100644
--- third_party/libwebrtc/video/video_gn/moz.build
+++ third_party/libwebrtc/video/video_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -62,190 +72,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("video_gn")
diff --git third_party/libwebrtc/video/video_receive_stream_timeout_tracker_gn/moz.build third_party/libwebrtc/video/video_receive_stream_timeout_tracker_gn/moz.build
index 2ddf1cba308d..6c05db21ae0a 100644
--- third_party/libwebrtc/video/video_receive_stream_timeout_tracker_gn/moz.build
+++ third_party/libwebrtc/video/video_receive_stream_timeout_tracker_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,189 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("video_receive_stream_timeout_tracker_gn")
diff --git third_party/libwebrtc/video/video_stream_buffer_controller_gn/moz.build third_party/libwebrtc/video/video_stream_buffer_controller_gn/moz.build
index f86dbd03a98b..54723e3b191e 100644
--- third_party/libwebrtc/video/video_stream_buffer_controller_gn/moz.build
+++ third_party/libwebrtc/video/video_stream_buffer_controller_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -43,190 +53,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("video_stream_buffer_controller_gn")
diff --git third_party/libwebrtc/video/video_stream_encoder_impl_gn/moz.build third_party/libwebrtc/video/video_stream_encoder_impl_gn/moz.build
index 2c9ea4a7d6c0..e181e0004d99 100644
--- third_party/libwebrtc/video/video_stream_encoder_impl_gn/moz.build
+++ third_party/libwebrtc/video/video_stream_encoder_impl_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -51,190 +61,32 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    CXXFLAGS += [
-        "-mfpu=neon"
-    ]
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_ENABLE_AVX2"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_X11"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86":
-
     CXXFLAGS += [
         "-msse2"
     ]
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-    CXXFLAGS += [
-        "-msse2"
-    ]
+if CONFIG["TARGET_CPU"] == "x86_64":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
-    DEFINES["_GNU_SOURCE"] = True
+    DEFINES["USE_X11"] = "1"
 
 Library("video_stream_encoder_impl_gn")
diff --git third_party/libwebrtc/video/video_stream_encoder_interface_gn/moz.build third_party/libwebrtc/video/video_stream_encoder_interface_gn/moz.build
index 68109330f136..b2239c8f9f0d 100644
--- third_party/libwebrtc/video/video_stream_encoder_interface_gn/moz.build
+++ third_party/libwebrtc/video/video_stream_encoder_interface_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,118 +49,17 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "iphlpapi",
-        "secur32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
-
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["TARGET_CPU"] == "mips64":
-
-    DEFINES["_GNU_SOURCE"] = True
 
 if CONFIG["TARGET_CPU"] == "x86":
 
@@ -160,50 +69,8 @@ if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
-
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["_GNU_SOURCE"] = True
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["_GNU_SOURCE"] = True
-
 Library("video_stream_encoder_interface_gn")
diff --git third_party/libwebrtc/webrtc_gn/moz.build third_party/libwebrtc/webrtc_gn/moz.build
index 50e90f5868e1..9ce063158578 100644
--- third_party/libwebrtc/webrtc_gn/moz.build
+++ third_party/libwebrtc/webrtc_gn/moz.build
@@ -12,11 +12,21 @@ AllowCompilerWarnings()
 DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
 DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
 DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["USE_GLIB"] = "1"
+DEFINES["USE_OZONE"] = "1"
+DEFINES["WEBRTC_BSD"] = True
+DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
 DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
 DEFINES["WEBRTC_LIBRARY_IMPL"] = True
 DEFINES["WEBRTC_MOZILLA_BUILD"] = True
 DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_POSIX"] = True
 DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["_FILE_OFFSET_BITS"] = "64"
+DEFINES["_LARGEFILE64_SOURCE"] = True
+DEFINES["_LARGEFILE_SOURCE"] = True
+DEFINES["__STDC_CONSTANT_MACROS"] = True
+DEFINES["__STDC_FORMAT_MACROS"] = True
 
 FINAL_LIBRARY = "xul"
 
@@ -39,143 +49,23 @@ if not CONFIG["MOZ_DEBUG"]:
 if CONFIG["MOZ_DEBUG"] == "1":
 
     DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
-
-if CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["ANDROID"] = True
-    DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
-    DEFINES["HAVE_SYS_UIO_H"] = True
-    DEFINES["WEBRTC_ANDROID"] = True
-    DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_GNU_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "GLESv2",
-        "log"
-    ]
-
-if CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["WEBRTC_MAC"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
-    DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    LOCAL_INCLUDES += [
-        "/third_party/libwebrtc/sdk/objc/",
-        "/third_party/libwebrtc/sdk/objc/base/"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_NSS_CERTS"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_UDEV"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_LINUX"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "rt"
-    ]
-
-if CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["USE_GLIB"] = "1"
-    DEFINES["USE_OZONE"] = "1"
-    DEFINES["USE_X11"] = "1"
-    DEFINES["WEBRTC_BSD"] = True
-    DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True
-    DEFINES["WEBRTC_POSIX"] = True
-    DEFINES["_FILE_OFFSET_BITS"] = "64"
-    DEFINES["_LARGEFILE64_SOURCE"] = True
-    DEFINES["_LARGEFILE_SOURCE"] = True
-    DEFINES["__STDC_CONSTANT_MACROS"] = True
-    DEFINES["__STDC_FORMAT_MACROS"] = True
-
-    OS_LIBS += [
-        "X11",
-        "Xcomposite",
-        "Xdamage",
-        "Xext",
-        "Xfixes",
-        "Xrandr",
-        "Xrender"
-    ]
-
-if CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
-    DEFINES["NOMINMAX"] = True
-    DEFINES["NTDDI_VERSION"] = "0x0A000000"
-    DEFINES["PSAPI_VERSION"] = "2"
-    DEFINES["RTC_ENABLE_WIN_WGC"] = True
-    DEFINES["UNICODE"] = True
-    DEFINES["USE_AURA"] = "1"
-    DEFINES["WEBRTC_WIN"] = True
-    DEFINES["WIN32"] = True
-    DEFINES["WIN32_LEAN_AND_MEAN"] = True
-    DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
-    DEFINES["WINVER"] = "0x0A00"
-    DEFINES["_ATL_NO_OPENGL"] = True
-    DEFINES["_CRT_RAND_S"] = True
-    DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
-    DEFINES["_HAS_EXCEPTIONS"] = "0"
-    DEFINES["_HAS_NODISCARD"] = True
-    DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
-    DEFINES["_SECURE_ATL"] = True
-    DEFINES["_UNICODE"] = True
-    DEFINES["_WIN32_WINNT"] = "0x0A00"
-    DEFINES["_WINDOWS"] = True
-    DEFINES["__STD_C"] = True
-
-    OS_LIBS += [
-        "crypt32",
-        "d3d11",
-        "dwmapi",
-        "dxgi",
-        "iphlpapi",
-        "ole32",
-        "oleaut32",
-        "secur32",
-        "shcore",
-        "strmiids",
-        "user32",
-        "winmm"
-    ]
+    DEFINES["_DEBUG"] = True
 
 if CONFIG["TARGET_CPU"] == "aarch64":
 
     DEFINES["WEBRTC_ARCH_ARM64"] = True
     DEFINES["WEBRTC_HAS_NEON"] = True
+    DEFINES["WEBRTC_USE_PIPEWIRE"] = True
 
-if CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_ARCH_ARM"] = True
-    DEFINES["WEBRTC_ARCH_ARM_V7"] = True
-    DEFINES["WEBRTC_HAS_NEON"] = True
+    LOCAL_INCLUDES += [
+        "/third_party/pipewire/"
+    ]
 
 if CONFIG["TARGET_CPU"] == "mips32":
 
     DEFINES["MIPS32_LE"] = True
     DEFINES["MIPS_FPU_LE"] = True
     DEFINES["WEBRTC_USE_PIPEWIRE"] = True
-    DEFINES["_GNU_SOURCE"] = True
 
     LOCAL_INCLUDES += [
         "/third_party/pipewire/"
@@ -184,7 +74,6 @@ if CONFIG["TARGET_CPU"] == "mips32":
 if CONFIG["TARGET_CPU"] == "mips64":
 
     DEFINES["WEBRTC_USE_PIPEWIRE"] = True
-    DEFINES["_GNU_SOURCE"] = True
 
     LOCAL_INCLUDES += [
         "/third_party/pipewire/"
@@ -193,32 +82,22 @@ if CONFIG["TARGET_CPU"] == "mips64":
 if CONFIG["TARGET_CPU"] == "x86":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
+    DEFINES["WEBRTC_USE_PIPEWIRE"] = True
+
+    LOCAL_INCLUDES += [
+        "/third_party/pipewire/"
+    ]
 
 if CONFIG["TARGET_CPU"] == "x86_64":
 
     DEFINES["WEBRTC_ENABLE_AVX2"] = True
+    DEFINES["WEBRTC_USE_PIPEWIRE"] = True
 
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
-
-    DEFINES["_DEBUG"] = True
-
-if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
-
-    DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
+    LOCAL_INCLUDES += [
+        "/third_party/pipewire/"
+    ]
 
-if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "FreeBSD":
 
     DEFINES["USE_X11"] = "1"
 
@@ -232,46 +111,4 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
         "Xrender"
     ]
 
-if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm":
-
-    OS_LIBS += [
-        "unwind"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64":
-
-    DEFINES["WEBRTC_USE_PIPEWIRE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-    LOCAL_INCLUDES += [
-        "/third_party/pipewire/"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm":
-
-    DEFINES["WEBRTC_USE_PIPEWIRE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-    LOCAL_INCLUDES += [
-        "/third_party/pipewire/"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86":
-
-    DEFINES["WEBRTC_USE_PIPEWIRE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-    LOCAL_INCLUDES += [
-        "/third_party/pipewire/"
-    ]
-
-if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
-
-    DEFINES["WEBRTC_USE_PIPEWIRE"] = True
-    DEFINES["_GNU_SOURCE"] = True
-
-    LOCAL_INCLUDES += [
-        "/third_party/pipewire/"
-    ]
-
 Library("webrtc_gn")
