Sip audio session

Version 12 (Adrian Georgescu, 03/30/2009 12:46 pm)

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 1 Adrian Georgescu
6 1 Adrian Georgescu
=== Description ===
7 1 Adrian Georgescu
8 1 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.
9 6 Adrian Georgescu
10 10 Adrian Georgescu
[[Image(http://www.tech-invite.com/img/cf3665/cf3665-32.gif)]]
11 1 Adrian Georgescu
12 1 Adrian Georgescu
Source code: [source:scripts/sip_audio_session.py scripts/sip_audio_session.py]
13 1 Adrian Georgescu
14 1 Adrian Georgescu
{{{
15 5 Adrian Georgescu
adigeo@ag-oxygen:~$sip_audio_session --help
16 1 Adrian Georgescu
Usage: sip_audio_session [options] [target-user@target-domain.com]
17 1 Adrian Georgescu
18 1 Adrian Georgescu
This script can sit idle waiting for an incoming audio call, or perform an
19 1 Adrian Georgescu
outgoing audio call to the target SIP account. The program will close the
20 1 Adrian Georgescu
session 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 5 Adrian Georgescu
  -c [FILE], --config_file=[FILE]
28 5 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 5 Adrian Georgescu
  -s [stdout|file|all|none], --trace-sip=[stdout|file|all|none]
32 5 Adrian Georgescu
                        Dump the raw contents of incoming and outgoing SIP
33 5 Adrian Georgescu
                        messages. The argument specifies where the messages
34 5 Adrian Georgescu
                        are to be dumped.
35 5 Adrian Georgescu
  -j [stdout|file|all|none], --trace-pjsip=[stdout|file|all|none]
36 5 Adrian Georgescu
                        Print PJSIP logging output. The argument specifies
37 1 Adrian Georgescu
                        where the messages are to be dumped.
38 5 Adrian Georgescu
  -S, --disable-sound   Disables initializing the sound card.
39 5 Adrian Georgescu
  --auto-answer         Interval after which to answer an incoming call
40 5 Adrian Georgescu
                        (disabled by default). If the option is specified but
41 5 Adrian Georgescu
                        the interval is not, it defaults to 0 (answer the call
42 5 Adrian Georgescu
                        as soon as it starts ringing).
43 1 Adrian Georgescu
  --auto-hangup         Interval after which to hangup an on-going call
44 1 Adrian Georgescu
                        (applies only to outgoing calls, disabled by default).
45 1 Adrian Georgescu
                        If the option is specified but the interval is not, it
46 1 Adrian Georgescu
                        defaults to 0 (hangup the call as soon as it
47 1 Adrian Georgescu
                        connects).
48 1 Adrian Georgescu
}}}
49 1 Adrian Georgescu
50 1 Adrian Georgescu
51 1 Adrian Georgescu
=== Example for incoming session ===
52 1 Adrian Georgescu
53 1 Adrian Georgescu
{{{
54 7 Adrian Georgescu
adigeo@ag-imac3:~$sip_audio_session
55 7 Adrian Georgescu
Using account 31208005169@ag-projects.com
56 1 Adrian Georgescu
Available control keys:
57 1 Adrian Georgescu
  h: hang-up the active session
58 1 Adrian Georgescu
  r: toggle audio recording
59 1 Adrian Georgescu
  t: toggle SIP trace on the console
60 7 Adrian Georgescu
  j: toggle PJSIP trace on the console
61 1 Adrian Georgescu
  <> : adjust echo cancellation
62 1 Adrian Georgescu
  SPACE: hold/on-hold
63 1 Adrian Georgescu
  Ctrl-d: quit the program
64 1 Adrian Georgescu
  ?: display this help message
65 7 Adrian Georgescu
Succesfully registered using contact "sip:cwntuzyl@192.168.1.6:61163"
66 1 Adrian Georgescu
Detected NAT type: Port Restricted
67 7 Adrian Georgescu
Incoming audio session from ""Adrian G." <sip:31208005169@ag-projects.com>", do you want to accept? (y/n)
68 7 Adrian Georgescu
Session established, using "PCMU" codec at 8000Hz
69 7 Adrian Georgescu
Audio RTP endpoints 192.168.1.6:50132 <-> 85.17.186.7:53358
70 7 Adrian Georgescu
Remote SIP User Agent is "CSCO/7"
71 7 Adrian Georgescu
Session ended by remote party.
72 7 Adrian Georgescu
Session duration was 3 seconds
73 7 Adrian Georgescu
74 1 Adrian Georgescu
}}}
75 1 Adrian Georgescu
76 1 Adrian Georgescu
=== Example for outgoing session ===
77 1 Adrian Georgescu
78 1 Adrian Georgescu
{{{
79 7 Adrian Georgescu
adigeo@ag-imac3:~$sip_audio_session ag@ag-projects.com
80 7 Adrian Georgescu
Using account 31208005169@ag-projects.com
81 8 Adrian Georgescu
Initiating SIP session from "Adrian G." <sip:31208005169@ag-projects.com> to 
82 8 Adrian Georgescu
sip:ag@ag-projects.com via udp:81.23.228.150:5060 ...
83 1 Adrian Georgescu
Available control keys:
84 1 Adrian Georgescu
  h: hang-up the active session
85 1 Adrian Georgescu
  r: toggle audio recording
86 1 Adrian Georgescu
  t: toggle SIP trace on the console
87 7 Adrian Georgescu
  j: toggle PJSIP trace on the console
88 1 Adrian Georgescu
  <> : adjust echo cancellation
89 1 Adrian Georgescu
  SPACE: hold/on-hold
90 1 Adrian Georgescu
  Ctrl-d: quit the program
91 1 Adrian Georgescu
  ?: display this help message
92 7 Adrian Georgescu
Succesfully registered using contact "sip:ztomvpis@192.168.1.6:61215"
93 1 Adrian Georgescu
Ringing...
94 1 Adrian Georgescu
Session established, using "speex" codec at 32000Hz
95 7 Adrian Georgescu
Audio RTP endpoints 192.168.1.6:50374 <-> 81.23.228.129:52156
96 7 Adrian Georgescu
Remote SIP User Agent is "sip2sip-0.9.0-pjsip-1.0.2-trunk-r2553"
97 7 Adrian Georgescu
Detected NAT type: Port Restricted
98 7 Adrian Georgescu
Ending session...
99 7 Adrian Georgescu
Session ended by local party.
100 7 Adrian Georgescu
Session duration was 12 seconds
101 1 Adrian Georgescu
}}}
102 11 Adrian Georgescu
103 11 Adrian Georgescu
104 11 Adrian Georgescu
=== Example for bonjour mode ===
105 11 Adrian Georgescu
106 11 Adrian Georgescu
In bonjour mode no server is used. This mode is useful for serverless ad-hoc LAN operation. 
107 11 Adrian Georgescu
108 11 Adrian Georgescu
> The actual bonjour protocol that uses multicast DNS to broadcast the contact SIP URIs is not implemented.
109 11 Adrian Georgescu
110 11 Adrian Georgescu
[[Image(http://www.tech-invite.com/img/cf3665/cf3665-31.gif)]]
111 11 Adrian Georgescu
112 12 Adrian Georgescu
'''Called party'''
113 12 Adrian Georgescu
114 1 Adrian Georgescu
{{{
115 12 Adrian Georgescu
adigeo@ag-imac3:~$sip_audio_session -a bonjour@local
116 11 Adrian Georgescu
Using account bonjour@local
117 12 Adrian Georgescu
Listening on "sip:wjnrczhi@192.168.1.6:57624;transport=tls"
118 12 Adrian Georgescu
Listening on "sip:wjnrczhi@192.168.1.6:57623;transport=tcp"
119 12 Adrian Georgescu
Listening on "sip:wjnrczhi@192.168.1.6:61994"
120 11 Adrian Georgescu
Available control keys:
121 11 Adrian Georgescu
  h: hang-up the active session
122 11 Adrian Georgescu
  r: toggle audio recording
123 1 Adrian Georgescu
  t: toggle SIP trace on the console
124 1 Adrian Georgescu
  j: toggle PJSIP trace on the console
125 11 Adrian Georgescu
  <> : adjust echo cancellation
126 11 Adrian Georgescu
  SPACE: hold/on-hold
127 11 Adrian Georgescu
  Ctrl-d: quit the program
128 11 Adrian Georgescu
  ?: display this help message
129 12 Adrian Georgescu
Incoming audio session from "sip:imdyzosg@192.168.1.6", do you want to accept? (y/n)
130 1 Adrian Georgescu
Session established, using "speex" codec at 32000Hz
131 12 Adrian Georgescu
Audio RTP endpoints 192.168.1.6:50276 <-> 192.168.1.6:50100
132 1 Adrian Georgescu
RTP audio stream is encrypted
133 1 Adrian Georgescu
Remote SIP User Agent is "sip2sip-0.9.0-pjsip-1.0.2-trunk-r2553"
134 12 Adrian Georgescu
Session ended by remote party.
135 11 Adrian Georgescu
Session duration was 5 seconds
136 11 Adrian Georgescu
}}}
137 11 Adrian Georgescu
138 12 Adrian Georgescu
'''Calling party'''
139 12 Adrian Georgescu
140 11 Adrian Georgescu
{{{
141 12 Adrian Georgescu
adigeo@ag-imac3:~$sip_audio_session -a bonjour@local "sip:wjnrczhi@192.168.1.6:57624;transport=tls"
142 1 Adrian Georgescu
Using account bonjour@local
143 12 Adrian Georgescu
Listening on "sip:imdyzosg@192.168.1.6:57626;transport=tls"
144 12 Adrian Georgescu
Listening on "sip:imdyzosg@192.168.1.6:57625;transport=tcp"
145 12 Adrian Georgescu
Listening on "sip:imdyzosg@192.168.1.6:62008"
146 12 Adrian Georgescu
Initiating SIP session from sip:imdyzosg@192.168.1.6 to sip:wjnrczhi@192.168.1.6:57624;transport=tls via tls:192.168.1.6:57624 ...
147 11 Adrian Georgescu
Available control keys:
148 11 Adrian Georgescu
  h: hang-up the active session
149 11 Adrian Georgescu
  r: toggle audio recording
150 11 Adrian Georgescu
  t: toggle SIP trace on the console
151 11 Adrian Georgescu
  j: toggle PJSIP trace on the console
152 11 Adrian Georgescu
  <> : adjust echo cancellation
153 11 Adrian Georgescu
  SPACE: hold/on-hold
154 11 Adrian Georgescu
  Ctrl-d: quit the program
155 11 Adrian Georgescu
  ?: display this help message
156 12 Adrian Georgescu
Ringing...
157 11 Adrian Georgescu
Session established, using "speex" codec at 32000Hz
158 12 Adrian Georgescu
Audio RTP endpoints 192.168.1.6:50100 <-> 192.168.1.6:50276
159 11 Adrian Georgescu
RTP audio stream is encrypted
160 11 Adrian Georgescu
Remote SIP User Agent is "sip2sip-0.9.0-pjsip-1.0.2-trunk-r2553"
161 12 Adrian Georgescu
Ending session...
162 12 Adrian Georgescu
Session ended by local party.
163 1 Adrian Georgescu
Session duration was 5 seconds
164 1 Adrian Georgescu
}}}