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