13 audio_init(void *cls
, int bits
, int channels
, int samplerate
)
15 return fopen("audio.pcm", "wb");
19 audio_set_volume(void *cls
, void *session
, float volume
)
21 printf("Setting volume to %f\n", volume
);
25 audio_set_metadata(void *cls
, void *session
, const void *buffer
, int buflen
)
28 FILE *file
= fopen("metadata.bin", "wb");
30 buflen
-= fwrite(buffer
+orig
-buflen
, 1, buflen
, file
);
33 printf("Metadata of length %d saved as metadata.bin\n", orig
);
37 audio_set_coverart(void *cls
, void *session
, const void *buffer
, int buflen
)
40 FILE *file
= fopen("coverart.jpg", "wb");
42 buflen
-= fwrite(buffer
+orig
-buflen
, 1, buflen
, file
);
45 printf("Coverart of length %d saved as coverart.jpg\n", orig
);
49 audio_process(void *cls
, void *session
, const void *buffer
, int buflen
)
53 buflen
-= fwrite(buffer
+orig
-buflen
, 1, buflen
, session
);
58 audio_flush(void *cls
, void *session
)
60 printf("Flushing audio\n");
64 audio_destroy(void *cls
, void *session
)
70 raop_log_callback(void *cls
, int level
, const char *msg
)
72 printf("RAOP LOG(%d): %s\n", level
, msg
);
76 main(int argc
, char *argv
[])
78 const char *name
= "AppleTV";
79 unsigned short raop_port
= 5000;
80 const char hwaddr
[] = { 0x48, 0x5d, 0x60, 0x7c, 0xee, 0x22 };
84 raop_callbacks_t raop_cbs
;
87 raop_cbs
.audio_init
= audio_init
;
88 raop_cbs
.audio_set_volume
= audio_set_volume
;
89 raop_cbs
.audio_set_metadata
= audio_set_metadata
;
90 raop_cbs
.audio_set_coverart
= audio_set_coverart
;
91 raop_cbs
.audio_process
= audio_process
;
92 raop_cbs
.audio_flush
= audio_flush
;
93 raop_cbs
.audio_destroy
= audio_destroy
;
95 raop
= raop_init_from_keyfile(10, &raop_cbs
, "airport.key", NULL
);
96 raop_set_log_level(raop
, RAOP_LOG_DEBUG
);
97 raop_set_log_callback(raop
, &raop_log_callback
, NULL
);
98 raop_start(raop
, &raop_port
, hwaddr
, sizeof(hwaddr
), "test");
100 dnssd
= dnssd_init(NULL
);
101 dnssd_register_raop(dnssd
, name
, raop_port
, hwaddr
, sizeof(hwaddr
), 1);
109 dnssd_unregister_raop(dnssd
);
110 dnssd_destroy(dnssd
);