diff --git a/.github/actions/prepare-linux/action.yml b/.github/actions/prepare-linux/action.yml index d9288b608..3e2db64f8 100644 --- a/.github/actions/prepare-linux/action.yml +++ b/.github/actions/prepare-linux/action.yml @@ -45,7 +45,7 @@ runs: # tools/clang/scripts/update.py of the webrtc.branch set in # webrtc-jni/pom.xml. Update it whenever that branch changes. - name: Select the Chromium Clang package - run: echo "CLANG_PACKAGE=clang-llvmorg-24-init-7747-g62397f8b-27.tar.xz" >> "$GITHUB_ENV" + run: echo "CLANG_PACKAGE=clang-llvmorg-24-init-14453-ge063be79-1.tar.xz" >> "$GITHUB_ENV" shell: bash - name: Cache the Chromium Clang package diff --git a/docs/guide/build.md b/docs/guide/build.md index 2f4817696..032dd0348 100644 --- a/docs/guide/build.md +++ b/docs/guide/build.md @@ -37,7 +37,7 @@ sudo apt-get install binutils cmake git libva-dev make meson nasm ninja-build pk The JNI library compiles against the libc++ headers of the WebRTC build. Those headers only support the Clang that the WebRTC branch pins, so the toolchain files expect that exact Clang in `/opt/clang`. Install it this way (the package name is in `.github/actions/prepare-linux/action.yml` and changes with the WebRTC branch): ```shell -CLANG_PACKAGE=clang-llvmorg-24-init-7747-g62397f8b-27.tar.xz +CLANG_PACKAGE=clang-llvmorg-24-init-14453-ge063be79-1.tar.xz wget https://commondatastorage.googleapis.com/chromium-browser-clang/Linux_x64/$CLANG_PACKAGE sudo mkdir -p /opt/clang sudo tar -xf $CLANG_PACKAGE -C /opt/clang @@ -99,7 +99,7 @@ On the first run, the WebRTC source tree is loaded into the `//webrtc | Parameter | Description | Default Value | | ------------------ | ------------------------------------------------------ |-----------------------------| -| webrtc.branch | The WebRTC branch to checkout. | branch-heads/8059 | +| webrtc.branch | The WebRTC branch to checkout. | branch-heads/8127 | | webrtc.src.dir | The absolute checkout path for the WebRTC source tree. | /\/webrtc | | webrtc.install.dir | The install path for the compiled WebRTC library. Is also used to link against a pre-compiled WebRTC library to reduce build time. | /\/webrtc/build | diff --git a/webrtc-jni/pom.xml b/webrtc-jni/pom.xml index f4fcc87db..6f1c9db03 100644 --- a/webrtc-jni/pom.xml +++ b/webrtc-jni/pom.xml @@ -12,7 +12,7 @@ pom - branch-heads/8059 + branch-heads/8127 ${user.home}/webrtc ${user.home}/webrtc/build Release diff --git a/webrtc-jni/src/main/cpp/dependencies/webrtc/CMakeLists.txt b/webrtc-jni/src/main/cpp/dependencies/webrtc/CMakeLists.txt index d48c874d8..367abea8d 100644 --- a/webrtc-jni/src/main/cpp/dependencies/webrtc/CMakeLists.txt +++ b/webrtc-jni/src/main/cpp/dependencies/webrtc/CMakeLists.txt @@ -137,6 +137,10 @@ message(STATUS "WebRTC install path: ${WEBRTC_INSTALL_DIR}") # The GN args WebRTC is built with. They come before the check for a compiled # WebRTC below, because a build is only used if it was made with these. +# rtc_rust=false: from M158 rtp_rtcp_format links a Rust cxx bridge, whose std +# and allocator objects are not in the static library, so the JNI link would +# leave __rust_* symbols undefined. WebRTC keeps a C++ fallback for it +# (WEBRTC_WITHOUT_RUST) while the switch exists. set(COMPILE_ARGS "target_cpu=\"${TARGET_CPU}\" \ use_custom_libcxx=${CUSTOM_LIBCXX} \ is_clang=true \ @@ -145,6 +149,7 @@ is_component_build=false \ treat_warnings_as_errors=false \ rtc_build_tools=false \ rtc_use_perfetto=false \ +rtc_rust=false \ rtc_use_pipewire=false \ rtc_enable_protobuf=false \ rtc_build_examples=false \ diff --git a/webrtc-jni/src/main/cpp/dependencies/webrtc/patches/windows/.gitattributes b/webrtc-jni/src/main/cpp/dependencies/webrtc/patches/windows/.gitattributes new file mode 100644 index 000000000..3d09cd1c5 --- /dev/null +++ b/webrtc-jni/src/main/cpp/dependencies/webrtc/patches/windows/.gitattributes @@ -0,0 +1,2 @@ +# Applied to an LF file from the Clang package, not to a git checkout. +clang_fpm_scale_linkage.patch text eol=lf diff --git a/webrtc-jni/src/main/cpp/dependencies/webrtc/patches/windows/clang_fpm_scale_linkage.patch b/webrtc-jni/src/main/cpp/dependencies/webrtc/patches/windows/clang_fpm_scale_linkage.patch new file mode 100644 index 000000000..f1e5acdc5 --- /dev/null +++ b/webrtc-jni/src/main/cpp/dependencies/webrtc/patches/windows/clang_fpm_scale_linkage.patch @@ -0,0 +1,23 @@ +The Clang that branch-heads/8127 pins declares the FP8 scale helpers as +builtins with C linkage, which fails when arm_neon.h is included inside an +extern "C++" block, as the UCRT's wchar.h does on Windows arm64. This is +llvm/llvm-project@1ac17ec2; drop it once the pinned Clang contains that commit. + +--- a/third_party/llvm-build/Release+Asserts/lib/clang/24/include/arm_vector_types.h ++++ b/third_party/llvm-build/Release+Asserts/lib/clang/24/include/arm_vector_types.h +@@ -58,9 +58,15 @@ + return (__fpm & ~0x8000ull) | ((fpm_t)__behaviour << 15u); + } + ++#ifdef __cplusplus ++extern "C" { ++#endif + __inline__ fpm_t __attribute__((__always_inline__, __nodebug__)) __arm_set_fpm_lscale(fpm_t __fpm, uint64_t __scale); + __inline__ fpm_t __attribute__((__always_inline__, __nodebug__)) __arm_set_fpm_nscale(fpm_t __fpm, int64_t __scale); + __inline__ fpm_t __attribute__((__always_inline__, __nodebug__)) __arm_set_fpm_lscale2(fpm_t __fpm, uint64_t __scale); ++#ifdef __cplusplus ++} ++#endif + + typedef __attribute__((neon_vector_type(8))) int8_t int8x8_t; + typedef __attribute__((neon_vector_type(16))) int8_t int8x16_t; diff --git a/webrtc-jni/src/main/cpp/src/JNI_RTCDataChannel.cpp b/webrtc-jni/src/main/cpp/src/JNI_RTCDataChannel.cpp index 823ae0ecf..dac197fe9 100644 --- a/webrtc-jni/src/main/cpp/src/JNI_RTCDataChannel.cpp +++ b/webrtc-jni/src/main/cpp/src/JNI_RTCDataChannel.cpp @@ -30,8 +30,10 @@ #include "api/data_channel_interface.h" #include "rtc_base/logging.h" +#include #include #include +#include namespace { @@ -279,7 +281,7 @@ JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_RTCDataChannel_sendDirectBuffer if (address != NULL) { jlong bufferLength = env->GetDirectBufferCapacity(jBuffer); - webrtc::CopyOnWriteBuffer data(address, static_cast(bufferLength)); + webrtc::CopyOnWriteBuffer data(std::span(address, static_cast(bufferLength))); if (!channel->Send(webrtc::DataBuffer(data, static_cast(isBinary)))) { env->Throw(jni::JavaRuntimeException(env, "Data channel rejected the send")); @@ -309,7 +311,8 @@ JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_RTCDataChannel_sendByteArrayBuffer if (!bytes) { return; } - webrtc::CopyOnWriteBuffer data(bytes.get(), env->GetArrayLength(jBufferArray)); + webrtc::CopyOnWriteBuffer data(std::span( + reinterpret_cast(bytes.get()), static_cast(env->GetArrayLength(jBufferArray)))); bytes.reset(); if (!channel->Send(webrtc::DataBuffer(data, static_cast(isBinary)))) { @@ -373,7 +376,7 @@ static void sendDirectBufferAsync(JNIEnv * env, jobject caller, jobject jBuffer, } // The data is copied before returning, so the caller may reuse the buffer. - webrtc::CopyOnWriteBuffer data(address + position, static_cast(length)); + webrtc::CopyOnWriteBuffer data(std::span(address + position, static_cast(length))); sendAsync(env, channel, webrtc::DataBuffer(data, static_cast(isBinary)), jObserver); } @@ -401,7 +404,8 @@ static void sendByteArrayBufferAsync(JNIEnv * env, jobject caller, jbyteArray jB if (!bytes) { return; } - webrtc::CopyOnWriteBuffer data(bytes.get(), env->GetArrayLength(jBufferArray)); + webrtc::CopyOnWriteBuffer data(std::span( + reinterpret_cast(bytes.get()), static_cast(env->GetArrayLength(jBufferArray)))); bytes.reset(); sendAsync(env, channel, webrtc::DataBuffer(data, static_cast(isBinary)), jObserver); diff --git a/webrtc/src/test/java/dev/onvoid/webrtc/media/video/desktop/DesktopCapturerTests.java b/webrtc/src/test/java/dev/onvoid/webrtc/media/video/desktop/DesktopCapturerTests.java index 5b0bb28b9..1b6d2792e 100644 --- a/webrtc/src/test/java/dev/onvoid/webrtc/media/video/desktop/DesktopCapturerTests.java +++ b/webrtc/src/test/java/dev/onvoid/webrtc/media/video/desktop/DesktopCapturerTests.java @@ -35,6 +35,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Locale; +import java.util.stream.Collectors; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.parallel.Execution; @@ -147,7 +148,16 @@ void pickerCanBeTurnedOff() { capturer.setUseSystemPicker(true); capturer.setUseSystemPicker(false); - assertEquals(screens, capturer.getDesktopSources()); + List after = capturer.getDesktopSources(); + + if (isWayland()) { + // The PipeWire capturer lists one source, whose ID is new for + // each native capturer. + assertEquals(titles(screens), titles(after)); + } + else { + assertEquals(screens, after); + } } finally { capturer.dispose(); @@ -285,7 +295,15 @@ void screenCapturerFollowsScreen() throws Exception { * Starting a capturer in a Wayland session asks the user what to share. */ private static void assumeNoPortalDialog() { - assumeFalse("wayland".equals(System.getenv("XDG_SESSION_TYPE")), "Wayland session"); + assumeFalse(isWayland(), "Wayland session"); + } + + private static boolean isWayland() { + return "wayland".equals(System.getenv("XDG_SESSION_TYPE")); + } + + private static List titles(List sources) { + return sources.stream().map(source -> source.title).collect(Collectors.toList()); } /** The mean luma of every fourth pixel in every fourth row. */