VoIP with FreeSWITCH

Talk Soft

© Mateusz Radek, Fotolia

© Mateusz Radek, Fotolia

Article from Issue 106/2009
Author(s):

FreeSWITCH is a powerful and versatile telephony platform that can scale from a softphone to a PBX and even to a carrier-class softswitch.

Open source projects have lowered the barrier to entry into telephony for hobbyists and businesses alike. The popular Asterisk PBX tool, for instance, is a high-functioning and low-budget telephony alternative that has proven disruptive in the world of business telephone systems [1]. Perhaps the most disruptive software of all, however, comes in the form of the scalable softswitch library called FreeSWITCH.

The FreeSWITCH website [2] says that it can be used as a "simple switching engine, a PBX, a media gateway, or a media server to host IVR applications."

True to that chameleon-like description, FreeSWITCH has appeared in production environments as a telco switch, in numerous business scenarios as a PBX, as a softphone for laptop users, and even as a voice routing engine for the OpenSim project.

Additionally, you can deploy FreeSWITCH as an application or use it as a library (libfreeswitch) that can be embedded in third-party software. This double identity is similar to the relationship between cURL (application) and libcurl (library).

FreeSWITCH has been used in some exotic scenarios; however, those new to telephony applications are best served starting out with FreeSWITCH in its default configuration as a SOHO PBX. Although you might find the numerous FreeSWITCH configuration files and settings overwhelming, in a short time, you will appreciate the power and flexibility of this versatile telephony tool.

Installing FreeSWITCH

As of this writing, the current, stable version of FreeSWITCH is 1.0.4, which can be downloaded from the project website [3], or you can use the Subversion repository to install the latest version. Unlike many projects, the SVN trunk is extremely stable, so it might be convenient for you simply to use the latest trunk.

In any case, the FreeSWITCH developers have made it very easy to update to the latest trunk, even if you have installed from the latest stable version. Some pre-compiled binaries are known to exist; however, I recommend compiling from source.

First, unpack and install the source. In this example, I will download into /usr/src and install from there:

tar zxvf freeswitch-1.0.4.tar.gz
cd freeswitch-1.0.4
./configure
make install

I recommend getting the sound files:

make cd-sounds-install
make cd-moh-install

FreeSWITCH comes with and can handle sound files at 8, 16, 32, and 48kHz sampling rates. Few, if any, telephony systems – open source or proprietary – can do the kinds of things FreeSWITCH can do with calls at multiple sampling rates.

The installation will take some time, so feel free to chain the commands together with the && operator.

When the process is complete, you will have a basic FreeSWITCH installation. Because it is handy to have the two main FreeSWITCH executable files available in the bin path, I use symlinks:

ln -s /usr/local/freeswitch/bin/freeswitch /usr/local/bin/freeswitch
ln -s /usr/local/freeswitch/bin/fs_cli /usr/local/bin/fs_cli

To launch the application, enter freeswitch, and use the fs_cli utility to access the command line of any FreeSWITCH server to which you have access, even if it is on another server. At first, you'll see quite a bit of debug/log information, but don't worry about errors or warnings at this point.

Your New Softswitch

The first basic command is version, which displays the version of Free-SWITCH you are running, including the SVN revision. The status command shows information about your instance of FreeSWITCH, including uptime and the number of currently active sessions. Another basic command is the self-descriptive help.

To exit FreeSWITCH, type fsctl shutdown or use the shortcut command (three periods).

If you have a sound card or headset on your system then try this:

load mod_portaudio

After several debug lines, you'll see +OK when the module is loaded. Now list the PortAudio devices available on your system:

pa devlist
API CALL [pa(devlist)] output:
0;Built-in Microphone;2;0;i
1;Built-in Input;2;0;
2;Built-in Output;0;2;r,o
3;Logitech USB Headset;0;2;
4;Logitech USB Headset;1;0;

The i and o are next to the currently selected input and output devices. To change the input device, use the pa indev command with the device number,

pa indev #x

where x is the number of the input device. The output device can be changed with the pa outdev command. In my setup, I'll use device 4 as output and device 5 as input.

If you have the MOH (music on hold) files installed, this command will make a call to the MOH extension and send the MOH to the PortAudio output device:

pa call 9999

If you hear music, it was a successful call. If not, make sure the MOH files were installed properly. Hang up with the pa hangup command.

To make sure both input and output devices are working, do an echo test:

pa call 9996

Now when you speak into the input device, your voice should be echoed to the output device. The pa hangup command disconnects.

As you can see, it is possible to use Free-SWITCH and PortAudio to create a simple softphone. In this way, you will be able to use any codec that your FreeSWITCH installation supports – and there are some very high quality codecs available – without installing a softphone client.

Connecting a SIP Phone

The most common way to use Free-SWITCH is with a SIP phone. A physical handset is often called a hard phone, whereas a software-based phone is appropriately called a softphone. Numerous types of hard phones are available from manufacturers. Softphones come in both proprietary and FLOSS varieties. A popular free – but not open source – softphone is X-Lite from CounterPath [4], which is available for Linux, Mac OS X, and Windows. Even if your FreeSWITCH server runs on Linux, your softphones can run on any operating system, as long as they are SIP compliant.

Session Initiation Protocol

SIP is a TCP/IP-based Application Layer protocol used for multimedia sessions over the Internet. The text-based protocol is similar to HTTP, with requests and responses, header fields, encoding rules, and status codes. In addition to VoIP, SIP is used in instant messaging, online gaming, and distribution of streaming multimedia.

To begin, download X-Lite for your desktop or laptop operating system and perform a default install. (Installing a softphone on the same system that is running FreeSWITCH is not recommended; however, in many cases, it will work for the sake of testing.)

Now launch X-Lite and open the SIP Account Settings menu by clicking the Show Menu button. (The button is the small down-arrow at the top of the phone, just left of center.)

Only one SIP account is available in X-Lite, so click on it then click the Properties button. As shown in Figure 1, fill in the fields and use 1234 as the password for extension 1000.

Next, clear out the Dialing plan field because it is not needed with FreeSWITCH. Now click OK then Close, and the phone will attempt to register. Figure 2 shows a successful registration.

To make a test call, dial 9999 and click the green button to send. In a few moments you should hear music on hold. Figure 3 shows a call in progress to extension 9999.

To shut down FreeSWITCH, use the fsctl shutdown () command.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Post-PRISM Privacy

    Linux users didn't need the recent NSA eavesdropping scandal to convince them that securing communication was a good idea. Free software developers have been creating secure tools for years that offer similar functionalities to all of those popular but very leaky services with ridiculous names.

  • FreeSWITCH 1.0.2 with New Codecs and Fax for VoIP

    Free VoIP platform software FreeSWITCH is now in version 1.0.2. Enhancements include a fax module and new codecs for higher sampling rates.

comments powered by Disqus