Sip audio session
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 | 28 | Adrian Georgescu | |
6 | 28 | Adrian Georgescu | |
7 | 28 | Adrian Georgescu | h3. Description |
8 | 28 | Adrian Georgescu | |
9 | 28 | Adrian Georgescu | |
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 | 27 | Adrian Georgescu | |
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 | 24 | Adrian Georgescu | 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 | 17 | Adrian Georgescu | outgoing audio session to a SIP address. The program will close the session |
20 | 17 | Adrian Georgescu | and quit when Ctrl+D is pressed. |
21 | 1 | Adrian Georgescu | |
22 | 1 | Adrian Georgescu | Options: |
23 | 1 | Adrian Georgescu | -h, --help show this help message and exit |
24 | 5 | Adrian Georgescu | -a NAME, --account=NAME |
25 | 5 | Adrian Georgescu | The account name to use for any outgoing traffic. If |
26 | 5 | Adrian Georgescu | 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 | 5 | Adrian Georgescu | file. |
31 | 17 | Adrian Georgescu | -s, --trace-sip Dump the raw contents of incoming and outgoing SIP |
32 | 17 | Adrian Georgescu | messages. |
33 | 17 | Adrian Georgescu | -j, --trace-pjsip Print PJSIP logging output. |
34 | 17 | Adrian Georgescu | -n, --trace-notifications |
35 | 17 | Adrian Georgescu | 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 | 1 | Adrian Georgescu | --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 | 19 | Adrian Georgescu | the interval is not, it defaults to 0 (hangup the |
44 | 19 | Adrian Georgescu | 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 | 1 | Adrian Georgescu | script in a non-interactive environment. |
49 | 1 | Adrian Georgescu | -D, --daemonize Enable running this program as a deamon. This option |
50 | 1 | Adrian Georgescu | implies --disable-sound, --auto-answer and --batch. |
51 | 28 | Adrian Georgescu | </pre> |
52 | 20 | Adrian Georgescu | |
53 | 1 | Adrian Georgescu | |
54 | 1 | Adrian Georgescu | |
55 | 28 | Adrian Georgescu | h3. Incoming Session |
56 | 28 | Adrian Georgescu | |
57 | 28 | Adrian Georgescu | |
58 | 28 | Adrian Georgescu | <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 | 21 | Adrian Georgescu | Logging PJSIP trace to file "/Users/adigeo/Library/Application Support/Blink/logs/pjsip_trace.txt" |
63 | 21 | Adrian Georgescu | Available audio input devices: None, system_default, Built-in Input, Built-in Microphone |
64 | 21 | Adrian Georgescu | Available audio output devices: None, system_default, Built-in Output |
65 | 19 | Adrian Georgescu | Using audio input device: Built-in Microphone |
66 | 19 | Adrian Georgescu | Using audio output device: Built-in Output |
67 | 19 | Adrian Georgescu | Using audio alert device: Built-in Output |
68 | 19 | Adrian Georgescu | |
69 | 1 | Adrian Georgescu | Available control keys: |
70 | 1 | Adrian Georgescu | s: toggle SIP trace on the console |
71 | 1 | Adrian Georgescu | j: toggle PJSIP trace on the console |
72 | 1 | Adrian Georgescu | n: toggle notifications trace on the console |
73 | 1 | Adrian Georgescu | p: toggle printing RTP statistics on the console |
74 | 19 | Adrian Georgescu | h: hang-up the active session |
75 | 19 | Adrian Georgescu | r: toggle audio recording |
76 | 21 | Adrian Georgescu | m: mute the microphone |
77 | 21 | Adrian Georgescu | i: change audio input device |
78 | 21 | Adrian Georgescu | o: change audio output device |
79 | 21 | Adrian Georgescu | a: change audio alert device |
80 | 1 | Adrian Georgescu | <>: adjust echo cancellation |
81 | 1 | Adrian Georgescu | SPACE: hold/unhold |
82 | 1 | Adrian Georgescu | Ctrl-d: quit the program |
83 | 1 | Adrian Georgescu | ?: display this help message |
84 | 1 | Adrian Georgescu | |
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 | 27 | Adrian Georgescu | 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 | 21 | Adrian Georgescu | 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 | 21 | Adrian Georgescu | 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 | 1 | Adrian Georgescu | Audio RTP endpoints 192.168.1.124:50378 <-> 85.17.186.6:58868 |
96 | 1 | Adrian Georgescu | RTP audio stream is encrypted |
97 | 1 | Adrian Georgescu | Remote SIP User Agent is "Blink-0.9.0" |
98 | 1 | Adrian Georgescu | Remote party has put the audio session on hold |
99 | 21 | Adrian Georgescu | Audio session is put on hold |
100 | 21 | Adrian Georgescu | Audio session ended by remote party |
101 | 21 | Adrian Georgescu | 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 | 28 | Adrian Georgescu | |
108 | 28 | Adrian Georgescu | |
109 | 28 | Adrian Georgescu | <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 | 21 | Adrian Georgescu | Logging SIP trace to file "/Users/adigeo/Library/Application Support/Blink/logs/sip_trace.txt" |
113 | 21 | Adrian Georgescu | Logging PJSIP trace to file "/Users/adigeo/Library/Application Support/Blink/logs/pjsip_trace.txt" |
114 | 21 | Adrian Georgescu | Available audio input devices: None, system_default, Built-in Input, Built-in Microphone |
115 | 21 | Adrian Georgescu | 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 | 11 | Adrian Georgescu | p: toggle printing RTP statistics on the console |
125 | 12 | Adrian Georgescu | h: hang-up the active session |
126 | 12 | Adrian Georgescu | r: toggle audio recording |
127 | 21 | Adrian Georgescu | m: mute the microphone |
128 | 21 | Adrian Georgescu | 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 | 26 | Adrian Georgescu | 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 | 1 | Adrian Georgescu | ICE negotiation succeeded in 1s:412 |
139 | 1 | Adrian Georgescu | Audio RTP endpoints 192.168.1.124:50852 (ICE type host) <-> 192.168.1.124:50871 (ICE type host) |
140 | 1 | Adrian Georgescu | RTP audio stream is encrypted |
141 | 1 | Adrian Georgescu | Audio session is put on hold |
142 | 23 | Adrian Georgescu | Remote party has put the audio session on hold |
143 | 23 | Adrian Georgescu | Detected NAT type: Port Restricted |
144 | 1 | Adrian Georgescu | Ending audio session... |
145 | 1 | Adrian Georgescu | Audio session ended by local party |
146 | 1 | Adrian Georgescu | 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 | 28 | Adrian Georgescu | |
152 | 28 | Adrian Georgescu | |
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 | 22 | Adrian Georgescu | |
155 | 28 | Adrian Georgescu | * Timeout |
156 | 28 | Adrian Georgescu | * Negative response code |
157 | 28 | Adrian Georgescu | * Lack of RTP media after the SIP session has been established |
158 | 28 | Adrian Georgescu | * Missing ACK |
159 | 22 | Adrian Georgescu | |
160 | 22 | Adrian Georgescu | |
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 | 1 | Adrian Georgescu | 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 | 1 | Adrian Georgescu | |
169 | 1 | Adrian Georgescu | 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 | 1 | Adrian Georgescu | 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. |