Pages

Thursday, 20 September 2012

使用本地手机接听Google Voice呼叫


Google Voice 是 Google 推出的一种电话服务,能够将个人所用的众多电话号码集中成为一个号码,同时提供许多增值服务,比如语音信箱,留言传译,便宜的国际电话费率等等。
注册 Google Voice,必须要用到一个美国的电话来进行验证,一般都会用 IPKall 或 VirtualPhoneLine 提供的虚拟号码,结合 sip 账户来完成,最终这个 sip 账户自然也就成了接听 Google Voice 呼叫的终端。
智能手机可以使用 fring / sipdroid 之类的 sip 软件来挂用于接听 Google Voice 呼叫的 sip 账户,在 wifi 下效果也非常好,但是在没有 wifi 的户外,仅仅依靠 edge 网络通话质量就很差了,而且也相当费网络流量。
这里就使用建立在 OpenWRT 上的 asterisk 服务器,通过 sip provider 来把 sip 呼叫转成本地的语音呼叫。
首先需要一个可以运行的 asterisk 系统,建立 sip 账户及 sip provider 账户
vi /etc/asterisk/sip.conf
register => accountno:password@sip.proxy.server:port/accountno
[provider]
defaultuser=accountno
secret=password
fromuser=accountno
host=sip.proxy.server
port=port
context=incoming
type=friend
qualify=yes
canreinvite=no
insecure=port,invite
dtmfmode=auto
disallow=all
allow=g729
allow=ulaw
allow=alaw

[101]
secret=101
context=sipphone
type=friend
host=dynamic
qualify=yes
canreinvite=no
dtmfmode=auto
disallow=all
allow=g729
allow=ulaw
allow=alaw
建立拨号规则
vi /etc/asterisk/extensions.conf
[public-direct-dial]
; Google Voice
exten => gv,1,NoOp(Goovle Voice Calling)
exten => gv,2,ChanIsAvail(SIP/101)
exten => gv,3,GotoIf($[${AVAILSTATUS}=0]? 4:6)
exten => gv,4,Dial(SIP/101,20,to)
exten => gv,5,Hangup()
exten => gv,6,Dial(SIP/MOBILENUMBER@provider,,To)
exten => gv,n,Hangup()
在 IPKall 中设置 SIP Phone Number 为 gv,SIP Proxy 为 asterisk 服务器 IP,手机上的 sip 软件设置仅使用 wifi 以保证通话质量。
至此,在手机可用 wifi 时 Google Voice 呼叫会转接到手机 sip 软件上的 voip 呼叫,wifi 不可用时 Google Voice 呼叫会转接到手机上的语音呼叫.