devopvoid / webrtc-java

WebRTC for desktop platforms running Java
Apache License 2.0
248 stars 60 forks source link

Build for Raspberry PI #58

Closed nchalon closed 1 year ago

nchalon commented 2 years ago

Hi,

First, thanks for your project that was the first straightforward java bridge to WebRTC. I successfully had my code run on OSX an windows but now I would like to test it on Raspberry PI and I hit a roadblock.

The first step for me was to try to build your project on the pi (or on a debian-10 container) but unfortunately without any success.

I tried the following:

I also updated the webrtc-jni pom.xml to point to latest maven-cmake plugin (version 3.22.1-b1) and specifying the cmake.download=False parameter and restarted the 3 tests --> No success either

I looked deeper at what the cmake plugin was doing and recontructed the cmake command line (executed in webrtc-jni) as follow: cmake -DWEBRTC_BRANCH=branch-heads/4692 -DWEBRTC_SRC_DIR=/buildit/webrtc -DWEBRTC_INSTALL_DIR=/buildit/webrtc/output -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_NAME=Linux -DTARGET_CPU=arm -S src/main/cpp/ -B target/linux-arm but this did not work

By any chance, would you have any procedure to build your project for raspberry PI (in a container or on the PI itself directly) ?

Many thanks in advance !

moonchitta commented 2 years ago

I was able to compile version 0.7.0-SNAPSHOT successfully, I ran the code on raspberry as well as on Pinephone Mobian and it worked very good. Though my current implementation needs some other optimization but this library works very good.

Following are the changes you have to made in the respective files as well you need to install respective compiler for cross compilation.

As I only needed to compile this library for linux-arm64 so the changes below are only tested on these devices. The cross compiler did work on Ubuntu 20.04 running gcc-9, g++-9 and moreover you will need GLIBC-2.31 (these are my findings for Pinephone)

  1. install cross compiler sudo apt install gcc-9-aarch64-linux-gnu g++-9-aarch64-linux-gnu libpulse-dev libudev-dev libx11-dev. The last three libraries are needed only for header files, we will need aarch64 so files for final linking.
  2. create lib directory in main webrtc-java directory, download libpulse.so libudev.so libx110.so for aarch64 and copy these files into lib directory. You might have to copy other supporting so files too like libpulse.so.6.
  3. apply the attached linux-arm64.patch patch
  4. during first time, it will fetch all the webrtc code, and it will fail for the first time during Webrtc generate command. stop the process and execute in /home/{user}/webrtc/src/ directory this command build/linux/sysroot_scripts/install-sysroot.py --arch=arm64
  5. start again by typing mvn clean package.

I hope these 5 steps will yield out a working aarch64 libwebrtc-java.so file. linux-arm64.zip

moonchitta commented 2 years ago

In case anyone wants to use already compiled libwebrtc-java.so file aarch64 linked against GLIBC-2.3, please find the attached file. libwebrtc-java.zip .