Sip audio session » History » Version 28
Adrian Georgescu, 03/10/2010 09:44 AM
1 | 2 | Adrian Georgescu | |
---|---|---|---|
2 | 28 | Adrian Georgescu | h2. sip-audio-session |
3 | 1 | Adrian Georgescu | |
4 | 28 | Adrian Georgescu | |
5 | |||
6 | |||
7 | h3. Description |
||
8 | |||
9 | |||
10 | 27 | Adrian Georgescu | 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. Once the media stream is connected, the outcome of the ICE negotiation and the selected RTP candidates are displayed. |
11 | |||
12 | 28 | Adrian Georgescu | > This script is available in _sipclients_ package that must be installed separately from SIP SIMPLe client SDK package. |
13 | 1 | Adrian Georgescu | |
14 | 28 | Adrian Georgescu | <pre> |
15 | 24 | Adrian Georgescu | adigeo@ag-blink:~$sip-audio-session -h |
16 | Usage: sip-audio-session [options] [user@domain] |
||
17 | 1 | Adrian Georgescu | |
18 | 17 | Adrian Georgescu | This script can sit idle waiting for an incoming audio session, or initiate an |
19 | outgoing audio session to a SIP address. The program will close the session |
||
20 | and quit when Ctrl+D is pressed. |
||
21 | 1 | Adrian Georgescu | |
22 | Options: |
||
23 | -h, --help show this help message and exit |
||
24 | 5 | Adrian Georgescu | -a NAME, --account=NAME |
25 | The account name to use for any outgoing traffic. If |
||
26 | not supplied, the default account will be used. |
||
27 | 19 | Adrian Georgescu | -c FILE, --config-file=FILE |
28 | 1 | Adrian Georgescu | The path to a configuration file to use. This |
29 | 5 | Adrian Georgescu | overrides the default location of the configuration |
30 | file. |
||
31 | 17 | Adrian Georgescu | -s, --trace-sip Dump the raw contents of incoming and outgoing SIP |
32 | messages. |
||
33 | -j, --trace-pjsip Print PJSIP logging output. |
||
34 | -n, --trace-notifications |
||
35 | Print all notifications (disabled by default). |
||
36 | 5 | Adrian Georgescu | -S, --disable-sound Disables initializing the sound card. |
37 | 17 | Adrian Georgescu | --auto-answer Interval after which to answer an incoming session |
38 | 1 | Adrian Georgescu | (disabled by default). If the option is specified but |
39 | 17 | Adrian Georgescu | the interval is not, it defaults to 0 (accept the |
40 | 1 | Adrian Georgescu | session as soon as it starts ringing). |
41 | --auto-hangup Interval after which to hang up an established session |
||
42 | 19 | Adrian Georgescu | (disabled by default). If the option is specified but |
43 | the interval is not, it defaults to 0 (hangup the |
||
44 | session as soon as it connects). |
||
45 | 1 | Adrian Georgescu | -b, --batch Run the program in batch mode: reading input from the |
46 | 19 | Adrian Georgescu | console is disabled and the option --auto-answer is |
47 | 1 | Adrian Georgescu | implied. This is particularly useful when running this |
48 | script in a non-interactive environment. |
||
49 | -D, --daemonize Enable running this program as a deamon. This option |
||
50 | implies --disable-sound, --auto-answer and --batch. |
||
51 | 28 | Adrian Georgescu | </pre> |
52 | 20 | Adrian Georgescu | |
53 | 1 | Adrian Georgescu | |
54 | |||
55 | 28 | Adrian Georgescu | h3. Incoming Session |
56 | |||
57 | |||
58 | <pre> |
||
59 | 24 | Adrian Georgescu | adigeo@ag-blink:~$sip-audio-session |
60 | 1 | Adrian Georgescu | Using account 31208005169@ag-projects.com |
61 | 21 | Adrian Georgescu | Logging SIP trace to file "/Users/adigeo/Library/Application Support/Blink/logs/sip_trace.txt" |
62 | Logging PJSIP trace to file "/Users/adigeo/Library/Application Support/Blink/logs/pjsip_trace.txt" |
||
63 | Available audio input devices: None, system_default, Built-in Input, Built-in Microphone |
||
64 | Available audio output devices: None, system_default, Built-in Output |
||
65 | 19 | Adrian Georgescu | Using audio input device: Built-in Microphone |
66 | Using audio output device: Built-in Output |
||
67 | Using audio alert device: Built-in Output |
||
68 | |||
69 | 1 | Adrian Georgescu | Available control keys: |
70 | s: toggle SIP trace on the console |
||
71 | j: toggle PJSIP trace on the console |
||
72 | n: toggle notifications trace on the console |
||
73 | p: toggle printing RTP statistics on the console |
||
74 | 19 | Adrian Georgescu | h: hang-up the active session |
75 | r: toggle audio recording |
||
76 | 21 | Adrian Georgescu | m: mute the microphone |
77 | i: change audio input device |
||
78 | o: change audio output device |
||
79 | a: change audio alert device |
||
80 | 1 | Adrian Georgescu | <>: adjust echo cancellation |
81 | SPACE: hold/unhold |
||
82 | Ctrl-d: quit the program |
||
83 | ?: display this help message |
||
84 | |||
85 | 27 | Adrian Georgescu | 2009-08-25 16:37:12 Registered contact "sip:hxsyungk@192.168.1.124:59164" for sip:31208005169@ag-projects.com |
86 | at 81.23.228.150:5060;transport=udp (expires in 600 seconds). |
||
87 | 1 | Adrian Georgescu | Other registered contacts: |
88 | 21 | Adrian Georgescu | sip:31208005169@192.168.1.123:5060 (expires in 274 seconds) |
89 | sip:kwbfxyvl@192.168.1.124:59116 (expires in 522 seconds) |
||
90 | 19 | Adrian Georgescu | sip:ilmegvkp@192.168.1.124:59003 (expires in 339 seconds) |
91 | 21 | Adrian Georgescu | sip:31208005169@192.168.1.1;uniq=5B2860C44383A3D6705629A7E1FB8 (expires in 1162 seconds) |
92 | Detected NAT type: Port Restricted |
||
93 | 19 | Adrian Georgescu | Incoming audio session from 'sip:adi@umts.ro', do you want to accept? (y/n) |
94 | 1 | Adrian Georgescu | Audio session established using "speex" codec at 16000Hz |
95 | Audio RTP endpoints 192.168.1.124:50378 <-> 85.17.186.6:58868 |
||
96 | RTP audio stream is encrypted |
||
97 | Remote SIP User Agent is "Blink-0.9.0" |
||
98 | Remote party has put the audio session on hold |
||
99 | 21 | Adrian Georgescu | Audio session is put on hold |
100 | Audio session ended by remote party |
||
101 | Session duration was 6 seconds |
||
102 | 8 | Adrian Georgescu | 2009-08-25 16:37:44 Registration ended. |
103 | 28 | Adrian Georgescu | </pre> |
104 | 21 | Adrian Georgescu | |
105 | 1 | Adrian Georgescu | |
106 | 28 | Adrian Georgescu | h3. Outgoing Session |
107 | |||
108 | |||
109 | <pre> |
||
110 | 24 | Adrian Georgescu | adigeo@ag-blink:~$sip-audio-session -a umts ag@ag-projects.com |
111 | 21 | Adrian Georgescu | Using account adi@umts.ro |
112 | Logging SIP trace to file "/Users/adigeo/Library/Application Support/Blink/logs/sip_trace.txt" |
||
113 | Logging PJSIP trace to file "/Users/adigeo/Library/Application Support/Blink/logs/pjsip_trace.txt" |
||
114 | Available audio input devices: None, system_default, Built-in Input, Built-in Microphone |
||
115 | Available audio output devices: None, system_default, Built-in Output |
||
116 | 1 | Adrian Georgescu | Using audio input device: Built-in Microphone |
117 | 11 | Adrian Georgescu | Using audio output device: Built-in Output |
118 | 1 | Adrian Georgescu | Using audio alert device: Built-in Output |
119 | 11 | Adrian Georgescu | |
120 | 12 | Adrian Georgescu | Available control keys: |
121 | 11 | Adrian Georgescu | s: toggle SIP trace on the console |
122 | 12 | Adrian Georgescu | j: toggle PJSIP trace on the console |
123 | 11 | Adrian Georgescu | n: toggle notifications trace on the console |
124 | p: toggle printing RTP statistics on the console |
||
125 | 12 | Adrian Georgescu | h: hang-up the active session |
126 | r: toggle audio recording |
||
127 | 21 | Adrian Georgescu | m: mute the microphone |
128 | i: change audio input device |
||
129 | 15 | Adrian Georgescu | o: change audio output device |
130 | 14 | Adrian Georgescu | a: change audio alert device |
131 | 16 | Adrian Georgescu | <>: adjust echo cancellation |
132 | 26 | Adrian Georgescu | SPACE: hold/unhold |
133 | Ctrl-d: quit the program |
||
134 | 18 | Adrian Georgescu | ?: display this help message |
135 | 1 | Adrian Georgescu | |
136 | 21 | Adrian Georgescu | Initiating SIP audio session from 'sip:adi@umts.ro' to 'sip:ag@ag-projects.com' via sip:85.17.186.7:5060;transport=udp... |
137 | 1 | Adrian Georgescu | Audio session established using "speex" codec at 16000Hz |
138 | ICE negotiation succeeded in 1s:412 |
||
139 | Audio RTP endpoints 192.168.1.124:50852 (ICE type host) <-> 192.168.1.124:50871 (ICE type host) |
||
140 | RTP audio stream is encrypted |
||
141 | Audio session is put on hold |
||
142 | 23 | Adrian Georgescu | Remote party has put the audio session on hold |
143 | Detected NAT type: Port Restricted |
||
144 | 1 | Adrian Georgescu | Ending audio session... |
145 | Audio session ended by local party |
||
146 | Session duration was 7 seconds |
||
147 | 28 | Adrian Georgescu | </pre> |
148 | 1 | Adrian Georgescu | |
149 | 25 | Adrian Georgescu | |
150 | 28 | Adrian Georgescu | h3. Alarm System |
151 | |||
152 | |||
153 | 22 | Adrian Georgescu | sip-audio-session script can be used for end-to-end testing of a SIP service including the RTP media path. The following failures can be detected: |
154 | |||
155 | 28 | Adrian Georgescu | * Timeout |
156 | * Negative response code |
||
157 | * Lack of RTP media after the SIP session has been established |
||
158 | * Missing ACK |
||
159 | 22 | Adrian Georgescu | |
160 | |||
161 | 1 | Adrian Georgescu | To setup the alarm system start periodically a caller script from a monitoring software using the following arguments: |
162 | 24 | Adrian Georgescu | |
163 | 28 | Adrian Georgescu | <pre> |
164 | 1 | Adrian Georgescu | sip-audio-session --auto-hangup user@domain |
165 | 28 | Adrian Georgescu | </pre> |
166 | 1 | Adrian Georgescu | |
167 | Where the user@domain has been configured as the SIP account of the listener, can be an answering machine on the PSTN network. The caller script hangs up after each call. The shell return code can be used to determine if the session setup has failed. |
||
168 | |||
169 | To receive calls and answer them automatically you can also use sip_audio_session script as follows: |
||
170 | 24 | Adrian Georgescu | |
171 | 28 | Adrian Georgescu | <pre> |
172 | 1 | Adrian Georgescu | sip-audio-session --daemonize |
173 | 28 | Adrian Georgescu | </pre> |
174 | 1 | Adrian Georgescu | |
175 | You must run the script as user root. The --daemonize option puts the client in the background and the logging goes to /var/log/syslog. The program saves its pid file to /var/run/sip_audio_session.pid. |