I changed a single setting in my Asterisk 1.8 gtalk.conf and bingo my Google Voice call worked. The setting was to specify a stunaddr rather than specifying an externip. It’s probably got something to do with the Amazon EC2 instance my test Asterisk server is running on being behind a NAT. With the call working I was finally to see the raw XMPP packets being sent and copy them into my own C# app and have it initiate a Google Voice call over XMPP.
The code is pretty useless in its current form, all it can do is get a phone to ring. No audio is available. However in theory that’s the hardest part out of the way and it shouldn’t be difficult to translate an incoming SIP request into an outgoing XMPP request.
For anyone curious the XMPP packets that need to be sent to initiate a Google Voice call are shown below. Whatever is sending those packets will need to be authenticated prior to sending them but at least that part of it follows the XMPP standards.
<iq email@example.com/Talk-12312' id='1234' firstname.lastname@example.org/srvres' type='set'> <session xmlns='http://www.google.com/session' type='initiate' id='abcdef12344' email@example.com/Talk-12312'> <description xmlns='http://www.google.com/session/phone'> <payload-type id='0' name='PCMU' bitrate='64000' clockrate='8000' /> <payload-type id='100' name='EG711U' bitrate='64000' clockrate='8000' /> <payload-type id='101' name='telephone-event' clockrate='8000' /> </description> </session> </iq> <iq firstname.lastname@example.org/Talk-12312' id='1234' email@example.com/srvres' type='set'> <session xmlns='http://www.google.com/session' type='candidates' id='abcdef12344' firstname.lastname@example.org/Talk-12312'> <candidate name='rtp' address='121.223.xxx.xxx' port='10202' username='asdasdoas' password='dshasjja84' preference='1.0' protocol='udp' type='stun' network='0' generation='0' /> <transport xmlns='http://www.google.com/transport/p2p'/> </session> </iq>