By the end of this project I want to be able to start a call on my laptop or my smartphone and start a conversation with whoever is standing next to R2D2, who will holographically project my likeness. That R2D2 model has yet to be built and the projector hasn't arrived yet, so I spent my first week trying to get video conferencing working on the Raspberry Pi 2. You know, baby steps.
When I say video conferencing you might immediately think of Skype, which is probably the most widely used video conferencing software. While Skype does have a Linux client, they don't distribute one that runs on ARM processors. On the Skype support forums someone mentions that the new web client at web.skype.com does work on the Raspberry Pi. Unfortunately, at the time of this writing, the Skype Web client is still in closed beta and I don't have an invitation. Whatever, I'm not particularly fond of Skype anyway.
There are a couple of open source alternatives and the ones I like best are Ekiga (formerly known as GnomeMeeting) and Linphone (part of the now-discontinued Linspire distribution). Both are SIP clients and offer free SIP accounts. Linphone wins major bonus points for having apps for both iOS and Android and for having python wrappers for the Raspberry Pi. These wrappers are featured on their home page, which links to a wiki page with documentation and an example script that is pretty close to what I want to achieve. Fantastic!
The kit we received for this challenge includes the Raspberry Pi camera board. The documentation at raspberrypi.org mentions methods for snapping stills and recording video with this camera. What I need for this project however, is something that I can use as a webcam. I spent a lot of time fiddling with something called v4l2loopback. The plan was to capture stills or a video stream with the python scripts, send those to the v4l2loopback device using gstreamer, and then access that video device with the conferencing software. It was much later that I found out that all this wasn't necessary. There already is a V4L2 kernel module for the Raspberry Pi camera and it's called bcm-2835-v4l2. Linphone's raspberry pi wiki page I mentioned earlier also makes mention of this kernel module. I wish I had found it earlier... Oh well, lesson learned.
Loading the module is really easy:
sudo modprobe bcm2835-v4l2
echo "bcm2835-v4l2" | sudo tee -a /etc/modules
If you see "ERROR: could not insert 'bcm2835_v4l2': Operation not permitted" when trying to load the module, make sure the ribbon cable is connected correctly with the blue end facing the Ethernet port.
I propped up the camera by stuffing the ribbon cable in a bank card holder
The kit also includes the Cirrus Logic Audio Card, but mine hasn't arrived yet. I was hoping to make due with a cheap USB sound adapter I already had lying around. Linux recognizes it as the Tenx Technology, Inc. TP6911 sound card. After configuring modprobe to load the snd_usb_audio driver for it, it doesn't appear to be fully supported on the Raspberry Pi and I can't get the audio input to work. If anyone knows a way of making both input and output of this thing to work on the Pi, please let me know in the comments.
The other two USB devices you see in the picture above are the Wi-Pi dongle that came in the kit and a wireless receiver for keyboard and mouse.
Closeup of the cheap Tenx Technology, Inc. TP6911 USB audio adapter
I installed iceweasel (~= Firefox, it's a long story) because the default Epiphany browser on Raspbian doesn't support WebRTC and visited vline.com to do a quick video conferencing test without involving any SIP software like Linphone. vLine generated a room and when I visited the link with my laptop, it worked!
The world's loneliest conference call.
This screenshot was taken on the Pi so the actual Pi Camera footage is in the lower right. As you can see in the top right corner, this is very demanding on the CPU. Hopefully this won't become a problem later. I'm not particularly worried about that because I have a more urgent problem right now: I can't get the camera to work anymore.
Shortly after taking the above screenshot I wiped my SD card to start from scratch, just to make sure I had all the necessary steps documented. I reinstalled Raspbian, enabled the camera in raspi-config and loaded the bcm2835-v4l2 module without errors, but the camera just won't work. I spent some time panicking and troubleshooting, trying to figure out what essential step I forgot. Then I got this clue: the raspistill and raspivid tools used to show me a full-screen camera preview. Now they show me this error:
mmal: Received unexpected camera control callback event, 0x4f525245
Judging by this thread on the Raspberry Pi forums, I'm dealing with a hardware failure. Maybe stuffing that ribbon cable in that bank card holder wasn't such a bright idea after all.