Skip to content

Commit fa31f17

Browse files
authored
fix: fix unable to locate __arm_tpidr2_save for android ffi. (#765)
* fix: fix unable to locate __arm_tpidr2_save for android ffi. * Add H265 and Simulcast support for iOS/macOS. * Remove ndk_arch from Android build configurations
1 parent 6464e2e commit fa31f17

9 files changed

Lines changed: 34 additions & 20 deletions

File tree

.github/workflows/builds.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,4 @@ jobs:
105105
ln -sf $ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/lib/${{ matrix.ndk_arch }}/{libunwind.so,libc++abi.a} $ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/lib/
106106
cargo install cargo-ndk
107107
# FIXME: wgpu_room does not link on aarch64
108-
cargo ndk --target ${{ matrix.target }} build --release -p livekit --workspace --exclude wgpu_room -vv
108+
cargo ndk --target ${{ matrix.target }} build --release -p livekit --workspace -vv

.github/workflows/ffi-builds.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,23 +89,20 @@ jobs:
8989
dylib: liblivekit_ffi.so
9090
jar: libwebrtc.jar
9191
target: aarch64-linux-android
92-
ndk_arch: aarch64-unknown-linux-musl
9392
name: ffi-android-arm64
9493
buildargs: --no-default-features --features "rustls-tls-webpki-roots"
9594
- os: ubuntu-latest
9695
platform: android
9796
dylib: liblivekit_ffi.so
9897
jar: libwebrtc.jar
9998
target: armv7-linux-androideabi
100-
ndk_arch: arm-unknown-linux-musleabihf
10199
name: ffi-android-armv7
102100
buildargs: --no-default-features --features "rustls-tls-webpki-roots"
103101
- os: ubuntu-latest
104102
platform: android
105103
dylib: liblivekit_ffi.so
106104
jar: libwebrtc.jar
107105
target: x86_64-linux-android
108-
ndk_arch: x86_64-unknown-linux-musl
109106
name: ffi-android-x86_64
110107
buildargs: --no-default-features --features "rustls-tls-webpki-roots"
111108

@@ -171,7 +168,6 @@ jobs:
171168
if: ${{ matrix.platform == 'android' }}
172169
run: |
173170
cd livekit-ffi/
174-
ln -sf $ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/lib/${{ matrix.ndk_arch }}/{libunwind.so,libc++abi.a} $ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/lib/
175171
cargo install cargo-ndk
176172
cargo ndk --target ${{ matrix.target }} build --release ${{ matrix.buildargs }}
177173

examples/wgpu_room/src/logo_track.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ impl LogoTrack {
7777
LocalTrack::Video(track.clone()),
7878
TrackPublishOptions {
7979
source: TrackSource::Camera,
80-
simulcast: false,
81-
video_codec: VideoCodec::H264,
80+
simulcast: true,
81+
video_codec: VideoCodec::H265,
8282
..Default::default()
8383
},
8484
)

livekit-ffi/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ from_variants = "1.0.2"
4040

4141
[target.'cfg(target_os = "android")'.dependencies]
4242
jni = "0.21.1"
43+
link-cplusplus = { version = "1", features = ["nothing"] }
4344

4445
[build-dependencies]
4546
prost-build = "0.14.1"

webrtc-sys/build.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,11 @@ fn main() {
249249

250250
println!("cargo:rustc-link-lib=EGL");
251251
println!("cargo:rustc-link-lib=OpenSLES");
252+
println!("cargo:rustc-link-lib=c++_static");
253+
println!("cargo:rustc-link-lib=c++abi");
252254

253255
configure_android_sysroot(&mut builder);
254-
255-
builder.file("src/android.cpp").flag("-std=c++20").cpp_link_stdlib("c++_static");
256+
builder.file("src/android.cpp").flag("-std=c++20");
256257
}
257258
_ => {
258259
panic!("Unsupported target, {}", target_os);
@@ -340,10 +341,6 @@ fn configure_darwin_sysroot(builder: &mut cc::Build) {
340341

341342
fn configure_android_sysroot(builder: &mut cc::Build) {
342343
let toolchain = webrtc_sys_build::android_ndk_toolchain().unwrap();
343-
let toolchain_lib = toolchain.join("lib");
344-
345344
let sysroot = toolchain.join("sysroot").canonicalize().unwrap();
346-
println!("cargo:rustc-link-search={}", toolchain_lib.display());
347-
348345
builder.flag(format!("-isysroot{}", sysroot.display()).as_str());
349346
}

webrtc-sys/build/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use regex::Regex;
2727
use reqwest::StatusCode;
2828

2929
pub const SCRATH_PATH: &str = "livekit_webrtc";
30-
pub const WEBRTC_TAG: &str = "webrtc-ebd5a9f";
30+
pub const WEBRTC_TAG: &str = "webrtc-ebd5a9f-2";
3131
pub const IGNORE_DEFINES: [&str; 2] = ["CR_CLANG_REVISION", "CR_XCODE_VERSION"];
3232

3333
pub fn target_os() -> String {

webrtc-sys/libwebrtc/build_android.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ git apply "$COMMAND_DIR/patches/ssl_verify_callback_with_native_handle.patch" -v
7272
git apply "$COMMAND_DIR/patches/add_deps.patch" -v --ignore-space-change --ignore-whitespace --whitespace=nowarn
7373
git apply "$COMMAND_DIR/patches/android_use_libunwind.patch" -v --ignore-space-change --ignore-whitespace --whitespace=nowarn
7474

75-
cd ..
75+
cd third_party/libyuv
76+
git apply "$COMMAND_DIR/patches/disable_sme_for_libyuv.patch" -v --ignore-space-change --ignore-whitespace --whitespace=nowarn
77+
78+
cd ../../..
7679

7780
mkdir -p "$ARTIFACTS_DIR/lib"
7881

@@ -95,6 +98,7 @@ args="is_debug=$debug \
9598
is_component_build=false \
9699
enable_stripping=true \
97100
rtc_use_h264=false \
101+
rtc_use_h265=true \
98102
rtc_use_pipewire=false \
99103
symbol_level=0 \
100104
enable_iterator_debugging=false \
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/libyuv.gni b/libyuv.gni
2+
index 3334df70..9859a121 100644
3+
--- a/libyuv.gni
4+
+++ b/libyuv.gni
5+
@@ -24,7 +24,7 @@ declare_args() {
6+
# errors on Fuchsia, macOS, and compilation errors on Windows.
7+
# TODO: bug 359006069 - Remove the restriction after the linker and
8+
# compilation errors are fixed.
9+
- libyuv_use_sme = current_cpu == "arm64" && (is_linux || is_android)
10+
+ libyuv_use_sme = current_cpu == "arm64" && (is_linux)
11+
libyuv_use_msa =
12+
(current_cpu == "mips64el" || current_cpu == "mipsel") && mips_use_msa
13+
libyuv_use_mmi =

webrtc-sys/src/objc_video_factory.mm

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,23 @@
1616

1717
#include "livekit/objc_video_factory.h"
1818

19-
#import <sdk/objc/components/video_codec/RTCVideoDecoderFactoryH264.h>
20-
#import <sdk/objc/components/video_codec/RTCVideoEncoderFactoryH264.h>
19+
#import <sdk/objc/components/video_codec/RTCDefaultVideoDecoderFactory.h>
20+
#import <sdk/objc/components/video_codec/RTCDefaultVideoEncoderFactory.h>
21+
#import <sdk/objc/components/video_codec/RTCVideoEncoderFactorySimulcast.h>
2122
#include "sdk/objc/native/api/video_decoder_factory.h"
2223
#include "sdk/objc/native/api/video_encoder_factory.h"
2324

2425
namespace livekit {
2526

2627
std::unique_ptr<webrtc::VideoEncoderFactory> CreateObjCVideoEncoderFactory() {
27-
// TODO(theomonnom): Simulcast?
28-
return webrtc::ObjCToNativeVideoEncoderFactory([[RTCVideoEncoderFactoryH264 alloc] init]);
28+
RTCDefaultVideoEncoderFactory* encoderFactory = [[RTCDefaultVideoEncoderFactory alloc] init];
29+
RTCVideoEncoderFactorySimulcast* simulcastFactory =
30+
[[RTCVideoEncoderFactorySimulcast alloc] initWithPrimary:encoderFactory fallback:encoderFactory];
31+
return webrtc::ObjCToNativeVideoEncoderFactory(simulcastFactory);
2932
}
3033

3134
std::unique_ptr<webrtc::VideoDecoderFactory> CreateObjCVideoDecoderFactory() {
32-
return webrtc::ObjCToNativeVideoDecoderFactory([[RTCVideoDecoderFactoryH264 alloc] init]);
35+
return webrtc::ObjCToNativeVideoDecoderFactory([[RTCDefaultVideoDecoderFactory alloc] init]);
3336
}
3437

3538
} // namespace livekit

0 commit comments

Comments
 (0)