VoIP with FreeSWITCH
Talk Soft
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
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Linux Sees Massive Performance Increase from a Single Line of Code
With one line of code, Intel was able to increase the performance of the Linux kernel by 4,000 percent.
-
Fedora KDE Approved as an Official Spin
If you prefer the Plasma desktop environment and the Fedora distribution, you're in luck because there's now an official spin that is listed on the same level as the Fedora Workstation edition.
-
New Steam Client Ups the Ante for Linux
The latest release from Steam has some pretty cool tricks up its sleeve.
-
Gnome OS Transitioning Toward a General-Purpose Distro
If you're looking for the perfectly vanilla take on the Gnome desktop, Gnome OS might be for you.
-
Fedora 41 Released with New Features
If you're a Fedora fan or just looking for a Linux distribution to help you migrate from Windows, Fedora 41 might be just the ticket.
-
AlmaLinux OS Kitten 10 Gives Power Users a Sneak Preview
If you're looking to kick the tires of AlmaLinux's upstream version, the developers have a purrfect solution.
-
Gnome 47.1 Released with a Few Fixes
The latest release of the Gnome desktop is all about fixing a few nagging issues and not about bringing new features into the mix.
-
System76 Unveils an Ampere-Powered Thelio Desktop
If you're looking for a new desktop system for developing autonomous driving and software-defined vehicle solutions. System76 has you covered.
-
VirtualBox 7.1.4 Includes Initial Support for Linux kernel 6.12
The latest version of VirtualBox has arrived and it not only adds initial support for kernel 6.12 but another feature that will make using the virtual machine tool much easier.
-
New Slimbook EVO with Raw AMD Ryzen Power
If you're looking for serious power in a 14" ultrabook that is powered by Linux, Slimbook has just the thing for you.