def Logger(): return Graphline(irc = SimpleIRCClientPrefab(host="irc.freenode.net", nick="jinnaslogbot", \ defaultChannel=channel), formatter = IRCFormatter("jinnaslogbot", channel), log = SimpleFileWriter("%s%i.log" % (channel[1:], time.time())), info = SimpleFileWriter("%s%i.info" % (channel[1:], time.time())), linkages = {("irc" , "outbox") : ("formatter", "inbox"), ("irc", "signal") : ("formatter", "control"), ("formatter", "outbox") : ("log", "inbox"), ("formatter", "system") : ("info", "inbox"), ("formatter", "signal") : ("log", "control"), ("log", "signal") : ("info", "control"), } )
def HTTPDataStreamingClient(fullurl, method="GET", body=None, headers={}, username=None, password=None, proxy=None): # NOTE: username not supported yet # NOTE: password not supported yet headers = dict(headers) proto, host, port, path = parse_url(fullurl) if username is not None and password is not None: (header_field, header_value) = http_basic_auth_header(username, password) headers[header_field] = header_value if proxy != None: request = fullurl _, req_host , req_port, _ = parse_url(proxy) else: request = path req_host , req_port = host, port return Pipeline( HTTPClientRequest(url=request, host=host, method=method, postbody=body, headers=headers), TCPClient(req_host, req_port, wait_for_serverclose=True), HTTPClientResponseHandler(suppress_header = True), ) # Leaving this here for a little while, since it is interesting/useful # Worth bearing in mind this next line will never execute return Pipeline( HTTPClientRequest(url=request, host=host, method=method, postbody=body, headers=headers), ComponentBoxTracer( TCPClient(req_host, req_port, wait_for_serverclose=True), Pipeline( PureFilter(lambda x: x[0] == "outbox"), # Only interested in data from the connection PureTransformer(lambda x: x[1]), # Just want the data from the wire PureTransformer(lambda x: base64.b64encode(x)+"\n"), # To ensure we capture data as chunked on the way in SimpleFileWriter("tweets.b64.txt"), # Capture for replay / debug ), ), ComponentBoxTracer( HTTPClientResponseHandler(suppress_header = True), Pipeline( PureFilter(lambda x: x[0] == "outbox"), # Only want the processed data here PureTransformer(lambda x: x[1]), # Only want the raw data SimpleFileWriter("tweets.raw.txt"), ), ) )
def recordForMe(channel, programme, filename): return \ Pipeline( SubscribeTo("nowEvents"), ProgrammeDetector( channel_name=channel, programme_name=programme, fromChannelLookup="LookupChannelName"), ControllableRecorder( channel_name=channel, fromDemuxer="DEMUXER", fromPSI="PSI_Tables", fromChannelLookup="LookupChannelName"), SimpleFileWriter(filename), )
def LoggerWriter(filename): """ puts an html header in front of every file it opens. Does not make well- formed HTML, as files are closed without closing the HTML tags. However, most browsers don't have a problem with this. =D """ htmlhead = "<html><body><table>\n" if not os.path.exists(filename): f = open(filename, "wb") f.write(htmlhead) f.close() return SimpleFileWriter(filename, mode='ab')
def WriteToFiles(): """\ Prefab. Takes in audio and video frames and writes them as a single YUV4MPEG2 and WAV files ("test.yuv" and "test.wav"). Used for testing Inboxes: - "inbox" -- NOT USED - "control" -- Shutdown signalling - "video" -- Video frames to be saved - "audio" -- Auio frames to be saved Outboxes: - "outbox" -- NOT USED - "signal" -- Shutdown signalling """ return Graphline( \ VIDEO = FrameToYUV4MPEG(), AUDIO = WAVWriter(2, "S16_LE", 48000), TEST = SimpleFileWriter("test.yuv"), TESTA = SimpleFileWriter("test.wav"), linkages = { ("","video") : ("VIDEO","inbox"), ("VIDEO","outbox") : ("TEST","inbox"), ("","audio") : ("AUDIO", "inbox"), ("AUDIO","outbox") : ("TESTA","inbox"), ("","control") : ("VIDEO","control"), ("VIDEO","signal") : ("AUDIO","control"), ("AUDIO","signal") : ("TEST", "control"), ("TEST", "signal") : ("TESTA", "control"), ("TESTA", "signal") : ("", "signal"), }, )
def AudioSplitterByFrames(framerate, channels, sample_rate, sample_format, tmpFilePath, edlfile): """\ Prefab. Saves raw audio data in the specified (chanels,sample_rate,sample_format) format sent to the "inbox" inbox into the specified temp directory. Chunks the audio into frames, as per the specified frame-rate. Only saves those frames actually referenced in the EDL file. Frames are saved in individual files in WAV format. They are named sequentially "00000001.wav", "00000002.wav", "00000003.wav", etc - being assigned frame numbers as they arrive, starting at 1. Arguments: - frame_rate -- the frame rate to chunk the audio into for saving - channels -- number of channels in the audio data - sample_rate -- sample rate of the audio data - sample_format -- sample format of the audio data - tmpFilePath -- temp directory into which frames should be saved - edlfile -- full filepathname of the EDL xml file Inboxes: - "inbox" -- raw audio data - "control" -- Shutdown signalling Outboxes: - "outbox" -- NOT USED - "signal" -- Shutdown signalling """ from Kamaelia.Support.PyMedia.AudioFormats import format2BytesPerSample quantasize = format2BytesPerSample[sample_format] * channels audioByteRate = quantasize * sample_rate return Pipeline( 10, RateChunker(datarate=audioByteRate, quantasize=quantasize, chunkrate=framerate), 1, TagWithSequenceNumber(), 1, FilterForWantedFrameNumbers(edlfile), 1, InboxControlledCarousel( lambda (framenum, audiochunk) : \ Pipeline( 1, OneShot(audiochunk), 1, WAVWriter(channels,sample_format,sample_rate), 1, SimpleFileWriter(tmpFilePath+("%08d.wav" % framenum)), ), boxsize=1, ), )
def SaveVideoFrames(tmpFilePath,edlfile): """\ Prefab. Saves video frames sent to the "inbox" inbox into the specified temp directory. Only saves those frames actually referenced in the EDL file. Frames are saved in individual files in YUV4MPEG2 format. They are named sequentially "00000001.yuv", "00000002.yuv", "00000003.yuv", etc - being assigned frame numbers as they arrive, starting at 1. Arguments: - tmpFilePath -- temp directory into which frames should be saved - edlfile -- full filepathname of the EDL xml file Inboxes: - "inbox" -- video frames to be saved - "control" -- Shutdown signalling Outboxes: - "outbox" -- NOT USED - "signal" -- Shutdown signalling """ return \ Pipeline( 1, TagWithSequenceNumber(), 1, FilterForWantedFrameNumbers(edlfile), 1, InboxControlledCarousel( lambda (framenum, frame) : \ Pipeline( OneShot(frame), 1, FrameToYUV4MPEG(), 1, SimpleFileWriter(tmpFilePath+("%08d.yuv" % framenum)), ), boxsize=1, ), )
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()
i = argv.index("-"+f) args[flag] = True del argv[i] except ValueError: args[flag] = False rest = [a for a in argv if len(argv)>0 and a[0] != "-"] args["__anon__"] = rest return args if __name__ == "__main__": from Kamaelia.File.Writing import SimpleFileWriter from Kamaelia.Chassis.Pipeline import Pipeline import sys args = parseargs( sys.argv[1:], { ("f", "file" ): "audio.raw", ("c", "channels"): 2, ("r", "rate"): 44100, }, [("h","help")], ) print repr(args) Pipeline( AlsaRecorder(channels=args["channels"],rate=args["rate"]), SimpleFileWriter(args["file"]) ).run()
# for timeshifting. # from Kamaelia.Device.DVB.Core import DVB_Multiplex from Kamaelia.Chassis.Pipeline import Pipeline from Kamaelia.File.Writing import SimpleFileWriter import dvb3 #freq = 505.833330 # 529.833330 # 505.833330 feparams = { "inversion": dvb3.frontend.INVERSION_AUTO, "constellation": dvb3.frontend.QAM_16, "coderate_HP": dvb3.frontend.FEC_3_4, "coderate_LP": dvb3.frontend.FEC_3_4, } freq = 754.166670 #feparams = { # "inversion" : dvb3.frontend.INVERSION_AUTO, # "constellation" : dvb3.frontend.QAM_16, # "coderate_HP" : dvb3.frontend.FEC_3_4, # "coderate_LP" : dvb3.frontend.FEC_3_4, #} # SOURCE=DVB_Multiplex(freq, pids["BBC TWO"]+pids["EIT"], feparams), # BBC Channels + EIT dat Pipeline( DVB_Multiplex(freq, [600, 601], feparams), # BBC ONE SimpleFileWriter("BBC_ONE.ts")).run() # RELEASE: MH, MPS
data = self.recv("inbox") size += len(data) self.send(data, "outbox") if (c % 20) == 0: t_dash = time.time() if t_dash - t > 1: print int((size / (t_dash - t)) * 8) t = t_dash size = 0 yield 1 if 1: pipeline( DVB_Multiplex(freq, [600, 601], feparams), SimpleFileWriter("somefile.ts"), ).run() if 0: pipeline( ReadFileAdaptor("somefile.ts", readsize=8000000), MaxSizePacketiser(), Multicast_transceiver("0.0.0.0", 0, "224.168.2.9", 1600), ).activate() pipeline( Multicast_transceiver("0.0.0.0", 1600, "224.168.2.9", 0), SimpleDetupler(1), SimpleFileWriter("otherfile.ts"), ).run()
for chan in chan_by_name.keys(): print("'" + chan + "'") sys.exit(0) channel = sys.argv[1] print("You want channel", channel) print("Using the following tuning info") print("") pprint.pprint(chan_by_name[channel]) print("") chan_info = chan_by_name[channel] if chan_info["apid"] + chan_info["vpid"] == 0: print( "Sorry, I can't determine the audio & video pids for that channel") sys.exit(0) X = time.localtime() str_stamp = "%d%02d%02d%02d%02d" % (X.tm_year, X.tm_mon, X.tm_mday, X.tm_hour, X.tm_min) filename = channel + "." + str_stamp + ".ts" print("Recording", channel, "to", filename) Pipeline( DVB_Multiplex(0, [chan_info["apid"], chan_info["vpid"]], chan_info["feparams"]), # BBC NEWS CHANNEL SimpleFileWriter(filename)).run()
LineFilter(eol="\r\n"), PureTransformer( lambda x: "TWEET: " + str(cjson.decode(x)) + "\n"), ConsoleEchoer(forwarder=True), ).run() if 1: Pipeline( HTTPDataStreamingClient(URL, proxy=proxy, username=username, password=password, headers=headers, method="POST", body=args), SimpleFileWriter("tweets.raw.txt"), ).run() if 0: Pipeline( HTTPClientRequest(), TCPClient("www.kamaelia.org", 80, wait_for_serverclose=True), HTTPClientResponseHandler(suppress_header=True), # LineFilter(eol="\n"), # PureTransformer(lambda x: "=="+x+"\n"), ConsoleEchoer()).run() if 0: Pipeline(HTTPClientRequest(), TCPClient("www.kamaelia.org", 80, wait_for_serverclose=True), HTTPClientResponseHandler(suppress_header=True),
# stream) not the stream itself SimpleHTTPClient(), # now use BitTorrent to download the stream itself using the # metadata retrieved from .torrent files (each has information about a # section of the stream - a section itself is typically a few MB of data) # (TorrentPatron is a BitTorrent client component) TorrentPatron(), # output the names of the chunks of the stream as soon as they and # all previous chunks have been downloaded StreamReconstructor(), # read the contents of these chunks (files) TriggeredFileReader(), ) return streamer if __name__ == '__main__': # ask the user from which website we should get the stream's metadata # e.g. "http://my.server.example.org/radioFoo/" torrentsfolder = raw_input("P2P-stream meta folder (URL): ") Pipeline( # fetch the stream using BitTorrent and HTTP - see above for details P2PStreamer(torrentsfolder), # write the stream to a file on disk SimpleFileWriter("myreconstructedstream.mp3")).run()
) if isinstance(request, TIPCMakeTorrent): self.maketorrent(request) else: print "TorrentMaker - what on earth is a " + str(type(request)) + "!?" elif self.dataReady("control"): msg = self.recv("control") if isinstance(msg, producerFinished): unfinished = False elif isinstance(msg, shutdown): return else: time.sleep(2.0) if __name__ == '__main__': from Kamaelia.Chassis.Pipeline import pipeline from Kamaelia.Util.Console import ConsoleReader, ConsoleEchoer from Kamaelia.File.Writing import SimpleFileWriter # type in a file path and have a .torrent file made for it # if you enter two file paths (i.e. two lines) you will get # two .torrent files one after the other in the same file # so don't! pipeline( ConsoleReader(">>> ", ""), TorrentMaker("http://example.com:12345/"), SimpleFileWriter("mytorrent.torrent") ).run()
"MORE4+1": ( 538, #MHz [701, 702] # PID (programme ID) for video and PID for audio ) } services = { "NEWS24": (754, [640, 641]), "MORE4+1": (810, [701, 702]), "TMF": (810, [201, 202]) } if 0: pipeline( DVB_Multiplex( 754, [640, 641, 620, 621, 622, 610, 611, 612, 600, 601, 602, 12]), SimpleFileWriter("multiplex_new.data")).run() if 1: Graphline(SOURCE=ReadFileAdaptor("multiplex.data"), DEMUX=DVB_Demuxer({ "640": "NEWS24", "641": "NEWS24", "600": "BBCONE", "601": "BBCONE", "610": "BBCTWO", "611": "BBCTWO", "620": "CBBC", "621": "CBBC", }), NEWS24=SimpleFileWriter("news24.data"), BBCONE=SimpleFileWriter("bbcone.data"), BBCTWO=SimpleFileWriter("bbctwo.data"),
# 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.Device.DVB.Core import DVB_Multiplex from Kamaelia.Chassis.Pipeline import Pipeline from Kamaelia.File.Writing import SimpleFileWriter import dvb3 feparams = { "inversion": dvb3.frontend.INVERSION_AUTO, "constellation": dvb3.frontend.QAM_16, "code_rate_HP": dvb3.frontend.FEC_3_4, "code_rate_LP": dvb3.frontend.FEC_3_4, } Pipeline( DVB_Multiplex(505.8, [640, 641], feparams), # BBC NEWS CHANNEL SimpleFileWriter("BBC_NEWS_CHANNEL.ts")).run() # RELEASE: MH, MPS
if 0: audienceout = pipeline(MatrixMixer(), SingleServer(port=mockserverport)).run() def dumping_server(): return pipeline( SingleServer(mockserverport), printer(), ) dumping_server().run() # Command line mixer control commandlineMixer = Graphline(TOKENISER=lines_to_tokenlists(), MIXER=MatrixMixer(), FILE=SimpleFileWriter("bingle.raw"), linkages={ ("USER", "outbox"): ("TOKENISER", "inbox"), ("TOKENISER", "outbox"): ("MIXER", "mixcontrol"), ("MIXER", "mixcontrolresponse"): ("USERRESPONSE", "inbox"), ("MIXER", "outbox"): ("FILE", "inbox"), }).run() # TCP Client sending audienceout = pipeline( MatrixMixer(), # SimpleFileWriter("bingle.raw"), TCPClient("127.0.0.1", mockserverport)).run()
"coderate_LP": dvb3.frontend.FEC_3_4 } print sys.argv if len(sys.argv) > 1: channels = [int(x) for x in sys.argv[1:]] else: channels = [600, 601, 18] print "RECORDING CHANNELS", channels class DieAtTime(Axon.Component.component): delay = 10 def main(self): now = time.time() while 1: if (time.time() - now) > self.delay: raise "AARRRRGGGHHH" yield 1 DieAtTime(delay=7500).activate() Pipeline( DVB_Multiplex(freq, channels, feparams), # BBC TWO SimpleFileWriter("Programme" + str(channels) + (str(time.time())) + ".ts")).run() # RELEASE: MH, MPS
# 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.Device.DVB.Core import DVB_Multiplex from Kamaelia.Chassis.Pipeline import Pipeline from Kamaelia.File.Writing import SimpleFileWriter import dvb3 freq = 505.833330 # 529.833330 # 505.833330 feparams = { "inversion": dvb3.frontend.INVERSION_AUTO, "constellation": dvb3.frontend.QAM_16, "code_rate_HP": dvb3.frontend.FEC_3_4, "code_rate_LP": dvb3.frontend.FEC_3_4, } Pipeline( # FIXME: Hmm. Need to check whether 0x2000 is supported by freecom DVB-T stick # FIXME: If it isn't need to change this to grab the pids manually, as it used to. # FIXME: Though that could be a different example... DVB_Multiplex(freq, [0x2000], feparams), # BBC Multiplex 1, whole transport stream SimpleFileWriter("BBC_MUX_1.ts"), ).run() # RELEASE: MH, MPS
# -*- 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.Pipeline import Pipeline from Kamaelia.Util.Console import ConsoleReader from Kamaelia.Protocol.HTTP.HTTPClient import SimpleHTTPClient from Kamaelia.File.Writing import SimpleFileWriter Pipeline( ConsoleReader(">>> ", ""), SimpleHTTPClient(), SimpleFileWriter("downloadedfile.txt"), ).run()
i = argv.index("-" + f) args[flag] = True del argv[i] except ValueError: args[flag] = False rest = [a for a in argv if len(argv) > 0 and a[0] != "-"] args["__anon__"] = rest return args if __name__ == "__main__": from Kamaelia.File.Writing import SimpleFileWriter from Kamaelia.Chassis.Pipeline import Pipeline import sys args = parseargs( sys.argv[1:], { ("f", "file"): "audio.raw", ("c", "channels"): 2, ("r", "rate"): 44100, }, [("h", "help")], ) print repr(args) Pipeline(AlsaRecorder(channels=args["channels"], rate=args["rate"]), SimpleFileWriter(args["file"])).run()
rport = int(sys.argv[4]) except: sys.stderr.write( "Usage:\n ./WhiteboardClerk play|record filename host port\n\n") sys.exit(1) if mode == "record": print "Recording..." pipeline( OneShot(msg=[["GETIMG"]]), tokenlists_to_lines(), TCPClient(host=rhost, port=rport), chunks_to_lines(), Timestamp(), IntersperseNewlines(), SimpleFileWriter(filename), ).run() elif mode == "play": print "Playing..." pipeline( Graphline( FILEREADER=PromptedFileReader(filename, "lines"), DETIMESTAMP=DeTimestamp(), linkages={ # data from file gets detimestamped and sent on ("FILEREADER", "outbox"): ("DETIMESTAMP", "inbox"), ("DETIMESTAMP", "outbox"): ("", "outbox"), # detimestamper asks for more data to be read from file ("DETIMESTAMP", "next"): ("FILEREADER", "inbox"),
def AppendingFileWriter(filename): """appends to instead of overwrites logs""" return SimpleFileWriter(filename, mode='ab')
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() print("Reading in test.wav and playing it back ...") Graphline(SRC=RateControlledFileReader("test.wav", readmode="bytes", rate=44100 * 4),
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"), }), SimpleFileWriter(outFileName), ).run()
'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()
ConsoleEchoer(), ).activate() Graphline( streamin=pipeline( IcecastClient("http://127.0.0.1:1234/"), # a stream's address IcecastDemux(), IcecastStreamRemoveMetadata(), Chunkifier(500000), ChunkDistributor("./"), WholeFileWriter(), TorrentMaker("http://192.168.1.5:6969/announce"), ), split=fanout(["toMetaUploader", "toSharer"]), fileupload=pipeline(ChunkDistributor("./torrents/", ".torrent"), WholeFileWriter(), PureTransformer(lambda x: x + "\n"), SimpleFileWriter("filelist.txt")), #WholeFileWriter() #HTTPMakePostRequest("http://192.168.1.15/torrentupload.php"), #SimpleHTTPClient() # uploader still to write bt=TorrentPatron(), linkages={ ("streamin", "outbox"): ("split", "inbox"), ("split", "toMetaUploader"): ("fileupload", "inbox"), ("split", "toSharer"): ("bt", "inbox"), #("split","toMetaUploader") : ("whatever","inbox"), }).run()
def capture_one(self): self.snapshot = None self.snapshot = self.camera.get_image() def main(self): self.camera.start() while 1: self.capture_one() self.send(self.snapshot, "outbox") time.sleep(self.delay) if __name__ == "__main__": from Kamaelia.Chassis.Pipeline import Pipeline from Kamaelia.File.Writing import SimpleFileWriter from Kamaelia.Codec.Dirac import DiracEncoder from Kamaelia.Video.PixFormatConversion import ToYUV420_planar from Kamaelia.Util.PureTransformer import PureTransformer Pipeline( VideoCaptureSource(), PureTransformer(lambda F : \ {"rgb" : pygame.image.tostring(F, "RGB"), "size" : (352, 288), "pixformat" : "RGB_interleaved", }), ToYUV420_planar(), DiracEncoder(preset="CIF", encParams={"num_L1":0}), SimpleFileWriter("X.drc"), ).run()
yield 1 index += 1 if index % 1 == 0: subindex += 1 self.send(str(self.fib(subindex)), "outbox") if index % 20 == 0: self.fibpattern[1].append(100 + self.fibpattern[0][-1]) self.fibpattern[0].append(self.fibpattern[1][0] - 100) while self.dataReady("control"): msg = self.recv("control") self.send(msg, "signal") self.pause() #must be woken by timer if __name__ == "__main__": from Kamaelia.File.Writing import SimpleFileWriter from Kamaelia.Util.Console import ConsoleReader from Kamaelia.Util.Pipeline import pipeline from PCMToWave import PCMToWave samplingfrequency = 44100 pipeline( CheapAndCheerfulClock(0.2), TuneGenerator(), Synthesizer(samplingfrequency), PCMToWave(2, samplingfrequency), SimpleFileWriter("tones.wav") ).run()