XMPP/Jingle To SIP Conversion

Published:
Hey there

Heard about jingle, the add on for XMPP that enables point to point audio between two XMPP clients. No server config necessary. Actually quite a cool feature. However, how good is it if you can not use those voice capabilities to do a PSTN phone cal, or call some SIP device you have. Well that isn't the purpose of Jingle anyhow. So other tools can do that including Asterisk and Freeswitch and that is what we are going to do in the article below.


Prerequisites :

Good Linux Administration Knowlege
Basic Understanding Of XMPP and SIP
A XMPP server running on a public IP "Openfire used here"
Access to change DNS names for your domain
A SIP client such as XTEN
A XMPP client with jingle capabilities such as JABBIN



Setting up Jingle To SIP

Well first of you will have to install Freeswitch since it the one tool that worked for me in Jingle to SIP conversion.

To do so go and get the latest Freeswitch and compile.

Well if you do have all the dependencies that should be as easy 1 2 3

The dependencies are

http://wiki.freeswitch.org/wiki/Inst...#Prerequisites

One thing you have to pay attention too is to enable the jingle module before compiling or you will have to recompile later on.

To enable the jingle module do the following:

Go to the directory where you extracted the Freeswitch source code, then go to modules.conf and make sure that the following line is not commented.

endpoints/mod_dingaling

After that follow the following guides

Check

http://wiki.freeswitch.org/wiki/Installation_Guide

and

http://wiki.freeswitch.org/wiki/Getting_Started_Guide

Once you did that you will have a couple of working extensions including 1000 and 1001 with password 1234. Just to make sure that everything is running correctly, launch freeswitch using

/usr/local/freeswitch/bin/freeswitch

It should load normally and give you no errors once that is done login using a softphone such as xlite or xten to the extension 1000 and dial 1001 it should return with a voicemail notice or ring and allow to make a call if you have to SIP phones registered.

So far so good let the dingaling beginning.

Now that we have freeswitch working fine and jingle support enabled, lets set up freeswitch to handle jingle traffic. What we want to achieve is the following. Login to your Gtalk account (You need two gtalk accounts for this test) and call the Gtalk account that you configured on your Freeswitch system, this will make the extension that you assigned to your Gtalk account ring. If you have set up your dialplan correctly your cellphone could ring too. That way all that you friends have to do to contact you is call you on gtalk. However you would be paying for the bills.

As a side note to close freeswitch, type shutdown

Back to the config part.

Edit dingaling.conf and set debug value to 1, this will help to know if something went wrong. I like to use jed as a command line text editor it is a great tool. If you set debug to 1 you can see all the XMPP messages that are passed between freeswitch and the XMPP server.

Now we can set up dingaling. In either of two modes client mode or server mode. If we choose client mode it means that the client we are going to configure is going to login to our xmpp server "gtalk server" in this case and therefore other jingle clients can see it as "online" call it, so the FS server would act as a jingle client.

If we configure component mode, it means that you do NOT have to set up one xml file per client instead you can have a whole sub domain of your XMPP domain being called automatically. To do so you have to set up your XMPP server (I use Openfire) and add a component secret and create a subdomain on your DNS server. That would be

Set up Component Secret + Port on openfire
Add Component to server on openfire
If the component name is fs add fs.mydomain.net to your DNS server and make it point to the FS server
Configure an XML server on FS and enter the correct configuration
Restart Freeswitch and you should be able to see the component connected in OpenFire.
To make a call you should login to your XMPP server as ususal and add a contact for example ext+ 1000@fs.mydomain.net this will allow you to call ext 1000 on your FS server.

Now I have to state the following. I have tried Freeswitch in client mode using the following two approaches:

With A Gtalk account and a gtalk client, this worked flawlessly
With server XMPP servers and jingle clients all register but FS was not able to do Jingle to SIP conversion in this case. The main reason as per FS developer Anthony is that jingle is a point to point protocol and FS was tested to work with Gtalk and telepathy. Note here that Freeswith does not use libjingle it uses it's own special jingle implementation
Another Approach I use was the component mode with my XMPP server, everything worked right expect jingle to sip conversion !! .

So Below I will show you a couple of sample configs however only the GTALK config really works.

You have to put the following configs in /usr/local/freeswitch/conf/jingle_profiles/

FS does read all XML files in this dir so if you want it to ignore one of those file either change the extension or change <profile></profile> to <x-profile></x-profile> FS is designed to ignore <x-etc></x-etc> directives.

GTALK Config "Works" this will allow you to call the account added below from any other gtalk client and the SIP extension defined in the lower part of the profile will ring

<profile type="client">
                      <param name="name" value="gmail.com"/>
                      <param name="login" value=" my_username@gmail.com/gtalk"/>
                      <param name="password" value="my_password"/>
                      <param name="server" value="talk.google.com"/>
                      <param name="dialplan" value="XML"/>
                      <param name="message" value="FreeSwitch (The Future of Telephony)"/>
                      <param name="rtp-ip" value="auto"/>
                      <!-- if you are behind NAT, you should probably use stun -->
                      <param name="ext-rtp-ip" value="stun:stun.xten.com"/>
                      <param name="auto-login" value="true"/>
                      <param name="auto-reply" value="Press *Call* to join my conference"/>
                      <param name="sasl" value="plain"/>
                      <param name="tls" value="true"/>
                      <param name="exten" value="1000"/>
                      </profile>

Open in new window


Typical XMPP Client Config "Logs in but did not work in Jingle->SIP" with Jabbin

Settings same as above however change necessary params and if it does not work set:

<param name="tls" value="false"/>

Component (Server-To-Server) Mode Configuration

<include>
                      <!-- Component (Server to Server Login) -->
                      <profile type="component">
                      <param name="name" value="fs.mydomain.net"/>
                      <param name="password" value="123456"/>
                      <param name="dialplan" value="XML"/>
                      <param name="context" value="public"/>
                      <param name="rtp-ip" value="$${bind_server_ip}"/>
                      <param name="server" value="mydomain.net:5275"/>
                      <!-- disable to trade async for more calls -->
                      <param name="use-rtp-timer" value="true"/>
                      <!-- "_auto_" means the extension will be automaticly set to the called jid -->
                      <param name="exten" value="_auto_"/>
                      <!-- <param name="exten" value="1000"/>-->
                      <!--<param name="vad" value="both"/>-->
                      <!--<param name="avatar" value="/path/to/tiny.jpg"/>-->
                      <!--If you have ODBC support and a working dsn you can use it instead of SQLite-->
                      <!--<param name="odbc-dsn" value="dsn:userass"/>-->
                      </profile>
                      </include>

Open in new window


As I said before, only the GTALK configuration worked for jingle to sip conversion. Set up a xml file with the gtalk contents and restart freeswitch once you do that logon to your gtalk account and you should be able to see that account configured on freeswitch online, call that account and the extension configured in the XML file --> param name="exten" will ring. Make sure you are signed in to your FS using XTEN and that extension as the username.

One more thing that could be done is to set up a PSTN gateway and a dial plan that way every time someone calls you on GTALK, FS converts jingle to SIP and forwards it to your PSTN gateway which in turn converts SIP to the circuit switched network. To achieve this do the following:

Create the file sip_profile/outbound/gw.xml
Insert the configuration below into after changing the params
<include>
                      <gateway name="PSTNgateway">
                      <param name="username" value="xyzxyz"/>
                      <param name="realm" value="pstn.gatway.com"/>
                      <param name="password" value="xyzxzyxzy"/> <param name="register-proxy" value="pstn.gatwway.com"/>
                      <param name="register-transport" value="udp"/>
                      </gateway>
                      </include>

Open in new window


Edit dialplan/default.xml and add the config below just below <context name="default">. This will cause all incoming calls to be routed to your PSTN gw. This config is NOT complete it's sole purpose is to demonstrate a FS feature. You can add/edit/remove conditions on this route as needed
<extension name="default">
                      <condition field="destination_number" expression=""/>
                      <action application="bridge" data="sofia/gateway/PSTNgateway/00yournumber"/>
                      </extension>

Open in new window


Once you did this you should be able to make a call from gtalk to your cellphone, to debug this configuration set sip_profiles/outbound.xml debug to 1 and trace to yes. This allows you to see SIP traces in the freeswitch console. If everything goes well it allows you to watch how the call starts in XMPP/Jingle and is later on routed to your PSTN GW as SIP.

The article above is in no way complete or guaranteed to work, it simply states how I got things to work in FS, the article also serves as a reminder for me because I could not complete the set up above untill a couple of days have passed and I asked in mailing lists, IRC and Google. The freeswitch documentation is cool but in jingle aspects it is very poor the only real reference to dinagling in the freeswitch documentation is:

http://wiki.freeswitch.org/wiki/Dingaling

It would be nice to hear some feedback, comments and/or corrections.
1
7,243 Views

Comments (0)

Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.