Exemple #1
0
def makeFileReader(filename):
    return ReadFileAdaptor(filename=filename)
Exemple #2
0
---------------------------------------
1. Add one node
ADD NODE TCPClient TCPClient auto -
ADD NODE VorbisDecode VorbisDecode auto -
2. add one link
ADD LINK TCPClient VorbisDecode
3. Delete one node/ link/ all 
DEL NODE TCPClient
ADD LINK TCPClient VorbisDecode
DEL ALL
"""

import sys

from Kamaelia.File.ReadFileAdaptor import ReadFileAdaptor
from Kamaelia.Visualisation.PhysicsGraph.lines_to_tokenlists import lines_to_tokenlists
from Kamaelia.Visualisation.PhysicsGraph.TopologyViewer import TopologyViewer
from Kamaelia.Util.Console import ConsoleEchoer
from Kamaelia.Chassis.Pipeline import Pipeline

# To see if the file name is included in the arguments
if len(sys.argv)==1:
    print "Bingo! not enough inputs: please type the file name you want to draw as well"
else:
    # ReadFileAdaptor->lines_to_tokenlists->TopologyViewer
    Pipeline(
        ReadFileAdaptor(filename=sys.argv[1], readmode="line"),
        lines_to_tokenlists(),
        TopologyViewer(),
        ConsoleEchoer(),
    ).run()    
Exemple #3
0
        for node in NODES:
            self.send(node, "outbox")

        for link in LINKS:
            self.send(link, "outbox")
        yield 1
        yield 1
        self.send(self.shutdown_mess, "signal")


__kamaelia_components__ = (
    ERParser,
    ERModel2Visualiser,
)

if __name__ == "__main__":
    import sys
    import pprint
    from Kamaelia.Util.PureTransformer import PureTransformer
    from Kamaelia.Util.Console import ConsoleEchoer
    from Kamaelia.File.ReadFileAdaptor import ReadFileAdaptor
    from Kamaelia.Chassis.Pipeline import Pipeline
    Pipeline(
        ReadFileAdaptor(sys.argv[1]),
        ERParser(),
        ERModel2Visualiser(),
        #        PureTransformer(lambda x: pprint.pformat(x)+"\n"),
        #        ConsoleEchoer(),
    ).run()
Exemple #4
0
                      [ 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 1:
     Pipeline(
        DVB_Multiplex(508, [640, 641, 620, 621, 622, 610, 611, 612, 600, 601, 602, 18],feparams),
        SimpleFileWriter("multiplex_new.data")
     ).run()
 if 0:
     Graphline(
         SOURCE=ReadFileAdaptor("multiplex_new.data"),
         DEMUX=DVB_Demuxer({
             640: ["NEWS24"],
             641: ["NEWS24"],
             600: ["BBCONE"],
             601: ["BBCONE"],
             610: ["BBCTWO"],
             611: ["BBCTWO"],
             620: ["CBBC"],
             621: ["CBBC"],
             18:  ["NEWS24", "BBCONE", "BBCTWO", "CBBC"],
         }),
         NEWS24=SimpleFileWriter("news24.data"),
         BBCONE=SimpleFileWriter("bbcone.data"),
         BBCTWO=SimpleFileWriter("bbctwo.data"),
         CBBC=SimpleFileWriter("cbbc.data"),
#     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.File.ReadFileAdaptor import ReadFileAdaptor
from Kamaelia.Codec.Vorbis import VorbisDecode, AOAudioPlaybackAdaptor
from Kamaelia.Internet.Multicast_transceiver import Multicast_transceiver
from Kamaelia.Chassis.Pipeline import Pipeline
from Kamaelia.Util.Detuple import SimpleDetupler

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

# Server
Pipeline(
    ReadFileAdaptor(file_to_stream, readmode="bitrate", bitrate=400000, chunkrate=50),
    Multicast_transceiver("0.0.0.0", 0, "224.168.2.9", 1600),
).activate()

# Client
Pipeline(
    Multicast_transceiver("0.0.0.0", 1600, "224.168.2.9", 0),
    SimpleDetupler(1),
    VorbisDecode(),
    AOAudioPlaybackAdaptor(),
).run()
from Kamaelia.File.ReadFileAdaptor import ReadFileAdaptor
from Kamaelia.Codec.RawYUVFramer import RawYUVFramer
from Kamaelia.Codec.Dirac import DiracEncoder, DiracDecoder
from Kamaelia.UI.Pygame.VideoOverlay import VideoOverlay

# Download and build dirac first!
#
# Get the source raw video file (in rgb format) from here, and gunzip it:
# http://sourceforge.net/project/showfiles.php?group_id=102564&package_id=119507
#
# To convert RGB to YUV:
#   RGBtoYUV420 snowboard-jum-352x288x75.rgb snowboard-jum-352x288x75.yuv 352 288 75
#
# Alternatively, source your own AVI file and convert with:
#   ffmpeg -i file_from_digital_camera.avi rawvideo.yuv
#
# and alter the config below as required.

FILENAME = "/data/dirac-video/snowboard-jum-352x288x75.yuv"
SIZE = (352, 288)
DIRACPRESET = "CIF"  # dirac resolution and encoder settings preset

# encoder param sets it to iframe only (no motion based coding, faster)
# (overrides preset)
ENCPARAMS = {"num_L1": 0}

Pipeline(ReadFileAdaptor(FILENAME, readmode="bitrate", bitrate=1000000),
         RawYUVFramer(size=SIZE),
         DiracEncoder(preset=DIRACPRESET, encParams=ENCPARAMS), DiracDecoder(),
         VideoOverlay()).run()
from Kamaelia.Codec.Dirac import DiracDecoder
from Kamaelia.File.ReadFileAdaptor import ReadFileAdaptor
from Kamaelia.Util.RateFilter import MessageRateLimit
from Kamaelia.UI.Pygame.VideoOverlay import VideoOverlay
from Kamaelia.UI.Pygame.Button import Button
from TwoWaySplitter import TwoWaySplitter

from VideoSurface import VideoSurface
from PixFormatConversion import ToRGB_interleaved

file = "../../../Code/Python/Kamaelia/Examples/VideoCodecs/Dirac/snowboard-jum-352x288x75.dirac.drc"
framerate = 1

Button(caption="<---overlay", position=(400, 10)).activate()
Button(caption="<---surface", position=(400, 310)).activate()

Graphline(SOURCE=Pipeline(
    ReadFileAdaptor(file, readmode="bitrate", bitrate=300000 * 8 / 5),
    DiracDecoder(),
    MessageRateLimit(framerate, buffer=15),
),
          SPLIT=TwoWaySplitter(),
          OVERLAY=VideoOverlay(),
          SURFACE=Pipeline(ToRGB_interleaved(),
                           VideoSurface(position=(0, 300))),
          linkages={
              ("SOURCE", "outbox"): ("SPLIT", "inbox"),
              ("SPLIT", "outbox"): ("OVERLAY", "inbox"),
              ("SPLIT", "outbox2"): ("SURFACE", "inbox"),
          }).run()
#     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_Demuxer
from Kamaelia.File.ReadFileAdaptor import ReadFileAdaptor
from Kamaelia.Chassis.Graphline import Graphline
from Kamaelia.File.Writing import SimpleFileWriter

Graphline(
    SOURCE=ReadFileAdaptor("BBC_MUX_1.ts"),
    DEMUX=DVB_Demuxer({
        640: ["NEWS24"],
        641: ["NEWS24"],
        600: ["BBCONE"],
        601: ["BBCONE"],
        610: ["BBCTWO"],
        611: ["BBCTWO"],
        620: ["CBBC"],
        621: ["CBBC"],
        18: ["NEWS24", "BBCONE"],  # "BBCTWO", "CBBC"],
    }),
    NEWS24=SimpleFileWriter("news24.data"),
    BBCONE=SimpleFileWriter("bbcone.data"),
    BBCTWO=SimpleFileWriter("bbctwo.data"),
    CBBC=SimpleFileWriter("cbbc.data"),
Exemple #9
0
    from Axon.Component import component
    class NullDemuxer(component):
        def __init__(self, *args, **argsd):
            super(NullDemuxer,self).__init__()
        def main(self):
           while not self.dataReady("control") or self.dataReady("inbox"):
               while self.dataReady("inbox"):
                   self.recv("inbox")
               self.pause()
               yield 1
           self.recv("control")
    
    results = {}
    for demuxer in [NullDemuxer, DVB_Demuxer,DVB_SoftDemuxer]:
        print ("Timing "+demuxer.__name__+" ...")
        start = time.time()
        for _ in range(3):
            Graphline(
                SOURCE=ReadFileAdaptor("/home/matteh/Documents/presentations/Skylife presentation/BBC TWO DVB.ts",readmode="bitrate",bitrate=600000000000,chunkrate=600000000000/8/2048),
                DEMUX=demuxer( { 18 : ["_EIT_"], 20 : ["_DATETIME_"] } ),
                linkages={ ("SOURCE", "outbox"):("DEMUX","inbox"),
                           ("SOURCE", "signal"):("DEMUX","control"),
                         }
                ).run()
        timetaken = time.time()-start
        results[demuxer.__name__] = timetaken
        
    lowerbound = min(*results.values())
    for name in results:
        print (name, results[name]-lowerbound, "out of",results[name])
Exemple #10
0
from Kamaelia.Util.RateFilter import MessageRateLimit
from Kamaelia.File.ReadFileAdaptor import ReadFileAdaptor
from Kamaelia.Video.PixFormatConversion import ToRGB_interleaved

# override pygame display service
ogl_display = OpenGLDisplay.getDisplayService(fullscreen=True)
PygameDisplay.setDisplayService(ogl_display[0])

READER = Textbox(size=(400, 300), text_height=30).activate()
WRITER = TextDisplayer(size=(400, 300), text_height=30).activate()

SCREEN = VideoSurface().activate()

Pipeline(
    ReadFileAdaptor("../TestMaterial/TrainWindow.drc",
                    readmode="bitrate",
                    bitrate=1000000),
    DiracDecoder(),
    MessageRateLimit(10),
    ToRGB_interleaved(),
    SCREEN,
).activate()

R_ = PygameWrapper(wrap=READER, position=(-2, -2, -10),
                   rotation=(20, 10, 0)).activate()

W_ = PygameWrapper(wrap=WRITER, position=(2, 2, -10),
                   rotation=(20, 10, 0)).activate()

S_ = PygameWrapper(wrap=SCREEN, position=(-2, 2, -10),
                   rotation=(20, 10, 0)).activate()
#!/usr/bin/env python

#
# Generated with Kamaelia: Compose
# (first real app created using it :-)
#

from Kamaelia.UI.Pygame.VideoOverlay import VideoOverlay
from Kamaelia.File.ReadFileAdaptor import ReadFileAdaptor
from Kamaelia.Internet.TCPClient import TCPClient
from Kamaelia.Util.RateFilter import MessageRateLimit
from Kamaelia.Codec.Dirac import DiracDecoder
from Kamaelia.Internet.SingleServer import SingleServer
from Kamaelia.Chassis.Graphline import Graphline
Graphline(RFA1=ReadFileAdaptor(
    filename=
    "/home/michaels/Development/Projects/Kamaelia/Code/Python/Kamaelia/Examples/VideoCodecs/Dirac/snowboard-jum-352x288x75.dirac.drc",
    bitrate=400000),
          TCPC3=TCPClient(host="127.0.0.1", port=1500),
          SS2=SingleServer(port=1500),
          MRL5=MessageRateLimit(messages_per_second=15, buffer=15),
          DD4=DiracDecoder(),
          VO6=VideoOverlay(),
          linkages={
              ('RFA1', 'outbox'): ('SS2', 'inbox'),
              ('TCPC3', 'outbox'): ('DD4', 'inbox'),
              ('DD4', 'outbox'): ('MRL5', 'inbox'),
              ('MRL5', 'outbox'): ('VO6', 'inbox'),
          }).run()