|
offering a genuine SIP <-> POTS. They provide you with a box (a |
|
offering a genuine SIP <-> POTS service. They provide you with a box (a |
|
I found the documentation for asterisk a bit confusing. But this place is a good starting point. |
|
I found the asterisk documentation a bit confusing. But this place is a good starting point. |
|
fiber connections between all points I think it's best to run the asterisk server at the place your calling from. |
|
fast connections (I'd say something like 10MB) between all points, in all directions I think it's best to run the asterisk server at the place your calling from. |
|
#I juse gogo instead of lame, cause gogo is a lot faster. But if you |
|
#I use gogo instead of lame, cause gogo is a lot faster. But if you |
SIP telcos are starting to emerge. Here in Sweden Rix Telecom are offering a genuine SIP <-> POTS service. They provide you with a box (a hardware SIP client) that you can connect to your old analog handset. By default the box talks to a asterisk server at Rix Telecom.
You can make the box connect to a asterisk server of your own and then have that server talk to the server at Rix. The point being that you can do all sorts of nice things on the asterisk server that you control.
I use it to record all my phone conversations and store them as mp3 files. This is perfectly legal in Sweden. In some parts of the US you need the consent of the other party to record a conversation.
To start with you have to run your own asterisk server. My distro (Debian GNU/Linux) has asterisk packaged so I just installed that.
apt-get install asterisk
I found the asterisk documentation a bit confusing. But this place is a good starting point.
When configuring and troubleshooting it's good to run asterisk like so:
asterisk -f
This will stop it from detaching from the console and you'll be able to find out what's going on behind the scenes. If you want more verbose debugging information you can attach to a running asterisk process with:
asterisk -rThat'll give you a command line interface to asterisk. The first thing to do is to run
sip debugand then
set verbose 4
I've included all the relevant configuration files below. Debian will put a lot of other stuff in /etc/astersisk, but you can just leave it there. In fact if you throw it out things will break.
I first tried running my asterisk server at a remote location where I already had a box set up for other purposes but that created a lot of lag resulting in breakups in the conversations. So unless you have fast connections (I'd say something like 10MB) between all points, in all directions I think it's best to run the asterisk server at the place your calling from.
You don't need a sound card on your server. All connections are via TCP/IP.
Vood VRG 121 is the hardware client that Rix Telecom sold me. When they ship it it's locked and will only talk to the asterisk server at Rix. To unlock it you have to call customer service at Rix. Once it's unlocked you can configure it via a web interface. The box accuires an ip address via DHCP. It will answer ping calls so you can probably figure out what address it recieved by doing a broadcast ping. Mine's at 192.168.0.100 so I point my browser at http://192.168.0.100/conf and log in as "Conf" with password "admin". Mind the casing.
Under codecs I disabled G711_u_64kb and G711_u_56kb because I hade some trouble getting DTMF to work properly with those codecs enabled.
Under NAT I disable UPnP? and STUN, because my Vood box is in the same subnet as my asterisk server. The NATing is taking place between my asterisk server and the one at Rix.
Next I connect to http://192.168.0.100/user with username "SubA?" and password "SubA?" and make some changes under "Account". And enter these settings.
Phone Number: oivvio User Id: oivvio User Password: sssssss Registration Server: 192.168.0.2 Proxy: Display Name (optional): xxxxxxxxx
Save your settings, cross your fingers and check the debug output on the asterisk server. For the next two or three days. :)
If that doesn't work sign up with the forum at Rix. The crowd over there is very helpful.
Here's my /etc/asterisk/sip.conf
[general] context=default port=5060 bindaddr=192.168.0.2 srvlookup=no disallow=all ; Disallow all codecs allow=ulaw allow=alaw register => xxxxxxxxx:yyyyyyyy@astrofix.rixtele.com/1000 [oivvio] type=friend host=dynamic username=zzzzzzz secret=ssssssss context=outgoing dtmfmode=inband qualify=yes mailbox=1000 ;on the rix forum they tell to put this in: canreinvite=no [rix] type=peer username=xxxxxxxxxx fromuser=xxxxxxxxxx secret=yyyyyyyy host=astrofix.rixtele.com context=sip-in insecure=very
My /etc/asterisk/extensions.conf
[general]
static=yes
writeprotect=yes
[default]
exten => 1000,1,SetVar(CALLFILENAME=incoming_${CALLERIDNUM}_${TIMESTAMP})
exten => 1000,2,Monitor(wav,${CALLFILENAME})
exten => 1000,3,Dial(SIP/zzzzzzzz,25)
exten => 1000,4,Voicemail(su1000)
exten => a,1,VoicemailMain(1000)
exten => h,1,Macro(wav2mp3)
[macro-wav2mp3]
exten => s,1,System(nice -n 19 python /path/to/asterisk2mp3.py /var/spool/asterisk/monitor ${CALLFILENAME})
[outgoing]
exten => _X.,1,SetVar(CALLFILENAME=outgoing_${EXTEN}_${TIMESTAMP})
exten => _X.,2,Monitor(wav,${CALLFILENAME})
exten => _X.,3,Dial(SIP/rix/${EXTEN}|1000|t)
exten => h,1,Macro(wav2mp3)
And the relevant part of my /etc/asterisk/voicemail.conf
[default] 1000 => XXXX, Oivvio Polite, my@email.com,,attach=yes
Here's the python script that launches mp3 encoding.
#!/usr/bin/python
import tempfile,os,sys,re,time
monitordir = sys.argv[1]
basename = sys.argv[2]
def runcmd(cmd):
print cmd
os.system(cmd)
#mix to one wav
inwav = os.path.join(monitordir, basename+"-in.wav")
outwav = os.path.join(monitordir, basename+"-out.wav")
waste, mixedwav = tempfile.mkstemp(".wav","audiopipe_","/tmp")
runcmd ("soxmix %s %s %s" % (inwav,outwav,mixedwav))
#up sample rate
waste, uppedsamplerate = tempfile.mkstemp(".wav","audiopipe_","/tmp")
runcmd("sox %s -r 22050 %s " % (mixedwav, uppedsamplerate))
#run lame
outfile = os.path.join(monitordir, basename+".mp3")
#I use gogo instead of lame, cause gogo is a lot faster. But if you
#can't compile gogo, lame will do just fine.
#
#runcmd("lame -S -v %s %s" % (uppedsamplerate, outfile))
runcmd("/usr/local/bin/gogo -v 6 %s %s" % (uppedsamplerate, outfile))
os.remove(inwav)
os.remove(outwav)
#but at least we can waste the temporaries
os.remove(mixedwav)
os.remove(uppedsamplerate)