Fix python bindings to hold a reference to sessions
[deb_shairplay.git] / src / test / test.py
1 import time
2 from struct import *
3 from Shairplay import *
4
5 hwaddr = pack('BBBBBB', 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB)
6 class SampleCallbacks(RaopCallbacks):
7 def audio_init(self, bits, channels, samplerate):
8 print "Initializing " + str(bits) + " " + str(channels) + " " + str(samplerate)
9 def audio_process(self, session, buffer):
10 print "Processing " + str(len(buffer)) + " bytes of audio"
11
12 shairplay = LoadShairplay(".")
13 callbacks = SampleCallbacks()
14
15 raop = RaopService(shairplay, callbacks)
16 port = raop.start(5000, hwaddr)
17
18 dnssd = DnssdService(shairplay)
19 dnssd.register_raop("RAOP test", port, hwaddr)
20
21 time.sleep(50)
22
23 dnssd.unregister_raop()
24 raop.stop()
25
26 del dnssd
27 del raop
28