Wanted: Jingle for Google Voice

And I don’t mean an advert for radio.

On the 25th of August 2010 Google Voice announced calls could now be made from within the Gmail web browser interface. Fine, handy, I didn’t think much of it at the time and assumed it was just an HTTP request from Gmail to the Google Voice web service to initiate the call and that included a new trick to avoid the need for a callback.

I didn’t think anything more of it until I saw a post on the recent Asterisk 1.8 release. I’d already seen that Asterisk 1.8 supported making calls via Google Voice and again assumed it was done using HTTP. However this particular article stated that wasn’t the case and that Asterisk was using XMPP and the Jingle extension and an Asterisk wiki article on the topic seemingly confirms it.

Being able to initiate calls through Google Voice via XMPP was something I found interesting. Not because I find the existing HTTP callback mechanism clunky, although it is, I just don’t need to make any calls to the US. But it’s always fun integrating voice technologies and being able to place calls to the PSTN through a major service with XMPP was something new, at least in my experience.

There are XMPP libraries around and in fact sipsorcery already uses the AG Software XMPP library to for the sys.GTalk dialplan method. For fun I decided to spend Saturday seeing how far I could get towards placing a call to Google Voice via XMPP from scratch. XMPP is a bit different from SIP and revolves around the concept of XML streams. Having worked a lot with XML over the years it wasn’t hard to grasp. By the end of the day I was able to successfully connect, authenticate and send instant messages to a GTalk client. However at the next step of initiating a call to Google Voice I ran into a bit of a dead end.

I obviously wasn’t the first programmer to try this as there was already the Asterisk 1.8 implementation that had been in existence for at least 3 weeks. And after a little bit more digging it appears the FreeSWITCH implementation was around for at least a month before that, I’m guessing the Asterisk implementation borrowed from the FreeSWITCH one. I therefore assume Google Voice must have documented or blogged about what was required to connect with them over XMPP. Although one thing I found strange was that there is no facility in Google’s own XMPP client, GTalk, to initiate a call to the PSTN, at least not for me. After a bit more searching I haven’t really made any headway and it looks like I’m going to have to fire up gdb and attach to Asterisk (I’m more capable of driving it than FreeSWITCH). The FreeSWITCH and/or Asterisk programmers got the knowledge from somewhere and I’m wondering if it was reverse engineering the GMail calls or not…

The exercise has left me wondering about Google Voice and XMPP. Given the level of activity around the various mechanisms to make Google Voice calls from SIP I would have thought that more people would have picked up on the new capability of originating calls via XMPP. To translate a SIP call to XMPP is actually very simple compared to the sort of mechanism sipsorcery uses with the HTTP request and the use of a callback provider. My main driver is curiosity but there are a lot of people out there that take it a personal challenge to get free calls as easily and conveniently as possible and it’s curious that they haven’t picked up on this yet.

Oh and if I’ve missed a reference which specifies the format for the Jingle calls to Google Voice, which is entirely possible, I’d be grateful for any information :).

Update (couple of hours after original post): I started trying the different call request formats I stumbled across in a Google Talk API reference. After a few attempts I was still getting nowhere and then I got a error message back with a redirect destination. That looked promising so I parsed that out and resent the call request. This time I got back what looked like a pending response but then after about 10 seconds I got a “pho:recipient-unavailable session timed” out error message. I tried a few different numbers and number formats just to make sure but still couldn’t get past that message or get any of my numbers to ring. Still it’s a step closer.

  1. Avi Marcus’s avatar

    Hi. I’ve been using freeswitch for a bit and it made it easy to set up google voice.
    There’s a mod called mod_dingaling which is the xmpp protocol. It uses gnutls for the tls, but otherwise it makes no mention in the wiki on any libraries it borrows from.
    The wiki http://wiki.freeswitch.org/wiki/Google_Voice defines the settings for the jingle client to login to a google voice account.
    You could grab a git clone of the freeswitch source and go to: /src/mod/endpoints/mod_dingaling
    I couldn’t make much of it, but it’s C and looks pretty neat.

    Reply

    1. sipsorcery’s avatar

      Have you been able to place an outgoing call to the PSTN via Google Voice through FreeSWITCH?

      Reply

    2. Avi Marcus’s avatar

      Yes, easily via the supplied instructions. In my little testing, it didn’t return a reliable ring-back and sometimes the remote party picked up and it rang by the caller for another few seconds before the RTP connected.
      Also, incoming via jingle is weird – I haven’t tested really much, but if you have other google voice clients on with the name it may not come in, and it doesn’t always “connect” when you pick up. You may need to set “call screening” and then press 1 with the pbx. Hmm, not a problem to do that with freeswitch but SS can’t press 1 for you for incoming.

      Reply

      1. sipsorcery’s avatar

        I’ve looked over the FreeSWITCH mod_dingaling code and also the Asterisk 1.8 chan_jingle. Unfortunately it looks like they are using different approaches and I think even different jingle standards. I’ve hit a snag installing FreeSWITCH on my windows laptop so I haven’t yet been able to try and do a call myself. If you’re willing and able to turn on FreeSWITCH verbose logging and see if you get any messages when the Google Voice call goes out it would be very handy for me. The message in question would be an XML packet with a format like:

        ….

        Reply

        1. yejun’s avatar

          Asterisk uses chan_gtalk.so.
          I can make pstn calls, but incoming call will be always screened. In gmail webclient, you get a dialog with answer, screen and cancel.

          Reply

        2. avimar’s avatar

          I tried a debug and lots of logs, but I didn’t really see anything that would be useful to you. Sorry. Also, I don’t think they implemented media bypass, meaning it wouldn’t be out of the stream like you want.
          Ask for the devs or something at #freeswitch on freenode

          Reply

        3. sipsorcery’s avatar

          I’ll fire up Asterisk 1.8 on an Amazon EC2 instance tonight. I’m pretty familiar with its soruce code, unlike FreeSWITCH, so it will be easy for me to debug or add some extra log statements to reverse engineer the XMPP jingle requests being sent to Google Voice.

          Reply

        4. Yitzchok’s avatar

          FreeSWITCH for windows MSI installer
          http://files.freeswitch.org/windows/installer/

          Reply

          1. sipsorcery’s avatar

            Yes I might give the Windows Installer a shot. I did get FreeSWITCH to build on my Windows 7 (64bit) laptop except for the sofia SIP library. Unfortunately it’s crucial as it’s the channel I need to initiate calls (don’t know any other way).

            Reply

          2. Yitzchok’s avatar

            I had that same pain going though compiling on windows with VS2010 so at the end I just compiled with vs2008 but i heard that it should compile now fine in VS2010 you just have to make sure that you set “core.autocrlf” to false in git http://wiki.freeswitch.org/wiki/Download_FreeSWITCH#Clone_on_Windows

            Reply

            1. sipsorcery’s avatar

              I didn’t have any problems with the git clone (maybe I was lucky). I suspect the core.autocrlf is to tweak the end of line characters and I didn’t seem to have any issues there either. Visual Studio can handle the unix n line feeds so it shouldn’t matter.

              Reply

Reply

Your email address will not be published. Required fields are marked *