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

From MythTV Official Wiki
Jump to: navigation, search
(Software)
 
(43 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[Category:Knowledge Base]]
 
 
 
[[Category:HOWTO]]
 
[[Category:HOWTO]]
  
 
= Introduction =
 
= 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.
+
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 altogether, 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.
+
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.  The relevant hardware costs 40 to 50 dollars US new --- and I hasten to add that I have no connection with any of the firms that make or market this item, nor with Skype.  I just find that a telephone, MythTV and Skype make a handy combo, and imagine that others might find it 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.
+
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, feel free to amend this document for the benefit of others.
  
 
= What we're after =
 
= 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.
+
As a learning-averse modern consumer, my needs are very simple.  To me, "making a call" means picking up a telephone, dialing a number, talking with the person on the other end of the line, and hanging up.  Conversely, "receiving a call" means that the telephone rings, and I answer by picking it up 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" [[#Notes|'''[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.
+
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''' [[#Notes|'''[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.
+
That is the target 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.
 
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.
Line 23: Line 21:
 
= Software =
 
= Software =
  
You will need two pieces of software to connect the telbox to Skype:
+
You will need three 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.
+
* '''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 (or at least, programmer-friendly) form.  Fetch the [http://sourceforge.net/project/showfiles.php?group_id=186708&package_id=217887 latest binary distribution] of this item.
* '''kb2kskype''' A bridge application that, using the simplified command set groked by usbb2k_api on 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.
+
* '''kb2kskype''' A bridge application that, using the simplified command set groked by usbb2k_api on 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.  Fetch the [http://sourceforge.net/project/showfiles.php?group_id=186708 latest binary distribution] of this item, as well.
 +
* '''skype''' You should install version 1.4 (or later) of Skype (version 1.3 will work, but 1.4 is superior software).  Fetch the [http://www.skype.com/download/skype/linux/ 32-bit beta version of Skype] for your Linux distribution, or fetch the [http://www.skype.com/go/getskype-linux-ubuntu-amd64 64-bit version of Skype for Ubuntu].
  
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.
+
= Hardware =
  
== Skype ==
+
Once you have grabbed the usbb2k_api and kb2kskype packages, 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:
  
You will need to install version 1.3 or 1.4 of SkypeIf 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 [http://share.skype.com/sites/garage/2007/05/skype_for_linux_14_alpha_updat.html#more an Alpha preview].
+
# '''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:
 +
#* [http://www.yealink.com/en/view.asp?ClassLayer=17 Yealink USB Adaptor USB-B2K]
 +
#* [http://www.lobos.com.tw/product/usbb2k_eng.htm  Lobos LB-USBB2K SkyMe Tel Box]
 +
#* [http://www.expansys.com/p.aspx?i=121153 Yamamoto Easyblue Telbox]
 +
#* [http://www.tiptel.com/aktion/ip_e.htm Tiptel Cyberbox 100]<br><u>Note:</u> ''There are other models of telbox out there, but the software described here only works with the USB-B2K.''
 +
# '''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.
 +
# '''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.<br><u>Note:</u> ''If you don't have a landline, you can set up the software for USB (Skype) mode only.''
  
== Telbox driver: usbb2k_api ==
+
= Setup =
  
=== Sources for usbb2k_api ===
+
With software and hardware in hand, you're ready 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.
  
For the box interface driver, fetch the following items.
+
== Architecture ==
  
# 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)
+
The following diagram gives an idea of how things will work in the completed system.  The '''usbb2k_api''' daemon provides an interface to the telbox.  The '''kb2kskype''' bridge passes commands and status messages back and forth between the telbox and Skype. All the user needs to worry about is checking that the PC is turned on, and using the telephone in the customary way.
#* [http://sourceforge.net/project/showfiles.php?group_id=186708 usbb2k-api-mod-2.1.tar.bz2]
 
# The  "32nd keypress" patch for usbb2k_api
 
#* [http://savannah.nongnu.org/patch/?5887 fix_32nd_keypress.patch]
 
# A couple of additional protocol-related patches for usbb2k_api:
 
#* [http://sourceforge.net/tracker/index.php?func=detail&aid=1723824&group_id=186708&atid=918377 ADNAMS_usbb2k-api.patch]
 
#* [http://sourceforge.net/tracker/index.php?func=detail&aid=1725955&group_id=186708&atid=918377 ADNAMS_supp1_usbb2k-api.patch]
 
  
=== Patching usbb2k_api ===
+
[[Image:telly.png|center|Architecture of the finished system]]
  
The patching process is straightforward.
+
== Hardware installation ==
  
  '''prompt$''' tar xfj usbb2k-api-mod-2.1.tar.bz2
+
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.
  '''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 ===
+
== Installing skype, usbb2k_api and kb2kskype ==
  
To compile the box driver, do the following (never mind what it says in the README, do this instead).
+
If you are are reading this, you are probably already familiar with the package installation process for your Linux distribution, but just in case, on Ubuntu, you can install these packages with commands similar to these:
 
 
  '''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
 
   '''prompt$''' su
   Password:  
+
   Password:
   '''prompt#''' cp src/usbb2k_api /usr/local/sbin
+
   '''prompt#''' dpkg -q -i skype-1.4.0.74.deb
 +
  '''prompt#''' dpkg -q -i usbb2k-api-mod_2.2-1_i386.kubuntu.deb
 +
  '''prompt#''' dpkg -q -i kb2kskype_0.3.3-1_i386.kubuntu.deb
 
   '''prompt#''' exit
 
   '''prompt#''' exit
 
   '''prompt$'''
 
   '''prompt$'''
  
== Skype-Telbox bridge: kb2kskype ==
+
Once installed, the usbb2k_api will start automatically at boot time.  It is a background process, so you can check that it is up with something like:
  
=== Sources for kb2kskype ===
+
  '''prompt$''' ps ax | grep usbb
  
For the application that bridges between Skype and the telbox, fetch these files:
+
This daemon expects the telbox to remain connected when it is running.  If the telbox is not connected when the daemon is started, it will eventually die.  Its behaviour if the USB cable of the telbox is disconnected while it is running is undefined --- which is to say, it will probably crash if you suddenly yank the USB cable out of your PC before it is shut down.
  
# Sources for the  kb2kskype bridge application (you need the ''source bundle'' for version 0.3.2)
+
== Running Skype and kb2kskype in a virtual X server window ==
#* [http://sourceforge.net/project/showfiles.php?group_id=186708 kb2kskype-0.3.2.tar.bz2]
 
# A series of patches for kb2kskype:
 
#* [http://sourceforge.net/tracker/index.php?func=detail&aid=1723834&group_id=186708&atid=918377 ADNAMS_kb2kskype.patch]
 
#* [http://sourceforge.net/tracker/index.php?func=detail&aid=1724491&group_id=186708&atid=918377 ADNAMS_supp1_kb2kskype.patch]
 
#* [http://sourceforge.net/tracker/index.php?func=detail&aid=1725876&group_id=186708&atid=918377 ADNAMS_supp2_kb2kskype.patch]
 
#* [http://sourceforge.net/tracker/index.php?func=detail&aid=1725958&group_id=186708&atid=918377 ADNAMS_supp3_kb2kskype.patch]
 
#* [http://sourceforge.net/tracker/index.php?func=detail&aid=1727148&group_id=186708&atid=918377 ADNAMS_supp4_kb2kskype.patch]
 
#* [http://sourceforge.net/tracker/index.php?func=detail&aid=1728907&group_id=186708&atid=918377 ADNAMS_supp5_kb2kskype.patch]
 
#* [http://sourceforge.net/tracker/index.php?func=detail&aid=1729184&group_id=186708&atid=918377 ADNAMS_supp6_kb2kskype.patch]
 
#* [http://sourceforge.net/tracker/index.php?func=detail&aid=1729235&group_id=186708&atid=918377 ADNAMS_supp7_kb2kskype.patch]
 
#* [http://sourceforge.net/tracker/index.php?func=detail&aid=1729736&group_id=186708&atid=918377 ADNAMS_supp8_kb2kskype.patch]
 
  
=== Patching kb2kskype ===
+
Now for the fun part.  Skype is a GUI application that likes to make its presence known when it performs operations.  There are a few sensible 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.  But when MythTV has control of the display, popups from the Skype client can be a distraction.
  
The patching process for kb2kskype is also straightforward, although it's a little tedious and repetitive (sorry about that).
+
The simplest and most comprehensive way of keeping Skype off the screen is to route its GUI to a virtual X server (an "X-windows virtual network console", or Xvnc).  This is a display separate from the physical screen(s) on your PC that is tucked away in the computer's memory, and can be accessed using a special Xvnc viewer client.  When an X application is running on a virtual X server, it is for practical purposes invisible; its windows and whatnot will only be shown if the user connects to the virtual display with an Xvnc viewer.
  
  '''prompt$''' tar xfj kb2kskype-0.3.2.tar.bz2
+
=== Installing an Xvnc server and its friends ===
  '''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 ===
+
The first step is to install an Xvnc server and client.  There are several in circulation.  The one I use is the Debian/Ubuntu package '''vnc4server''' for the server, and '''xvncviewer''' for the viewer client.  Unless you have a strong preference for another combination of Xvnc tools, use the package manager to install these two packages.
  
To compile the bridge application, run '''./configure''', then '''make''':
+
The Xvnc server, just like the server that runs the physical X display on the monitor, needs to have a window manager.  Gnome is much too heavy for a server that will only run a couple of applications. There are many lightweight window managers around; the one I use is '''blackbox'''.  If you don't feel like shopping around and tinkering with the setup, use your package manager to install this package as well.
  
  '''prompt$''' ./configure --quiet
+
Installing these tools runs something like this:
  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
 
   '''prompt$''' su
   Password:  
+
   Password:
   '''prompt#''' cp src/kb2kskype /usr/local/bin
+
   '''prompt#''' dpkg -q -i vnc4server
 +
  '''prompt#''' dpkg -q -i xvncviewer
 
   '''prompt#''' exit
 
   '''prompt#''' exit
 
   '''prompt$'''
 
   '''prompt$'''
  
= Hardware =
+
'''[Complete to this point]'''
 
 
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:
 
 
 
# '''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:
 
#* [http://www.yealink.com/en/view.asp?ClassLayer=17  Yealink USB Adaptor USB-B2K]
 
#* [http://www.lobos.com.tw/product/usbb2k_eng.htm  Lobos LB-USBB2K SkyMe Tel Box]
 
#* [http://www.expansys.com/p.aspx?i=121153  Yamamoto Easyblue Telbox]
 
#* [http://www.tiptel.com/aktion/ip_e.htm Tiptel Cyberbox 100]<br><u>Note:</u> ''There are other models of telbox out there, but the software described here only works with the USB-B2K.''
 
# '''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.
 
# '''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.<br><u>Note:</u> ''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.
+
=== Configuring the server ===
  
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.
+
The VNC server uses its own xstartup script, located at '''~/.vnc/xstartup'''.  Here is a copy of the one that I use, with commands and options explained in the comments(Note that the VNC server display name is "bigbox"More on where that comes from in the next section.)
 
 
== Starting usbb2k_api at boot time ==
 
 
 
The '''usbb2k_api''' driver expects the telbox to remain connected when it is runningIts 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 driverSo we'll assume that the telbox remains hooked up while the PC is runningIn 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:
 
  
 
<pre>
 
<pre>
 
#!/bin/sh
 
#!/bin/sh
#
 
#
 
  
test -f /usr/local/sbin/usbb2k_api || exit 0
+
## Allow connections from this computer (possibly not required)
 +
xhost +localhost
  
case "$1" in
+
## A grey background is easier on the eyes than the default
  start)
+
## hash pattern used by X
    echo -n "Starting usbb2k_api:"
+
xsetroot -solid grey
    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
 
</pre>
 
  
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''':
+
## Force the VNC server configuration widget to the virtual display
 +
vncconfig -display bigbox:1 &
  
  '''prompt$''' su
+
## Possibly gratuitous pause inserted to give Skype a comfortable
  Password:
+
## startup environment
  '''prompt#''' chmod uog+x usbb2k_api
+
/bin/sleep 1
  '''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):
+
## Skype accepts the usual X11 options.  We force it to use
 +
## the virtual display
 +
/usr/bin/skype -display bigbox:1 &
  
  '''prompt$''' su
+
## Several options are used with kb2kskype
  Password:
+
## --cmap forces kb2kskype to use a private colormap, to avoid overburdening
  '''prompt#''' update-rc.d -f usbb2k_api start 90 2 3 4 5 . stop 90 0 1 6 .
+
##    the server colormap
  Adding system startup for /etc/init.d/usbb2k_api ...
+
## --geometry just sizes and positions the kb2kskype GUI widget inside
    /etc/rc0.d/K90usbb2k_api -> ../init.d/usbb2k_api
+
##    the virtual display
    /etc/rc1.d/K90usbb2k_api -> ../init.d/usbb2k_api
+
## --display just forces the widget to display in the virtual server
    /etc/rc6.d/K90usbb2k_api -> ../init.d/usbb2k_api
+
## --offhook-stamp causes the named file to be created when the
    /etc/rc2.d/S90usbb2k_api -> ../init.d/usbb2k_api
+
##    telephone is off-hook, and deleted when the telephone is
    /etc/rc3.d/S90usbb2k_api -> ../init.d/usbb2k_api
+
##    placed on-hook
    /etc/rc4.d/S90usbb2k_api -> ../init.d/usbb2k_api
+
## --status-script causes the last-named script to be run every
    /etc/rc5.d/S90usbb2k_api -> ../init.d/usbb2k_api
+
##    ten seconds, and the Skype online status to be set to
  '''prompt#''' exit
+
##    according to its exit status. An exit status of 0 uses
  '''prompt$'''
+
##    the first option, 1 the second, and so on
 +
/usr/local/bin/kb2kskype --cmap --geometry 50x50+200x+0 --display bigbox:1 \
 +
  --offhook-stamp /tmp/CALL_IN_PROGRESS \
 +
  --status-script na,online,/usr/local/bin/MyB2Kcheckstatus.sh &
  
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:
+
## Run the window manager!
 
+
blackbox -display bigbox:1 &
  '''prompt$''' ps ax | grep usbb2k_api
+
</pre>
  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 lessEven 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.
+
If you have installed the '''blackbox''' window manager package, and both '''usbb2k_api''' and '''kb2kskype''' are in place, you should be able to use this script, tooCreate a subdirectory '''.vnc''' in the account used by MythTV, and use cut and paste to copy the text above into a file '''xstartup''' in that subdirectory.
  
The simplest and most comprehensive way of keeping Skype off the screen is to route its GUI to a virtual X server (a 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 clientWhen an X application is attached to the virtual X server, it is for practical purposes invisible; its windows and whatnot will only be shown if the user connects to the virtual display with a VNC viewer.
+
A few comments about the last two options fed to '''kb2kskype''' are in order.  These options were added specifically to support MythTV.  With the '''--offhook-stamp''' option, a MythTV shutdown script can check for the named file, and postpone a shutdown when it is found.  This can be used to prevent the Myth box from suddenly shutting down in the middle of a Skype call.  The '''--status-script''' option can be used to set Skype's online status using a script that is run periodically (every 10 seconds)In my installation, '''mythfrontend''' sets a pid file when it is running.  The script invoked in the example checks for the pid file, and sets the user status to '''online''' when it is found, '''na''' otherwise.
  
(more coming ...)
+
(more coming soon ...)
  
 
= Notes =
 
= Notes =
  
[[#What we're after|'''[1]''']] The current version of Skype for Linux does not offer a "desperate for something else to do" setting.
+
[[#What we're after|'''[1]''']] The current version of Skype for Linux does not offer a '''Desperate for Something Else to Do''' setting.

Latest revision as of 02:12, 15 October 2009


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 altogether, 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. The relevant hardware costs 40 to 50 dollars US new --- and I hasten to add that I have no connection with any of the firms that make or market this item, nor with Skype. I just find that a telephone, MythTV and Skype make a handy combo, and imagine that others might find it 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, feel free to amend this document for the benefit of others.

What we're after

As a learning-averse modern consumer, my needs are very simple. To me, "making a call" means picking up a telephone, dialing a number, talking with the person on the other end of the line, and hanging up. Conversely, "receiving a call" means that the telephone rings, and I answer by picking it up 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 target 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 three 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 (or at least, programmer-friendly) form. Fetch the latest binary distribution of this item.
  • kb2kskype A bridge application that, using the simplified command set groked by usbb2k_api on 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. Fetch the latest binary distribution of this item, as well.
  • skype You should install version 1.4 (or later) of Skype (version 1.3 will work, but 1.4 is superior software). Fetch the 32-bit beta version of Skype for your Linux distribution, or fetch the 64-bit version of Skype for Ubuntu.

Hardware

Once you have grabbed the usbb2k_api and kb2kskype packages, 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

With software and hardware in hand, you're ready 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.

Architecture

The following diagram gives an idea of how things will work in the completed system. The usbb2k_api daemon provides an interface to the telbox. The kb2kskype bridge passes commands and status messages back and forth between the telbox and Skype. All the user needs to worry about is checking that the PC is turned on, and using the telephone in the customary way.

Architecture of the finished system

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.

Installing skype, usbb2k_api and kb2kskype

If you are are reading this, you are probably already familiar with the package installation process for your Linux distribution, but just in case, on Ubuntu, you can install these packages with commands similar to these:

 prompt$ su
 Password:
 prompt# dpkg -q -i skype-1.4.0.74.deb
 prompt# dpkg -q -i usbb2k-api-mod_2.2-1_i386.kubuntu.deb
 prompt# dpkg -q -i kb2kskype_0.3.3-1_i386.kubuntu.deb
 prompt# exit
 prompt$

Once installed, the usbb2k_api will start automatically at boot time. It is a background process, so you can check that it is up with something like:

 prompt$ ps ax | grep usbb

This daemon expects the telbox to remain connected when it is running. If the telbox is not connected when the daemon is started, it will eventually die. Its behaviour if the USB cable of the telbox is disconnected while it is running is undefined --- which is to say, it will probably crash if you suddenly yank the USB cable out of your PC before it is shut down.

Running Skype and kb2kskype in a virtual X server window

Now for the fun part. Skype is a GUI application that likes to make its presence known when it performs operations. There are a few sensible 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. But when MythTV has control of the display, popups from 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 (an "X-windows virtual network console", or Xvnc). This is a display separate from the physical screen(s) on your PC that is tucked away in the computer's memory, and can be accessed using a special Xvnc viewer client. When an X application is running on a virtual X server, it is for practical purposes invisible; its windows and whatnot will only be shown if the user connects to the virtual display with an Xvnc viewer.

Installing an Xvnc server and its friends

The first step is to install an Xvnc server and client. There are several in circulation. The one I use is the Debian/Ubuntu package vnc4server for the server, and xvncviewer for the viewer client. Unless you have a strong preference for another combination of Xvnc tools, use the package manager to install these two packages.

The Xvnc server, just like the server that runs the physical X display on the monitor, needs to have a window manager. Gnome is much too heavy for a server that will only run a couple of applications. There are many lightweight window managers around; the one I use is blackbox. If you don't feel like shopping around and tinkering with the setup, use your package manager to install this package as well.

Installing these tools runs something like this:

 prompt$ su
 Password:
 prompt# dpkg -q -i vnc4server
 prompt# dpkg -q -i xvncviewer
 prompt# exit
 prompt$

[Complete to this point]


Configuring the server

The VNC server uses its own xstartup script, located at ~/.vnc/xstartup. Here is a copy of the one that I use, with commands and options explained in the comments. (Note that the VNC server display name is "bigbox". More on where that comes from in the next section.)

#!/bin/sh

## Allow connections from this computer (possibly not required)
xhost +localhost

## A grey background is easier on the eyes than the default
## hash pattern used by X
xsetroot -solid grey

## Force the VNC server configuration widget to the virtual display
vncconfig -display bigbox:1 &

## Possibly gratuitous pause inserted to give Skype a comfortable
## startup environment
/bin/sleep 1

## Skype accepts the usual X11 options.  We force it to use
## the virtual display
/usr/bin/skype -display bigbox:1 &

## Several options are used with kb2kskype
## --cmap forces kb2kskype to use a private colormap, to avoid overburdening
##     the server colormap
## --geometry just sizes and positions the kb2kskype GUI widget inside
##     the virtual display
## --display just forces the widget to display in the virtual server
## --offhook-stamp causes the named file to be created when the
##     telephone is off-hook, and deleted when the telephone is
##     placed on-hook
## --status-script causes the last-named script to be run every
##     ten seconds, and the Skype online status to be set to
##     according to its exit status.  An exit status of 0 uses
##     the first option, 1 the second, and so on
/usr/local/bin/kb2kskype --cmap --geometry 50x50+200x+0 --display bigbox:1 \
  --offhook-stamp /tmp/CALL_IN_PROGRESS \
  --status-script na,online,/usr/local/bin/MyB2Kcheckstatus.sh &

## Run the window manager!
blackbox -display bigbox:1 &


If you have installed the blackbox window manager package, and both usbb2k_api and kb2kskype are in place, you should be able to use this script, too. Create a subdirectory .vnc in the account used by MythTV, and use cut and paste to copy the text above into a file xstartup in that subdirectory.

A few comments about the last two options fed to kb2kskype are in order. These options were added specifically to support MythTV. With the --offhook-stamp option, a MythTV shutdown script can check for the named file, and postpone a shutdown when it is found. This can be used to prevent the Myth box from suddenly shutting down in the middle of a Skype call. The --status-script option can be used to set Skype's online status using a script that is run periodically (every 10 seconds). In my installation, mythfrontend sets a pid file when it is running. The script invoked in the example checks for the pid file, and sets the user status to online when it is found, na otherwise.

(more coming soon ...)

Notes

[1] The current version of Skype for Linux does not offer a Desperate for Something Else to Do setting.