Some weeks ago, I’ve borrowed a Logitech QuickCam Pro 4000 to one of my work colleagues, to check the support on FreeBSD. It turned out that there was a driver for it in ports (multimedia/pwcbsd). So I installed it, loaded the kernel module, unplugged then replugged the webcam. Fair enough, it’s detected correctly. Now let’s have a look what we can do with that.
So multimedia/pwcbsd comes with pwcview, I’m not sure why but AFAIR it didn’t work. Ok, so I have a webcam but I can’t get anything of it. Grin. Let’s google a bit about Webcam tools. Found camorama. If I can get this to work, I won’t be able to use it to broadcast anything but at least I’ll be able to see my face and then check that the camera and the driver work correctly. Ok, so this is using v4l extensions. AFAIK, FreeBSD doesn’t support v4l but wait… I think I read that pwcbsd supported v4l ioctls. Let’s check again, yes it’s a port of Linux pwc driver, and it supports v4l, w00t. So how does it work? The pwcbsd tarball embeds a slightly modified videodev.h header file and uses it. Fair enough. So I guess I just have to copy the same exact file to camorama source directory and sed -e ’s|linux/videodev.h|videodev.h|’. Let’s write a port for it and try to compile again… Yay, compiled successfully \o/
Now try to run it. Damn, some cryptic error message about ioctl not supported. That can’t be true. Let’s go for a debugging session. So it returns ENXIO (IIRC) for VIDIOCGMBUF. But that’s a “get” function, that should just work™. Except if… the ioctl doesn’t exist, a ENXIO is returned. So I noticed the “#ifdef USE_MMAP” in pwc-v4l.c. Ok so somehow it’s not defined. And then I remember the OPTIONS config screen for multimedia/pwcbsd… Ok, let’s reinstall this again with MMAP option. Unload the kernel module, reload it, unplug the camera, re-plug it. Launch camorama. It works \o/. Ok, so now I have a webcam working, but I can’t do anything with it except seeing myself. That’s not really useful. Let’s find something to broadcast the video stream.
Note: I knew about multimedia/camserv at that time, but I just didn’t think about it…
Enter flumotion. Flumotion is a streaming media server using python, gstreamer and twisted. Cool, everything I like. So, let’s write a port, seems to be compiling and installing fine, sweet! Let’s run it. Kaboom. Some sort of error message about “import dl” not working. Let’s google for it. Nothing relevant, ok then I guess it’s you an me gstreamer-python. So there’s no dlmodule for python on amd64? Ok it doesn’t seem to be officially supported, let’s tweak the lang/python port to force the build of this module on !i386 architectures. Reinstalled the port, “import dl” in python seems to work. Cool. Let’s re-run flumotion. Ok seems to work now, but it doesn’t see my webcam! WTF?!?? What? gstreamer-plugins didn’t install the v4l plugin. Seems reasonable, FreeBSD ports don’t know v4l. Let’s hack multimedia/gstreamer-plugins now. Reinstalled the port. Re-runned flumotion. It works! That’s amazing \o/
So now I can stream the video from the webcam with a lag between 8 and 15 seconds which is ok for everything but video-conference. At that point I was stuck. I couldn’t find anything else to show my face to the world. But since it took me quite some efforts, I figured it would be good to share it with others. First I sent a mail to the FreeBSD developers list. I got an interesting answer from Julian Elischer saying he had written permission from v4l authors to use the header files as we wish and that he had some WIP in perforce for a v4l framework. Also, Warner said he’d be interested in working on this.
Some days have passed, I’ve contacted the multimedia/pwcbsd port maintainer to ask him to modify the port to not install the header file anymore, so that I could create his own port. He said it was ok with him so I’ve committed the port (multimedia/v4l_compat) few days ago. Now any app is free to use it, just BUILD_DEPENDS on it and that should be enough.
So now, the answers part. I can’t really do much work on pwc stuff anymore before I gave the webcam back (Note: I bought an iSight in the meantime, but it’s currently unusable on FreeBSD). The camorama and flumotion ports are not in the ports tree yet. The former isn’t clean enough and the latter still requires the multimedia/gstreamer-plugins modification I made (which should be committed with Gnome 2.16, Michael Johnson (ahze) said he’ll take care of this).