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

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

    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
    SimpleServer(protocol=AdHocFileProtocolHandler(file_to_stream),
    port=clientServerTestPort).activate()

    # Start the client
    pipeline(
    TCPClient("127.0.0.1",clientServerTestPort),
    VorbisDecode(),
    AOAudioPlaybackAdaptor(),
    ).activate()

    # This next pipeline is new
    # Start the introspector and connect to a local visualiser
    pipeline(
    Introspector(),
    TCPClient("127.0.0.1", 1500),
    ).run()

    Source: Examples/example5/IntrospectingSimpleStreamingSystem.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)