I've spent a lot of time figuring out how to connect to my AppleTV and send it pictures, videos, music, etc... then i've realize that there is no documented protocol for it. Apple just mantains the interface for Cocoa and hides the undelying protocol
The research to make the airplay gem was slow, mainly because was only a proof of concept to communicate with the AppleTV from ruby.
One of the first things to know is that the Airplay Protocol uses a subset of HTTP to communicate, uses an upgraded connections PTTH and persistent connections to the resources.
Second generation AppleTV with iOS 5 will also broadcast Airtunes and Mirroring through the LAN.
The AppleTV will broadcast himself in the LAN using Bonjour). You can find yours browsing for '_airplay._tcp.'.
This will give you and Ip and a port, normally being :7000.
The resource for photos is "photo" there are only a few things that you can do here.
You cannot send the path of the image, you need to send it's content so if you wanted so send an image you could only:
$ cat image.jpg
Or
content = File.read(image_path)
# PUT /photo
# X-Apple-Transition: None
# Connection: Keep-Alive
#
# ... raw img content ...
#
Please note the "X-Apple-Transition" header, this header is not mandatory with it you can create transitions between the current image and another.
The ones i've found are:
Two of them will give the chance so simulate the slide as when seeing in an iPhone.
+-----------+
| AppleTV +----+
+-----------+ |
|
+---------+-----+
| PUT /photo |
| |
| img content |
+---------+-----+
|
+----------+ |
| Client +-----+
+----------+
The resource for videos is divided according for some it features, so you'll have "play", "stop", "rate".
Note three things:
# POST /play
# Connection: Keep-Alive
#
# Content-Location: http://something.com/video.mp4
# Start-Position: 0
#
This will stop (and end) the current playback
# POST /stop
# Connection: Keep-Alive
#
This was a tricky one, rate it's just to pausing and resuming playback of media.
To pause:
# POST /rate?value=0
# Connection: Keep-Alive
#
To play:
# POST /rate?value=1
# Connection: Keep-Alive
#
+-----------+
| AppleTV +----+
+-----------+ |
|
+---------+---------------------------------------------------+
| POST /play |
| |
| Content-Location: http://somewhere.com/overtherainbow.mp4 |
| Start-Position: 5 |
+---------+---------------------------------------------------+
|
+----------+ |
| Client +-----+
+----------+