コード例 #1
0
    def initialiseComponent(self):
        """\
      Initialises component. Sets up a ReadFileAdapter to read in the contents
      of an audio file at 95.2kbit/s and wires it to fire the contents out
      """
        myDataSource = ReadFileAdaptor(command="./afortune.pl",
                                       readmode="bitrate",
                                       bitrate=95200,
                                       chunkrate=25)
        assert self.debugger.note(
            "AudioCookieProtocol.initialiseComponent", 1,
            "Initialising AudioCookieProtocol protocol handler ", self.name)
        self.link(source=(myDataSource, "outbox"),
                  sink=(self, "outbox"),
                  passthrough=2)
        self.addChildren(myDataSource)

        return newComponent(myDataSource)

    def mainBody(self):
        """Main body - sits and waits, as ReadFileAdapter is getting on with the work for us"""
        return 1


__kamaelia_components__ = (AudioCookieProtocol, )

if __name__ == '__main__':
    from Kamaelia.Chassis.ConnectedServer import SimpleServer

    SimpleServer(protocol=AudioCookieProtocol, port=1500).run()
コード例 #2
0
ファイル: LoopbackServer.py プロジェクト: thangduong/kamaelia
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright 2010 British Broadcasting Corporation and Kamaelia Contributors(1)
#
# (1) Kamaelia Contributors are listed in the AUTHORS file and at
#     http://www.kamaelia.org/AUTHORS - please extend this file,
#     not this notice.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from Kamaelia.Chassis.ConnectedServer import SimpleServer
from Kamaelia.Protocol.EchoProtocol import EchoProtocol

SimpleServer(protocol=EchoProtocol, port=1500).run()
コード例 #3
0
rootip = "127.0.0.1"  # not needed
rootcontrolport = 1500  # not needed

#
#\-----------------------------------------------------------------


#/-----------------------------------------------------------------
# So we can handle requests for our control port for building
# the mesh
#
def mySwarmer():
    return SimpleSwarm(mydataport)


SimpleServer(protocol=mySwarmer, port=mycontrolport).activate()
#
#\-----------------------------------------------------------------

#/-----------------------------------------------------------------
# Mechanism to allow the audio data to be shared to all clients
#
Backplane("RADIO").activate()
#
#\-----------------------------------------------------------------

#/---------------------------------------------------------------------------
#
# Data source portion of this peer. Connect to the DVB-T
# stream for Radio 1 !
#
コード例 #4
0
SERVERPORT      = 1500


def MultiFileReaderProtocol(filenames, bitrate, chunksizebytes):

    def protocolFactory(*argv, **argd):
        return JoinChooserToCarousel(
            ForwardIteratingChooser(filenames),
            FixedRateControlledReusableFileReader(readmode="bytes",
                                               rate=bitrate/8,
                                               chunksize=chunksizebytes)
          )
    return protocolFactory



if __name__ == '__main__':
   from Axon.Scheduler import scheduler

   filereader = MultiFileReaderProtocol( FILES_TO_STREAM, BITRATE, CHUNKSIZEBYTES)

   server     = SimpleServer( protocol = filereader, port = SERVERPORT ).activate()

   if 0:
        from Kamaelia.Internet.TCPClient import TCPClient
        from Kamaelia.Util.Introspector import Introspector
        pipeline(Introspector(), TCPClient("127.0.0.1",1501)).activate()
   
   scheduler.run.runThreads(slowmo=0)

コード例 #5
0
ファイル: SimpleStreamer.py プロジェクト: thangduong/kamaelia
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# -------------------------------------------------------------------------
#
# Simple Ogg Vorbis audio streaming system
#

import Kamaelia.File.ReadFileAdaptor
from Kamaelia.Chassis.ConnectedServer import SimpleServer

file_to_stream = "../../SupportingMediaFiles/KDE_Startup_2.ogg"


def AdHocFileProtocolHandler(filename):
    class klass(Kamaelia.File.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()
コード例 #6
0
ファイル: Whiteboard.py プロジェクト: thangduong/kamaelia
def LocalWebcamEventServer(webcamBackplane="WEBCAM", port=1501):
    # Sets up the webcam server in a similar way to the one used for images and audio
    def configuredClientConnector():
        return clientconnectorwc(webcamBackplane=webcamBackplane, port=port)

    return SimpleServer(protocol=clientconnectorwc, port=port)
コード例 #7
0
#            self.ShouldShutdownCode = 2 # cf the comment above when this is initialised
                            # Magic numbers are evil
            if self.ShouldShutdownCode > 0:
                self.send(producerFinished(), "signal") #this functionality is semi-complete
#                print "HERE"
                yield 1
                return

            self.pause()
        
        #print 'HTTP Handler dead'

__kamaelia_components__  = ( HTTPRequestHandler, )

if __name__ == '__main__':
    import socket

    from Kamaelia.Chassis.ConnectedServer import SimpleServer

    # this works out what the correct response to a request is
    from Kamaelia.Protocol.HTTP.HTTPResourceGlue import createRequestHandler 

    def createhttpserver():
        return HTTPServer(createRequestHandler)

    SimpleServer(
        protocol=createhttpserver,
        port=8082,
        socketOptions=(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    ).run()