Notes from the Kamaelia talk at BBC Mashed

These are rough notes from a public event, and any errors or stupidity should be attributed to me and my poor note taking; I hope these notes are useful despite their obvious flaws, and everything should be double checked :)

Kamaelia is an awesome framework and doesn’t get anywhere near enough recognition, and I have enormous respect for the project lead Michael Sparks although we disagree on a couple of things :-)

Kamaelia at Mashed, 2008-06-21 12:20

[20 mins late :( ]

http://edit.kamaelia.org/GetMashed

/Examples/Introspection

This is a pyGame window that visualises the program! You can see the program is made is discrete individual chunks.

/Examples/VideoCodecs/SimpleDiracPlayer.py

This has a simple pipeline, like a UNIX pipe, which links together these boxes - like hardware and mashups. Whats inside a box?

It has a ConsoleReader() that takes input and pushes it to an outbox. The original concept is network servers, and things are non-blocking there, so they are here too. Note that python “yeild” is not the same as Ruby’s.

So how do you write a component?

/Examples/Sketches/

This is a Webcam exmaple: It uses pyGame for display, and starts with getting a display, getting a camera, taking images, and finally displays them. its simple and fun :)

But not massively reusable. Its just a mirroring thing, right? So then we make it a threaded component; you can see the changes from a standard python object class to a ThreadedComponent one in this file, and we separate out flipping the display; thats a global thing that we want to reuse. (You can only have one display in pyGame because its a limitation of SDL.)

To turn this component into something you can re-use, you need to have it spit the output out, instead of keeping it internally. This makes the code a lot simpler, so you just have something that captures the image and puts it into an outbox.

Now that it is a component, you can use the inbox of any other component to process that outbox; a diplayer, a video encoder - anything. So you make a displayer component, that is simplified too, although maybe won’t play nice with other concurrent components, so could be improved.

“Here’s one I made earlier.” A metaphor for components is someone in an office who needs to know something: they go and ask someone. This code goes and finds who is displaying things, and uses their outbox. This is a complex example, since it looks for other components in the system globally, and then asks them to do something.

Axon is like the Linux kernel, its the very low level stuff, and then Kamaelia is the bulk of the components itself, like GNU, that completes the system and makes it easy to do things.

/Examples/TCP_systems/SimpleStreaming

This is a TCP server instead of a GUI display. The CookBook on the wiki has great examples; the SimpleBittorrentExample page was written by non-BBC people, and its great. You can use all the components in the same system if you want.

/Examples/SimpleGraphicalApps/BouncingCat

This is a silly exmaple, with just 2 components. What happens if you bolt a webserver onto it? Well its easy, you can have a webpage to upload images and add them to the bouncing caracel - that becomes straightforward to do with Kamaelia.

So that is how you build systems and wire them together.

Kamaelia Macro

This records and transcodes what is broadcast over DTT, for future viewing. Timeshifting is perfectly legal, you just can’t redistribute the data legally. So you can build you own home ‘redux’ system easily using the Macro example. It also has a method for ‘Finding Programme Junctions’ and transcoding to any format, using a ‘pipe through’ to mencoder. If anyone can build a redux this weekend, that would be awesome; you could make it controlled via IRC easily with our IRC component, loads of fun stuff.

Kamaelia Grey

This is an email greylisting server, and this is what Michael uses personally at home, and it works very well. Greylisting works with 3 pieces of information: who they send it to, who they claim to be, and what IP they are using. If any one of them hasn’t been seen before, it asks for a SMTP resend, and most spam doesn’t resend, and if it gets a resend, it accepts it. This has eradicated Michael’s spam!

The core is GreyListServer, with a TCPserver inbox which is a Selector. Someone connects, Selector tells the TCPServer, and that opens a new GreyListServer instance. It you have a large number of connections at once, the Selector handles that with ease. The 3 main components of the greylisting core are GreylistServer, ConnectedSocketAdapter and GreyListingPolicy. These 3 things create a factory for handle new connections.

New Release

There is a new release of Kamaelia today, anyone can contribute to the Ideas page on the wiki, please do. Someone making a homebased redux system for recording everything is possible: 1Tb harddisks are now only £70 and you only need a cheap laptop worth of processing power…

Q: Repository format?

A: We use SVN. We allow people to make branches with their names, and have a ‘Sketches’ tree. The 3DFolding one is in the MH/OpenGL dir. There is a handwriting recognition component which works pretty well (StrokeRecognition.py) and a speech generation component too! And you can join these together as they are just components. GP2X with the stylus input, you could make a ‘speak and spell’ easily enough: It could say “Spell the word Cat” and then recognise the hand writing. [Someone actually made this at Mashed!]

Q: License?

A: Mozilla trilicense: MPL1.1, LGPL2.1, GPL2. Boils down to, change our stuff, share it, write your stuff, don’t have to share. Mozilla was chosen because of an explicit patent grant, in case the BBC went to patent some of these stuff. And it protects recipients of the code too.

Q: Whats the relation between redux, pandora, macro?

A: Pandora was made by some brothers; they were commissioned to make Macro for the BBC. Tom Loosemore then wanted to replace the backend; he heard Radio had a system for transcoding everything from radio for podcasts. So that needed a lot more efficiency for video. Redux was a different thing at the same time, that doesn’t transcode. But this was great for us so we could focus on the opimisation of things, such as zero copy transfer between components. So now implementing redux takes a day!

12:50 end

Creative Commons License
The Notes from the Kamaelia talk at BBC Mashed by David Crossland, except the quotations and unless otherwise expressly stated, is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.

Comments

Leave a Reply