Пример #1
0
def DetermineMaxFrameNumber(edlfile):
    """\
    Prefab.
    
    "outbox" sends out the highest frame number referenced in the EDL xml file.
    Then terminates immediately and sends out a producerFinished() message from
    the "signal" outbox.
    
    Arguments:
    
    - edlfile  -- full filepathname of the EDL xml file
    
    Inboxes:
    
    - "inbox"    -- NOT USED
    - "control"  -- Shutdown signalling
    
    Outboxes:
    
    - "outbox"  -- sends out the highest frame number referenced in the EDL file
    - "signal"  -- Shutdown signalling
    """
    return Pipeline(
        RateControlledFileReader(edlfile,readmode="lines",rate=1000000),
        SimpleXMLParser(),
        EDLParser(),
        SimpleDetupler("end"),
        Collate(),
        Max(),
        )
Пример #2
0
def clientconnector(whiteboardBackplane="WHITEBOARD", audioBackplane="AUDIO", port=1500):
    return Pipeline(
        chunks_to_lines(),
        lines_to_tokenlists(),
        Graphline(
            ROUTER = Router( ((lambda T : T[0]=="SOUND"), "audio"),
                             ((lambda T : T[0]!="SOUND"), "whiteboard"),
                           ),
            WHITEBOARD = FilteringPubsubBackplane(whiteboardBackplane),
            AUDIO = Pipeline(
                        SimpleDetupler(1),     # remove 'SOUND' tag
                        SpeexDecode(3),
                        FilteringPubsubBackplane(audioBackplane, dontRemoveTag=True),
                        RawAudioMixer(),
                        SpeexEncode(3),
                        Entuple(prefix=["SOUND"],postfix=[]),
                    ),
            linkages = {
                # incoming messages go to a router
                ("", "inbox") : ("ROUTER", "inbox"),
                # distribute messages to appropriate destinations
                ("ROUTER",      "audio") : ("AUDIO",      "inbox"),
                ("ROUTER", "whiteboard") : ("WHITEBOARD", "inbox"),
                # aggregate all output
                ("AUDIO",      "outbox") : ("", "outbox"),
                ("WHITEBOARD", "outbox") : ("", "outbox"),
                # shutdown routing, not sure if this will actually work, but hey!
                ("", "control") : ("ROUTER", "control"),
                ("ROUTER", "signal") : ("AUDIO", "control"),
                ("AUDIO", "signal") : ("WHITEBOARD", "control"),
                ("WHITEBOARD", "signal") : ("", "signal")
                },
            ),
        tokenlists_to_lines(),
        )
        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
Пример #4
0
    def clientconnector():
        return Pipeline(
            chunks_to_lines(),
            lines_to_tokenlists(),
            Graphline(
                WHITEBOARD=FilterAndTagWrapper(
                    Pipeline(
                        publishTo(whiteboardBackplane),
                        # well, should be to separate pipelines, this is lazier!
                        subscribeTo(whiteboardBackplane),
                    )),
                AUDIO=Pipeline(
                    SimpleDetupler(1),  # remove 'SOUND' tag
                    SpeexDecode(3),
                    FilterAndTagWrapperKeepingTag(
                        Pipeline(
                            publishTo(audioBackplane),
                            # well, should be to separate pipelines, this is lazier!
                            subscribeTo(audioBackplane),
                        ), ),
                    RawAudioMixer(),
                    SpeexEncode(3),
                    Entuple(prefix=["SOUND"], postfix=[]),
                ),
                ROUTER=Router(
                    ((lambda tuple: tuple[0] == "SOUND"), "audio"),
                    ((lambda tuple: tuple[0] != "SOUND"), "whiteboard"),
                ),
                linkages={
                    # incoming messages go to a router
                    ("", "inbox"): ("ROUTER", "inbox"),

                    # distribute messages to appropriate destinations
                    ("ROUTER", "audio"): ("AUDIO", "inbox"),
                    ("ROUTER", "whiteboard"): ("WHITEBOARD", "inbox"),

                    # aggregate all output
                    ("AUDIO", "outbox"): ("", "outbox"),
                    ("WHITEBOARD", "outbox"): ("", "outbox"),

                    # shutdown routing, not sure if this will actually work, but hey!
                    ("", "control"): ("ROUTER", "control"),
                    ("ROUTER", "signal"): ("AUDIO", "control"),
                    ("AUDIO", "signal"): ("WHITEBOARD", "control"),
                    ("WHITEBOARD", "signal"): ("", "signal")
                },
            ),
            tokenlists_to_lines(),
        )
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()
Пример #6
0
            'timestamp': timestamp,
            'ssrc': ssrc,
            'extension': extension,
            'csrcs': csrcs,
            'marker': hasMarker,
        })


__kamaelia_components__ = (RTPDeframer, )

if __name__ == "__main__":
    from Kamaelia.Chassis.Pipeline import Pipeline
    #    from Kamaelia.Internet.Multicast_transceiver import Multicast_transceiver
    from Multicast_transceiver import Multicast_transceiver
    from Kamaelia.Protocol.SimpleReliableMulticast import RecoverOrder
    from Kamaelia.File.Writing import SimpleFileWriter
    from Kamaelia.Util.Detuple import SimpleDetupler
    from Kamaelia.Util.Console import ConsoleEchoer

    Pipeline(
        Multicast_transceiver("0.0.0.0", 1600, "224.168.2.9", 0),
        #Multicast_transceiver("0.0.0.0", 1234, "239.255.42.42", 0),  # for live555 testing
        SimpleDetupler(1),
        RTPDeframer(),
        RecoverOrder(),
        SimpleDetupler(1),
        SimpleDetupler("payload"),
        SimpleFileWriter("received.ts"),
        #              ConsoleEchoer(),
    ).run()
Пример #7
0
def EventServerClients(rhost,
                       rport,
                       whiteboardBackplane="WHITEBOARD",
                       audioBackplane="AUDIO"):
    # plug a TCPClient into the backplae
    from Kamaelia.Internet.TCPClient import TCPClient
    from Kamaelia.Chassis.Carousel import Carousel

    loadingmsg = "Fetching sketch from server..."

    failuremsg = "FAILED: Couldn't connect to server:"
    failuremsg2 = str(rhost) + " on port " + str(rport)

    return Graphline(
        NETWORK=Graphline(
            PIPE=Pipeline(
                tokenlists_to_lines(),
                TCPClient(host=rhost, port=rport),
                chunks_to_lines(),
                lines_to_tokenlists(),
            ),
            SHUTDOWN=TriggeredOneShot(msg=shutdownMicroprocess()),
            linkages={
                ("", "inbox"): ("PIPE", "inbox"),
                ("PIPE", "outbox"): ("", "outbox"),

                # shutdown stuff - TCPClient may have caused it, so need to
                # loop the shutdown message back round to the front of the pipe
                # as well as propagating it onwards
                ("", "control"): ("PIPE", "control"),
                ("PIPE", "signal"): ("SHUTDOWN", "inbox"),
                ("SHUTDOWN", "outbox"): ("PIPE", "control"),
                ("SHUTDOWN", "signal"): ("", "signal"),
            }),
        ROUTER=Router(
            ((lambda tuple: tuple[0] == "SOUND"), "audio"),
            ((lambda tuple: tuple[0] != "SOUND"), "whiteboard"),
        ),
        WHITEBOARD=FilterAndTagWrapper(
            Pipeline(
                publishTo(whiteboardBackplane),
                #
                subscribeTo(whiteboardBackplane),
            )),
        AUDIO=Pipeline(
            SimpleDetupler(1),  # remove 'SOUND' tag
            SpeexDecode(3),
            FilterAndTagWrapperKeepingTag(
                Pipeline(
                    publishTo(audioBackplane),
                    #
                    subscribeTo(audioBackplane),
                ), ),
            RawAudioMixer(),
            SpeexEncode(3),
            Entuple(prefix=["SOUND"], postfix=[]),
        ),
        GETIMG=OneShot(msg=[["GETIMG"]]),
        BLACKOUT=OneShot(
            msg=[["CLEAR", 0, 0, 0],
                 ["WRITE", 100, 100, 24, 255, 255, 255, loadingmsg]]),
        FAILURE=TriggeredOneShot(
            msg=[["WRITE", 100, 200, 32, 255, 96, 96, failuremsg],
                 ["WRITE", 100, 232, 24, 255, 160, 160, failuremsg2]]),
        linkages={
            # incoming messages from network connection go to a router
            ("NETWORK", "outbox"): ("ROUTER", "inbox"),

            # distribute messages to appropriate destinations
            ("ROUTER", "audio"): ("AUDIO", "inbox"),
            ("ROUTER", "whiteboard"): ("WHITEBOARD", "inbox"),

            # aggregate all output, and send across the network connection
            ("AUDIO", "outbox"): ("NETWORK", "inbox"),
            ("WHITEBOARD", "outbox"): ("NETWORK", "inbox"),

            # initial messages sent to the server, and the local whiteboard
            ("GETIMG", "outbox"): ("NETWORK", "inbox"),
            ("BLACKOUT", "outbox"): ("WHITEBOARD", "inbox"),

            # shutdown routing, not sure if this will actually work, but hey!
            ("NETWORK", "signal"): ("FAILURE", "inbox"),
            ("FAILURE", "outbox"): ("WHITEBOARD", "inbox"),
            ("FAILURE", "signal"): ("ROUTER", "control"),
            ("ROUTER", "signal"): ("AUDIO", "control"),
            ("AUDIO", "signal"): ("WHITEBOARD", "control"),
            ("WHITEBOARD", "signal"): ("", "signal"),
        })