15 #define CHALLENGE "LfBLs2pkGT4yYAJrxj2K9Q=="
16 static unsigned char ipaddr
[] = { 192, 168, 1, 10 };
17 static unsigned char hwaddr
[] = { 0x00, 0x5A, 0xDB, 0xE4, 0xE6, 0xFD };
19 #define AESENC "B69yRGHoriZZeJNKghotJi6Pt7dEPEwKSoieM6dk8YE1D23/jyOsg0ZoJZmodHB4lR9Q9CmeoqgU0GX1KkYNafCrNUlXxJAZuMTISGmyeDegnH73ul1NQwIjfphGgwrx7dp7J+p4lyQi+Yt/daQyjE//Od0viD37GQtI9B7GukaiWrMl94wJmSLUL94VpKUxnD9E7T/LesX7bEMfUgSQUpIE+T2anp6eRqE/5R3kNYdEH9JcCEFu5DLqbbvMqgc0ewr81BNeVG5ck1iI2eF+OJVm9g082ZXqGAPFGwmcYiiLfjrQY5hnEUi7IeWqgX5Xd82DyW9BeDzT5MXVyI/GwQ=="
22 test_rsa(const char *pemstr
)
28 rsakey
= rsakey_init_pem(pemstr
);
30 printf("Initializing RSA failed\n");
34 rsakey_sign(rsakey
, buffer
, sizeof(buffer
), CHALLENGE
,
35 ipaddr
, sizeof(ipaddr
), hwaddr
, sizeof(hwaddr
));
36 printf("Signature:\n%s\n", buffer
);
38 ret
= rsakey_decrypt(rsakey
, (unsigned char *)buffer
, sizeof(buffer
), AESENC
);
39 printf("Decrypted length: %d\n", ret
);
41 rsakey_destroy(rsakey
);
45 photo_cb(char *data
, int datalen
)
51 printf("Got photo with data length: %d\n", datalen
);
53 memset(template, 0, sizeof(template));
54 strcpy(template, "/tmp/tmpXXXXXX.JPG");
55 fd
= mkstemps(template, 4);
57 while (written
< datalen
) {
58 ret
= write(fd
, data
+written
, datalen
-written
);
62 if (written
== datalen
) {
63 printf("Wrote to file %s\n", template);
99 audio_init(void *opaque
, int bits
, int channels
, int samplerate
)
102 ao_sample_format format
;
103 ao_option
*ao_opts
= NULL
;
106 printf("Opening audio device\n");
107 driver
= ao_driver_id("pulse");
109 memset(&format
, 0, sizeof(format
));
111 format
.channels
= channels
;
112 format
.rate
= samplerate
;
113 format
.byte_format
= AO_FMT_LITTLE
;
115 ao_append_option(&ao_opts
, "id", "0");
116 device
= ao_open_live(driver
, &format
, ao_opts
);
118 fprintf(stderr
, "Error opening audio device.\n");
120 printf("Opening device successful\n");
126 audio_process(void *ptr
, const void *buffer
, int buflen
)
128 ao_device
*device
= ptr
;
132 printf("Got %d bytes of audio\n", buflen
);
133 ao_play(device
, (char *)buffer
, buflen
);
137 audio_flush(void *ptr
)
142 audio_destroy(void *ptr
)
144 ao_device
*device
= ptr
;
146 printf("Closing audio device\n");
151 main(int argc
, char *argv
[])
153 const char *name
= "AppleTV";
154 unsigned short raop_port
= 5000;
155 unsigned short airplay_port
= 7000;
156 const char hwaddr
[] = { 0x48, 0x5d, 0x60, 0x7c, 0xee, 0x22 };
161 airplay_callbacks_t ap_cbs
;
163 raop_callbacks_t raop_cbs
;
165 if (utils_read_file(&pemstr
, "airport.key") < 0) {
174 dnssd
= dnssd_init(hwaddr
, sizeof(hwaddr
), NULL
);
175 dnssd_register_raop(dnssd
, name
, raop_port
);
176 dnssd_register_airplay(dnssd
, name
, airplay_port
);
178 ap_cbs
.photo_cb
= &photo_cb
;
179 ap_cbs
.play_cb
= &play_cb
;
180 ap_cbs
.stop_cb
= &stop_cb
;
181 ap_cbs
.rate_set_cb
= &rate_set_cb
;
182 ap_cbs
.scrub_get_cb
= &scrub_get_cb
;
183 ap_cbs
.scrub_set_cb
= &scrub_set_cb
;
184 ap_cbs
.playback_info_cb
= &playback_info_cb
;
186 raop_cbs
.audio_init
= audio_init
;
187 raop_cbs
.audio_process
= audio_process
;
188 raop_cbs
.audio_flush
= audio_flush
;
189 raop_cbs
.audio_destroy
= audio_destroy
;
191 airplay
= airplay_init(&ap_cbs
, hwaddr
, sizeof(hwaddr
));
192 airplay_start(airplay
, airplay_port
);
194 raop
= raop_init(&raop_cbs
, pemstr
, hwaddr
, sizeof(hwaddr
));
195 raop_start(raop
, &raop_port
);
202 airplay_stop(airplay
);
203 airplay_destroy(airplay
);
205 dnssd_unregister_airplay(dnssd
);
206 dnssd_unregister_raop(dnssd
);
207 dnssd_destroy(dnssd
);