def main(self):
            receiver = Multicast_transceiver("0.0.0.0", 1600, "224.168.2.9", 0)
            detupler = SimpleDetupler(1)
            decoder = VorbisDecode()
            player = AOAudioPlaybackAdaptor()

            self.link((receiver, "outbox"), (detupler, "inbox"))
            self.link((detupler, "outbox"), (decoder, "inbox"))
            self.link((decoder, "outbox"), (player, "inbox"))

            self.addChildren(receiver, detupler, decoder, player)
            yield Axon.Ipc.newComponent(*(self.children))
            while 1:
                yield 1
from Kamaelia.Protocol.SimpleReliableMulticast import SRM_Sender, SRM_Receiver
from Kamaelia.Protocol.Packetise import MaxSizePacketiser
from Kamaelia.Util.Detuple import SimpleDetupler

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

#
# Server with simple added reliabilty protocol
#
Pipeline(
    ReadFileAdaptor(file_to_stream,
                    readmode="bitrate",
                    bitrate=400000,
                    chunkrate=50),
    SRM_Sender(),
    MaxSizePacketiser(),  # Ensure chunks small enough for multicasting!
    Multicast_transceiver("0.0.0.0", 0, "224.168.2.9", 1600),
).activate()

#
# Client with simple added reliability protocol
#
Pipeline(
    Multicast_transceiver("0.0.0.0", 1600, "224.168.2.9", 0),
    SimpleDetupler(1),
    SRM_Receiver(),
    SimpleDetupler(1),
    VorbisDecode(),
    AOAudioPlaybackAdaptor(),
).run()
Exemplo n.º 3
0
#
# 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 Axon.likefile import LikeFile, schedulerThread
from Kamaelia.Codec.Vorbis import VorbisDecode, AOAudioPlaybackAdaptor
from Kamaelia.Chassis.Pipeline import Pipeline
from Kamaelia.File.ReadFileAdaptor import ReadFileAdaptor
import ao
schedulerThread(slowmo=0.001).start()

filename = "./snail.ogg"

playStream = LikeFile(Pipeline(VorbisDecode(), AOAudioPlaybackAdaptor()))

# Play the ogg data in the background
oggdata = open(filename, "r+b").read()
playStream.put(oggdata)
while True:
    playStream.get()
    # there's no data produced but this will prevent us from exiting immediately.
Exemplo n.º 4
0
#

from Kamaelia.Chassis.Pipeline import Pipeline
from Kamaelia.Chassis.ConnectedServer import SimpleServer
from Kamaelia.Internet.TCPClient import TCPClient
from Kamaelia.Codec.Vorbis import VorbisDecode, AOAudioPlaybackAdaptor
import Kamaelia.File.ReadFileAdaptor
import random

file_to_stream = "../SupportingMediaFiles/KDE_Startup_2.ogg"
clientServerTestPort = random.randint(1500, 2000)

print "Client Server demo running on port", clientServerTestPort


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

    return klass


server = SimpleServer(protocol=AdHocFileProtocolHandler(file_to_stream),
                      port=clientServerTestPort).activate()

Pipeline(TCPClient("127.0.0.1", clientServerTestPort), VorbisDecode(),
         AOAudioPlaybackAdaptor()).run()
Exemplo n.º 5
0
# limitations under the License.

from Axon.background import background
from Axon.Handle import Handle
from Kamaelia.Codec.Vorbis import VorbisDecode, AOAudioPlaybackAdaptor
from Kamaelia.Chassis.Pipeline import Pipeline
from Kamaelia.File.ReadFileAdaptor import ReadFileAdaptor
from Kamaelia.Internet.TCPClient import TCPClient
import time
import Queue
import ao
background(slowmo=0.001).start()

filename = "./snail.ogg"

playStream = Handle(Pipeline(VorbisDecode(), AOAudioPlaybackAdaptor())).activate()
# set of components for playing the stream back.

host = "bbc.kamaelia.org"
port = 1500

client = Handle(TCPClient(host = host, port = port)).activate()
# component to grab a stream from the internet

filedump = open("streamdump.ogg", "w+b")

def get_item(handle):
    while 1:
        try:
            X = handle.get("outbox")
            return X
Exemplo n.º 6
0
#
#     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 Axon.background import background
from Axon.Handle import Handle
from Kamaelia.Codec.Vorbis import VorbisDecode, AOAudioPlaybackAdaptor
from Kamaelia.Chassis.Pipeline import Pipeline
from Kamaelia.File.ReadFileAdaptor import ReadFileAdaptor
import time
import ao

background(slowmo=0.001).start()

filename = "../SupportingMediaFiles/KDE_Startup_2.ogg"

playStream = Handle(Pipeline(VorbisDecode(),
                             AOAudioPlaybackAdaptor())).activate()

# Play the ogg data in the background
oggdata = open(filename, "r+b").read()
playStream.put(oggdata, "inbox")
while True:
    time.sleep(0.1)