AI and VoIP Blog

VOIP | AI | Cloud | Kamailio | Open Source


PJSUA: Getting Started with the CLI Softphone

PJSUA is a versatile command line SIP user agent based on the PJSIP stack, ideal for VoIP engineers and enthusiasts. This guide covers the installation process on Linux and MacOS, and provides a quick start on its usage. For Windows users, please refer to the detailed instructions provided in the official PJSIP documentation.

Installing PJSUA on Linux

Install Dependencies: Open a terminal and update your repositories. Then install the following packages:

apt-get update
apt install python-dev-is-python3 gcc make gcc binutils build-essential

Get PJSIP: Download the PJSIP source code from github. We will use the latest version which is currently 2.14:

wget https://github.com/pjsip/pjproject/archive/refs/tags/2.14.tar.gz 
tar xvf 2.14.tar.gz
cd pjproject-2.14/

Configure and Build PJSIP: Configure the environment and build PJSIP:

export CFLAGS="$CFLAGS -fPIC"./configure && make dep && make

Install PJSUA: Copy the PJSUA binary to a directory in your PATH:

cp pjsip-apps/bin/pjsua* /usr/local/bin/pjsua

Verify Installation: Check if PJSUA is properly installed:

pjsua --version

Installing PJSUA on MacOS

On MacOS, the process is simplified with Homebrew:

brew install pjproject

Using PJSUA

Register a SIP Account: Use the following command to register a SIP account

pjsua --id="sip:USERNAME@DOMAIN" --registrar="sip:DOMAIN" --realm="*" --username="USERNAME" --password="PASSWORD"

Making a Call: To make a call, press “m” and then press enter key. Then enter the SIP URI in sip:number@host format and press the enter key again to place the call. Allow the request for microphone access to enable audio access for the call.

Specifying a Protocol: The default protocol is UDP. To specify a different protocol, use the --use-tcp, --use-udp, or --use-tls flags.For TLS, you might need to specify the TLS certificate file and the TLS private key file if required by your setup.

Receiving a Call without Registration: To start PJSUA without registering to a SIP server, you simply omit the registration-related parameters when launching it. You still need to specify your SIP URI with the –id option to identify yourself in calls

pjsua --id="sip:user1@ip_address"

Make a call to the SIP URI to and you should receive a call on the terminal.

The following tables show how to use other features, like answer an inbound call, send Update request etc.

Sample command

pjsua --id="sip:test@1.2.3.4:5060" --registrar="sip:1.2.3.4:5060" --realm="*" --username="test" --password="password"

You can also make a call directly without registering first, using the below command

pjsua --id="sip:USERNAME@DOMAIN" --realm="*" --username="USERNAME" --password="PASSWORD" <SIP_URI>

Sample Command

pjsua --id="sip:akash@test.com" --username="akash" --password="password" --realm="*" sip:123456@test.com

Conclusion

PJSUA offers a powerful and flexible way to interact with SIP protocols directly from your command line. Whether you’re a VoIP engineer or just starting out, PJSUA is an invaluable tool for testing, debugging, and managing SIP calls.

For more detailed information, visit the official PJSUA documentation.

Leave a Reply

Join 49 other subscribers

Akash Gupta
Senior VoIP Engineer and AI Enthusiast



Discover more from AI and VoIP Blog

Subscribe to get the latest posts sent to your email.



3 responses to “PJSUA: Getting Started with the CLI Softphone”

  1. […] For linux I prefer to build it from source – checkout my article about PJSUA to learn more – here […]

  2. […] For linux I prefer to build it from source – checkout my article about PJSUA to learn more – here […]

Leave a Reply

Discover more from AI and VoIP Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading