Amarisoft

How to answer a MO call with an audio file

This article describes how to setup an IMS environment to answer call from UE with an audio file.

 

Use PJProject as SIP client

First step is to build pjproject with AMR codec support.

Follow the following tutorial.

Note that you can download pjproject sources Here.

When building pjproject, you may have errors and need to install dev packages (alsa, ffmpeg).
After installing packages, start building from scratch (from ./configure).

 

Convert audio file to wav to use with pjsua

The pjsua SIP clients requires a 16bits mono wav file.
To create it from any audio format use the following command line:

ffmpeg -i myaudiofile -acodec pcm_s16le -ac 1 -ar 16000 test.wav

It will generate a test.wav file that will be used in next step.

 

Configure IMS for pjsua SIP client

When running pjsua SIP client, you need it to register to IMS.
We assume that you use default ims.cfg configuration file.

Add the following entry in your ue_db (ue_db-ims.cfg):

{ /* Dummy SIM information for MME */ sim_algo: "xor", imsi: "000000000000000", K: "00000000000000000000000000000000", amf: 0x0000, /* SIP client informations */ impi: "sipclient", impu: ["tel:1234"], pwd: "sipclient", authent_type: "MD5", }

 

Run pjsua SIP client

After building pjproject, you should find the pjsua SIP client under pjsip-apps/bin/pjsua-x86_64-unknown-linux-gnu pjproject sources subdirectory.

Create the following text file as pjsua.cfg:

--realm amarisoft.com --registrar sip:192.168.4.1 --id tel:1234 --username sipclient --password sipclient --local-port=5061 --play-file=test.wav --auto-play --auto-answer=200 --null-audio

 

Start pjsua

Your IMS server must be running (and thus your MME).
Launch the following command:

./pjsip-apps/bin/pjsua-x86_64-unknown-linux-gnu --config-file=pjsua.cfg

It assume your are under pjproject source directory and you have copied your test.wav audio file and pjsua.cfg config file there.
Of course you can change the path if needed.

Once started, the pjsua SIP client should be registered.
You can check it by typing users in IMS CLI with the following result:

IMPI: sipclient SIP Binding: URI: sip:192.168.4.1:5061;ob IMEISV: Prio: 1.0 Expires: 255s Options: IMPU: tel:1234

 

Place a call

All you have to do right now is placing a call with 1234 as phone number from your VoLTE client.
You should here your audio file played.

 

Beyond

Take a look at pjsua configuration, you may find a way to record calls or advanced features.

 

Start PJSUA as a service linked to LTE

Create a pjsua.sh file with execution permissions and following content:

#!/bin/bash set -e cd $(dirname $(readlink -f $0)) /usr/bin/screen -dmS PJSUA ./pjproject-2.10/pjsip-apps/bin/pjsua-x86_64-unknown-linux-gnu --config-file pjsua.cfg while [ true ] ; do sleep 5; screen -ls | grep PJSUA; done

Create a pjsua.service file with following content:

[Unit] Description=PJSUA Requires=lte.service After=lte.service [Service] Type=simple ExecStart=/data/sip/pjsua.sh Restart=always RestartSec=5 User=root [Install] WantedBy=multi-user.target WantedBy=lte.service

NB: change path of ExecStart in pjsua.service (Must be an absolute path).
NB: Those two files should be placed at same location as audio file and pjsua config file.
NB: You may change the User parameter of pjsua.service if you have not done first steps of this page as root.

Then execute the following commands as root:

cp pjsua.service /lib/systemd/system/ systemctl -q --system daemon-reload systemctl enable pjsua systemctl start pjsua

Now, pjsua will be started and stopped automatically depending on LTE service state.
Note that it is launched in a separate screen instance called PJSUA. You may access it via:

screen -x PJSUA