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 .

Server script

    #!/usr/bin/python

    import Kamaelia.ReadFileAdaptor
    from Kamaelia.SimpleServerComponent import SimpleServer

    file_to_stream = "/usr/share/wesnoth/music/wesnoth-1.ogg"

    def AdHocFileProtocolHandler(filename):
    class klass(Kamaelia.ReadFileAdaptor.ReadFileAdaptor):
    def __init__(self,*argv,**argd):
    super(klass,self).__init__(filename, readmode="bitrate", bitrate=400000)
    return klass

    clientServerTestPort=1500
    SimpleServer(protocol=AdHocFileProtocolHandler(file_to_stream),
    port=clientServerTestPort).run()
    Source: Examples/example3/SimpleStreamer.py

Client script

    #!/usr/bin/python 

    from Kamaelia.Internet.TCPClient import TCPClient
    from Kamaelia.vorbisDecodeComponent import VorbisDecode, AOAudioPlaybackAdaptor
    from Kamaelia.Util.PipelineComponent import pipeline

    clientServerTestPort=1500
    pipeline(TCPClient("127.0.0.1",clientServerTestPort),
    VorbisDecode(),
    AOAudioPlaybackAdaptor()
    ).run()

    Source: Examples/example3/SimpleStreamingClient.py

 

Kamaelia is an open source project originated from and guided by BBC Research. For more information browse the site or get in contact.

This is an ongoing community based development site. As a result the contents of this page is the opinions of the contributors of the pages involved not the organisations involved. Specificially, this page may contain personal views which are not the views of the BBC. (the site is powered by a wiki engine)

(C) Copyright 2008 Kamaelia Contributors, including the British Broadcasting Corporation, All Rights Reserved

This web site is powered by the same code created for the bicker manor project. For more details, contact Michael Sparks at BBC Research directly (cf contact)