August'24: Kamaelia is in maintenance mode and will recieve periodic updates, about twice a year, primarily targeted around Python 3 and ecosystem compatibility. PRs are always welcome. Latest Release: 1.14.32 (2024/3/24)
Cookbook Example
How can I...?
Example 5: An introspecting version of Examples 2/3. This creates a simple streaming system, and looks inside to see what components are running/active, and passes the resulting information over a network connection to an Axon Visualisation server. Components used:SimpleServer, TCPClient, ReadFileAdaptor, VorbisDecode, AOAudioPlaybackAdaptor, Introspector
#!/usr/bin/python
from Kamaelia.SimpleServerComponent import SimpleServer
from Kamaelia.Internet.TCPClient import TCPClient
from Kamaelia.vorbisDecodeComponent import VorbisDecode, AOAudioPlaybackAdaptor
from Kamaelia.Util.PipelineComponent import pipeline
import Kamaelia.ReadFileAdaptor
# This next line is new
from Kamaelia.Util.Introspector import Introspector
= "/usr/share/wesnoth/music/wesnoth-1.ogg"
file_to_stream = 1501
clientServerTestPort
def AdHocFileProtocolHandler(filename):
class klass(Kamaelia.ReadFileAdaptor.ReadFileAdaptor):
def __init__(self,*argv,**argd):
super(klass,self).__init__(filename, readmode="bitrate", bitrate=400000)
return klass
# Start the server
=AdHocFileProtocolHandler(file_to_stream),
SimpleServer(protocol=clientServerTestPort).activate()
port
# Start the client
pipeline("127.0.0.1",clientServerTestPort),
TCPClient(
VorbisDecode(),
AOAudioPlaybackAdaptor(),
).activate()
# This next pipeline is new
# Start the introspector and connect to a local visualiser
pipeline(
Introspector(),"127.0.0.1", 1500),
TCPClient( ).run()
Source: Examples/example5/IntrospectingSimpleStreamingSystem.py