Add log level and callback functions to the python bindings
[deb_shairplay.git] / src / test / test.py
index 4340ca11b8f750c46ab150339c0c26480efbe287..45eab3b46ab09b25530e8144e7e2abf3b70db8ef 100644 (file)
@@ -5,14 +5,27 @@ from Shairplay import *
 hwaddr = pack('BBBBBB', 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB)
 class SampleCallbacks(RaopCallbacks):
        def audio_init(self, bits, channels, samplerate):
-               print "Initializing " + str(bits) + " " + str(channels) + " " + str(samplerate)
+               print "Initializing", bits, channels, samplerate
        def audio_process(self, session, buffer):
-               print "Processing " + str(len(buffer)) + " bytes of audio"
+               print "Processing", + len(buffer), "bytes of audio"
+       def audio_destroy(self, session):
+               print "Destroying"
+       def audio_set_volume(self, session, volume):
+               print "Set volume to", volume
+       def audio_set_metadata(self, session, metadata):
+               print "Got", len(metadata),  "bytes of metadata"
+       def audio_set_coverart(self, session, coverart):
+               print "Got", len(coverart), "bytes of coverart"
 
 shairplay = LoadShairplay(".")
 callbacks = SampleCallbacks()
 
-raop = RaopService(shairplay, callbacks)
+def log_callback(level, message):
+       print "Level", level, ":", message
+
+raop = RaopService(shairplay, 10, callbacks)
+raop.set_log_level(RaopLogLevel.DEBUG)
+raop.set_log_callback(log_callback)
 port = raop.start(5000, hwaddr)
 
 dnssd = DnssdService(shairplay)