一、安装依赖包(libtiff & spandsp)
$ sudo apt-get install libtiff4 libtiff4-dev
$ mkdir ~/src/asterisk-complete/thirdparty
$ cd ~/src/asterisk-complete/thirdparty
$ wget http://www.soft-switch.org/downloads/spandsp/spandsp-0.0.6pre21.tgz
$ tar zxvf spandsp-0.0.6pre21.tgz
$ cd spandsp-0.0.6
$ make
$ sudo make install
二、把spandsp库放入libpath
$ sudo cat >> /etc/ld.so.conf.d/usrlocallib.conf
/usr/local/lib
通过$ sudo ldconfig使其生效
三、重新编译Asterisk添加spandsp支持
$ cd ~/src/asterisk-complete/asterisk/1.8/
$ ./configure
$ make menuselect
确保Resource Modules菜单下的res_fax_spandsp看起来像[*] res_fax_spandsp,保存并退出
$ make
$ make install
四、检查
重新启动asterisk,通过以下命令确认spandsp是否已经工作
*CLI> module show like res_fax_spandsp.so
Module Description Use Count
res_fax_spandsp.so Spandsp G.711 and T.38 FAX Technologies 0
1 modules loaded
如果看到如上结果,则表示spandsp可以工作了,也就是说SendFax() & ReceiveFax()可用在extensions拨号方案中了
五、配置拨号方案
收传真,
[fax-in]
exten => fax,1,Verbose(3,Incoming fax)
; folder where your incoming faxes will initially be stored
same => n,Set(FAXDEST=/var/spool/asterisk/fax)
same => n,Set(tempfax=${CALLEDFAX}/${UNIQUEID})
same => n,ReceiveFax(${FAXDEST}/${tempfax}.tif)
same => n,Verbose(3,- Fax receipt completed with status: ${FAXSTATUS})
发传真
[fax-out]
exten => s,1,Verbose(2,Set options and transmit fax)
; some folder where your outgoing faxes will be found
same => n,Set(faxlocation=/tmp)
; In production you would probably not want to hardcode the filename
same => n,Set(faxfile=faxfile.tif)
same => n,Set(FAXOPT(headerinfo)=Fax from xxxx.org)
same => n,Set(FAXOPT(localstationid=xxxxxx)
same => n,SendFax(${faxlocation}/${faxfile})