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