/shairplay

An up-to-date fork of https://github.com/juhovh/shairplay, with Xcode project files that can build on both macOS and iOS.

Primary LanguageCOtherNOASSERTION

Shairplay

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).

Name Title
libao Cross platform audio library
libavahi DNS/DNS-SD service discovery
autoconf Generatinge configure scripts
automake Generating Makefiles
libtool Creating portable compiled libraries
pkg-config Gathering 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

Output Location
Application Binary src/shairplay
Static Library src/lib/.libs/libshairplay.a
Dynamic Library src/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 File Location
Main Project extras/xcode/shairplay/shairplay.xcodeproj
Dependency: Crypto extras/xcode/crypto/crypto.xcodeproj
Dependency: ALAC extras/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

Component Folder
Main Application & Library sources src/lib/
Main Library public headers include/shairplay/
Qt4 Application sources AirTV-Qt/
Python bindings src/bindings/python/
Qt bindings src/bindings/qt4/

Source Location

Main Application

File Contents
shairplay.c Shairplay application

Main Library

File Contents
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

File Contents
main.cpp Initializes the application
mainapplication.cpp Creates the tray icon and starts RAOP
raopservice.cpp Handles all communication with the library
raopcallbackhandler.cpp Converts C callbacks to Qt callbacks
audiooutput.cpp Takes 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.

Related Projects

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