betabug... Sascha Welter

home english | home deutsch | Site Map | Sascha | Kontakt | Pro | Weblog | Wiki

06 March 2010

pjsua: The Geek Out SIP Client

It's as geeky as making a phone call can get

There are many options for making SIP/VoIP phone calls over the Internet. There are some with nice user interface, some that get you over almost all the the little hurdles and problems (like for example X-Lite, which you should try if you're ever stuck unable to make a connection, as it seems to work around most problems on its own). But if you're a real geek at heart, there is only one choice: pjsua. pjsua does not have any such timewasting features as a GUI or an address book.


In fact pjsua isn't really meant to be used as an everyday SIP client. It's more of a reference implementation, helping to make sure that a setup is right, helping you to find out what's going on over the (virtual) SIP wire. In the default setup it spews out all kind of connection messages and status things. The configuration is done over command line arguments.

But then, if you want to geek out, you can use pjsua very well as your everyday SIP client. Some of the shortcommings it has, will only help to keep you interested... and in the end you could use one of the language interfaces to the pjsip API to build your own client anyway.

So here's some of my setup: First of all you can also place those command line arguments you need to set up accounts and all that into a file in order to get something like a "saved account preferences". I then call pjsua with only one argument, the path to that file. Next I've created an alias in the shell, to call pjsua with that one argument.

Here is how such a config file could look:

# pjsua SIP client config file
# http://www.pjsip.org/pjsua.htm
--app-log-level=3
# get rid of almost all those status and debug messages
# ------------------------------------------
# when I'm in the office, I hook up to the PBX
--id sip:112@10.0.7.14
--registrar sip:10.0.7.14
--realm 'Registered Users'
# the realm used for our Panasonic PBX
--username 112
--password supersecret
--reg-timeout=1800
# the PBX initially complained about a too short registration
# timeout value, that's why this is here
# ------------------------------------------
--next-account
# ------------------------------------------
# a (hypothetical) SIP provider for my private calls:
--id sip:1234567890@sip.example.com
--registrar sip:sip.example.com
--username 1234567890
--password supersecret
--realm=sip.example.com
# this provider works only with UDP:
--no-tcp
--stun-srv=stun.example.com

You separate different accounts with ``--next-account``, then you probably can set up as many accounts as you want. So, even if this file is just "command line arguments written into a file", it works as well as any Unix config file.

Given that I've used ``--app-log-level=3`` to cut out most of the debug infos, the user interface is much more useable. The debug info *does come in handy*, the moment something doesn't work out, like when I had to find out why the PBX complained about a "too short time given" or something. In everyday usage, I just cut the log-level down and the UI cleans up. It now looks something like this:

+=============================================================================+
|       Call Commands:         |   Buddy, IM & Presence:  |     Account:      |
|                              |                          |                   |
|  m  Make new call            | +b  Add new buddy       .| +a  Add new accnt |
|  M  Make multiple calls      | -b  Delete buddy         | -a  Delete accnt. |
|  a  Answer call              |  i  Send IM              | !a  Modify accnt. |
|  h  Hangup call  (ha=all)    |  s  Subscribe presence   | rr  (Re-)register |
|  H  Hold call                |  u  Unsubscribe presence | ru  Unregister    |
|  v  re-inVite (release hold) |  t  ToGgle Online status |  >  Cycle next ac.|
|  U  send UPDATE              |  T  Set online status    |  [  Cycle prev ac.|
| ],[ Select next/prev call    +--------------------------+-------------------+
|  x  Xfer call                |      Media Commands:     |  Status + Config: |
|  X  Xfer with Replaces       |                          |                   |
|  #  Send RFC 2833 DTMF       | cl  List ports           |  d  Dump status   |
|  *  Send DTMF with INFO      | cc  Connect port         | dd  Dump detailed |
| dq  Dump curr. call quality  | cd  Disconnect port      | dc  Dump config   |
|                              |  V  Adjust audio Volume  |  f  Save config   |
|  S  Send arbitrary REQUEST   | Cp  Codec priorities     |  f  Save config   |
+------------------------------+--------------------------+-------------------+
|  q  QUIT   L  ReLoad   sleep MS   echo [0|1|txt]     n: detect NAT type     |
+=============================================================================+
You have 1 active call
Current call id=1 to sip:00411234567@sip.example.com [CONFIRMED]
>>> h
>>>  14:16:00.784    pjsua_app.c  Call 1 is DISCONNECTED [reason=200 (Normal call clearing)]

At the top is the status-and-command menu, a bit like on a BBS. Below is a prompt. There was a call in progress, which I just hung up using the h command. For example to make another call, I'd enter m, then I would be prompted to enter the number... but pjsua expects a sip-URI, something like the sip:00411234567@sip.example.com in the example screen. I'm not currently using the "buddy list" stuff, probably I could use that as some sort of rudimentare address book. For the few calls that I make currently, I just cut and paste these URLs.

So the usage of this beast can't get any more geeky. What's great though is the technical level: Since pjsip/pjsua is a reference implementation, you get the best that there is. The call quality is great. There are no delays to draw some GUI elements on the screen. (At least on my Macs,) audio just worked. I don't have to live with the limitation of some GUI SIP-clients (like the free X-Lite only giving you one account set up), I have my own geeky limitations!

Posted by betabug at 14:51 | Comments (13) | Trackbacks (0)
ch athens
Life in Athens (Greece) for a foreigner from the other side of the mountains. And with an interest in digital life and the feeling of change in a big city. Multilingual English - German - Greek.
Main blog page
Recent Entries
Best of
Some of the most sought after posts, judging from access logs and search engine queries.

Apple & Macintosh:
Security & Privacy:
Misc technical:
Athens for tourists and visitors:
Life in general:
<< Strike in Athens | Main | Planting Trees >>
Comments
PJSIP rocks !

Nice article Sasha. PJSIP rocks ! So much so that I wrote a mos score calculator for it ! at http://www.unix.gr/siprtp_report.diff

Posted by: Angelos Karageorgiou at March 08,2010 12:31
Re: pjsua: The Geek Out SIP Client

Yes Angele, pjsip / pjsua r0xx. Just a few days ago a friend couldn't get some setup to work on one machine. Trying with pjsua he could prove that it was possible to get a working SIP setup. From that point on, other "more user friendly" clients were researched.

Posted by: betabug at March 11,2010 14:37
Re: pjsua: The Geek Out SIP Client

Did you use the default config to compile on OS X? I got pjsip to build, but I get no audio from pjsua...

Posted by: Kurt Ward at March 12,2010 01:28
Re: pjsua: The Geek Out SIP Client

Hi Kurt, yes, I used the default config. Sound was working both on 10.4 and 10.6 (a white MacBook and a MacBook Pro 15", so both machines with Intel processors). Everything worked without any special intervention from me.

Posted by: betabug at March 12,2010 10:24
Re: pjsua: The Geek Out SIP Client

It's realy GEEKy..:) i like it very much..Thanks for good info.

Posted by: schef at December 20,2010 14:49
Re: pjsua: The Geek Out SIP Client

Is it possible to call landlines via a sip provider?

Posted by: Steve Furniss at April 26,2012 23:22
Re: pjsua: The Geek Out SIP Client

Steve, yes, of course it is possible to call landlines via a sip provider. I do it all the time. I even gave an example in the article. There is no difference there between pjsua and any other sip client software.

Posted by: betabug at April 27,2012 08:51
Re: pjsua: The Geek Out SIP Client

Hi betabug,
I'm also having trouble with no sound! (osx 10.8)

Could you possibly run with --app-log-level 5 and paste your sound config info? Apparently pasound.c shold run, but my console output doesn't show it!

Thanks :)

Posted by: hayim at August 23,2013 00:25
Re: pjsua: The Geek Out SIP Client

hayim, sorry, I don't have access to that OS X machine any more.

Posted by: betabug at August 23,2013 10:48
Re: pjsua: The Geek Out SIP Client

"Steve, yes, of course it is possible to call landlines via a sip provider. I do it all the time. I even gave an example in the article. There is no difference there between pjsua and any other sip client software."

I don't see this example in the article. I'm scripting pjsua to call me and if I don't enter a SIP destination but instead enter a regular phone number I just get "Invalid SIP URI". Thank you !

Posted by: Nick Teeple at February 05,2015 20:56
Re: pjsua: The Geek Out SIP Client

In the example given, "sip:00411234567@sip.example.com" is the SIP URI. Usually you will have to build the SIP URI out of the prefix ("sip:"), the landline phone number (00411234567 in the example), and - joined by "@" - your provider's domain ("sip.example.com" in the example).

Posted by: betabug at February 05,2015 21:52
Re: pjsua: The Geek Out SIP Client

That worked perfectly, thank you so much for your prompt assistance. Here's the guide I was following: http://www.admin-magazine.com/Archive/2013/13/Nagios-alerts-implemented-via-VoIP

Posted by: Nick Teeple at February 06,2015 02:29
Re: pjsua: The Geek Out SIP Client

Hi betabug,
I was searching for command line SIP client and came across your link.
pjsua does seem interesting option to me as I plan to do following.
(1)Register with remote SIP server. (define codecs,remote port,tranport,secure rtp)
(2)Receive incoming calls from that server and auto answer.
(3)Play an audio file
(4)Terminate

I plan to run my sip client in backend and handle the call flow which I mentioned above.
Do you think I won't have any issues implementing above with pjsua?

Posted by: Sam at October 12,2015 13:58
Trackbacks
You can trackback to: http://betabug.ch/blogs/ch-athens/1051/tbping
There are no trackbacks.
Leave a comment