Esempio n. 1
0
                dec = xxtea.xxbtea(data, -2,
                                   "AABBCCDDEE0123456789AABBCCDDEEFF")
                self.send(dec, "outbox")
            if not self.anyReady():
                self.pause()
            yield 1
        self.send(self.recv("control"), "signal")


class echoer(Axon.Component.component):
    def main(self):
        count = 0
        while 1:
            while self.dataReady("inbox"):
                data = self.recv("inbox")
                print data, "count:", count
                count = count + 1
            self.pause()
            yield 1


if __name__ == "__main__":
    pipeline(
        RateControlledFileReader("../AM/KPIFramework/SelfishTriangle.jpg",
                                 readmode="bytes",
                                 rate=100000,
                                 chunksize=8),
        Encryptor("12345678901234567890123456789012"),
        Decryptor("12345678901234567890123456789012"),
        SimpleFileWriter("SelfishTriangle-dec.jpg")).run()
Esempio n. 2
0
if __name__ == "__main__":

    from Kamaelia.Chassis.Pipeline import Pipeline
    from Kamaelia.File.Reading import RateControlledFileReader
    from Kamaelia.UI.Pygame.VideoOverlay import VideoOverlay
    from Kamaelia.Audio.PyMedia.Output import Output
    from Kamaelia.Chassis.Carousel import Carousel
    from Kamaelia.Chassis.Graphline import Graphline

    from Kamaelia.File.Reading import RateControlledFileReader
    from Kamaelia.File.Writing import SimpleFileWriter

    print "Reading in WAV file, parsing it, then writing it out as test.wav ..."
    Graphline(
        READ=RateControlledFileReader(
            "/usr/share/sounds/alsa/Front_Center.wav",
            readmode="bytes",
            rate=1000000),
        PARSE=WAVParser(),
        ENC=Carousel(lambda meta: WAVWriter(**meta)),
        WRITE=SimpleFileWriter("test.wav"),
        linkages={
            ("READ", "outbox"): ("PARSE", "inbox"),
            ("PARSE", "outbox"): ("ENC", "inbox"),
            ("PARSE", "all_meta"): ("ENC", "next"),
            ("ENC", "outbox"): ("WRITE", "inbox"),
            ("READ", "signal"): ("PARSE", "control"),
            ("PARSE", "signal"): ("ENC", "control"),
            ("ENC", "signal"): ("WRITE", "control"),
        },
    ).run()
Esempio n. 3
0
        print
        sys.exit(1)

    channelsConfFile = sys.argv[1]
    channelName = sys.argv[2].upper().strip()
    outFileName = sys.argv[3]

    def chooseChannelName((name, params, ids)):
        if name == channelName:
            return (name, params, ids)
        else:
            return None

    Pipeline(
        RateControlledFileReader(channelsConfFile,
                                 readmode="lines",
                                 rate=1000,
                                 chunksize=1),
        ParseChannelsConf(),
        PureTransformer(chooseChannelName),
        Graphline(Router=TwoWaySplitter(),
                  DVBReceiver=Carousel(
                      lambda (_, (freq, params), __): Tuner(freq, params)),
                  PidReq=PureTransformer(lambda (n, (f, p), pids): (
                      "ADD", [pids["audio_pid"], pids["video_pid"]])),
                  linkages={
                      ("", "inbox"): ("Router", "inbox"),
                      ("Router", "outbox"): ("DVBReceiver", "next"),
                      ("Router", "outbox2"): ("PidReq", "inbox"),
                      ("PidReq", "outbox"): ("DVBReceiver", "inbox"),
                      ("DVBReceiver", "outbox"): ("", "outbox"),
                  }),
Esempio n. 4
0
    from Kamaelia.Internet.TCPClient import TCPClient
    from Kamaelia.File.Reading import RateControlledFileReader
    from Kamaelia.Audio.Codec.PyMedia.Decoder import Decoder
    from Kamaelia.Audio.PyMedia.Resample import Resample

    import sys
    try:
        if "--help" in sys.argv:
            sys.stderr.write("Usage:\n    ./MP3Player filename host port\n\n")
            sys.exit(0)
        filename = sys.argv[1]
        rhost = sys.argv[2]
        rport = int(sys.argv[3])
    except:
        sys.stderr.write("Usage:\n    ./MP3Player filename host port\n\n")
        sys.exit(1)

#    rhost = "127.0.0.1"
#    rport=1500

    Pipeline(
        RateControlledFileReader(filename, readmode="bytes", rate=160*1024/8,chunksize=1024),
        Decoder("mp3"),
        Resample(sample_rate=44100, channels=2,
                 to_sample_rate=8000, to_channels=1),
        SpeexEncode(3),
        Entuple(prefix=["SOUND"],postfix=[]),
        tokenlists_to_lines(),
        TCPClient(host=rhost,port=rport),
    ).run()
    
Esempio n. 5
0
    from Kamaelia.File.Writing import SimpleFileWriter
    
    TS_FILE = "/home/matteh/dvb/2008-05-16 11.27.13 MUX1_EIT_TOT_TDT.ts"
    
#    def AddInVersion():
#        def transf(x):
#            x["version"] = 0
#            return x
#        return PureTransformer(transf)
    
    print "run a diff over the two output files to compare the results"
    
    splitter=PlugSplitter()
    
    Pipeline(
        RateControlledFileReader(TS_FILE, readmode="bytes", rate=1000*1000, chunksize=188),
        DVB_SoftDemuxer( {0x12:["outbox"]} ),
        ReassemblePSITables(),
        ParseEventInformationTable_Subset( \
            actual_presentFollowing = True,
            other_presentFollowing = True,
            actual_schedule = True,
            other_schedule = True,
            ),
        splitter
    ).activate()
    
    Plug(splitter, Pipeline(
        PrettifyEventInformationTable(),
        SimpleFileWriter("original_eit_parsed.text"),
    )).activate()
Esempio n. 6
0
# (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 Audio.PyMedia.Output import Output

from Kamaelia.File.Reading import RateControlledFileReader

from Kamaelia.Chassis.Pipeline import Pipeline

Pipeline(
    RateControlledFileReader("/home/matteh/music/Radiohead - Creep.wav",
                             readmode="bytes",
                             rate=44100 * 2 * 2,
                             chunksize=1024),
    Output(sample_rate=44100, channels=2, format="S16_LE"),
).run()
Esempio n. 7
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 Kamaelia.Chassis.Pipeline import Pipeline

from Kamaelia.Internet.Multicast_transceiver import Multicast_transceiver
from Kamaelia.Protocol.SimpleReliableMulticast import SRM_Sender
from Kamaelia.Protocol.Packetise import MaxSizePacketiser
from Kamaelia.File.Reading import RateControlledFileReader

path = "/home/jlei/Kamaelia/files/finite.mp3"
ip = "224.0.0.1"

Pipeline(
    RateControlledFileReader(path, readmode="bytes", rate=128000 / 8),
    SRM_Sender(),
    MaxSizePacketiser(),
    Multicast_transceiver("0.0.0.0", 0, ip, 1600),
).run()

#This comment added is useless.
Esempio n. 8
0
            yield _
    
    
    def write_frame(self, frame):
        """\
        Generator.
        
        Writes out YUV4MPEG format frame marker and data.
        """
        for _ in self.sendoutbox("FRAME\x0a"):
            yield _
        for component in frame['yuv']:
            for _ in self.sendoutbox(component):
                yield _


__kamaelia_components__  = ( YUV4MPEGToFrame, FrameToYUV4MPEG, )


if __name__ == "__main__":
    from Kamaelia.Chassis.Pipeline import Pipeline
    from Kamaelia.File.Reading import RateControlledFileReader
    from Kamaelia.UI.Pygame.VideoOverlay import VideoOverlay
    
    Pipeline( RateControlledFileReader("/data/stream.yuv",readmode="bytes",rate=25*(608256+128)),
              YUV4MPEGToFrame(),
              FrameToYUV4MPEG(),
              YUV4MPEGToFrame(),
              VideoOverlay(),
            ).run()
Esempio n. 9
0
            for box in outboxes.keys():
                self.postoffice.deregisterlinkage(thelinkage=linkages[box])
                self.deleteOutbox(outboxes[box])

            del self.actors[actorName]

    def exeuntAll(self, includingNarrator=False):
        self.send("EXIT ALL...\n", "outbox")
        for actor in self.actors.keys():
            if includingNarrator or actor != "NARRATOR":
                for retval in self.exeunt(actor):
                    yield retval


if __name__ == "__main__":
    from Kamaelia.Util.PipelineComponent import pipeline
    from Kamaelia.File.Reading import RateControlledFileReader
    from Kamaelia.Util.ConsoleEcho import consoleEchoer

    pipeline(
        RateControlledFileReader("../CE/twelfthnight.txt",
                                 readmode="lines",
                                 rate=50,
                                 chunksize=1),
        demodulation(),
        error_correction(),
        demultiplexing(),
        director("127.0.0.1", "#theglobe"),
        consoleEchoer(),
    ).run()
Esempio n. 10
0
                         ("", "inbox"): ("splitter", "inbox"),
                         ("", "control"): ("splitter", "control"),
                         ("splitter", "outbox"): ("", "outbox"),
                         ("splitter", "signal"): ("", "signal")
                     },
                     **plugs)


#Pipeline( FormattedProfiler(10.0, 1.0),
#          ConsoleEchoer(),
#        ).activate()

Pipeline(
    RateControlledFileReader(TS_FILE,
                             "bytes",
                             rate=2500000,
                             chunksize=188,
                             allowchunkaggregation=True),
    #          Tee(
    #              Pipeline( DVB_SoftDemuxer({0x14 : ["outbox"]}),
    #                        ReassemblePSITables(),
    #                        ParseTimeAndDateTable(),
    #                        PrettifyTimeAndDateTable(),
    #                        ConsoleEchoer(),
    #                      ),
    #          ),
    DVB_SoftDemuxer({0x12: ["outbox"]}),
    ReassemblePSITables(),
    ParseEventInformationTable_Subset(actual_presentFollowing=True),
    PrettifyEventInformationTable(),
    ConsoleEchoer()).run()
Esempio n. 11
0
 def rfa_factory(_):
     return RateControlledFileReader("junction.ts",
                                     readmode="bytes",
                                     rate=18000000 / 8,
                                     chunksize=2048)
Esempio n. 12
0
 def create_xml_parser(self):
     return Pipeline(RateControlledFileReader(self._fileName),
                     SimpleXMLParser())
Esempio n. 13
0
                        edit["right"] = int(attrs["x2"])
                        edit["bottom"] = int(attrs["y2"])

                    elif self.ifIs("chars"):
                        pass
                #assert( contains["start","end","left","top","right","bottom"], edit)
                yield edit

            elif self.ifIs("/element", "EDL"):
                return

    def ifIs(self, *args):
        return self.token[:len(args)] == args


if __name__ == "__main__":
    from Kamaelia.Chassis.Pipeline import Pipeline
    from Kamaelia.Chassis.Graphline import Graphline
    from Kamaelia.Util.Console import ConsoleEchoer
    from XMLParser import XMLParser

    from Kamaelia.File.Reading import RateControlledFileReader

    Pipeline(
        RateControlledFileReader("TestEDL.xml", readmode="lines",
                                 rate=1000000),
        XMLParser(),
        EDLParser(),
        ConsoleEchoer(),
    ).run()