Dear Aunt TUAW: Can I AirPlay to my Mac?
Dear Aunt TUAW,
Do you think a Mac will be able to accept an AirPlay feed in the future? Here's why I ask -- I'm considering getting a Mac mini for my home theater. But I realized that a great feature of AppleTV is the AirPlay functionality. It seems strange that the mini (that costs 7x more) lacks this functionality. Have you heard any rumblings that accepting an AirPlay stream could come to Mac OS X?
Love & snuggles,
Your adoring nephew Todd V.
Darling Nephew Todd,
There's no reason that the Mac cannot accept and play an AirPlay video or photo stream, other than that Apple has yet to get around to implementing it and there aren't yet third-party 'catcher' apps available. AirPlay is basically a standard Bonjour service that advertises itself and accepts playback requests through simple URLs.
The problem lies in reverse engineering the service. I've poked around under the covers and have discovered that AirPlay is built using a reverse-HTTP protocol, which allows a client to connect to a host and then flip the way that the connection (called a "socket") works. The client becomes the host and the host becomes the client.
In practical terms it means this: your AirPlay-ready device (or iTunes running on your Mac or PC) searches for playback systems like Apple TV, Airport Express or stereo systems supporting AirPlay. Once it finds one, it opens a connection to that system and then reverses the normal interaction style. Instead of requesting data from the Apple TV, the Apple TV takes control and it starts requesting information (like what file to play) from the iPhone or iPad or whatever. It's a pretty cool way of going about things.
Unfortunately, I've barely scratched the surface of how this works. There are a bunch of technical details that I haven't yet figured out, such as the TXT record that accompanies the Bonjour service, and how the handshaking takes place, and what authentication is required, and so forth. Once that's figured out, you could theoretically be able to stream from any app on a Mac to your Apple TV or from your handheld iDevice to a Macintosh.
If you want to get a wee little peek at what's going on with AirPlay, you can do so via your command-line Terminal application. Telnet over to your Apple TV and connect via port 7000. Send the bolded text over requesting the reverse HTTP connection and you'll receive a confirmation back from the system. The scrub command is another valid request that I stumbled over.
% telnet 192.168.0.100 7000
Connected to 192.168.0.100.
Escape character is '^]'.
POST /reverse HTTP/1.1
HTTP/1.1 101 Switching Protocols
Date: Wed, 08 Dec 2010 18:28:45 GMT
POST /scrub?position=0.000000 HTTP/1.1
HTTP/1.1 200 OK
Date: Wed, 08 Dec 2010 18:28:54 GMT
Connection closed by foreign host.
Other commands seem to include stop, photo, volume, rate, play, authorize, and event. Play is, in particular, interesting for the Mac application-to-AppleTV component of the puzzle.
POST /play HTTP/1.1
This is what a typical on-device play request looks like. Off-device requests like those from YouTube have non-local URLs, such as from v7.lscache2.googlevideo.com.
There's obviously a lot left to do in the reverse engineering department. (Feel free to join in over at irc.moofspeak.net in #awkwardtv.) This reply should, however, give you a taste of what's to come.
Hopefully we'll be able to build a Mac-side client that handshakes over AirPlay, accepts the content URL (like the one shown above) automatically and opens a playback window either in Safari or QuickTime when that playback request comes through. AppleScript will further help automate device-side control of the the Mac-side playback.
For now, Auntie's sciatica is acting up; she was up all night hacking and is just exhausted. So that's where we'll stop for now.
Hugs & love,
Subscribe to Newsletter
Software Updatesmore updates
- iOS 8.0.1 update now available (Updated -- Don't update!)
- NFL Mobile updated for 2014 Season with new Fantasy Football features, NFL Now integration
- Yahoo Mail improves email inbox searching with new filtering options
- Ember for Mac gains 'hugely-requested' screen recording feature
- Spotify update adds equalizer, refreshed Artist page and more
- Fantastical 2.1 for iOS adds new snooze, search and notification features