Arnaldo’s Weblog

comments and stuff about linux, mac os x, freeswitch and asterisk – mainly

Skype, Gtalk and SIP

leave a comment »

FreeSWITCH supports some endpoints, most notably Skype through mod_skypiax, Gtalk through mod_dingaling and SIP through mod_sofia. Some time ago, I’ve thought about setting up my gtalk and skype accounts on a FreeSWITCH installation and let it automatically handle the calls’ routes, collect voicemails and what not.

I’ve been so lazy that it took me a lot of time to set it up. Anyway, I’ve configured it on a slicehost’s VPS and it works like a charm, making possible inter endpoints calls, taking care of the audio transcoding and everything. I can think of a few goodies of having the gtalk, skype and a SIP account configured on a FreeSWITCH instance:

1. Convergence: if a friend calls me on Gtalk, my SIP client rings. Note that the SIP client might be anywhere – I’ve been using it on my mobile and find it great.

2. Features/facilities for them all: all the three protocols might take advantage of the applications that comes with FreeSWITCH. I have configured: voicemail, hunt group / follow-me with whitelisting for calling me on my mobile if the call comes from a trusted source, call back + “DISA” allowed just for my mobile number, conference with an icecast live streaming, etc.

3. LCR: if you have more than one way to reach PSTN, each one with different call rates, you might configure different routes for each number pattern. In my case, I’m using SkypeOut for all my outgoing calls.

4. Ease of use: the user doesn’t have to open his/her Gtalk and Skype every time he/she wants to be online. Instead, just open the SIP client on the mobile phone (if it’s not opened already, mine is for days) and it just works.

My FreeSWITCH server runs on a virtual server with 512MB of RAM memory and the calls usually works perfectly on the three protocols. Please note that this isn’t the recommended hardware for running FreeSWITCH, but it just works. And well.

Written by arnaldopereira

January 19, 2010 at 6:44 pm

Posted in FreeSWITCH, VoIP

Android + Ubuntu

leave a comment »

I’ve got a brand new (old) HTC G1 phone and just connected it to an Ubuntu box. The Android documentation instructs us to create an udev rule, as:

SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", MODE="0666"

After doing so, connecting the G1 to the box and running adb devices, I’ve got the error:

???????????? no permissions

Some pages says one has to be more specific on the udev rule and also add the device id (not just vendor id) to the rule, like so:

SUBSYSTEMS=="usb", ATTRS{idVendor}=="0bb4", ATTRS{idProduct}=="0c02", MODE="0666"

Although, that doesn’t solve the problem. I’ve had to start adb server as root instead and the problem disappears. As a normal user:

./adb kill-server
sudo ./adb start-server
./adb devices

Written by arnaldopereira

January 19, 2010 at 5:59 pm

Posted in android templetor

leave a comment »

I’ve used some times (or even several, already?) and really enjoy it. The majority of the framework is really easy to use – and powerful, but the usage of $ on the templetor can be confusing, even after reading it’s well written documentation.

A question about it has raised on the webpy mailing list and Anand Chitipothu, as clear as always, explained, in the simplest form, how it must be used:

1. As a marker to indicate python expressions.

$f(x, y)
$(x + y)

2. As as a marker to indicate python statements and var. ($
immediately followed by a keyword).

$for n in numbers:
$if x == 0:

3. As a marker to indicate python assignment. ($ followed by space)

$ x = 1
$ x = y + z*x

I think this covers all possible uses.

Written by arnaldopereira

November 5, 2009 at 3:24 pm

Posted in python, web


leave a comment »

I was trying to figure out where to host a svn server for a project and got impressed when I realized my client’s account on Locaweb already provides that. Also, it allows one to log into the server through ssh – no big deal, but cool.

Then, for the first time, I’ve logged into the server. As curious as I am, I was wondering what command line tools was available to my account and also in which (scripting) language they were written in, which led me to:

[mahuser@thahost ~]$ user
user-fix-owner users user-svn-deactivate user-svn-permissions user-wsgi-autostart user-wsgi-list
user_list user-svn-activate user-svn-list user-wsgi-activate user-wsgi-deactivate
[mahuser@thahost ~]$ which user-svn-activate
[mahuser@thahost ~]$ file /usr/bin/user-svn-activate
/usr/bin/user-svn-activate: Bourne-Again shell script text executable
[mahuser@thahost ~]$ cat /usr/bin/user-svn-activate

if [ -z "$domain" ] ; then
echo "Usage: ${0/*\//} "
exit 0

/usr/local/locaweb/bin/locarun svn activate $domain
[mahuser@thahost ~]$ file /usr/local/locaweb/bin/locarun
/usr/local/locaweb/bin/locarun: setuid ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, not stripped
[mahuser@thahost ~]$ /usr/local/locaweb/bin/locarun
Segmentation fault

We all know that parsing is the biggest point of security flaws in software, BUT, when I saw that this locarun program expected an argument, I could bet it would crash if I didn’t pass one to it.

There’s also GCC and debugging tools on the server. What confidence does a service like that gives me? Well, do the math.

Written by arnaldopereira

June 13, 2009 at 4:13 pm

Posted in random

Web console for FreeSWITCH

with 10 comments

After the addition of event_sink command to the event_socket interface (more on that later), I’ve rewrote the web console with more functionality: commands, event and logging. That means one can see the logs that appears on FreeSWITCH default console through a web browser.

The console is written using GWT.

Command completion screenshot:

Command completion

Event details:

Event detail

View logs:

View logs

To use it, download the compiled code from here, unzip it into FreeSWITCH’s htdocs folder and point your browser to http://freeswitch-ip-address:8080/org.freeswitch.FSConsole/FSConsole.html

Full size screenshots:

Written by arnaldopereira

January 4, 2009 at 5:24 pm

Posted in FreeSWITCH

Tagged with

Rough FreeSWITCH console with GWT

with 3 comments

When writing an web ui for a automated dialer, I thought it’d be nice to have a client for FreeSWITCH written in GWT, the Google Web Toolkit. Actually, it would be even more nice to have a full featured ui written in GWT.

Anyway, I wrote a test and it works. It’s far from being nice to use, but it shows how easy it is to write web 2.0 apps that communicate with FreeSWITCH. The compiled source code is here, to use it, just unzip it on FreeSWITCH’s htdocs directory, usually: /usr/local/freeswitch/htdocs and point your browser to http://ipaddr:8080/com.ap.FSConsole/FSConsole.html

There’s almost no functionality in this program, it just works as a wrapper between your browser and FreeSWITCH’s xmlrpc interface. It also has completion for a minor number of commands (screen shot here). You should have mod_xml_rpc enabled to use it.

I tried to paste the source code here, but it stays VERY ugly with this template.

Update: As suggested by MikeJ, the autocomplete commands’ list is now fetched from FreeSWITCH.

An updated version of the gwt console for FreeSWITCH

Enormous source code here.

Zip with the whole directory tree, as well as Eclipse’s project file, here. The two scripts inside the zip file, FSConsole-{shell,compile} should be updated with the proper gwt’s compiler path for the whole thing to work. They both are generated by gwt and have the jar’s path absolute; I’m not sure how to change that, but if anyone is willing to touch the code, please let me know.

In the meantime, I’ll keep shaping in my spare time.

Just to double check if you understood what’s this about: GWT is a set of axioms and a compiler. It allows the user to write code in Java and generates an output in HTML+Javascript. So you just have to touch the Java code if you plan to change/extend the UI’s behaviour, otherwise just use the zip file.

Written by arnaldopereira

November 19, 2008 at 12:58 am

Posted in FreeSWITCH

Tagged with , ,

libopenr2 and FreeSWITCH

with 2 comments

I haven’t taken the time to do some things with FreeSWITCH or anything alike. Actually, I dropped the development of the MFC/R2 endpoint for Digivoice cards and have written nothing since that, so it’s time to come back. As I get no money out if it (either from VoixTel nor anybody), I work on it when I can, so don’t create any expectations about it. I don’t create any about you, the visitor, neither.

One thing I should mention here, is the willingness of Devel IT, a brazilian company, to borrow me some Digivoice cards, free of charge, so that I could write and endpoint for FreeSWITCH to support it. Digivoice itself has borrow me a card, but for a limited time and, when the period has expired, they had asked me to buy the card or to return it.

For some months I’ve used FreeSWITCH in production systems, in the middle of Asterisk and SipXecs to take care of things Asterisk just don’t understand – and to more reliably take care of the things, none wants a PBX software process to hang on gethostbyname() calls when a DNS server is not available. It has shown to be a very stable and rock solid piece of software, easily extensible and many-other-good-things-anyone-can-write-here. Now, Moy, a Mexican software engineer, has come up with another good piece of software: libopenr2.

There are also some brazilians working on the develpment of the library, most notably the ones cited on the CREDITS file, as: Alexandre Cavalcante Alencar, Cleiber Marques da Silva and Humberto Figuera. (NOTE: Humberto Figuera is actually venezuelan, really sorry Humberto.) Melcon Moraes is also notable for taking the time and risk of installing the library on some of our company’s production servers. I know those guys will keep the good work and fix/report any issues they might find.

What I plan to do now, is to make sure the build process works on mac OS X. After that, write an FreeSWITCH endpoint. Besides it’s 4:27am, and I haven’t slept more than 10 hours in the last ~5 days, I’m pretty much excited about all this and I’m anxious to port the library and write the endpoint for FreeSWITCH. The company I co-own uses fonast as it’s gateway platform, which means an Asterisk 1.2 which _a lot_ of fixes from Fonality, but that’s just not acceptable anymore.

The last thing I needed to write for it, was a work-around to get a partial QSIG-CF (ECMA-174) to work with Ericsson MD110 devices. I promised to myself not to touch any Asterisk’s, or libpri’s as that’s the case, anymore, as they’re VERY badly written. As a note, again: I really enjoy what Asterisk has exported, but it doesn’t fit my present needs and I don’t plan to use it on new projects. Anyway, after a hack in libpri, the partial QSIG-CF was working properly with MD110 and our client was happy.

Now to the real solution: let’s see how many days I take to port OpenZAP to OS X and, after that, make libopenr2 build on OS X. That’s the first step to have a FreeSWITCH endpoint which already implements forced disconnection on MFC/R2 Brazilian links, collect calls blocking and some other goodies. Of course I have just my spare time to work on that, but I don’t think It’ll take very long time – and I’m sure it’ll worth it, FreeSWITCH just runs out of the box and fixes the issues we have, instead of adding more. So, I really think the path to the MFC/R2’s FreeSWITCH endpoint is with libopenr2.

The conclusion is a little confusing here, but, for the people who work with those things, the idea is clear. Maybe I’ll try to sleep a little now.

Written by arnaldopereira

September 26, 2008 at 4:47 am

Posted in FreeSWITCH

Tagged with , , , ,


with 3 comments

I can’t wait to have a dozen of FreeSWITCH deploys, so we can sleep at night without worries. For that I have to satisfy a need in Brazilian telephony systems: E1 MFC/R2 support. That procotol was developed in 1954 and is still broadly used in Brazil, Mexico and Asian countries.

We can add support to it in Asterisk, since Steve Underwood wrote chan_unicall and, most importantly, spandsp, libunicall and libmfcr2. That was a huge contribution to us, merely mortals from the third world. Asterisk could then be used as the gateway between calls from the TDM to the IP world and vice-versa; within a single box, we could have a Sangoma card (no, not Digium) and some application the callers/callee would end up being served with.

That was nice, but that was before the problems started to appear. Asterisk showed itself poorly designed, the deadlocks were frequent and there really wasn’t anything being done to address this issue. We weren’t even using (ISDN) PRIs, “there’s probably something wrong with the unicall implementation”, we naively thought, but years after hunting bugs that lied in bottom layers, we found out that Asterisk itself implemented the errors. Or, probably more appropriately, that it has never written to deal with those situations, which fired a paradox in my head, I thought it was.

Today, Digivoice, a Brazilian cards manufacturer, produces cheap E1 cards which takes care of the signalling on the hardware side. I’m writing a driver so that FreeSWITCH can support MFC/R2 through the usage of those cards, which will be extremely useful to us. Besides that, Steve Underwood is also making his protocol’s implementation set work on FreeSWITCH, which will probably become officially supported by the project.

At the same time version 1.0 will be released, I’ll have the MFC/R2 driver for Digivoice cards. I’ll soon be able to use just FreeSWITCH where I need MFC/R2.

Written by arnaldopereira

May 25, 2008 at 2:09 am

Posted in FreeSWITCH

Tagged with ,

FreeSWITCH 1.0 coming

leave a comment »

The FreeSWITCH project will get to an important milestone may 26th, next monday, when the version 1.0 will be released.

For the people involved with the project, which includes the developers, testers, users and everybody else, this is a great achievement. The project was a promise since it’s early days of development and, since it reached some level of stability, several months ago, it already showed it’s architecture was rock-solid.

My company has used FreeSWITCH in a multihomed environment for several months, serving a passive call center, which used to make television ads to receive calls, hence creating a peak of calls on small periods of time. Asterisk was the gateway between a TDM E1 MFC/R2 link and a SIP VoIP account, for that it worked kind of fine; the errors were manageable. When two internet links were connected to it, with the purpose of load balance the outbound calls, we got stucket. Asterisk just sends RTP packets to the server’s default route, hence making it useless on multihomed environments.

I advised my fellow Melcon Moraes to use FreeSWITCH to solve the problem. He was already aware of the project and probably had played with it at home, but he surely had never used it on production systems, neither I did, the first version wasn’t even released – we were issuing svn checkouts commands to install it on our client box. Our plan was to put it in front of the Asterisk process, which should act as the gateway between SIP and MFC/R2, also making the transcoding of the RTP media from/to g729 and g711 – a candy to who figure out what codec was used at each side.

 The downside here is that we had to keep Asterisk on the path, because FreeSWITCH doesn’t support MFC/R2, nor does it transcode g729. That’s a bad thing, because assuming FreeSWITCH works the way we expect it to, we don’t want to have Asterisk anywhere near that system, but it turns out everything worked well together. FreeSWITCH solved our issues with load balancing, sending or receiving the calls the way we wanted it to do and Asterisk was kept as the gateway. 

It was incredible to checkout the project’s trunk and have it working for months without a single human interaction. After the first configuration, everything was fine and the outbound calls were sent to the VoIP provider using a simple round-robin strategy, which was more than enough to solve the client’s issues.

Version 1.0 will be out on monday. 🙂

Written by arnaldopereira

May 25, 2008 at 1:38 am

Posted in FreeSWITCH

Tagged with ,

Friendfeed’s rooms

leave a comment »

Friendfeed has rooms now. If you’re not familiar with friendfeed, mixing feeds with rooms may sound very strange to you, but for the site’s users this probably makes sense. If you’re not getting anything and doesn’t know friendfeed, it’s a news streamer, created by Google’s ex-employees. Check it out here, it’s worth it.

I’ve used friendfeed for some months now and found it to be very handy for sharing stuff and discussing ideas, but I felt there could be some boundaries on the context you discuss things, or the context the things are shared, or something like that. What I mean is: I can choose the people I subscribe to, but I can’t filter my friends’ feed, in a way I could get a feed about a specific subject.

Friendfeed’s rooms brings that functionality to the users. It actually goes beyond that, since it makes possible to the users to control who can join a specific group, which is useful to discuss private things (I wonder what “the terms of use” says about the content).

Anyway, Google Blogoscoped has a more clarifying post about ff’s rooms here.

Written by arnaldopereira

May 23, 2008 at 11:51 am

Posted in random

Tagged with