This morning around 2:30 AM I finally got a semi-working implementation of video4linux2 in xine-lib. Clone my hg xine-lib 1.1 repository from http://tdfischer.fedorapeople.org/xine-lib/ and have a look at src/input/input_v4l2.c. Thats one big roadblock out of the way towards getting webcam support in Phonon.
Having never hacked on xine before, the code isn’t nearly as nice as I want it to be. In fact, you’ll notice around line 215 that I magically multiply the image size by two and it suddenly works. Yay. There’s also a few other interesting bits, such as returning “v4l:/” as the media URI I’m currently playing, despite being told to play /dev/video0. This appears to be the only way to get the v4l demuxer to start demuxing my video stream. After that though, it Just Works.
So right now my plans are to get it included into xine-lib proper, which might mean porting it to the 1.2 unstable branch. In addition, it needs to be able to support more than just one format (including the MPEG streams that some capture devices use), radio devices, closed captioning, OSD output, and probably most importantly, audio. Bits of that sound to me like I’ll have to write a better demuxer, specific to v4l2 to better handle things. I’ve heard demuxers are easy though.
Lastly, in reply to all the comments on my last v4l-in-phonon post, thanks for the links, but the bit about wanting to write a photobooth clone was just a handy introduction to the real goal: getting webcams in phonon. I don’t really think its possible to simply ‘drop in’ one of those many libraries into Phonon to make things work, as those are all C++ (both gstreamer and xine are pure C), and its the backend’s job to handle getting video from the device anyways. But the kopete library is where I started, and its how I learned how video4linux2 works, so thanks for that.