Service Discovery

AirPlay does not require any configuration to be able to find compatible devices on the network, thanks to [DNS-based service discovery], based on [Multicast DNS], aka Bonjour.

An AirPlay device such as the Apple TV publishes two services. The first one is the Airplay for photo and video and in later versions also audio content and the other one is [RAOP], used for audio streaming and in later versions superseded by Airplay service.

_airplay._tcp

name: Apple TV
type: _airplay._tcp
port: 7000
txt:
  deviceid=58:55:CA:1A:E2:88
  features=0x39f7
  model=AppleTV2,1
  srcvers=130.14

The following fields are available in the TXT record:

nametypedescription
modelstringdevice model
manufacturerstringdevice manufacturer
serialNumberstringdevice serial number
fvstringdevice firmware version
osversstringdevice OS version
deviceidstringDevice ID. Usually MAC address of the device
features32 bit hex number,optional high order 32 bit hex numberbitfield of supported features. This was originally a 32 bit value but it has since been expanded to a 64 bit value. To support both these types the mDNS value is encoded as two 32 bit values separated by comma with the comma and second 32 bit value being optional.
pwbooleanserver is password protected
aclint64Access control level
srcversstringairplay version
flags20 bit hex numberbitfield of status flags
pkhex stringpublic key
piUUID stringgroup_id / PublicCUAirPlayPairingIdentifier
psiUUID stringPublicCUSystemPairingIdentifier
gidUUID stringgroup UUID
gcglbooleangroup contains group leader / Group contains discoverable leader
iglbooleanis group leader
gpnstringgroup public name
hgidUUID stringhome group UUID
hmidstringhousehold ID
pgcglbooleanparent group contains discoverable leader
pgidUUID stringparent group UUID
tsidUUID string3008B5C8-9BD3-4479-A564-90BFB3D780C0
rsf64 bit hex numberrequired sender features
protoversstringprotocol version
vv?vodka version

_raop._tcp

name: 5855CA1AE288@Apple TV
type: _raop._tcp
port: 49152
txt:
  txtvers=1
  ch=2
  cn=0,1,2,3
  da=true
  et=0,3,5
  md=0,1,2
  pw=false
  sv=false
  sr=44100
  ss=16
  tp=UDP
  vn=65537
  vs=130.14
  am=AppleTV2,1
  sf=0x4

The name is formed using the MAC address of the device and the name of the remote speaker which will be shown by the clients.

The following fields appear in the TXT record:

namevaluedescription
txtvers1TXT record version 1
ch2audio channels: stereo
cn0,1,2,3audio codecs
et0,3,5supported encryption types
md0,1,2supported metadata types
pwfalsedoes the speaker require a password?
sr44100audio sample rate: 44100 Hz
ss16audio sample size: 16-bit
tpUDPsupported transport: TCP or UDP
vs130.14server version 130.14
amAppleTV2,1device model

Audio codecs

cndescription
0PCM
1Apple Lossless (ALAC)
2AAC
3AAC ELD (Enhanced Low Delay)

Encryption/Authentication Types

etdescription
0no encryption
1RSA (AirPort Express)
3FairPlay
4MFiSAP (3rd-party devices)
5FairPlay SAPv2.5

Metadata Types

mdbitdescription
017text
115artwork
216progress
50bplist

Subtype

AppleTV = deviceModel has prefix “AppleTV”
HomePod = deviceModel has prefix “AudioAccessory”
ThirdPartySpeaker = HasUnifiedAdvertiserInfo or SupportsUnifiedPairSetupAndMFi feature is set
Unknown = otherwise

CanBeRemoteControlled

SupportsBufferedAudio is set and PINRequired is not set

State Changes

Depending on the state of the device the mDNS record is changed to reflect this. Primarily it is the flags, gid, igl, gcgl, pgid and pgcgl fields that are changed.

Apple TV not playing

flags=0x10644
gid=712F0759-5D44-41E7-AB67-FAB0AD39E165
igl=1
gcgl=1

Apple TV receiving AirPlay audio

flags=0x30e44
gid=19F5D4B2-8A06-4792-923E-8AFA83913238
igl=0
gcgl=0
pgid=19F5D4B2-8A06-4792-923E-8AFA83913238
pgcgl=0

Apple TV receiving AirPlay video

flags=0x30e44
gid=19F5D4B2-8A06-4792-923E-8AFA83913238
igl=0
gcgl=0
pgid=19F5D4B2-8A06-4792-923E-8AFA83913238
pgcgl=0

Apple TV receiving AirPlay screen

flags=0x30644
gid=712F0759-5D44-41E7-AB67-FAB0AD39E165
igl=1
gcgl=1

Apple TV playing local media

flags=0x10644
gid=FA69F5A2-5574-4E4D-A676-CA7F61A904A3
igl=1
gcgl=1