Files
shairport-sync/AIRPLAY2.md
T
2022-07-01 18:02:53 +01:00

4.3 KiB
Raw Blame History

AirPlay 2

Shairport Sync offers AirPlay 2 support for audio sources on iOS devices, Macs, HomePod minis and Apple TVs.

What Works

  • AirPlay 2 audio for iOS, HomePod mini, AppleTV and Mac players.

    • Two types of audio are received by Shairport Sync – "Realtime" streams of CD quality ALAC (like "classic" AirPlay) and "Buffered Audio" streams of AAC stereo at 44,100 frames per second. The selection of stream type is made by the player. Realtime streams generally have a latency of about two seconds. Buffered Audio streams typically have a latency of half a second or less.
    • Audio is synchronised with other AirPlay 2 devices.
    • Shairport Sync offers "classic" AirPlay compatibility for situations where iTunes on macOS or macOS Music plays to multiple speakers and where one of more of them is compatible with AirPlay only.
  • Devices running Shairport Sync in AirPlay 2 mode can be added to the Home app.

What Does Not Work

  • No AirPlay 2 for Windows iTunes.
  • Remote control facilities are not implemented.

General

Shairport Sync uses a companion application called nqptp ("Not Quite PTP") for timing and synchronisation in AirPlay 2. nqptp must run as root and must have exclusive access to ports 319 and 320.

Lossless and High Definition Lossless material is transcoded to AAC before it reaches Shairport Sync.

What You Need

AirPlay 2 support needs a slightly more powerful CPU for decoding and synchronisation and more memory for bigger buffers and larger libraries. A Raspberry Pi 2 or Raspberry Pi Zero 2 W or better is recommended.

Here are some guidelines:

  • Full access, including root privileges, to a system at least as powerful as a Raspberry Pi 2 or a Raspberry Pi Zero 2 W.
  • Ports 319 and 320 must be free to use (i.e. they muist not be in use by another service such as a PTP service) and must not be blocked by a firewall.
  • An up-to-date Linux or FreeBSD. This is important, as some of the libraries must be the latest available.
  • Shairport Sync will not run on a Mac because NQPTP, on which it relies, needs ports 319 and 320, which are already used by macOS.
  • A version of the ffmpeg library with an AAC decoder capable of decoding Floating Planar -- fltp -- material. There is a guide here to help you find out if your system has it.
  • An audio output, for example an alsa device (or sndio in FreeBSD). You can use an application called sps-alsa-explore to test the suitability of hardware alsa audio devices on your device. Other backends continue to work as with "classic" Shairport Sync.

Guides

  • To build Shairport Sync for AirPlay 2 on Linux, please follow the guide at BUILDFORAP2.md.
  • A guide for building on FreeBSD is available here.

Note

The functionality offered by Shairport Sync is the result of study and analysis of the AirPlay and AirPlay 2 protocols by many people over the years. These protocols have not been officially published, and there is no assurance that Shairport Sync will continue to work with AirPlay in future.

Acknowledgements

Huge thanks are due to a number of individuals who made direct and valuable contributions to Shairport Sync:

  1. ejurgensen contributed ideas and code. The pair_ap submodule and related code in rtsp.c is theirs.
  2. JD Smith contributed ideas, comments and suggestions along with extensive and thorough testing.
  3. Charles Omer contributed ideas, comments, bug fixes, documentation and Docker automation (forthcoming).
  4. ckdo for their pathfinding work on AirPlay 2, especially the HomeKit pairing.

Much of Shairport Sync's AirPlay 2 functionality is based on ideas developed at the openairplay airplay2-receiver repository. It is a pleasure to acknowledge the work of the contributors there.