Creating a WebRTC WOW Moment With Raspberri Pi and Node.JS

Want to WOW your friends? Show a video calling service running off your Raspberry Pi.

Raspberry Pi

I’ve been running some trainings for product managers and developers here in Israel for the past several months. All of them are focused on WebRTC and how it transforms the market.

When I first did my developer training, asking for feedback at the end of the workshop, one thing that was raised is that going over sample code and understanding it isn’t enough. What is missing is to show the simplicity. To show how easy it is to get up and running from scratch.

Call it the 0 to 100 kph of doing a hello world video calling.

With WebRTC it can be achieved just before lunch break and in record time.

What I decided doing is purchase a Raspberry Pi Starter Kit. For those who don’t know, a Raspberry Pi is a small machine (credit card size) that can run Linux. It has an ARM chip, HDMI output, 2 USB inputs, SD card input and Ethernet cable input. You can buy one to create your own home video streamer… or you can use it to teach WebRTC.

The idea was simple:

  1. Get a vinyl distribution of a Linux operating system for Raspberry Pi
  2. Install it on the SD card (which is used to boot a Raspberry Pi)
  3. In the training itself, get and install Node, get and install a sample, run the sample

For the curtsy of those who came to the training, and those who just want to understand how simple this is, here are the step-by-step instructions I came up with for myself. I decided to do this on a Windows machine (just because it is what I have during the trainings to show the presentation).

1. Things to download and install

My assumption is that your machine has an SD card reader/writer. Most laptops these days do (mine has one). You will have to have a few tools on your Windows machine to get things going:

  1. SD Formatter – to format the SD card when needed and before first use
  2. Win32 Disk Imager – to write the OS image to the SD card
  3. Nmap and Zenmap – to locate your Raspberry Pi on the network
  4. Bitvise SSH Client – or any other SSH client for Windows (not needed on Linux)

Install all of the above.

2. Get a Raspberry Pi operating system

There are several options for operating systems on a Raspberry Pi. I ended up selecting the “default” one. Go to http://www.raspberrypi.org/downloads/ and select the one you want. I chose to go with Raspbian (Debian ported to Raspberry Pi). Also called on that size Debian Wheezy. The version I used was January 2014 with the release date 2014-01-07.

3. Prepare the SD card

This step is long, so I do it prior to the training, and I do it before each and every training – just to show that I am starting from a vinyl system. Format the SD card To prepare the card, we need to format it and install the image on it: Run SDFormatter, and select Quick Format with no size adjustments.

SDFormatter

Once done, it is time to write the image into it. Write the OS image Unzip the Raspbian image file you downloaded. Mine was called 2014-01-07-wheezy-raspbian.img with a size of ~2.8Mb. Run Win32 Disk Imager, select the image file and write it to the SD card. This is going to take a few minutes.

SDWrite

4. Find your Raspberry Pi on the network

Plug the SD card into your Raspberry Pi, connect it to the power and the network with the Ethernet cable. Since I don’t usually have extra display and keyboard in these sessions, my only option to login to the Raspberry Pi is over the network. For that, I am using Zenmap in order to find out the IP address the Raspberry Pi got. Run Zenmap. Write in the target your subnet. For me, that’s 10.0.0.* Switch the profile to Quick scan Count to 10. Look at the results and search for a (Raspberry Pi Foundation) MAC address. That’s going to have the IP address of your Raspberry Pi. Here’s how it looks for me:

Zenmap in action

Now use your SSH client to login to this IP address. The default username is pi and the default password to go along with it is raspberry.

5. Install Node.js on Raspberry Pi

Logged in? Good. Node.js doesn’t come preinstalled on a Raspberry Pi, so we need it there. Googling a bit, got me to this set of instructions. What I need is:

  1. Node.js
  2. Websocket support for Node.js

Run the following from the command line of your Raspberry Pi:

The last one installs Websocket support.

6. Get your preferred WebRTC sample

For me, that would be Rob Manson’s Getting Started With WebRTC. This code is explained in detail in his book under the same name which I reviewed here already. Since this is on Github, we follow these instructions:

 7. Prepare the sample

Rob’s sample requires one additional step. The Node.js code sends a .html file to the browser, and in it, there’s an indication where the Websocket signaling need to go to. In the HTML file, that’s set to “localhost”. I had to change that value to the IP address of my Raspberry Pi. For that, just use:

Change in line 149 from “ws://localhost:1234″ to “ws//<ip-address>:1234″

8. Showoff

Start the server by calling:

Connect 2 browsers to the IP address of your Raspberry Pi at port 1234, or 2 tabs from the same browser. For this sample, you will need to connect the first browser, and then copy the URL provided on the screen to the second browser to join the session.

Why does this matter?

Before WebRTC, getting such a thing to work from source to running a demo took a day or a week.

Now it is down to 5 minutes.

If you wanted disruption, then here you have it: WebRTC is all about reducing the barrier of entry for developers.

It can’t get any simpler than this hello world sample.

Tags: , , , , , , , , , ,

Liked this post?

Share it!

Never miss a post!

Or just grab the RSS feed!

Comments

  1. I have been running proto-WebRTC app on Raspi-like device (http://blog.enthinnai.com/2011/04/28/enthinnai-running-on-a-home-server/). This app has IM and voice capability by dynamically downloading a Java applet. It does even ICE with a TRN server built in. Once Raspi was released, the app was moved to it with no further modification. Of course recently we replaced the Java applet and are using WebRTC. A Raspi is running at my home and using it for my personal use.

  2. The Jitsi crew did a FOSDEM presentation running an early version of Jitsi Meet on an Intel NUC. That’s perhaps not as DIY was a Raspberry Pi, but it’s still a nice, transportable demo.

    There are pics from this event on their Facebook page: https://www.facebook.com/media/set/?set=a.534932376547382.121156.217524784954811&type=3

    • True. My main point here is how easy it is to get started with the basic “Hello World” of WebRTC as a developer versus the same “Hello World” in previous video conferencing SDKs.

  3. OK i was wondering have you actually getting video calling working?

    • Sure. I make it a point to show this specific “use case” in training sessions I do.

      One thing to note here is that the media itself doesn’t get passed or processed through the Raspberry Pi – that is done solely in the browsers.

      • what browser do you use on the Raspberry PI?

        another question would this be possible as well to connect to other webRTC site like vline or similar service?

        thanks it is very interesting i am just now getting around playing with my Pi

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">