Airplay is a suite of protocols implemented by Apple to enable viewing of various media content on the iPhone, iPod touch, iPad (hardware device) or iTunes (software) on Apple TV. AirPlay supports the following usage scenarios:
• Transfer and display photos and slideshows from iOS devices;
• Transfer and play audio from iOS devices or Itunes software;
• Transfer and play videos from iOS devices or Itunes software;
• Screen imagery of iOS devices or OS X Mountain Lion. Since this feature requires hardware hard decoding support, it can only be supported on iPad 2, iPhone 4S, Mac computers with Sandy Bridge CPU (or newer devices).
Initially, the protocol was called AirTunes and only supported audio streaming. Later, when Apple developed Apple TV, this protocol was expanded and improved, added video support, and renamed Airplay. The Airplay protocol is based on well-known network standard protocols such as Multicast DNS, HTTP, RTSP, RTP or NTP and other custom extensions.
Since we only focus on the audio part, the focus of the study below is the AirTunes service.
2. the realization mechanism
The software that implements the Airplay protocol can discover related devices on the same network without any configuration, which is mainly due to Bonjour (based on the M-DNS protocol).
Bonjour: Apple's name for the open Zeroconf standard based on multicast DNS.
Zeroconf (Zero Setting Network Standard): Fully called Zero configuration networking, Chinese name is zero configuration network service standard, is a network technology for automatically generating available IP addresses, no additional manual configuration, and dedicated configuration server. The goal of "zero-configuration network" is to enable non-professional users to easily connect various network devices, such as computers and printers. The entire process of building a network is achieved through program automation. If there is no Zeroconf, the user must manually configure some services, such as DHCP, DNS, other settings on the computer network, and so on. These are very difficult for non-technical users and new users.
The specific example is: the user owns an apple tv and an iPhone4s, then as long as they are connected to the same wireless LAN, iphone4s will automatically find the apple tv, then when playing music or video, the user just clicks on the push. You can play music and videos to play on apple tv.
In addition to Bonjour, Avahi and howl are implemented to implement the Zeroconf protocol.
3. the implementation, porting and debugging of the Airplay protocol:
The open source software that implements the Airplay protocol under Linux has shairport and xmbc (the audio part implementation mechanism is also based on shairport).
Shairport is a software that emulates an ApEx router for the purpose of transferring music from iTunes and other compatible devices. It is a server that supports RAOP. The 0.X version is written in the perl script, but the current shairport has been updated to 1.0-dev. This version has removed the perl script part and changed it to C, which is more convenient for us to port. However, it is still under development and has not yet been officially released, potentially with bugs. The required dependencies after the 1.0-dev version are OpenSSL, and the optional dependencies are libao, PulseAudio, avahi (or howl). Through analysis, if libao and PulseAudio are installed, shairport will have 5 output backends (ie alsa, ao, pusle, dummy, pipe) to choose from, and even if libao and PulseAudio are not installed, shairport will still have 3 output backends. (ie alsa, dummy, pipe), does not affect the function of shairport (there is a delay in playback), if you want to achieve high quality sound quality, it is best to install PulseAudio. Through constant experimentation, you can choose to cross-compile OpenSSL and howl to avoid complex cross-compilation.