An open-source implementation of an AirPlay mirroring server for the Raspberry Pi. The goal is to make it run smoothly even on a Raspberry Pi Zero.
Screen mirroring and audio works for iOS 9 or newer. Recent macOS versions also seem to be compatible. The GPU is used for decoding the h264 video stream. The Pi has no hardware acceleration for audio (AirPlay mirroring uses AAC), so the FDK-AAC decoder is used for that.
Both audio and video work fine on a Raspberry Pi 3B+ and a Raspberry Pi Zero, though playback is a bit smoother on the 3B+.
For best performance:
- Use a wired network connection
- Compile with -O3 (cmake --DCMAKE_CXX_FLAGS="-O3" --DCMAKE_C_FLAGS="-O3" ..)
- Make sure the DUMP flags are not active
- Make sure you don't use the -d debug log flag
- Make sure no other demanding tasks are running (this is particularly important for audio on the Pi Zero)
By using OpenSSL for AES decryption, I was able to speed up the decryption of video packets from up to 0.2 seconds to up to 0.007 seconds for large packets (On the Pi Zero). Average is now more like 0.002 seconds.
There still are some minor issues. Have a look at the TODO list below.
RPiPlay might not be suitable for remote video playback, as it lacks a dedicated component for that: It seems like AirPlay on an AppleTV effectively runs a web server on the device and sends the URL to the AppleTV, thus avoiding the re-encoding of the video. For rough details, refer to the (mostly obsolete) inofficial AirPlay specification.
The following packages are required for building on Raspbian:
- cmake (for the build system)
- libavahi-compat-libdnssd-dev (for the bonjour registration)
- libplist-dev (for plist handling)
- libssl-dev (for crypto primitives)
- ilclient and Broadcom's OpenMAX stack as present in
/opt/vc
in Raspbian.
For downloading the code, use these commands:
git clone https://github.com/FD-/RPiPlay.git
cd RPiPlay
For building on a fresh Raspbian Stretch or Buster install, these steps should be run:
sudo apt-get install cmake
sudo apt-get install libavahi-compat-libdnssd-dev
sudo apt-get install libplist-dev
sudo apt-get install libssl-dev
mkdir build
cd build
cmake ..
make -j
GCC 5 or later is required.
For building on desktop linux, follow these steps as per your distribution:
sudo apt-get install cmake libavahi-compat-libdnssd-dev libplist-dev libssl-dev \
libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev gstreamer1.0-libav \
gstreamer1.0-vaapi gstreamer1.0-plugins-bad
mkdir build
cd build
cmake ..
make