Project

General

Profile

Sip audio session » History » Version 4

Adrian Georgescu, 03/14/2009 09:51 AM

1 1 Adrian Georgescu
== sip_audio_session ==
2 2 Adrian Georgescu
[[TOC(SipTesting*, sip_*, xcap*,depth=2)]]
3 1 Adrian Georgescu
4 3 Adrian Georgescu
To use this script you must to have a valid [wiki:SipSettingsAPI configuration].
5 4 Adrian Georgescu
[[Image(http://www.tech-invite.com/img/cf3665/cf3665-31.gif, align=right)]]
6 1 Adrian Georgescu
7
=== Description ===
8
9
This script can be used for interactive audio session or for scripting alarms. The script returns appropriate shell response codes for failed or successful sessions. The script can be setup to auto answer and auto hangup after predefined number of seconds, detects SIP negative response codes, missing ACK and the lack of RTP media after a session has been established.
10
11
Source code: [source:scripts/sip_audio_session.py scripts/sip_audio_session.py]
12
13
{{{
14
adigeo@ag-imac3:~$sip_audio_session -h
15
Usage: sip_audio_session [options] [target-user@target-domain.com]
16
17
This script can sit idle waiting for an incoming audio call, or perform an
18
outgoing audio call to the target SIP account. The program will close the
19
session and quit when Ctrl+D is pressed.
20
21
Options:
22
  -h, --help            show this help message and exit
23
  -a NAME, --account-name=NAME
24
                        The account name from which to read account settings.
25
                        Corresponds to section Account_NAME in the
26
                        configuration file. If not supplied, the section
27
                        Account will be read.
28
  --sip-address=SIP_ADDRESS
29
                        SIP address of the user in the form user@domain
30
  -p PASSWORD, --password=PASSWORD
31
                        Password to use to authenticate the local account.
32
                        This overrides the setting from the config file.
33
  -n DISPLAY_NAME, --display-name=DISPLAY_NAME
34
                        Display name to use for the local account. This
35
                        overrides the setting from the config file.
36
  -o IP[:PORT], --outbound-proxy=IP[:PORT]
37
                        Outbound SIP proxy to use. By default a lookup of the
38
                        domain is performed based on SRV and A records. This
39
                        overrides the setting from the config file.
40
  -s, --trace-sip       Dump the raw contents of incoming and outgoing SIP
41
                        messages (disabled by default). The argument specifies
42
                        where the messages are to be dumped.
43
  -t EC_TAIL_LENGTH, --ec-tail-length=EC_TAIL_LENGTH
44
                        Echo cancellation tail length in ms, setting this to 0
45
                        will disable echo cancellation. Default is 50 ms.
46
  -r SAMPLE_RATE, --sample-rate=SAMPLE_RATE
47
                        Sample rate in kHz, should be one of 8, 16 or 32kHz.
48
                        Default is 32kHz.
49
  -c CODECS, --codecs=CODECS
50
                        Comma separated list of codecs to be used. Default is
51
                        "speex,g711,ilbc,gsm,g722".
52
  -S, --disable-sound   Do not initialize the soundcard (by default the
53
                        soundcard is enabled).
54
  -j, --trace-pjsip     Print PJSIP logging output (disabled by default).
55
  --auto-hangup         Interval after which to hangup an on-going call
56
                        (applies only to outgoing calls, disabled by default).
57
                        If the option is specified but the interval is not, it
58
                        defaults to 0 (hangup the call as soon as it
59
                        connects).
60
  --auto-answer         Interval after which to answer an incoming call
61
                        (disabled by default). If the option is specified but
62
                        the interval is not, it defaults to 0 (answer the call
63
                        as soon as it starts ringing).
64
65
}}}
66
67
68
=== Example for incoming session ===
69
70
{{{
71
adigeo@ag-imac3:~/Business/Personal$sip_audio_session 
72
Accounts available: 'alice', 'as', 'bob', 'ew', 'ewt', 'mrg', 'pbx', 's', 'tf', 'umts', 'umts_test', 'unet', 'unet_test', default
73
Using default account: 31208005169@ag-projects.com
74
Registering ""Adrian G." <sip:31208005169@ag-projects.com>" at 81.23.228.129:5060
75
REGISTER was successful
76
Contact: sip:HZ1BYFQtHR@192.168.1.6:49421;transport=udp (expires in 300 seconds)
77
Available control keys:
78
  h: hang-up the active session
79
  r: toggle audio recording
80
  t: toggle SIP trace on the console
81
  <> : adjust echo cancellation
82
  SPACE: hold/on-hold
83
  Ctrl-d: quit the program
84
  ?: display this help message
85
Waiting for incoming session...
86
Detected NAT type: Port Restricted
87
Incoming session...
88
Incoming audio session from "sip:adi@umts.ro", do you want to accept? (y/n)
89
Session established, using "speex" codec at 32000Hz
90
Audio RTP endpoints 192.168.1.6:40064 <-> 81.23.228.150:56618
91
Remote SIP User Agent is "sip2sip-0.4.0-pjsip-1.0.1-r2453"
92
Call is put on hold
93
Call is taken out of hold
94
Ending session...
95
Session ended by local party.
96
Session duration was 6 seconds
97
}}}
98
99
=== Example for outgoing session ===
100
101
{{{
102
adigeo@ag-imac3:~$sip -a umts ag@ag-projects.com
103
Accounts available: 'alice', 'as', 'bob', 'ew', 'ewt', 'mrg', 'pbx', 's', 'tf', 'umts', 'umts_test', 'unet', 'unet_test', default
104
Using account 'umts': adi@umts.ro
105
Call from "Adi UMTS" <sip:adi@umts.ro> to sip:ag@ag-projects.com through proxy udp:85.17.186.7:5060
106
Available control keys:
107
  h: hang-up the active session
108
  r: toggle audio recording
109
  t: toggle SIP trace on the console
110
  <> : adjust echo cancellation
111
  SPACE: hold/on-hold
112
  Ctrl-d: quit the program
113
  ?: display this help message
114
Ringing...
115
Ringing...
116
Ringing...
117
Session established, using "speex" codec at 32000Hz
118
Audio RTP endpoints 192.168.1.6:40048 <-> 81.23.228.150:56616
119
Remote SIP User Agent is "sip2sip-0.4.0-pjsip-1.0.1-r2453"
120
Remote party has put the call on hold
121
Remote party has taken the call out of hold
122
Session ended by remote party.
123
Session duration was 6 seconds
124
125
}}}
126
127
128
=== Ongoing sessions ===
129
130
During an ongoing session you can record the audio stream in a file by pressing r. You can hangup by pressing h.