Cross compiling Mediasoup (and WebRTC) for the RPI4

I’m trying to develop a C++ SFU using libmediasoupclient v3. My development server is a Raspberry Pi 4 (running Ubuntu 20.04), while my production server is running an x86 processor.

So I have tried to install Mediasoup on the RPI using the offical instructions, but failed while trying to build WebRTC. Then I tried cross-compiling WebRTC on another x86 server, but failed again (see error below) and now I have no idea on how to progress further. I also have no idea on whether or how to cross-compile Mediasoup.

[1658/3239] CC obj/third_party/libaom/libaom/variance.o
ninja: build stopped: subcommand failed.

I have no idea how to debug this error or whether there is a log. (Note: The cross-compiling server only has 2GB RAM so that may be the issue)

I understand that this forum is about Mediasoup, but I have thrown in some questions regarding the building of WebRTC as well in case they are trivial to answer.

My questions are:

  1. Why is there no libmediasoup / WebRTC package (apt, snap, …)?
  2. Does Mediasoup even support ARM?
  3. How do I cross-compile WebRTC for libmediasoup (using the right branch) / What did I do wrong?
  4. How do I (cross-?)compile libmediasoup afterwards?

Here is my current approach using these sources:

  • https://mediasoup.org/documentation/v3/libmediasoupclient/installation/
  • https://webrtc.github.io/webrtc-org/native-code/development/
  • https://github.com/mpromonet/webrtc-streamer/wiki/Cross-compile-WebRTC-for-Raspberry-Pi
  • https://raspberrypi.stackexchange.com/questions/29871/how-to-build-native-webrtc
# see: https://github.com/mpromonet/webrtc-streamer/wiki/Cross-compile-WebRTC-for-Raspberry-Pi
# Setup some stuff
sudo su
cd /home/myuser/
apt install git
mkdir cross-compile/
cd cross-compile/
# Get depot_tools 
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git /opt/depot_tools
nano /etc/profile.d/depot_tools.sh
 +	export PATH=$PATH:/opt/depot_tools
 >	C + x
# see: https://sourceforge.net/projects/raspberry-pi-cross-compilers
# Get the cross-compiler
# The URL from the blog was outdated, so I just went for the latest version here
wget -O- https://sourceforge.net/projects/raspberry-pi-cross-compilers/files/Raspberry%20Pi%20GCC%20Cross-Compiler%20Toolchains/Buster/GCC%2010.2.0/Raspberry%20Pi%203A%2B%2C%203B%2B%2C%204/cross-gcc-10.2.0-pi_3%2B.tar.gz | sudo tar xz -C /opt
nano /etc/profile.d/arm_tools.sh
 +	export PATH=$PATH:/opt/cross-pi-gcc-10.2.0-2/bin
 >	C + x
source /etc/profile
# Get WebRTC
fetch --no-history --nohooks webrtc
./src/build/linux/sysroot_scripts/install-sysroot.py --arch=arm
# see: https://mediasoup.org/documentation/v3/libmediasoupclient/installation/
chown -R myuser:myuser /home/myuser/cross-compile/
chown -R myuser:myuser /opt/depot_tools/
# Switch to myuser
exit
gclient sync
cd src/
git checkout -b m84 refs/remotes/branch-heads/4147
gclient sync
./build/install-build-deps.sh --arm
# I tried to apply common sense here (merging the args from multiple sources), since I have no idea what these args actually mean / do
gn gen out/m84 --args='is_debug=false is_clang=false target_cpu="arm" is_component_build=false rtc_use_h264=true rtc_include_tests=false rtc_build_examples=false use_rtti=true treat_warnings_as_errors=false use_custom_libcxx=false use_ozone=true'
ninja -C out/m84
# Theorethically move on to (cross-?)compiling mediasoup
# Move .so to target server /lib/ directory?

Any hint or answer on just some question(s) would be much apprichiated!

You are talking about libmediasoupclient as if it was mediasoup. They are completely different things that do not share any line of code.

BTW: if you want to have a SFU, why don’t you just use mediasoup instead of libmediasoupclient?

1 Like

Thanks for the fast reply.
Sorry, I abbreviated libmediasoupclient to Mediasoup for simplicity (which is ironic i know).

I am just starting with mediasoup and don’t have a complete overview of all of it.
My understanding is that mediasoup is build on libmediasoupclient and mediasoup is a ready-to-use SFU.
What I want is programmatic control over which streams get send to who (and room creation etc.).
My current impression is that mediasoup might not be that flexible and I would be better of trying to write my own SFU on top of libmediasoupclient, which can that interact with the rest of my plattform.

Please correct me if i am mistaken.
I’m AFK for some time, so I may not reply for a few hours.

As I said mediasoup and libmediasoupclient do not share any single line of code, nor one of them uses the other. Forget completely about libmediasoupclient, please. Just run npm install mediasoup in your target host and, before that, ensure your host satisfies the mediasoup Installation requirements (docs).

1 Like

Okay, i’ve looked at the documentation again and using mediasoup seems like the obvious answer.
Sorry for the unnecessary question, i’ve read all day about streaming solutions before choosing libmediasoupclient and don’t know how i didn’t read it’s primary description.

Thanks for the quick responses! - They probably saved me alot of headaches.