Update licensing information
[deb_shairplay.git] / src / test / test.py
CommitLineData
8be1424a
JVH
1import time
2from struct import *
3from Shairplay import *
4
5hwaddr = pack('BBBBBB', 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB)
094e4ad1
JVH
6class SampleCallbacks(RaopCallbacks):
7 def audio_init(self, bits, channels, samplerate):
23ab90af 8 print "Initializing", bits, channels, samplerate
094e4ad1 9 def audio_process(self, session, buffer):
23ab90af
JVH
10 print "Processing", + len(buffer), "bytes of audio"
11 def audio_destroy(self, session):
12 print "Destroying"
13 def audio_set_volume(self, session, volume):
14 print "Set volume to", volume
15 def audio_set_metadata(self, session, metadata):
16 print "Got", len(metadata), "bytes of metadata"
17 def audio_set_coverart(self, session, coverart):
18 print "Got", len(coverart), "bytes of coverart"
8be1424a
JVH
19
20shairplay = LoadShairplay(".")
094e4ad1 21callbacks = SampleCallbacks()
8be1424a 22
10ceb254
JVH
23def log_callback(level, message):
24 print "Level", level, ":", message
25
23ab90af 26raop = RaopService(shairplay, 10, callbacks)
10ceb254
JVH
27raop.set_log_level(RaopLogLevel.DEBUG)
28raop.set_log_callback(log_callback)
8be1424a
JVH
29port = raop.start(5000, hwaddr)
30
31dnssd = DnssdService(shairplay)
094e4ad1 32dnssd.register_raop("RAOP test", port, hwaddr)
8be1424a
JVH
33
34time.sleep(50)
35
36dnssd.unregister_raop()
37raop.stop()
094e4ad1
JVH
38
39del dnssd
8be1424a
JVH
40del raop
41