RPi Using Skypekit

=About SkypeKit=

Sadly, there's no desktop Skype application currently available for the Raspberry Pi. However, Skype do have a Developer Program, and through that program it's possible to get the basic bits & pieces needed to put together a Skype client that will run on the Pi.

SkypeKit is an SDK & set of runtimes provided by Skype to developers who want to create applications with Skype-based functionality.

You can think of a runtime as a 'headless' version of Skype: it's an executable which has no interface, runs on the commandline & connects to the Skype network and provides stuff like contact lists and the ability to make calls. The SDK allows you to write code which talks to the runtime. You're never dealing with the Skype network directly; just manipulating the runtime. When you're developing with SkypeKit, presenting an interface to the user is your responsibility. The core Skype functionality is the runtime's responsibility.

There are a number of runtimes available for various combinations of OS & architecture. Luckily for us, there's a linux-armv7le-eabi runtime which runs on the Pi.

Handily, the SDK also comes with a bunch of example code which lets you do things like chat & make and receive calls on the command-line.

'''The purpose of this guide is to get you to a point where you can hack about with SkypeKit on the Pi. It's not a canonical guide to making Skype calls on the Pi, although hopefully may make such a thing possible in the future.'''

Prerequisites
There's a fair bit of footwork required to get to the point where you can get your Pi connecting to Skype. Firstly, most importantly, and the reason that this stuff is currently only useful to developers is the fact that you'll need to sign up to the SkypeKit Developer Program to get the runtime and the application keys needed for its use.

Getting the SkypeKit SDK & runtime

 * 1) First, you'll need to sign up to the SkypeKit Developer Program. Visit https://developer.skype.com/signup. Click "Sign in with Skype" and do that thing.
 * 2) Once you're signed up to the Developer Program, you'll need to sign up to the "SkypeKit for Embedded" Program to download the runtime for Pi. Go to http://developer.skype.com/account/projects and click the link that says Join for US $5 on the "SkypeKit for Embedded" line in the Programs section. The astute will already have realised that it costs $5.
 * 3) Once you're signed up to the SkypeKit for Embedded program, you'll need to create a Project to get the key pair that the runtime requires to run. Visit http://developer.skype.com/account/projects again; you should now see that where the Join for US $5 link was which you used to sign up to the Embedded program, it now says "Create a new project". Click that link and follow the instructions to create a project.
 * 4) Once you've created a project, you'll be able to download the SDK, runtime & key pair you need to run a runtime on the Pi. Visit http://developer.skype.com/skypekit/releases. Remember, we're interested in the Embedded runtime for the Pi's ARMv7 chip; at the time of writing,  this download is the 4.2.1 for Embedded SDK from the Step 1 section.
 * 5) You'll need to request the runtime, since they're built uniquely against a Developer Program account. Click "Request a runtime" in Step 2: Request and download runtimes. We're after a Linux / ARMv7 runtime, so select those in the dropdowns at the column headings in the table which appears. There's a few which can be used; I'm currently working with linux-armv7-skypekit-voicepcm-novideo, so that's as good a choice to make as any at this point.
 * 6) Finally, we'll request a key pair. Go back to the project that you created and click "Development key pair". Then click "Request a new key pair" and give it a name (I use dates). Click "Request key pair" after proving you're a human, then "Download the key pair"
 * 7) That's it! You now have everything you need to start slapping together a simple Skype-connected app

Building an Audio Host & running an example app
Now we've got the SDK, runtime & keyfile, we're ready to start putting things togeher on the Pi. Copy over linux-armv6-skypekit-xxx.gz, linux-armv6-skypekit-xxx.tar.gz, skypekit-sdk_sdk-xxx.tar.gz and the .pem keyfile to a sensible place on your Pi (I made ~/dev/skype and put them there) and uncompress both archives with: tar xvzf filename.gz

The rest of this guide is all Pi-side, since I'm not quite ready to attempt to get my Mac cross-compiling for the Pi just yet.

About Audio Hosts
The Skypekit ARM runtime needs to connect to an Audio Host at the time that it connects to the Skype network, even if we're not actually interested in making calls (say, using the runtime for chat). An Audio Host is a standalone binary which runs alongside the runtime and provides it with access to audio in & out connections. The Audio PCM Quick Start guide on http://developer.skype.com gives more detail about this setup, but the practical upshot is that we'll need to compile an Audio PCM Host before we can use any of the services provided by the runtime.

''Most of this information is extracted from Skype's Audio PCM Quick Start guide, but this doc seems to lag behind regarding the build system used in more recent versions of the SDK (4.2.1 at time of writing). There's some tidbits of information about the new build system in the Release Notes for 4.2.1, but other stuff I've basically guessed at/worked out through trial & error. YMMV.''

Building voicepcmhost-loopback
The simplest reference Audio Host provided in the SDK is voicepcmhost-loopback, which as the name suggests, just copies audio data from its input back to its output.

Hopefully, we should now have a built binary at ~/dev/skype/skypekit-sdk_sdk-4.2.1.97_1379776/reference/voicepcmhost-loopback/build/voicepcmhost-loopback.
 * 1)  Build voicepcmhost-loopback. Change to the relevant build directory: cd ~/dev/skype/skypekit-sdk_sdk-4.2.1.97_1379776/reference/voicepcmhost-loopback/build/gmake and build it: make

Building voicepcmhost-rtaudio
If you'd like to try making a call through to actual audio hardware on the Pi, you can build voicepcmhost-rtaudio which uses the RtAudio library to connect to an audio device.

Prerequisites

 * RtAudio. At the time of writing, the most current version is 4.0.11 which can be downloaded here.
 * libasound2-dev, the ALSA shared library which RtAudio needs to connect to ALSA (if you're wondering, ALSA is the Linux sound system). Install this library with sudo apt-get install libasound2-dev
 * A USB soundcard which has an audio-in port. voicepcmhost-rtaudio fails if it can't connect to an audio input, and the Pi's onboard sound only has an audio-out connection. Connect the device before you turn on the Pi; if its chipset is supported, drivers will be loaded at boot.
 * Premake, a build utility which generates a correct makefile for voicepcmhost-rtaudio.
 * 1) Download the source from http://industriousone.com/premake/download.
 * 2) Extract the source somewhere useful. If you're following my directory structure, copy the downloaded tarball to ~/dev, then extract with unzip premake-4.3-src.zip
 * 3) Change to the build folder in the extracted source directory cd ~/dev/premake-4.3/build/gmake.unix and build premake make
 * 4) Make the premake binary available to the system by copying it to /usr/sbin sudo cp ~/dev/premake-4.3/bin/release/premake4 /usr/sbin

Once you've taken care of the prerequisites, we're ready to compile voicepcmhost-rtaudio.

If all of this worked, you should be left with a built binary at ~/dev/skype/skypekit-sdk_sdk-4.2.1.97_1379776/reference/voicepcmhost-rtaudio/build/voicepcmhost-rtaudio.
 * 1) Extract rtaudio somewhere useful. If you're following my directory structure, extract it to ~/dev with the following commands:
 * 2) Copy the rtaudio tarball to ~/dev
 * 3) tar xzvf rtaudio-4.0.11.tar.gz This should leave you with an extracted folder named rtaudio-4.0.11 in ~/dev.
 * 4) Move to the directory where the voicepcmhost-rtaudio source lives: ~/dev/skype/skypekit-sdk_sdk-4.2.1.97_1379776/reference/voicepcmhost-rtaudio
 * 5) Make a link to the RtAudio source. The makefile for voicepcmhost-rtaudio expects the source for RtAudio to be present in this folder at compile-time. We'll make a link back to the extracted source to keep things tidy. ln -s ~/dev/rtaudio-4.0.11 ./rtaudio-4.0.6  Note that the link is named rtaudio-4.0.6: the makefile is expecting an older version of RtAudio, and rather than mucking about with the makefile, it's probably just better to be a little disingenuous with the link name. This strategy works fine at the time of writing with rtaudio-4.0.11 standing in for 4.0.6.
 * 6) Generate the correct makefile for voicepcmhost-rtaudio, since the default one doesn't work. make This will generate a bunch of makefiles and try to build voicepcmhost-rtaudio, which will fail. This is OK though, since we'll build it in the next step.
 * 7) Build voicepcmhost-rtaudio with the following commands: cd ~/dev/skype/skypekit-sdk_sdk-4.2.1.97_1379776/reference/voicepcmhost-rtaudio/build/gmake  make

Making a test call to the Pi
Let's try putting the whole thing together and making a test call to the Pi. If it works, we'll hear our own voice echoed back to us through the loopback host. You'll need the logins for two different Skype accounts: we'll use on the Pi and one on your desktop. You'll also need Skype installed on your desktop.
 * 1) Copy the .pem keyfile to ~/dev/skype/skypekit-sdk_sdk-4.2.1.97_1379776/examples/python/tutorial. We'll use it later to run a test app. Edit ~/dev/skype/skypekit-sdk_sdk-4.2.1.97_1379776/examples/python/keypair.py to reflect the filename of the keyfile.
 * 2) Start the ARM runtime in the background: ~/dev/skype/linux-armv6-skypekit-voicepcm-novideo_4.2.1.723_1708442/bin/linux-armv6le-eabi/linux-armv6-skypekit-voicepcm-novideo &
 * 3) Start a Voice PCM Audio Host in the background:
 * 4) For voicepcmhost-loopback: ~/dev/skype/skypekit-sdk_sdk-4.2.1.97_1379776/reference/voicepcmhost-loopback/build/voicepcmhost-loopback &
 * 5) For voicepcmhost-rtaudio: ~/dev/skype/skypekit-sdk_sdk-4.2.1.97_1379776/reference/voicepcmhost-rtaudio/build/voicepcmhost-rtaudio &
 * 6) Move to the folder containing the Python app examples: cd ~/dev/skype/skypekit-sdk_sdk-4.2.1.97_1379776/examples/python/tutorial/
 * 7) Run the autoanswer.py example. This is a simple Python app which will automatically answer any incoming Skype call and connect it to the running Audio Host. python autoanswer.py &lt;Skype account #1 login&gt; &lt;Skype account #1 password&gt;
 * 8) On your desktop, login to Skype with the details for account #2 and place a call to account #1. You should see a whole load of output spill across the Pi's console, including the lines Incoming call from:   and  is now live.

At this point, we should have a Skype call connected to the instance of SkypeKit running on the Pi. Congratulations! Say something.
 * If you're using voicepcmhost-loopback, you should hear your own voice coming back to you over the Skype connection.
 * If you're using voicepcmhost-rtaudio, you should hear your own voice coming out of the USB audio device connected to the Pi.

And that's how to make a Skype connection to the Pi. Have fun hacking around it with it, build awesome stuff!