Archive for the ‘Gnome’ Category

Extending Clutter-Box2d

Monday, May 7th, 2012

The following is a block diagram of ClutterBox2dmm. It’s at a high level of abstraction, so most of the detail is lost. What’s of interest is that Cluttermm is stacked on top of Clutter and that there exists a Clutter-Box2d.

Clutter is the graphics library I use for first year C++. I’ll explain why some day. The Clutter library is written in C. Cluttermm contains the C++ bindings for Clutter. Therefore we can use the awesome accelerated graphics of Clutter in C++. Clutter also has a related library called Clutter-Box2d. The Clutter-Box2d library contains C bindings for the upstream (and awesome) Box2D C++ library. Box2D is used in many places including, I believe, in Angry Birds. Box2D has also been cloned in many languages such as JavaScript. On top of Clutter-Box2d, I mantain Clutter-Box2dmm which are C++ bindings to Clutter-Box2d (yes, C++ bindings to C bindings for a C++ library….but it does make sense).

I’ve just extended both Clutter-box2d and Clutter-box2dmm to support the IsFixedRotation() functionality in Box2d. This hack isn’t hard. It does require modifying the C library Clutter-Box2d and then modifginy the C++ library Clutter-Box2dmm on top of this. The relevent commits are here and here. If you need this feature in Clutter-box2dmm you currently have to compile from source. Get it whilst it’s hot.

Clutter-box2dmm bindings updated to 0.12.1

Thursday, February 2nd, 2012

I submitted a patch to Gnome bugzilla last night that updates the clutter-box2d C++ bindings so that they build against the current git master version of clutter-box2d. The patch is a little of a mess. However, this morning, I think the patch is a little less of a mess than I thought last night. Mainly because I managed to do the following on the train into work

Simply build one of the examples in the clutter-box2dmm folder.

I now have Fedora 15 & 16 packages for cluttermm, clutter-box2d and will have clutter-box2dmm later today. I’ll push these clutter-box2d* packages upstream to Fedora later, but I won’t hold my breath to see them approved. The approval process is a little unwieldy.

Pipelines for visual programming languages

Tuesday, November 1st, 2011

As a long time Unix user I’ve always found pilelines to be very useful. They allow you to build up extremely complex functions by sticking together much less complex parts. On Linux we put together commands and pipe the output into the next command. If you ask the question “How many mp3 files are there in this directory?” you can say “Ah, I know how to list all mp3 files, and I know how to count the number of lines in a list” then the answer becomes

$ ls -l *.mp3 | wc --lines

Pipelines can become arbitrarily complex. For example, the pipeline

$ cat /var/log/maillog | grep "status=sent" | grep -v phoric | wc --lines

counts the number of lines in my maillog that contain the text “status=sent” and omit the text “phoric” (my hostname). There is usually someone smart enough to write a shorter pipeline than what you’ve written, but that’s not the point. The point is that pipelines allow us to construct complex functionality by chaining together small programs.

If I were an academic (and I am), I’d probably generalise. I’d say somthing like, “pipelines have a source, they have many filter and translate actions and finally an action”. This, I believe, is a reasonable generalisation. In a pipeline, we often take some data, strip out the bits we don’t need, translate it into another format, maybe filter some more stuff and then finally do something. Such processes can be (relatively) easily turned into a visual programming language. The web application if this, then that is a simple visual programming language. Apple’s Automator is a more general visual programming language for such pipelines on OS X. And, going back to text-based pipelines, Window’s Powershell does away with much of the faffing about with text processing found in a Unix pipeline (by encapsulating the faffing in objects)

Get-ChildItem C:\Scripts | Where-Object {$_.Length -gt 200KB} | Sort-Object Length

The powershell example is stolen from technet.microsoft.com.

Let’s say I have an application area in mind. It’s a technical area with highly complex theory such that we can expect the individual components of our pipeline to contain complex functionality. Lets take the world of audio and video processing. The words are technical, we can expect to mux (i.e. multiplex) and demux audio. And we can also expect to transcode it. Decoding, say, a flac stream and re-encoding it as a vorbis stream requires complex algorithms. Furthermore, the language is generally well understood by geeks, like you. So, how do I do exactly that. Open a flac file, decode it, re-encode it as a vorbis stream and save it to a file. Fortunatly, a pipeline based toolset for audio (and video) already exists. We’re going to look at GStreamer. It’s effectively a domain-specific programming language that could be easily implemented as a visual programming language (it previously has been, but the visual side wasn’t of use to anyone who could actually understand the domain). We want to look at how GStreamer makes constructing complex pipelines easy.

The following pipeline is the start of an answer our problem (it intentionally doesn’t work):

$ gst-launch filesrc location=song.flac ! flacdec ! vorbisenc ! filesink location=song.ogg

In the above example we construct the pipeline, where ! is the pipe symbol and launch it with gst-launch. Each of the pipeline elements, on their own, are simple to understand. A filesrc element reads a file at the specified location. A flacdec element decodes a flac stream. A vorbisenc element encodes something in to vorbis and a filesink element stores a stream back into a file. The above pipeline produces the error

WARNING: erroneous pipeline: could not link flacdec0 to vorbisenc0

This is brilliant. A major difference between a GStreamer pipeline and a Unix pipeline is that I get static checking. It can tell me, from the structure of the pipeline, whether the type of data produced by each element, can be consumed by the following element. This is brilliant because it saves time.

Imagine that my pipeline was much more complicated. Imagine that the pipeline encoded a long, high-quality, video (taking several hours) and then tried to do something specific with the audio stream. As a Unix pipeline it would look like

$ cat video.raw | encodevid | modifyaudio > video.webm

We would have to run this pipeline before we saw passing of data from encodevid to decodevid failed. So having some static checking a-priori (I’m an acadmeic, I’m allowed to use Latin) could save us a lot of time. Static checking, like in a programming language, also ensures that we are passing the right data into an element that handles that data.

Ok, so what’s a working pipeline for the above question?

$ gst-launch filesrc location=song.flac ! flacdec ! audioconvert ! audioresample ! vorbisenc ! oggmux ! filesink location=song.ogg

Note: there’s a much shorter pipeline, but this one makes most of the stages explicit. I was missing the audioconvert, the audioresample and the filesink steps. Once again, this is a very complex domain. Each of the elements in this pipeline are more simple to understand than the entire pipeline.

Let’s do something magic. Take the original flac file, convert it to 8-bit audio and re-encode it as a vorbis stream in an ogg container. Why? Well this is the point of pipelines. Someone might want to do this sometime. The pipeline architecture allows you to combine elements in ways that other people may not have considered, or simply don’t need.

$ gst-launch filesrc location=song.flac ! flacdec ! audioconvert ! audioresample ! capsfilter caps=audio/x-raw-int,channels=2,width=8,depth=8 ! audioconvert ! vorbisenc ! oggmux ! filesink location=song.ogg

I think that GStreamer is a well desiged, well implemented pipeline architecture for a complex domain. So how does it achieve what it does?

Each of the elements in GStreamer advertises its capabilities. Each element advertises the capabilities of what it accepts (eg: raw audio with sample freq > 8hHz and < 44kHz) and the capabilities of what it produces (eg: audio bit stream conforming to the vorbis spec). You can then do static checking on pipelines by ensuring the capabilities of what is produced by one element are a subset of those consumed by the following element. It's very neat.

How might you retrofit this into an existing set of complex Unix applications? You could add a --caps flag (or -caps if you insist on BSD style) to each of your applications. If you have no source, wrap them in a shell script that takes --caps. Make the caps option outupt the input and output capabilities of your pipeline elements. Bonus hipster points if this is outputted in JSON. Then write a my_static_checker that takes your pipeline as a string, checks it statically a-la-GStreamer (I’m allowed to abuse French, I’m an academic) and then executes the pipeline.

Why! Now we’re in a position to write a very domain-specific visual programming language. This could be useful in a lot of cases. Particularly in the case of at least one person I’ll be emailing this to.

Recording presentations

Monday, September 26th, 2011

I have had a need to record lecture presentations. To this end I’ve hacked up some software which (a) takes a feed from a webcam, and (b) takes a PDF/ODF presentation and combines them into a WebM file.

For the code:

git clone git://gitorious.org/lecturec/lecturec.git

A simple overview:

A tough Q1 for open-source

Friday, March 25th, 2011

You can feel the recession biting. It seems to have encouraged several companies to evaluate their open-source strategy. Actually, maybe that reasoning is a little too shallow. There are some deeper reasons we’ve seen Nokia, Google and RedHat change some of their practices. But let’s be clear from the start; some companies, like Nokia, have changed their whole strategy. Others, like RedHat, have made little corrections to their general practice. Nokia made their strategic decision based on failure and RedHat made their practice change due to success.

The Nokia thing. They’ve executed an entire U-turn on their open-source strategy. At a high-level their previous strategy seemed to be (as an external observer) to use their excellent QT toolkit to develop applications for their newly open-sourced Symbian platform for low to mid-range mobiles. Furthermore, they’d use the same toolkit to develop for their next-gen Meego platform. However, for reasons to do with both business and technology, they’ve decided that Windows Phone 7 is to be their next-gen platform of choice. Thankfully, the open-source nature of Meego means that we don’t loose the innovation that has been already contributed to the platform.

The reasons for Nokia’s change have been extensively covered in the computing press. My take is that the major consequence of this is an observation that all of our next-gen mobile platform providers are non-European (yes I’m discounting Symbian). So Android is from Google, WP7 from Microsoft, WebOS from HP and Blackberry from RIM. The first three are US companies, the last is Canadian. This, in my opinion, is a bad thing for Europe. Much of the Nokia R&D on Meego seemed to be outsourced to small to medium sized European companies. I know of at least three British companies (I have resided in the UK for a few years now) that did Meego development which was paid for by Nokia.

On Google’s Honeycomb decision. I’ve not decided yet if this is in response to

      The Chinese strawman argument, or
      Some deep-integration argument.

Maybe it’s both or neither. However, the Chinese strawman is the argument that if Honeycomb is open-source then many companies come along and produce poor-quality, but cheap, devices running the platform. Therefore, devaluing the perception of the platform. I believe that this argument is a poor one, hence I’ve called it a strawman. I don’t see how Android resellers can charge the 30% markup that one of their competitors can charge. Maybe this allows the small number of honeycomb licensees to bump up their margins slightly?

The deep integration argument is that honeycomb is bound to a specific platform like NVidia’s Tegra. Or, more interestingly, Google don’t think that you can do really high-quality UX design in an open-source fashion. There’s been a lot of talk about this lately in the open source world. About the open-source world being hostile to designers. One aspect of this has been the Canonical/Gnome argument. Where, it appears, that Canonical decided that the best way to design their next-gen desktop was to bring the design team in-house (it’s more grey than in-house -v- not in-house) whereas the Gnome team are (almost) entirely open and have even developed the fantabulous sparkle share tool for sharing designs between Gnome designers. What’s clear is that good UX design is hard. What’s unclear is whether being open-source makes good UX more difficult. I think that ThinkUp, Firefox and Gnome 3 make good design stories. For the record, I think Caonical’s Unity is interesting but doesn’t add anything to the point I’m trying to make.

I don’t know the ThinkUp people. But they seem to have a great attitude to encouraging contributions from people who might have traditionally found open-source hostile. From an external perspective, they seem to do great design in a small team and apply it to a hosted web application. Web designers are awesome. They’ve, arguably, made more design progress in the past ten years than desktop designers have made in the past thirty. Those of us who build fat (desktop) apps can then borrow their design ideas.

The Firefox devs are entirely different. It’s a massive project. They have different design constraints than ThinkUp, particularly as they have such a massive install base on so many different platforms. Furthermore, Mozilla has a lot of cash to spend on both user testing and a team of UX desigers. I like Firefox 4. I think you can see the fruits of incremental, good design.

The design community I’m most familiar with are the Gnome 3 designers. What they’ve done in the past six months is amazing. Furthermore, unlike the small integrated team at ThinkUp or the large on-site team at Mozilla, the Gnome design team is distributed (in terms of geography and companies) but well-integrated.


This picture speaks more than a paragraph of text. It shows a clean and consistent desktop. Yes there are a few unpolished edges, but the software hasn’t been released yet. What’s interesting is to observe the “traditional code geeks” talking to the UX designers. Changes to the UI or the UX are, more often than not, bounced off one of the designers. And, more interesting, is that the ideas that the UX designers communicate are being internalised by the developers. Ok, so very few of these developers will ever be kick-ass designers. However, by internalising the design ideas you can see a commitment to bringing fresh UX ideas on board and the value that the developers place on the design team. They’re highly valued and stunningly smart people.

So as usual I started off talking about how this Q1 has been tough for open-source. However my internal optimist has trumped my internal cynic. Nokia and Google may make decisions about their open-source policy, but they’re not the only places that are (or were) doing excellent open-source design and engineering. The loss of Nokia from our ecosystem will be keenly felt. But Intel are pressing forward with Meego and the design ideas that come from Meego are finding their way into Gnome 3 (and vice-versa).

Creating a Fedora 9 Pre-release boot USB key

Friday, May 2nd, 2008

I’ve got a new backup server at home. I want to boot it from a USB key or compact flash so that I may spin down the hard drives when they’re not in use. This saves me an extra 6W per disk in power consumption. Given that I want my backup server running 24/7 (and I invested in a low power mini-ITX solution) any power saving is of monetary consequence.

Update: Rahul Sundaram suggested I try using livecd-iso-to-disk. If I were to create a LiveCD using revisor, and then use livecd-iso-to-disk the process would be much easier. Thanks Rahul. The method I was using is below. And it’s missing a step, before dd’ing to the flash drive you need to rebuild the initrd to include usb-storage. Rahul’s method begins to look even better after the addition of that step. End Update.

There are many ways to create a Fedora 9 boot USB device. I tried several, but because Fedora is still in pre-release there are some issues with using tools such as revisor (I fixed all the bugs I came accross, so it’ll be ok in the release). I have the added complication that when I’m in work there’s a http proxy. This shouldn’t be an issue, but kickstart (one of the tools I used) doesn’t suport http proxies. Anyway, on to the solution.

I’m creating a USB boot disk. USB disks are good for about 100,000 write operations (or so the folk wisdom has it). They’re less reliable than hard drives so I expect to repeat my installation every year or so. Kickstart is an excellent tool which allows me to both (a) repeat the same installation multiple times, and (b) more importantly (for me in this case) provides simple documentation of what was on the system and the configuration of the install. (b) is important as I won’t remember my install configuration next year when I have to replace the USB drive.

I used the graphical “system-config-kickstart” as the root user, to create a ks.cfg file. I wanted the kickstart file on a floppt disk so I downloaded a FreeDOS floppy image. This saved me having to create a 1.44Mb formatted floppy :) I mounted the floppy image “sudo mount floppy.img -o loop /mnt” and copied the ks.cfg file to /mnt. Unmount the floppy drive.

Rather than second guess the geometry of the USB disk, I cheated. I dumped the current contents as a binary image “sudo dd if=/dev/sdb of=USB-disk.img”. It’s important to dump the entire device (generally /dev/sdb or /dev/sdc) rather than a partition on the device (/dev/sdb1). Oh, and I downloaded the Fedora 9 pre-release DVD.

So with the floppy image containing my kickstart file, the Fedora DVD and my new USB disk image I launched qemu, a virtual machine. i told qemu where the floppy disk was (-fd0 floppy.img) and where the dvd was (-cdrom Fedora-9-Preview-i386-DVD.iso) and told it that my USB disk image was the systems first hard drive (-hda USB-disk.img). Most importantly, I told qemu to use 256Mb of RAM. The default 128Mb is too little for the Fedora installer to run (note: it’s not too little to run Fedora in, if you don’t run a GUI). So use the -m 256 option.

When qemu boots the DVD and presents the GRUB bootloader screen you have to edit the boot options to include “ks=hd:fd0:/ks.cfg”. This can be done by presssing the Tab button. This magical incantation tells the Fedora installer (called anaconda) to pick up the configuration from the floppy disk in the file ks.cfg. This allows the install to complete without any manual interference by me.

When the install is finished you have a brand new Fedora install on a USB disk image. It’s then necessary to write that image to the USB key itself. This is the reverse of the above operation so “sudo dd if=USB-image.img of=/dev/sdb”. This time the input to the dd tool is the USB image and the output file is the USB device itself.

Have fun.

Issue with Revisor from Git

Sunday, April 27th, 2008

Rarely is a blog a good place to discuss a bug, however Revisor does not use the GNOME accessibility framework (yet) so I can’t submit this issue as a DogTail test.

Update: I figured out the issue after the blog post. I fixed it at 18:55. The patch was reviewed at 19:01 and thereafter applied. The power of Free Software!

Revisor, when choosing the options I want, presents 13 screens. Here is each screen just before I hit the “Forward” button

Step 1: I’m trying to make a live DVD. Actually, I just want the ISO so that I can make a live USB disk from it.
Select Media

Step 2: Build from the Fedora 9 sources

Step 3: Load no kickstart file.

Step 4: Choose only some server packages, the emacs editor (can’t live without it) and the UK language pack

Step 5: Get a nice screen detailing what you’ve just chosen and the file size of this.

Step 6: The server lives in Brighton, otherwise I’d choose English (Ireland) :)

Step 7: Nothing fancy with the bootloader plase

Step 8: A fairly standard configuration of requesting DHCP for eth0

Step 9: No fancy network authentication, simple passwd/shadow stuff please

Step 10: We don’t need no stinkin firewalls

Step 11: I didn’t select any package with an Xorg dependancy, so there’s no need to configure X

Step 12: Do as little work as possible, so I didn’t bother to fill in a user (not that this affects the bug)

Step 13: Haven’t we seen this before?

The UI always brings me back to step 5. Ad infinitum. This is with the latest Git. I created a new user with which to check out and build the source and before running “./revisor-devel.sh” (as root) I deleted the /srv/revisor and /var/tmp/revisor stuff.

Of Fedora 8 and Sony’s PS3

Friday, March 14th, 2008

Fedora 8 runs in 1080p on a PS3.

My desktop with laptop, PS3 and 1080p monitor.

There’s a picture (obviously not a screenshot) here

GNOME on a PS3.

It makes a dreadful workstation as it only has 192Mb RAM. However I’ll strip it down to bare metal with Cell development kit and a bare(ish) Xorg. It would make my job a lot easier if Sony relaxed the restrictions on Linux access to the RSX unit (the PS3′s graphics card).

My plan over summer, to get the University of Brighton games development lab up and running, is to turn the Gen1 PS3 into a server providing DHCP, LDAP authentication, NFS and Cobbler. Cobbler is particularly nice, it’s an automagic provisioning service for boxes. It should make provisioning of the 20 PS3s and associated workstations much easier. Furthermore, it’ll allow me to manage and maintain the software over time. So I may have a PS3-bare-metal config and an Intel-core-games-workstation config. It’s much more work than I want to do, but in the long run it’s easier than depending on the existing services. Essentially, to get one lab up and running I’ll have to fork most of the network services.

In the meantime I’ve to finish a paper for Diagrams 2008.

Clutter OpenSG backend

Monday, March 3rd, 2008

Neal won’t buy me more beer until I update my blog (and my laptop to Fedora). So this one, the first in a long time, is for him. The reaon for the blackout is that I’m busy at home with Lori due at the end of March, plus our mailserver has some strange internet-traffic-doubling setup which rejected my password reset email (I forgot my password).

Last week Karina, Dave and I hacked up a simple clutter backend using OpenSG. It’s not as trivial as it sounds. We first had to wrap specific OpenSG C++ calls in a state-machine C API. We wrote a C++ library which exports some useful calls as extern C.

In its current state it builds. It also builds as part of clutter. This weeks task is to (a) fork the clutter-ivan branch to clutter-osg, (b) merge our work onto clutter-osg and (c) hopefully make a window actually show something :) . As you can see, we’re going upstream, which is good. We’re becoming part of the clutter project, if only an expirimental branch for the moment.

Ubuntu 7.10 “Juice” VirtualBox image

Sunday, December 2nd, 2007

I’ve created an Ubuntu 7.10 “just enough operating system” i.e. the JeOS flavour as a VirtualBox VDI image. This is to help one of my students so the login name and password are “james”. Some caveats

  • This image is a VirtualBox image. It only works with the VirtualBox virtual machine.
  • This image is a JeOS (pronounced Juice) image. As such, it boots to a command line.

To install the GNOME desktop on this image, you should “apt-get install ubuntu-desktop” i.e. install a package called ubuntu-desktop. This will pull in a _lot_ of other packages in order to support the deskop interface. Furthermore, given the fact that I’ve used Juice, not the standard Ubuntu desktop, you may have to manually configure the “/etc/X11/xorg.conf” file in order to make the graphics work.

The image is here http://foss.it.brighton.ac.uk/downloads/Ubuntu7.10.vdi.