Shairplay

October 30, 2016 ยท View on GitHub

Free, portable AirPlay Server implementation similar to ShairPort.
Currently, only AirPort Express emulation is supported.

Table of Contents

  1. Prerequisites
  1. How-to-Build
  1. Installation
  2. Airport.key File
  3. Usage
  4. Development
  1. Disclaimer
  2. Related Projects

Prerequisites

External Dependencies

Before building, a number of external dependencies needs to be installed (depending on your platform).

NameTitle
libaoCross platform audio library
libavahiDNS/DNS-SD service discovery
autoconfGeneratinge configure scripts
automakeGenerating Makefiles
libtoolCreating portable compiled libraries
pkg-configGathering metadata of installed packages

Installation on Linux

Using apt-get:

sudo apt-get install autoconf automake libtool libltdl-dev
sudo apt-get libao-dev
sudo apt-get libavahi-compat-libdnssd-dev
sudo apt-get install avahi-daemon

Installation on OSX

On Apple OSX, a third-party package manager such as Homebrew needs to be installed before installing dependencies.

After installing Homebrew, run:

brew install autoconf automake libtool pkg-config
brew install libao

How-to-Build

In order to build the shairplay application, the libao audio library dependency needs to be installed - otherwise, only the library will be built.

Using Make

Preparation

./autogen.sh
./configure

Building

make clean
make

Output

OutputLocation
Application Binarysrc/shairplay
Static Librarysrc/lib/.libs/libshairplay.a
Dynamic Librarysrc/lib/.libs/libshairplay.0.dylib

Using XCode

Both the Shairplay application and library are available as targets within a main XCode project file. Internal dependencies are registered as dependencies within this project.

Preparation

./autogen.sh
./configure
make clean

XCode Project Files

XCode Project FileLocation
Main Projectextras/xcode/shairplay/shairplay.xcodeproj
Dependency: Cryptoextras/xcode/crypto/crypto.xcodeproj
Dependency: ALACextras/xcode/alac/alac.xcodeproj

Output

All XCode build output is deployed the "build" folder.

Installation

After building, run:

sudo make install

The results will be located at

  • /usr/local/bin (application binary)
  • /usr/local/lib (static & dynamic libraries)
  • /usr/local/include/shairplay (library header files)

Usage

Running an AirPlay Server

Place the airport.key file in your working directory. Then, start the server with:

shairplay [options...]

If you are connected to a Wi-Fi, the server should show as an AirPort Express on your iOS devices and Mac OS X computers in the same network.

Options

  • -a, --apname=AirPort - Sets Airport name (Default: Shairplay)
  • -p, --password=secret - Sets password
  • -o, --server_port=5000 - Sets port for RAOP service
  • -h, --help - Help
  • --hwaddr=address - Sets the MAC address, useful if running multiple instances
  • --ao_driver=driver - Sets the ao driver
  • --ao_devicename=devicename - Sets the ao device name
  • --ao_deviceid=id - Sets the ao device id

Example:

shairplay --help

Airport.key File

You need to have the airport.key file in the current working directory when starting the server.

It is not included in the binary for legal reasons.

Development

Components

ComponentFolder
Main Application & Library sourcessrc/lib/
Main Library public headersinclude/shairplay/
Qt4 Application sourcesAirTV-Qt/
Python bindingssrc/bindings/python/
Qt bindingssrc/bindings/qt4/

Source Location

Main Application

FileContents
shairplay.cShairplay application

Main Library

FileContents
base64.*base64 encoder/decoder
dnssd.*dnssd helper functions
http_parser.*HTTP parser from joyent (nginx fork)
http_request.*Request parser that uses http_parser
http_response.*Extremely simple HTTP response serializer
httpd.*Generic HTTP/RTSP server
logger.*Logging related functions
netutils.*Mostly socket related code
raop.*Main RAOP handler, handles all RTSP stuff
raop_rtp.*Handles the RAOP RTP related stuff (UDP/TCP)
raop_buffer.*Parses and buffers RAOP packets, resend logic here
rsakey.*Decrypts and parses the RSA key to bigints
rsapem.*Converts the RSA PEM key to DER encoded bytes
sdp.*Extremely simple RAOP specific SDP parser
utils.*Utils for reading a file and handling strings

Qt Application

FileContents
main.cppInitializes the application
mainapplication.cppCreates the tray icon and starts RAOP
raopservice.cppHandles all communication with the library
raopcallbackhandler.cppConverts C callbacks to Qt callbacks
audiooutput.cppTakes care of the actual audio output

Disclaimer

All the resources in this repository are written using only freely available information from the internet. The code and related resources are meant for educational purposes only. It is the responsibility of the user to make sure all local laws are adhered to.

  • ShairPort, original AirPort Express emulator
  • ALAC, ALAC decoder by David Hammerton