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 3: Same as example 2, but as separate scripts. Components used in server script: SimpleServer, ReadFileAdaptor. Components used in client script: pipeline, TCPClient, VorbisDecode, AOAudioPlaybackAdaptor .
#!/usr/bin/python
import Kamaelia.ReadFileAdaptor
from Kamaelia.SimpleServerComponent import SimpleServer
= "/usr/share/wesnoth/music/wesnoth-1.ogg"
file_to_stream
def AdHocFileProtocolHandler(filename):
class klass(Kamaelia.ReadFileAdaptor.ReadFileAdaptor):
def __init__(self,*argv,**argd):
super(klass,self).__init__(filename, readmode="bitrate", bitrate=400000)
return klass
=1500
clientServerTestPort=AdHocFileProtocolHandler(file_to_stream),
SimpleServer(protocol=clientServerTestPort).run() port
Source: Examples/example3/SimpleStreamer.py
#!/usr/bin/python
from Kamaelia.Internet.TCPClient import TCPClient
from Kamaelia.vorbisDecodeComponent import VorbisDecode, AOAudioPlaybackAdaptor
from Kamaelia.Util.PipelineComponent import pipeline
=1500
clientServerTestPort"127.0.0.1",clientServerTestPort),
pipeline(TCPClient(
VorbisDecode(),
AOAudioPlaybackAdaptor() ).run()
Source: Examples/example3/SimpleStreamingClient.py