Java’s Achilles heel
Many aspects of the Java platform have improved tremendously over the past years. Sun has always focused a lot of energy around improving “business” features. Hopefully, they’ve recently diverted their focus on Desktop issues. In this regard, they’ve adressed performance (Hotspot compiler, refreshed OpenGL / DirectX based Java 2D pipelines), data binding (JSR-295), Swing Application Framework (JSR-296), new look-and-feel (Nimbus) etc… One area where most developers agree that Java is still lagging behind the hip / trendy frameworks (Flex, AIR, .NET 3.0, Silverlight…) is definitely video !
The way I see it, Java’s main advantage is the overall consistency and cleanliness of its APIs, which makes it an ideal academic language and encourages high quality object-oriented designs. After all, it’s not about the programming language itself… even though I generally find Java source code sexier than other languages.
Last summer, when I started working on the mini multitouch table project, I got up to speed with the state of video in Java. I realized that the Java Media Framework hasn’t been updated in ages and its APIs feel pretty old by today’s standards. On the Mac OS X platform, Apple willingly dropped support of the Quicktime for Java bindings, which currently forces Java developers to rely on very very old Quicktime interfaces, that do not benefit from the major Quicktime overhaul made in Tiger (10.4). I’m refering to full access to the features of newer codecs (H.264) and high performance capture interfaces (QTKit).
A few days ago, I attended a couple of the final project (projet synthèse) presentations by students of my university. A friend of mine, François Caron, presented his implementation of an error correcting codec for live H.264 broadcasting (such as live TV feed or mobile videoconferencing). Let me point out that it is a lot more challenging to do error correction in these contexts as you don’t have access to pixels in next frames when correcting the current frame…. unless you buffer the data, which is totally unacceptable for videoconferencing. François implemented a new optional feature available for RTP packets (RFC3984) which allows to specify the decoding order of the macroblocks (top-to-bottom order VS checkered pattern). The benefit is that if, for instance 50% of RTP packets are dropped (or delayed) you still have a lot more chance to have a nicely scattered set of pixels in the buffer. This allows you to apply bilinear interpolation between the macroblocks of the checkered pattern for spatial error correction. Also this increases chances to have more good pixels from previous frames when doing temporal error correction. As I’ve always wanted to experiment more with H.264 in general, I started looking for alternatives to JMF.
FFMpeg, GStreamer and VLC are pretty much de facto open source libraries for C/C++ video development. I was pleased to see that all of them have wrappers for Java: JVLC, FMJ/FFMpeg, GStreamer-Java. The level of support and quality of most of these abstraction is pretty crappy though….
Obviously there is still a lot of work to do and I hope that Sun and Apple will sort this out soon (hint: Java One 2008 is in two weeks). In the meantime, I’ll have to resume learning Objective C and refresh my C++… in any case it’ll be useful to do some more useful iPhone SDK hacking.