Difference between revisions of "Integrating Skype with a MythTV system"

From MythTV Official Wiki
Jump to: navigation, search
(Running kb2kskype in a virtual X server window)
(Running Skype and kb2kskype in a virtual X server window)
Line 261: Line 261:
 
Skype is a GUI application that likes to make its presence known when it performs operations.  There are at least reasons for this.  There is a very vocal population of users clamouring for video in Skype for Linux, so the pressure is for more on-screen activity, not less.  Even without video, Skype has more features than can be easily controlled through a 12-key handset, so in most environments, putting the GUI in front of the user when it might be needed is convenient.  There are security concerns as well.  Skype can be accessed and controlled by other applications via a hidden communication channel (the Skype Public API), and in many environments it is a good thing for the user to be made aware of what these programs are doing.  When MythTV has control of the display, however, the Skype client can be a distraction.
 
Skype is a GUI application that likes to make its presence known when it performs operations.  There are at least reasons for this.  There is a very vocal population of users clamouring for video in Skype for Linux, so the pressure is for more on-screen activity, not less.  Even without video, Skype has more features than can be easily controlled through a 12-key handset, so in most environments, putting the GUI in front of the user when it might be needed is convenient.  There are security concerns as well.  Skype can be accessed and controlled by other applications via a hidden communication channel (the Skype Public API), and in many environments it is a good thing for the user to be made aware of what these programs are doing.  When MythTV has control of the display, however, the Skype client can be a distraction.
  
The simplest way of keeping Skype off the screen is to route its GUI to a virtual X server (Virtual Network Console, or VNC).  This is a display separate from the physical screen(s) on your PC, that can be accessed using a special VNC viewer client.  When an X application is attached to the virtual X server, it is for practical purposes invisible; it will only be displayed if the user connects to the virtual display with a VNC viewer.
+
The simplest and most comprehensive way of keeping Skype off the screen is to route its GUI to a virtual X server (Virtual Network Console, or VNC).  This is a display separate from the physical screen(s) on your PC, that can be accessed using a special VNC viewer client.  When an X application is attached to the virtual X server, it is for practical purposes invisible; it will only be displayed if the user connects to the virtual display with a VNC viewer.
  
 
(more coming ...)
 
(more coming ...)

Revision as of 04:24, 3 June 2007


Introduction

The approach to integrating Skype with a MythTV system described here is an attempt to get these two pieces of software to play nicely with one another inside a home entertainment PC. Please note that the "integration" described here does not involve cluttering up MythTV with an additional "Skype management screen" or the like. On the contrary, the aim is to get Skype working smoothly through an ordinary telephone and remove it from the computer display, to prevent it from interfering with the operation of MythTV.

This document assumes the use of an external piece of hardware (see below) that is used to connect an ordinary telephone to the USB port of a PC. This relevant hardware costs 40 to 50 dollars US new --- and I hasten to add that I have no connection with the people who make this item, nor with Skype. I just find that a telephone, MythTV and Skype make a handy combo, and imagine that others might find the setup useful as well. So here goes with the explanation.

In their initial version, these instructions assume the use of the Ubuntu Linux distribution. They should also work for GNU/Linux (Debian) systems. If you run a different distribution and find that some parts of the instructions need to be modified, please amend this document for the benefit of others.

What we're after

As a learning-averse modern consumer, I would kind of like to make outgoing calls by picking up a telephone, dialing a number, talking with the person on the other end of the line, and then hanging up. For incoming Skype calls (and ordinary calls too), the telephone should ring, so that I can answer by picking up the phone and speaking into the receiver. Notice that the words "keyboard", "monitor" and "mouse" do not figure in this description. As an aspiring Luddite, when I come home from work and flop down in front of the telly, I want --- however briefly --- to be able to forget what those terms mean.

On the other hand, I have more technology-tolerant friends who do make calls using Skype from their computer monitors. When I find myself sitting at home getting reacquainted with subtle plot twists in The Brady Bunch or admiring the fine dramatic performances of David Hasselhoff, I would like Skype to broadcast my online status as "online" [1]. When the Myth box is busy recording programs, but the front end is not in use, the world should be told that I am "not available". And stuff.

That is the entire feature set in a nutshell: a telephone that can be used for ordinary inbound and outbound calls via Skype or the landline, and which gives a hint to other Skype users about whether I'm around and likely to pick up the phone if they should ring.

This scenario can be realized by matching Skype with a small device that we will call a "telbox", using a small amount of software glue.

Software

You will need two pieces of software to connect the telbox to Skype:

  • usbb2k_api A small driver daemon that converts simple human-friendly commands to the binary whatsit language used by the telbox, and likewise returns responses sent back by the box in human-friendly form.
  • kb2kskype A bridge application that, using the simplified command set groked by usbb2k_api one one side, and the Skype Public API on the other, causes incoming Skype calls to ring the phone, and keypresses on the telephone to be fed through to Skype.

As of this writing, you will need to compile these two pieces of software from source in order to install them (the latest phase of work on them was only completed a few days ago). If you are not familiar or comfortable with that process, you might want to stop here, ask around, and wait for packages to become available for your particular distribution. If you're up for this, though, here is what to do.

Skype

You will need to install version 1.3 or 1.4 of Skype. If you use version 1.4 (which I use myself) the full version number must higher than 1.4.0.64. See your distribution package list or the Skype site for further details. (As of this writing, Skype version 1.4 is currently available only as an Alpha preview.

Telbox driver: usbb2k_api

Sources for usbb2k_api

For the box interface driver, fetch the following items.

  1. Sources for the usbb2k_api interface driver (you need the source bundle for version 2.1-1 with the filename shown below, not one of the binary packages)
  2. The "32nd keypress" patch for usbb2k_api
  3. A couple of additional protocol-related patches for usbb2k_api:

Patching usbb2k_api

The patching process is straightforward.

 prompt$ tar xfj usbb2k-api-mod-2.1.tar.bz2
 prompt$ cd usbb2k-api-mod-2.1
 prompt$ patch -p1 <../fix_32nd_keypress.patch
 patching file src/usbb2k-main.c
 Hunk #1 succeeded at 140 (offset 1 line).
 prompt$ patch -p1 <../ADNAMS_usbb2k-api.patch
 patching file ChangeLog
 patching file README
 patching file src/usbb2k-main.c
 prompt$ patch -p1 <../ADNAMS_supp1_usbb2k-api.patch
 patching file BUGS
 patching file ChangeLog
 patching file README
 patching file src/usbb2k-main.c
 prompt$

Compiling and installing usbb2k_api

To compile the box driver, do the following (never mind what it says in the README, do this instead).

 prompt$ sh ./autoconf.sh
 prompt$ ./configure --quiet
 Usb lib found
 pthread lib found
 prompt$ make
 prompt$


If any of the steps fail, it will probably be due to missing headers or libraries. Check the error messages, and install the relevant files for your distribution (you need both the relevant library, plus the header files, which typically have a package name ending is -dev).

After successfully compiling usbb2k_api, copy the binary file into a sensible location in your filesystem. These instructions will assume that you have put it in /usr/local/sbin:

 prompt$ su
 Password: 
 prompt# cp src/usbb2k_api /usr/local/sbin
 prompt# exit
 prompt$

Skype-Telbox bridge: kb2kskype

Sources for kb2kskype

For the application that bridges between Skype and the telbox, fetch these files:

  1. Sources for the kb2kskype bridge application (you need the source bundle for version 0.3.2)
  2. A series of patches for kb2kskype:

Patching kb2kskype

The patching process for kb2kskype is also straightforward, although it's a little tedious and repetitive (sorry about that).

 prompt$ tar xfj kb2kskype-0.3.2.tar.bz2
 prompt$ cd kb2kskype-0.3.2
 prompt$ patch --quiet -p1 <../ADNAMS_kb2kskype.patch
 prompt$ patch --quiet -p1 <../ADNAMS_supp1_kb2kskype.patch
 prompt$ patch --quiet -p1 <../ADNAMS_supp2_kb2kskype.patch
 prompt$ patch --quiet -p1 <../ADNAMS_supp3_kb2kskype.patch
 prompt$ patch --quiet -p1 <../ADNAMS_supp4_kb2kskype.patch
 prompt$ patch --quiet -p1 <../ADNAMS_supp5_kb2kskype.patch
 prompt$ patch --quiet -p1 <../ADNAMS_supp6_kb2kskype.patch
 prompt$ patch --quiet -p1 <../ADNAMS_supp7_kb2kskype.patch
 prompt$ patch --quiet -p1 <../ADNAMS_supp8_kb2kskype.patch
 prompt$

Compiling and installing kb2kskype

To compile the bridge application, run ./configure, then make:

 prompt$ ./configure --quiet
 appending configuration tag "CXX" to libtool
 appending configuration tag "F77" to libtool
 fast creating Makefile
 fast creating doc/Makefile
 fast creating doc/en/Makefile
 fast creating po/Makefile
 fast creating src/Makefile
 config.pl: fast created 5 file(s).
 
 Good - your configure finished. Start make now
 
 prompt$ make --quiet
 Making all in doc
 Making all in .
 Making all in en
 Making all in po
 Making all in src
 prompt$

Again, any errors will likely be due to missing libraries and headers that the application needs in order to compile and run. On Debian and Ubuntu, the following packages may help get you past this step. If the exact package name is not in the package list, look for something similar (say, kdelibs-dev instead of kdelibs4-dev).

 libz-dev
 kdelibs4-dev

To install, you need to copy the application binary into your path somewhere. These instructions assume that it is at /usr/local/bin.

 prompt$ su
 Password: 
 prompt# cp src/kb2kskype /usr/local/bin
 prompt# exit
 prompt$

Hardware

Once you have have compiled usbb2k_api and kb2kskype successfully, and checked that the two main apps (Skype and Myth) will both run in your environment, you will need the following hardware in order to proceed:

  1. USB-B2K telbox The original manufacturer is Yealink, but the same product has been rebranded as OEM equipment by several other firms. Here are a few links to check for information:
  2. Open USB port This will be used to connect the telbox to your computer. The USB-B2K uses USB 1.1, so any USB port should work.
  3. Ordinary telephone You probably already have one of these lying around. The phone will be used for both PSTN (landline) and Skype calls, so your existing phone will continue to work.
    Note: If you don't have a landline, you can set up the software for USB (Skype) mode only.

Setup

Now that you have all of the bits and pieces collected, it's time to put it all together. As indicated above, these instructions assume the use of the Ubuntu or GNU/Linux (Debian) distribution of the Linux OS. Some details (particularly the startup scripts) may need to be modified when working with another distribution.

Hardware installation

The first step is refreshingly simple. Connect the USB cable to the USB-B2K box, and plug the other end into a free USB port on your PC. Connect your telephone to the appropriate phone jack on the box (on mine, it is labeled "TEL"). If you use a landline, connect the line to the other phone jack on the box (on mine, this one is labeled "LINE"). The telbox draws its power from the USB cable, so that's all you need to do.

When the telbox has no power (i.e. when your PC is turned off) the phone should work normally for landline calls. To get Skype working, we have to attend to that software.

Starting usbb2k_api at boot time

The usbb2k_api driver expects the telbox to remain connected when it is running. Its behaviour if the USB cable of the telbox is disconnected while it is running is undefined --- which is to say, something will probably crash if you suddenly yank the USB cable out of your PC before shutting down the driver. So we'll assume that the telbox remains hooked up while the PC is running. In that case, running usbb2k_api automatically at boot time will serve our purposes.

If you have copied the usbb2k_api binary to /usr/local/sbin, you can use the following as a startup script:

#!/bin/sh
#
#

test -f /usr/local/sbin/usbb2k_api || exit 0

case "$1" in
  start)
    echo -n "Starting usbb2k_api:"
    echo -n " usbb2k_api"
    start-stop-daemon --start --quiet --exec /usr/local/sbin/usbb2k_api \
      < /dev/null
    echo "."
    ;;
  stop)
    echo -n "Stopping usbb2k_api:"
    echo -n " usbb2k_api"
    start-stop-daemon --stop --quiet --exec /usr/local/sbin/usbb2k_api \
      < /dev/null
    test -f /var/run/usbb2k_api.pid && rm /var/run/usbb2k_api.pid
    echo "."
    ;;
  reload|force-reload|restart)
    $0 stop
    $0 start
    ;;
  *)
    echo "Usage: /etc/init.d/usbb2k_api {start|stop|reload|restart|force-reload}"
    exit 1
esac
  
exit 0

Using cut and paste, save the text above to a file named usbb2k_api. As the root user, make the script executable and move it to the directory /etc/init.d:

 prompt$ su
 Password:
 prompt# chmod uog+x usbb2k_api
 prompt# mv usbb2k_api /etc/init.d
 prompt# exit
 prompt$

To get the startup script to run at boot time on an Ubuntu or GNU/Linux (Debian) system, use the update-rc.d system configuration command (note that a different procedure may well be required for this step on other systems):

 prompt$ su
 Password:
 prompt# update-rc.d -f usbb2k_api start 90 2 3 4 5 . stop 90 0 1 6 .
  Adding system startup for /etc/init.d/usbb2k_api ...
    /etc/rc0.d/K90usbb2k_api -> ../init.d/usbb2k_api
    /etc/rc1.d/K90usbb2k_api -> ../init.d/usbb2k_api
    /etc/rc6.d/K90usbb2k_api -> ../init.d/usbb2k_api
    /etc/rc2.d/S90usbb2k_api -> ../init.d/usbb2k_api
    /etc/rc3.d/S90usbb2k_api -> ../init.d/usbb2k_api
    /etc/rc4.d/S90usbb2k_api -> ../init.d/usbb2k_api
    /etc/rc5.d/S90usbb2k_api -> ../init.d/usbb2k_api
 prompt# exit
 prompt$

To confirm that the driver is working and set to run at boot time, restart your system and then look for usbb2k_api in the process table:

 prompt$ ps ax | grep usbb2k_api
 11496 pts/0    S+     0:00 grep usbb2k_api
 prompt$

Running Skype and kb2kskype in a virtual X server window

Skype is a GUI application that likes to make its presence known when it performs operations. There are at least reasons for this. There is a very vocal population of users clamouring for video in Skype for Linux, so the pressure is for more on-screen activity, not less. Even without video, Skype has more features than can be easily controlled through a 12-key handset, so in most environments, putting the GUI in front of the user when it might be needed is convenient. There are security concerns as well. Skype can be accessed and controlled by other applications via a hidden communication channel (the Skype Public API), and in many environments it is a good thing for the user to be made aware of what these programs are doing. When MythTV has control of the display, however, the Skype client can be a distraction.

The simplest and most comprehensive way of keeping Skype off the screen is to route its GUI to a virtual X server (Virtual Network Console, or VNC). This is a display separate from the physical screen(s) on your PC, that can be accessed using a special VNC viewer client. When an X application is attached to the virtual X server, it is for practical purposes invisible; it will only be displayed if the user connects to the virtual display with a VNC viewer.

(more coming ...)

Notes

[1] The current version of Skype for Linux does not offer a "desperate for something else to do" setting.