gvsurenderreddy / audiospread

Automatically exported from code.google.com/p/audiospread
0 stars 0 forks source link

Install Asterisk + an SIP softphone, call a local Asterisk sever over SIP with the softphone #7

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,
this Development Ticket concerns:
cycle number: 0,
milestone: 0.01
implementation requested by ticket:
Install Asterisk + an SIP softphone, call a local Asterisk sever over SIP
with the softphone.

Original issue reported on code.google.com by jonathan.schroder@gmail.com on 20 Jan 2009 at 6:31

GoogleCodeExporter commented 8 years ago
changed title to match roadmap.
more help for this Asterisk discovery ticket:
  * *install asterisk* (on linux, get the asterisk package in your package manager
(ie synaptic on gnome))
  * *go to /etc/asterisk an look at extensions.conf* there, at the end of the file
you have a section called [default] or something like that.
There is help on the extensions.conf syntax and more on :
http://www.voip-info.org/tiki-index.php?page=Asterisk%20config%20extensions.conf
#PredefinedExtensionNames
  * look at the extensions written there: exten => someNumber, somePriority,
someAsteriskCommand ..
imagine you have a line like exten => 1234,s,what
  * *install a softphone* through your package manager (kphone is cool and available
from the Ubuntu package manager, ekiga is buggy, don't use it, x-lite is used 
by ECE
students here in ing5 as I've heard and has linux & windows versions)
  * make sure asterisk runs (ie. pstree | grep asterisk for example), if it's not
running, you can start by typing: /etc/init.d/asterisk start
  * asterisk is listening on port 5060 normally (you can check that with: sudo
netstat -ntpa | grep asterisk)
  * *edit sip.conf* to add an SIP user(=phone) (add what's below to the file)
[101] #101 is a username, change to something ascii if you want
type=friend
secret=welcome #this is the passwor for user 101 (or whatever name has been 
defined
in the [] above)
qualify=yes    ; Qualify peer is not more than 2000 mS away
nat=no         ; This phone is not natted
host=dynamic   ; This device registers with us
canreinvite=no ; Asterisk by default tries to redirect
context=home
port=5061     ; Uncomment this line if Ekiga and Asterisk are on the same host
#Note for last line,
#(a softphone is like a server in some way, because it can receive calls, so it 
has
to listen to some port, asterisk listens to some port as well (for SIP this 
port is
5060 by default)... we must have those two ports different, we decide to make
asterisk listen on a different port, and we won't touch the softphone config).
#We ask asterisk to listen on 5061 instead of default 5060 port because our 
softphone
maybe stupid and it's maybe harder to setup the softphone to listen on/call 
from a
different port.
For info on SIP open ports, see 
http://www.chebucto.ns.ca/~rakerman/port-table.html
and look for SIP (ctrl+f).
  * save the sip.conf file and restart asterisk: type /etc/init.d/asterisk restart
(note there is a way to reload the sip.conf file without restarting asterisk 
also...)
  * you can check that asterisk is listening on port 5061 (sudo netstat -ntpa | grep
5061)
  * you can get into asterisk's interactive console by typing "asterisk -vvvvr" (at
actually any number of v for verboseness, tutorials on the net put 4 or 5 v , 
but put
at least the r to have access to asterisk's command line)
  * run kphone (or the softphone you took), create a phone/connection with username
to 101 (or whatever you defined in sip.conf between [brackets]) and password to
"welcome" (without the "")
you want to log into the server localhost on port 5061 (maybe you have to type
localhost:5061 instead of having two fields).
- call the number 1234@localhost
- you hear thing and can typed keys on the DTMF big telephone buttons.
- the line exten => 1234,....  of the extensions.conf file was actually played 
when
you called. Notice that PlayBackground(someFileNameWithNo.Extension) plays a 
file in
a non-modal/background way (in short in this case, doesn't block keyboard). the 
file
played comes from */usr/share/asterisk/sounds/ where you have lots of .gsm sound
files*. You can play those gsm files in console with the command named "play" 
(except
that you have to install it first... with command "sudo apt-get install sox" as
proposed by the shell when you try to type "play").
root@jonathan:/usr/share/asterisk/sounds# sudo apt-get install sox
...... #sox which contains the play program gets downloaded from the web and
installed on your computer
#now you can use play to play many types of files including gsm in console
root@jonathan:/usr/share/asterisk/sounds# play vm-goodbye.gsm
# you hear a girl saying "Good bye !"
Input File     : 'vm-goodbye.gsm'
Sample Size    : 8-bit (1 byte)
Sample Encoding: GSM
Channels       : 1
Sample Rate    : 8000

Time: 00:01.02 [00:00.00] of 00:00.00 (0.00%) Samples out: 49.0k Clips: 0
Done.

Original comment by jonathan.schroder@gmail.com on 20 Jan 2009 at 6:41

GoogleCodeExporter commented 8 years ago

Original comment by jonathan.schroder@gmail.com on 20 Jan 2009 at 7:23

GoogleCodeExporter commented 8 years ago
here's a *setup that works* (ie. a sip.conf and extensions.conf and kphone's 
config
for that):

asterisk (sip.conf and extensions.conf file are in the /etc/asterisk/ folder, 
you
must be root/sudo-ing to edit them):
sip.conf
[general]
context=default
srvlookup=yes
videosupport=yes

disallow=all   ; First disallow all codecs
allow=ulaw
allow=alaw     ; Allow codecs in order of
allow=ilbc     ; preference
allow=gsm
allow=h261
;bindport=5060

[101]
type=friend
secret=welcome
qualify=yes    ; Qualify peer is not more than 2000 mS away
nat=no         ; This phone is not natted
host=dynamic   ; This device registers with us
canreinvite=no ; Asterisk by default tries to redirect
context=default
port=5061     ; Uncomment this line if Ekiga and Asterisk
               ; are on the same host

extensions.conf: this is the exact same content as extensions.conf.orig, so 
what you
can do is rm extensions.conf; cp extensions.conf.orig extensions.conf; so we're 
not
pasting it here.
We may just notice that in sip.conf above, for the user 101 (see section 
[101]), the
user has a context=default, so this will make the extensions.conf's context 
[default]
available to him(101) anytime as soon as he's registered/logged/connected into 
asterisk).
In extensions.conf, [default] contains one line which is:
include => demo which says "put here all the code from section [demo]" (this 
section
is above in extensions.conf)

in extensions.conf, we have a lines like:
exten => s,.... where s means start point... so anyone calling an unknown
extension(=number) will make those "s"-extension commands run.

exten => 2,1,Background(more-info) plays more-info.gsm file
exten => 2,n,Goto(s,instruct) asks go branch/goto extension s(the one above) at 
the
label "instruct" (this will jump to line exten=>s,n(instruct),....) see
http://www.voip-info.org/wiki-Asterisk+cmd+goto for help on the goto 
instruction (for
this extension, the  Goto(extension,label)  form was used)

all possible extensions for the demo:
*(=s)->(in short) do nothing,
2->more info,instructions
3->language:=french,congratulations,instructions, #note, we should comment that
language change to french because some messages seem not to play at all, maybe
because their french version can't be found...
1000->same as * extension
1234->global console (?)
1235->Voicemail (répondeur?)
1236->Voicemail (répondeur?) (I haven't searched for why busy, why not, this 
is maybe
not important for the audiospread scope anyway)
#->good bye then hangup
t->#
i->"I am sorry that's not a valid extension, please try again"
500->connect to the Inter Asterisk eXchange (IAX) connection (you need internet 
for
that, + you need to load first the IAX2 modules in asterisk's command line 
(asterisk
-vvvvr) with command: module load chan_iax2.so), this seems to connect you to 
IVR of
the asterisk company
600->echotest (you are asked to say something that is recorded by asterisk, and 
then
echoed(repeated) back to you)

running asterisk:
do as root or sudo: /etc/ini.d/asterisk
then do asterisk -vvvvvr (4 or 5v..)
you now get into asterisk's command line interface (it's just a terminal to the
asterisk server, so when you leave that program with exit, the asterisk server
doesn't shut down)
try typing word sip and press tab key several times to see if asterisk gives you
proposals
if not, sip is not loaded. Another way to ensure what channels are loaded is to 
type:
show modules like chan_
to load the SIP channel module, anyway you should do:
module load chan_sip.so
...which loads the SIP channel
you can check to see whate users the channel has been able to read from 
sip.conf:
sip show peers
...should show a user named 101 with status UNKNOWN or so

if ever you want to change either of extensions.conf or sip.conf while asterisk 
is
running, there's a way to skip having to restart asterisk so that it reads and 
takes
into account its config files.
-to reload extensions.conf, type:
dialplan reload
-to reload sip.conf (with of course the SIP module loaded before with module 
load
chan_sip.so) type:
sip reload
(note that when SIP module is not loaded yet and you type module load 
chan_sip.so,
the sip.conf file gets parsed once during the SIP module's initialization).

kphone (install it with sudo apt-get install kphone in shell or with a graphical
package manager (synaptic on Gnome or adept on KDE)).
Make sure you have:
- Preferences menu>SIP Preferences (you must not touch anything here, just for 
info,
we use the software's defaults)
Setup your SIP identity:
- File menu>Identify :
Full Name: 101
User Part of SIP URL: 101
Host Part of SIP URL: 127.0.0.1
Outbound Proxy (optional): nothing
Authentication Username (optional): 101
q-value between 0.0-1.0 (optional): nothing
Auto Register set to enabled
the button below that should read Unregister (because Register has been
clicked/enabled before).
(click OK)
On first registration, put welcome for the requested password.

when you're registered onto the server, you should see the following:
- in the Asterisk command line (the one run with asterisk -vvvvvr), showing 
packets
that Asterisk sends, or at least messages saying that someone has registered.
In this same command line, you can type: sip show peers (the state for user 101 
has
changed to something different than UNKNOWN), and also sip show users, or sip 
show
user 101
- in kphone
you should see the text Online in a text field at the window's bottom. And left 
and
right of this text field, you icons with colors (they are not grey/disabled).

calling things with kphone:
in the text field below the large button sip:101@127.0.0.1, left from a phone 
button
and a camera button, type some extension (ie 2 or 3... this can be of several 
digits)
and press enter.
This will send a request for a call to someone/some machine who has the entered
extension (ie 2 or 3), which asterisk will handle with lines exten => (2 or 
3),...
and decide to receive the call and decide to do things (in our case, play 
information
sounds and tell the user what extensions he could call to reach what demo 
application
(this is what one of the played sound files says)).

Original comment by jonathan.schroder@gmail.com on 28 Jan 2009 at 2:43

GoogleCodeExporter commented 8 years ago
This is ok on local laptops.
Todo = asterisk team using the multitunneler with IAX softphones.

Original comment by jonathan.schroder@gmail.com on 3 Mar 2009 at 11:37

GoogleCodeExporter commented 8 years ago
Softphone + new multitunneler version supporting IAX2 has to be given to the 
right
people.
I'm closing this.

Original comment by jonathan.schroder@gmail.com on 7 Mar 2009 at 5:30