AirPlay DACP: can an AirPlay 1 speaker pause and skip the sender?
Status (2026-12-05): working on an iPhone; the hardened build still needs its run. The receiver reads the sender's remote control from its RTSP headers (checked against pyatv 0.18.0), looks it up over mDNS, and sends DACP commands. An iPhone paused and skipped from a Shelly Wall Display XL's halo. After review, the panel sends only to the address the AirPlay session came from, keeps a link-local sender's interface, bounds each command's whole time, and retries an mDNS resolve Android refuses while another runs. That build has passed only off-device tests so far.
Device: Shelly Wall Display XL (the iPhone run); otherwise none (JVM and Robolectric tests). Tools: pyatv 0.18.0
(atvremote), the raop library's tests, shairport-sync's source (dacp.c at commit 7ce90d8).
Question
The audio halo's sheet shows Play/Pause and skip only for what a source can carry out. AirPlay 1 has no way for a speaker to talk back on the RTSP connection, so the sheet said "Pause and skip from the device that's playing". Can the panel pause and skip the sender anyway?
How we got here
iTunes' Remote app protocol, DACP (Digital Audio Control Protocol), runs the other way: the speaker is the client and the sender is the server. Open receivers such as shairport-sync use it for their remote-control hooks. The pieces:
- Every RTSP request from the sender carries
DACP-ID(a 64-bit id in hex) andActive-Remote(a 32-bit number). - The sender announces an HTTP server over mDNS as
iTunes_Ctrl_<DACP-ID>under_dacp._tcp. - The speaker sends
GET /ctrl-int/1/<command>there, with theActive-Remoteheader as the credential. Commands includeplaypause,play,pause,nextitemandprevitem.
That gave three things to check: that real senders send the headers, that the name and the request are right, and what the speaker should do when the remote isn't there.
The third piece has a catch: the Active-Remote token is the session's credential, and anyone on the network can
announce iTunes_Ctrl_<DACP-ID> under _dacp._tcp. The DACP id is no secret; the sender sends it in the clear on
every RTSP request. A panel that sends to whatever address the lookup resolves could hand the token to another host,
which could then pause and skip the sender itself. The first version did exactly that, and the PR's review caught it.
shairport-sync doesn't trust the lookup's address at all: set_dacp_server_information in dacp.c copies the RTSP
connection's own address and scope (conn->client_ip_string, conn->self_scope_id), and
dacp_monitor_port_update_callback takes only the port from mDNS (read, commit 7ce90d8). The panel now does the
same, and also ignores a resolution whose address is of the session's family but isn't the sender's, so a stranger
can't choose the port either. An address of the other family can't be compared (Android's NsdManager gives one
address per service, and a sender reached over IPv4 may resolve to its IPv6 one), so it's accepted for its port;
the request still goes to the sender's own address.
We weighed the toggle (playpause) against play and pause by name. The halo only learns that AirPlay paused
when audio stops arriving, about 3 s later (AirPlaySpeaker.PAUSED_AFTER_NANOS). In that window a second press of
the toggle would start the music again. Named commands can't do that, so the panel sends pause and play.
What we tried
- pyatv's headers (2026-12-05, verified).
PyatvInteropTeststreams a WAV fromatvremoteto the receiver, and the receiver'sonRemotegets oneDacpRemoteper session:
pyatv sends both headers on every request ($ RAOP_ATVREMOTE=/tmp/pyatv-venv/bin/atvremote ./gradlew :raop:testDebugUnitTest --tests '*PyatvInteropTest*' PyatvInteropTest > pyatvStreamsAWavSampleForSample PASSEDpyatv/support/rtsp.py,RtspSession.exchange, read). ItsDACP-IDisf"{randrange(2**64):X}", so it isn't zero-padded and can be shorter than 16 digits. The receiver accepts 1 to 16 hex digits and keeps the case it was sent in. pyatv serves no_dacp._tcpremote, so it can't test the commands themselves. - The request (2026-12-05, verified against a fake).
DacpRemoteTestsends each command to a loopback HTTP server that answers 204 to the session'sActive-Remoteand 403 to anything else:
A closed port, a remote that never answers, and one that sends a byte of its status line every 100 ms all give false within the 5 s budget for the whole command (a per-read timeout alone never ends the trickle). The link-local test listens on$ ./gradlew --max-workers=2 :raop:testDebugUnitTest --tests '*DacpRemoteTest*' DacpRemoteTest > eachCommandIsAGetWithTheActiveRemote PASSED DacpRemoteTest > aRefusalOrNoAnswerIsFalse PASSED DacpRemoteTest > aRemoteThatTricklesItsAnswerIsCutOffInTime PASSED DacpRemoteTest > aLinkLocalSenderIsAskedOnItsOwnInterface PASSED DacpRemoteTest > onlyTheSendersOwnAddressCountsAsItsRemote PASSEDfe80::1%lo0on macOS and checks the request keeps the interface; it skips on a machine with no link-local address it can reach itself on. - The lookup (2026-12-05, verified against a fake
NsdManager).AirPlayRemote.lookupbrowses_dacp._tcp, matchesiTunes_Ctrl_<DACP-ID>without regard to case, resolves it, and gives up after 10 s. Android 10 resolves one service at a time and answers another app's (or the last sender's) resolve withFAILURE_ALREADY_ACTIVE, so a refused or failed resolve is tried again after 250 ms, then twice as long each time, up to 2 s:
The fake resolver that answers with another host ($ ./gradlew --max-workers=2 :pane-sendspin:testDebugUnitTest --tests '*AirPlayRemoteTest*' AirPlayRemoteTest > theLookupTriesAgainWhileAnotherResolveIsActive PASSED AirPlayRemoteTest > theLookupGivesUpInTime PASSED AirPlayRemoteTest > aRemoteAnnouncedFromAnotherHostGetsNoToken PASSED AirPlayRemoteTest > anAddressOfTheOtherFamilyKeepsTheButtonsAndAsksTheSender PASSED AirPlayRemoteTest > aCommandForASenderThatLeftIsDropped PASSED AirPlayRemoteTest > aSlowSenderDoesntHoldUpTheCaller PASSED192.0.2.66) leaves the halo without buttons, and nothing is sent anywhere. Commands run on a queue of their own, so a sender slow to answer never holds up the pane's switches or its stop, and a command queued for a sender that has since left is dropped. - An iPhone on a Shelly Wall Display XL (2026-12-05, verified, the maintainer's run, on the build before the review's changes). The halo showed Play/Pause, Previous and Next for the iPhone's AirPlay, and they acted on the iPhone. The run's logs aren't recorded here. It ran before the sender-address check and the raw-socket request, so it doesn't cover them.
Result
| Claim | Evidence |
|---|---|
Senders put DACP-ID and Active-Remote on the RTSP requests |
pyatv 0.18.0, verified (1) |
The remote is iTunes_Ctrl_<DACP-ID>._dacp._tcp |
read: shairport-sync's documentation and pyatv's sender code; untested with Apple's senders |
GET /ctrl-int/1/{play,pause,nextitem,previtem} with Active-Remote controls the sender |
an iPhone on the Shelly XL, verified (4); a fake remote (2) |
| The token goes only to the address the AirPlay session came from | a fake resolver (3); shairport-sync does the same (read); untested with an iPhone since the change |
| A resolve Android refuses while another runs is tried again within the 10 s | a fake NsdManager (3); untested on Android 10 |
The halo offers its buttons only after the lookup finds the remote, and drops them when a command fails, falling back to "Pause and skip from the device that's playing". A sender without a remote costs nothing but the lookup.
How to reproduce
RAOP_ATVREMOTE=<pyatv venv>/bin/atvremote ./gradlew --max-workers=2 :raop:testDebugUnitTest :pane-sendspin:testDebugUnitTest
RAM and loopback only: the tests open sockets on 127.0.0.1 (and a link-local address of this machine, when it has
one) and close them; nothing on a panel or the network changes. They write only Gradle's build/ folders, which
./gradlew clean removes.
On a panel, with the AirPlay switch on: play from an iPhone, then watch
adb logcat -s Glassworks.AirPlay for "the sender's remote control answers on port" and press each of the halo's
buttons. "announced from another address" means the lookup resolved to a host other than the sender. Turning the
AirPlay switch off undoes it.
Open questions
- The hardened build on a panel: does an iPhone still get its buttons? It would lose them if the lookup resolved to an address of the session's own family that isn't the one the AirPlay connection came from (another of the iPhone's IPv6 addresses, say). "announced from another address" in the log means that happened.
- An iPad and a Mac with Apple Music: does the remote resolve within 10 s, and do
play,pause,nextitemandprevitemact? - Which apps don't announce a remote (podcasts apps, Spotify's AirPlay 1 output)? They should show no buttons.
- Does a Mac's Music app answer
playafter it paused itself, or onlyplaypause?