-
Notifications
You must be signed in to change notification settings - Fork 45
/
AirPlay.html
3337 lines (2854 loc) · 110 KB
/
AirPlay.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
<meta http-equiv="Content-language" content="en"/>
<meta name="keywords" content="airplay,airtunes,protocol,specification"/>
<meta name="author" content="Clément Vasseur"/>
<title>Unofficial AirPlay Protocol Specification</title>
<link rel="stylesheet" type="text/css" href="AirPlay.css"/>
<script type="text/javascript">
/*
____________________________
( Stay hungry. Stay foolish. )
----------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
*/
</script>
</head>
<body>
<div id="content">
<h1 class="title">Unofficial AirPlay Protocol Specification</h1>
<ul class="toc">
<li><a href="#introduction">1. Introduction</a></li>
<li><a href="#servicediscovery">2. Service Discovery</a></li>
<li><ul>
<li><a href="#servicediscovery-airtunesservice">2.1. AirTunes service</a></li>
<li><a href="#servicediscovery-airplayservice">2.2. AirPlay Service</a></li>
</ul></li>
<li><a href="#photos">3. Photos</a></li>
<li><ul>
<li><a href="#photos-httprequests">3.1. HTTP requests</a></li>
<li><a href="#photos-events">3.2. Events</a></li>
<li><a href="#photos-photocaching">3.3. Photo Caching</a></li>
<li><a href="#photos-slideshows">3.4. Slideshows</a></li>
</ul></li>
<li><a href="#video">4. Video</a></li>
<li><ul>
<li><a href="#video-httprequests">4.1. HTTP requests</a></li>
<li><a href="#video-events">4.2. Events</a></li>
</ul></li>
<li><a href="#audio">5. Audio</a></li>
<li><ul>
<li><a href="#audio-rtsprequests">5.1. RTSP requests</a></li>
<li><a href="#audio-rtpstreams">5.2. RTP Streams</a></li>
<li><a href="#audio-volumecontrol">5.3. Volume Control</a></li>
<li><a href="#audio-metadata">5.4. Metadata</a></li>
<li><a href="#audio-airportexpressauthentication">5.5. AirPort Express Authentication</a></li>
<li><a href="#audio-remotecontrol">5.6. Remote Control</a></li>
</ul></li>
<li><a href="#screenmirroring">6. Screen Mirroring</a></li>
<li><ul>
<li><a href="#screenmirroring-httprequests">6.1. HTTP requests</a></li>
<li><a href="#screenmirroring-streampackets">6.2. Stream Packets</a></li>
<li><a href="#screenmirroring-timesynchronization">6.3. Time Synchronization</a></li>
</ul></li>
<li><a href="#passwordprotection">7. Password Protection</a></li>
<li><a href="#history">8. History</a></li>
<li><a href="#resources">9. Resources</a></li>
<li><ul>
<li><a href="#resources-ietfrfcs">9.1. IETF RFCs</a></li>
<li><a href="#resources-ietfdrafts">9.2. IETF drafts</a></li>
<li><a href="#resources-appleprotocols">9.3. Apple Protocols</a></li>
</ul></li>
</ul>
<h1 id="introduction">1. Introduction</h1>
<p>AirPlay is a family of protocols implemented by Apple to view various
types of media content on the <em>Apple TV</em> from any iOS device or iTunes.
In this documentation, “<em>iOS device</em>” refers to an iPhone, iPod touch or
iPad. The following scenarios are supported by AirPlay:</p>
<ul>
<li><p>Display photos and slideshows from an iOS device.</p></li>
<li><p>Stream audio from an iOS device or iTunes.</p></li>
<li><p>Display videos from an iOS device or iTunes.</p></li>
<li><p>Show the screen content from an iOS device or OS X Mountain Lion.
This is called <em>AirPlay Mirroring</em>. It requires hardware capable of
encoding live video without taking too much CPU, so it is only
available on iPhone 4S, iPad 2, the new iPad, and Macs with Sandy
Bridge CPUs.</p></li>
</ul>
<p>Audio streaming is also supported from an iOS device or iTunes to an
AirPort Express base station or a 3<sup>rd</sup> party AirPlay-enabled audio
device. Initially this was called <em>AirTunes</em>, but it was later renamed
to AirPlay when Apple added video support for the Apple TV.</p>
<p>This document describes these protocols, as implemented in Apple TV
software version 5.0, iOS 5.1 and iTunes 10.6. They are based on
well-known standard networking protocols such as <em>Multicast DNS</em>,
<em>HTTP</em>, <em>RTSP</em>, <em>RTP</em> or <em>NTP</em>, with custom extensions.</p>
<p>All these information have been gathered by using various techniques of
reverse engineering, so they might be somewhat inaccurate and
incomplete. Moreover, this document does not explain how to circumvent
any kind of security implemented by Apple:</p>
<ul>
<li><p>It does not give any RSA keys.</p></li>
<li><p>It does not explain how to decode iTunes videos protected with the
<em>FairPlay</em> DRM.</p></li>
<li><p>It does not explain the FairPlay authentication (SAPv2.5) used by iOS
devices and OS X Mountain Lion to protect audio and screen content.</p></li>
</ul>
<p>Please don’t e-mail me about this, I won’t reply. In fact, none of this
is actually required to be able to view media content on Apple TV.</p>
<h1 id="servicediscovery">2. Service Discovery</h1>
<p>AirPlay does not require any configuration to be able to find compatible
devices on the network, thanks to <a href="http://www.ietf.org/id/draft-cheshire-dnsext-dns-sd-11.txt">DNS-based service discovery</a>, based
on <a href="http://www.ietf.org/id/draft-cheshire-dnsext-multicastdns-15.txt">multicast DNS</a>, aka <em>Bonjour</em>.</p>
<p>An AirPlay device such as the Apple TV publishes two services. The first
one is <em>RAOP</em> (<a href="http://en.wikipedia.org/wiki/Remote_Audio_Output_Protocol">Remote Audio Output Protocol</a>), used for audio
streaming, and the other one is the AirPlay service, for photo and video
content.</p>
<h2 id="servicediscovery-airtunesservice">2.1. AirTunes service</h2>
<p class="caption">RAOP service from Apple TV</p>
<pre><code>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
</code></pre>
<p>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.</p>
<p>The following fields appear in the TXT record:</p>
<table>
<colgroup>
<col style="text-align:left;"/>
<col style="text-align:left;"/>
<col style="text-align:left;"/>
</colgroup>
<thead>
<tr>
<th style="text-align:left;">name</th>
<th style="text-align:left;">value</th>
<th style="text-align:left;">description</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left;"><code>txtvers</code></td>
<td style="text-align:left;">1</td>
<td style="text-align:left;">TXT record version 1</td>
</tr>
<tr>
<td style="text-align:left;"><code>ch</code></td>
<td style="text-align:left;">2</td>
<td style="text-align:left;">audio channels: stereo</td>
</tr>
<tr>
<td style="text-align:left;"><code>cn</code></td>
<td style="text-align:left;">0,1,2,3</td>
<td style="text-align:left;">audio codecs</td>
</tr>
<tr>
<td style="text-align:left;"><code>et</code></td>
<td style="text-align:left;">0,3,5</td>
<td style="text-align:left;">supported encryption types</td>
</tr>
<tr>
<td style="text-align:left;"><code>md</code></td>
<td style="text-align:left;">0,1,2</td>
<td style="text-align:left;">supported metadata types</td>
</tr>
<tr>
<td style="text-align:left;"><code>pw</code></td>
<td style="text-align:left;">false</td>
<td style="text-align:left;">does the speaker require a password?</td>
</tr>
<tr>
<td style="text-align:left;"><code>sr</code></td>
<td style="text-align:left;">44100</td>
<td style="text-align:left;">audio sample rate: 44100 Hz</td>
</tr>
<tr>
<td style="text-align:left;"><code>ss</code></td>
<td style="text-align:left;">16</td>
<td style="text-align:left;">audio sample size: 16-bit</td>
</tr>
<tr>
<td style="text-align:left;"><code>tp</code></td>
<td style="text-align:left;">UDP</td>
<td style="text-align:left;">supported transport: TCP or UDP</td>
</tr>
<tr>
<td style="text-align:left;"><code>vs</code></td>
<td style="text-align:left;">130.14</td>
<td style="text-align:left;">server version 130.14</td>
</tr>
<tr>
<td style="text-align:left;"><code>am</code></td>
<td style="text-align:left;">AppleTV2,1</td>
<td style="text-align:left;">device model</td>
</tr>
</tbody>
</table>
<h3>Audio codecs</h3>
<table>
<colgroup>
<col style="text-align:left;"/>
<col style="text-align:left;"/>
</colgroup>
<thead>
<tr>
<th style="text-align:left;">cn</th>
<th style="text-align:left;">description</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left;">0</td>
<td style="text-align:left;">PCM</td>
</tr>
<tr>
<td style="text-align:left;">1</td>
<td style="text-align:left;">Apple Lossless (ALAC)</td>
</tr>
<tr>
<td style="text-align:left;">2</td>
<td style="text-align:left;">AAC</td>
</tr>
<tr>
<td style="text-align:left;">3</td>
<td style="text-align:left;">AAC ELD (Enhanced Low Delay)</td>
</tr>
</tbody>
</table>
<h3>Encryption Types</h3>
<table>
<colgroup>
<col style="text-align:left;"/>
<col style="text-align:left;"/>
</colgroup>
<thead>
<tr>
<th style="text-align:left;">et</th>
<th style="text-align:left;">description</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left;">0</td>
<td style="text-align:left;">no encryption</td>
</tr>
<tr>
<td style="text-align:left;">1</td>
<td style="text-align:left;">RSA (AirPort Express)</td>
</tr>
<tr>
<td style="text-align:left;">3</td>
<td style="text-align:left;">FairPlay</td>
</tr>
<tr>
<td style="text-align:left;">4</td>
<td style="text-align:left;">MFiSAP (3rd-party devices)</td>
</tr>
<tr>
<td style="text-align:left;">5</td>
<td style="text-align:left;">FairPlay SAPv2.5</td>
</tr>
</tbody>
</table>
<h3>Metadata Types</h3>
<table>
<colgroup>
<col style="text-align:left;"/>
<col style="text-align:left;"/>
</colgroup>
<thead>
<tr>
<th style="text-align:left;">md</th>
<th style="text-align:left;">description</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left;">0</td>
<td style="text-align:left;">text</td>
</tr>
<tr>
<td style="text-align:left;">1</td>
<td style="text-align:left;">artwork</td>
</tr>
<tr>
<td style="text-align:left;">2</td>
<td style="text-align:left;">progress</td>
</tr>
</tbody>
</table>
<h2 id="servicediscovery-airplayservice">2.2. AirPlay Service</h2>
<p class="caption">AirPlay service</p>
<pre><code>name: Apple TV
type: _airplay._tcp
port: 7000
txt:
deviceid=58:55:CA:1A:E2:88
features=0x39f7
model=AppleTV2,1
srcvers=130.14
</code></pre>
<p>The following fields are available in the TXT record:</p>
<table>
<colgroup>
<col style="text-align:left;"/>
<col style="text-align:left;"/>
<col style="text-align:left;"/>
</colgroup>
<thead>
<tr>
<th style="text-align:left;">name</th>
<th style="text-align:left;">value</th>
<th style="text-align:left;">description</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left;"><code>model</code></td>
<td style="text-align:left;">AppleTV2,1</td>
<td style="text-align:left;">device model</td>
</tr>
<tr>
<td style="text-align:left;"><code>deviceid</code></td>
<td style="text-align:left;">58:55:CA:1A:E2:88</td>
<td style="text-align:left;">MAC address of the device</td>
</tr>
<tr>
<td style="text-align:left;"><code>features</code></td>
<td style="text-align:left;">0x39f7</td>
<td style="text-align:left;">bitfield of supported features</td>
</tr>
<tr>
<td style="text-align:left;"><code>pw</code></td>
<td style="text-align:left;">1</td>
<td style="text-align:left;">server is password protected</td>
</tr>
</tbody>
</table>
<p>The <code>pw</code> field appears only if the AirPlay server is password protected.
Otherwise it is not included in the TXT record.</p>
<p>The <code>features</code> bitfield allows the following features to be defined:</p>
<table>
<colgroup>
<col style="text-align:left;"/>
<col style="text-align:left;"/>
<col style="text-align:left;"/>
</colgroup>
<thead>
<tr>
<th style="text-align:left;">bit</th>
<th style="text-align:left;">name</th>
<th style="text-align:left;">description</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left;">0</td>
<td style="text-align:left;"><code>Video</code></td>
<td style="text-align:left;">video supported</td>
</tr>
<tr>
<td style="text-align:left;">1</td>
<td style="text-align:left;"><code>Photo</code></td>
<td style="text-align:left;">photo supported</td>
</tr>
<tr>
<td style="text-align:left;">2</td>
<td style="text-align:left;"><code>VideoFairPlay</code></td>
<td style="text-align:left;">video protected with FairPlay DRM</td>
</tr>
<tr>
<td style="text-align:left;">3</td>
<td style="text-align:left;"><code>VideoVolumeControl</code></td>
<td style="text-align:left;">volume control supported for videos</td>
</tr>
<tr>
<td style="text-align:left;">4</td>
<td style="text-align:left;"><code>VideoHTTPLiveStreams</code></td>
<td style="text-align:left;">http live streaming supported</td>
</tr>
<tr>
<td style="text-align:left;">5</td>
<td style="text-align:left;"><code>Slideshow</code></td>
<td style="text-align:left;">slideshow supported</td>
</tr>
<tr>
<td style="text-align:left;">7</td>
<td style="text-align:left;"><code>Screen</code></td>
<td style="text-align:left;">mirroring supported</td>
</tr>
<tr>
<td style="text-align:left;">8</td>
<td style="text-align:left;"><code>ScreenRotate</code></td>
<td style="text-align:left;">screen rotation supported</td>
</tr>
<tr>
<td style="text-align:left;">9</td>
<td style="text-align:left;"><code>Audio</code></td>
<td style="text-align:left;">audio supported</td>
</tr>
<tr>
<td style="text-align:left;">11</td>
<td style="text-align:left;"><code>AudioRedundant</code></td>
<td style="text-align:left;">audio packet redundancy supported</td>
</tr>
<tr>
<td style="text-align:left;">12</td>
<td style="text-align:left;"><code>FPSAPv2pt5_AES_GCM</code></td>
<td style="text-align:left;">FairPlay secure auth supported</td>
</tr>
<tr>
<td style="text-align:left;">13</td>
<td style="text-align:left;"><code>PhotoCaching</code></td>
<td style="text-align:left;">photo preloading supported</td>
</tr>
</tbody>
</table>
<p>Note that the Apple TV does not support <code>VideoVolumeControl</code>. It has
probably been introduced for the upcoming Apple television.</p>
<p>The AirPlay server is a <em>HTTP</em> server (<a href="http://www.ietf.org/rfc/rfc2616.txt">RFC 2616</a>). Two connections are
made to this server, the second one being used as a <a href="http://tools.ietf.org/id/draft-lentczner-rhttp-00.txt">reverse HTTP</a>
connection. This allows a client to receive asynchronous events, such
as playback status changes, from a server.</p>
<p>All HTTP requests share some common headers:</p>
<table>
<colgroup>
<col style="text-align:left;"/>
<col style="text-align:left;"/>
<col style="text-align:left;"/>
</colgroup>
<thead>
<tr>
<th style="text-align:left;">name</th>
<th style="text-align:left;">value</th>
<th style="text-align:left;">description</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left;"><code>X-Apple-Session-ID</code></td>
<td style="text-align:left;">1bd6ceeb…</td>
<td style="text-align:left;">UUID for the session</td>
</tr>
<tr>
<td style="text-align:left;"><code>X-Apple-Device-ID</code></td>
<td style="text-align:left;">0xdc2b61a0ce79</td>
<td style="text-align:left;">MAC address</td>
</tr>
</tbody>
</table>
<p>The reverse connection looks like this:</p>
<p class="cli_srv">client → server</p>
<pre><code>POST /reverse
Upgrade: PTTH/1.0
Connection: Upgrade
X-Apple-Purpose: event
Content-Length: 0
User-Agent: MediaControl/1.0
X-Apple-Session-ID: 1bd6ceeb-fffd-456c-a09c-996053a7a08c
</code></pre>
<p class="srv_cli">server → client</p>
<pre><code>HTTP/1.1 101 Switching Protocols
Date: Thu, 23 Feb 2012 17:33:41 GMT
Upgrade: PTTH/1.0
Connection: Upgrade
</code></pre>
<p>The <code>X-Apple-Purpose</code> header makes it clear that this connection is used
for sending events to the client, whereas <code>X-Apple-Session-ID</code> is used
to link this connection to the other (non-reverse) one. Events are
delivered using a <code>POST</code> request for sending an XML property list to the
<code>/event</code> location.</p>
<h1 id="photos">3. Photos</h1>
<p>Photos are <em>JPEG</em> data transmitted using a <code>PUT</code> request to the AirPlay
server. They can be displayed immediately, or cached for future use.</p>
<h2 id="photos-httprequests">3.1. HTTP requests</h2>
<h3>GET /slideshow-features</h3>
<p>A client can fetch the list of available transitions for slideshows.
Then it can let the user pick one, before starting a slideshow. The
<code>Accept-Language</code> header is used to specify in which language the
transition names should be.</p>
<p class="cli_srv">client → server</p>
<pre><code>GET /slideshow-features HTTP/1.1
Accept-Language: English
Content-Length: 0
User-Agent: MediaControl/1.0
X-Apple-Session-ID: cdda804c-33ae-4a0b-a5f2-f0e532fd5abd
</code></pre>
<p class="srv_cli">server → client</p>
<pre><code>HTTP/1.1 200 OK
Date: Thu, 23 Feb 2012 17:33:41 GMT
Content-Type: text/x-apple-plist+xml
Content-Length: 6411
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>themes</key>
<array>
<dict>
<key>key</key>
<string>Reflections</string>
<key>name</key>
<string>Reflections</string>
</dict>
...
</array>
</dict>
</plist>
</code></pre>
<h3>PUT /photo</h3>
<p>Send a JPEG picture to the server. The following headers are supported:</p>
<table>
<colgroup>
<col style="text-align:left;"/>
<col style="text-align:left;"/>
</colgroup>
<thead>
<tr>
<th style="text-align:left;">name</th>
<th style="text-align:left;">description</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left;"><code>X-Apple-AssetKey</code></td>
<td style="text-align:left;">UUID for the picture</td>
</tr>
<tr>
<td style="text-align:left;"><code>X-Apple-Transition</code></td>
<td style="text-align:left;">transition that should be used to show the picture</td>
</tr>
<tr>
<td style="text-align:left;"><code>X-Apple-AssetAction</code></td>
<td style="text-align:left;">specify a caching operation</td>
</tr>
</tbody>
</table>
<p><span class="ex">Example 1:</span> show a picture without any transition (for the first time)</p>
<p class="cli_srv">client → server</p>
<pre><code>PUT /photo HTTP/1.1
X-Apple-AssetKey: F92F9B91-954E-4D63-BB9A-EEC771ADE6E8
Content-Length: 462848
User-Agent: MediaControl/1.0
X-Apple-Session-ID: 1bd6ceeb-fffd-456c-a09c-996053a7a08c
<JPEG DATA>
</code></pre>
<p class="srv_cli">server → client</p>
<pre><code>HTTP/1.1 200 OK
Date: Thu, 23 Feb 2012 17:33:42 GMT
Content-Length: 0
</code></pre>
<p><span class="ex">Example 2:</span> show a picture using the dissolve transition</p>
<p class="cli_srv">client → server</p>
<pre><code>PUT /photo HTTP/1.1
X-Apple-AssetKey: F92F9B91-954E-4D63-BB9A-EEC771ADE6E8
X-Apple-Transition: Dissolve
Content-Length: 462848
User-Agent: MediaControl/1.0
X-Apple-Session-ID: 1bd6ceeb-fffd-456c-a09c-996053a7a08c
<JPEG DATA>
</code></pre>
<p class="srv_cli">server → client</p>
<pre><code>HTTP/1.1 200 OK
Date: Thu, 23 Feb 2012 17:33:42 GMT
Content-Length: 0
</code></pre>
<h3>PUT /slideshows/1</h3>
<p>Start or stop a slideshow session. When starting, slideshow settings
such as the slide duration and selected transition theme are
transmitted. The following parameters are sent in an XML property list:</p>
<table>
<colgroup>
<col style="text-align:left;"/>
<col style="text-align:left;"/>
<col style="text-align:left;"/>
</colgroup>
<thead>
<tr>
<th style="text-align:left;">key</th>
<th style="text-align:left;">type</th>
<th style="text-align:left;">description</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left;">settings.slideDuration</td>
<td style="text-align:left;">integer</td>
<td style="text-align:left;">slide duration in seconds</td>
</tr>
<tr>
<td style="text-align:left;">settings.theme</td>
<td style="text-align:left;">string</td>
<td style="text-align:left;">selected transition theme</td>
</tr>
<tr>
<td style="text-align:left;">state</td>
<td style="text-align:left;">string</td>
<td style="text-align:left;"><code>playing</code> or <code>stopped</code></td>
</tr>
</tbody>
</table>
<p><span class="ex">Example:</span> send slideshow settings</p>
<p class="cli_srv">client → server</p>
<pre><code>PUT /slideshows/1 HTTP/1.1
Content-Type: text/x-apple-plist+xml
Content-Length: 366
User-Agent: MediaControl/1.0
X-Apple-Session-ID: 98a7b246-8e00-49a6-8765-db57165f5b67
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>settings</key>
<dict>
<key>slideDuration</key>
<integer>3</integer>
<key>theme</key>
<string>Classic</string>
</dict>
<key>state</key>
<string>playing</string>
</dict>
</plist>
</code></pre>
<p class="srv_cli">server → client</p>
<pre><code>HTTP/1.1 200 OK
Date: Thu, 08 Mar 2012 16:30:01 GMT
Content-Type: text/x-apple-plist+xml
Content-Length: 181
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/>
</plist>
</code></pre>
<h3>POST /stop</h3>
<p>Stop a photo or slideshow session.</p>
<p class="cli_srv">client → server</p>
<pre><code>POST /stop HTTP/1.1
Content-Length: 0
User-Agent: MediaControl/1.0
X-Apple-Session-ID: 1bd6ceeb-fffd-456c-a09c-996053a7a08c
</code></pre>
<p class="srv_cli">server → client</p>
<pre><code>HTTP/1.1 200 OK
Date: Thu, 23 Feb 2012 17:33:55 GMT
Content-Length: 0
</code></pre>
<h2 id="photos-events">3.2. Events</h2>
<h3>Photo</h3>
<p>This event notifies a client that a photo session has ended. Then the
server can safely disconnect.</p>
<table>
<colgroup>
<col style="text-align:left;"/>
<col style="text-align:left;"/>
<col style="text-align:left;"/>
</colgroup>
<thead>
<tr>
<th style="text-align:left;">key</th>
<th style="text-align:left;">type</th>
<th style="text-align:left;">description</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left;">category</td>
<td style="text-align:left;">string</td>
<td style="text-align:left;"><code>photo</code></td>
</tr>
<tr>
<td style="text-align:left;">sessionID</td>
<td style="text-align:left;">integer</td>
<td style="text-align:left;">session ID</td>
</tr>
<tr>
<td style="text-align:left;">state</td>
<td style="text-align:left;">string</td>
<td style="text-align:left;"><code>stopped</code></td>
</tr>
</tbody>
</table>
<p><span class="ex">Example:</span> stop photo session</p>
<p class="srv_cli">server → client</p>
<pre><code>POST /event HTTP/1.1
Content-Type: text/x-apple-plist+xml
Content-Length: 277
X-Apple-Session-ID: 1bd6ceeb-fffd-456c-a09c-996053a7a08c
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>category</key>
<string>photo</string>
<key>sessionID</key>
<integer>38</integer>
<key>state</key>
<string>stopped</string>
</dict>
</plist>
</code></pre>
<p class="cli_srv">client → server</p>
<pre><code>HTTP/1.1 200 OK
Content-Length: 0
</code></pre>
<h3>Slideshow</h3>
<p>Slideshow events are used to notify the server about the playback state.</p>
<table>
<colgroup>
<col style="text-align:left;"/>
<col style="text-align:left;"/>
<col style="text-align:left;"/>
</colgroup>
<thead>
<tr>
<th style="text-align:left;">key</th>
<th style="text-align:left;">type</th>
<th style="text-align:left;">description</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left;">category</td>
<td style="text-align:left;">string</td>
<td style="text-align:left;"><code>slideshow</code></td>
</tr>
<tr>
<td style="text-align:left;">lastAssetID</td>
<td style="text-align:left;">integer</td>
<td style="text-align:left;">last asset ID</td>
</tr>
<tr>
<td style="text-align:left;">sessionID</td>
<td style="text-align:left;">integer</td>
<td style="text-align:left;">session ID</td>
</tr>
<tr>
<td style="text-align:left;">state</td>
<td style="text-align:left;">string</td>
<td style="text-align:left;"><code>loading</code>, <code>playing</code> or <code>stopped</code></td>
</tr>
</tbody>
</table>
<p><span class="ex">Example:</span> slideshow is currently playing</p>
<p class="srv_cli">server → client</p>
<pre><code>POST /event HTTP/1.1
Content-Type: text/x-apple-plist+xml
Content-Length: 371
X-Apple-Session-ID: f1634b51-5cae-4384-ade5-54f4159a15f1
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>category</key>
<string>slideshow</string>
<key>lastAssetID</key>
<integer>5</integer>
<key>sessionID</key>
<integer>4</integer>
<key>state</key>
<string>playing</string>
</dict>
</plist>
</code></pre>
<p class="cli_srv">client → server</p>
<pre><code>HTTP/1.1 200 OK
Content-Length: 0
</code></pre>
<h2 id="photos-photocaching">3.3. Photo Caching</h2>
<p>AirPlay supports preloading picture data to improve transition latency.
This works by preloading a few pictures (most likely the ones before and
after the current picture) just after displaying one.</p>
<p>Preloading is achieved using the <code>cacheOnly</code> asset action. Upon
receiving this request, a server stores the picture in its cache. Later,
a client can request the display of this picture using the
<code>displayCached</code> asset action and the same asset key. This is much faster
than a full picture upload because no additional data is transmitted.</p>
<p>When asked for a picture which is no longer in the cache, a server
replies with an HTTP 412 error code (Precondition Failed).</p>
<p><span class="ex">Example 1:</span> cache a picture for future display</p>
<p class="cli_srv">client → server</p>
<pre><code>PUT /photo HTTP/1.1
X-Apple-AssetAction: cacheOnly
X-Apple-AssetKey: B0DDE2C0-6FDD-48F8-9E5B-29CE0618DF5B
Content-Length: 462848
User-Agent: MediaControl/1.0
X-Apple-Session-ID: 1bd6ceeb-fffd-456c-a09c-996053a7a08c
<JPEG DATA>
</code></pre>
<p class="srv_cli">server → client</p>
<pre><code>HTTP/1.1 200 OK
Date: Thu, 23 Feb 2012 17:33:45 GMT
Content-Length: 0
</code></pre>
<p><span class="ex">Example 2:</span> show a cached picture</p>
<p class="cli_srv">client → server</p>
<pre><code>PUT /photo HTTP/1.1
X-Apple-AssetAction: displayCached
X-Apple-AssetKey: B0DDE2C0-6FDD-48F8-9E5B-29CE0618DF5B
X-Apple-Transition: Dissolve
Content-Length: 0
User-Agent: MediaControl/1.0
X-Apple-Session-ID: 1bd6ceeb-fffd-456c-a09c-996053a7a08c
</code></pre>
<p class="srv_cli">server → client</p>
<pre><code>HTTP/1.1 200 OK
Date: Thu, 23 Feb 2012 17:33:45 GMT
Content-Length: 0
</code></pre>
<h2 id="photos-slideshows">3.4. Slideshows</h2>
<p>Slideshows are using the reverse HTTP connection for asynchronous
loading of pictures. Three connections are performed in parallel. The
<code>X-Apple-Purpose</code> header is set to <code>slideshow</code>. A <code>GET</code> request to the
<code>/slideshows/1/assets/1</code> location is issued to fetch a new picture from
the AirPlay client. A binary property list with the following parameters
is expected as reply:</p>
<table>
<colgroup>
<col style="text-align:left;"/>
<col style="text-align:left;"/>
<col style="text-align:left;"/>
</colgroup>
<thead>
<tr>
<th style="text-align:left;">key</th>
<th style="text-align:left;">type</th>
<th style="text-align:left;">description</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left;">data</td>
<td style="text-align:left;">data</td>
<td style="text-align:left;">JPEG picture</td>
</tr>
<tr>
<td style="text-align:left;">info.id</td>
<td style="text-align:left;">integer</td>
<td style="text-align:left;">asset ID</td>
</tr>
<tr>
<td style="text-align:left;">info.key</td>
<td style="text-align:left;">integer</td>
<td style="text-align:left;">1</td>
</tr>
</tbody>
</table>
<p><span class="ex">Example:</span> fetch a new picture</p>
<p class="srv_cli">server → client</p>
<pre><code>GET /slideshows/1/assets/1 HTTP/1.1
Content-Length: 0
Accept: application/x-apple-binary-plist
X-Apple-Session-ID: 98a7b246-8e00-49a6-8765-db57165f5b67
</code></pre>