Project

General

Profile

Sip audio session » History » Version 5

Adrian Georgescu, 03/23/2009 07:04 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 4 Adrian Georgescu
[[Image(http://www.tech-invite.com/img/cf3665/cf3665-31.gif, align=right)]]
6 1 Adrian Georgescu
7
=== Description ===
8
9
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.
10
11
Source code: [source:scripts/sip_audio_session.py scripts/sip_audio_session.py]
12
13
{{{
14 5 Adrian Georgescu
adigeo@ag-oxygen:~$sip_audio_session --help
15 1 Adrian Georgescu
Usage: sip_audio_session [options] [target-user@target-domain.com]
16
17
This script can sit idle waiting for an incoming audio call, or perform an
18
outgoing audio call to the target SIP account. The program will close the
19
session and quit when Ctrl+D is pressed.
20
21
Options:
22
  -h, --help            show this help message and exit
23 5 Adrian Georgescu
  -a NAME, --account=NAME
24
                        The account name to use for any outgoing traffic. If
25
                        not supplied, the default account will be used.
26
  -c [FILE], --config_file=[FILE]
27
                        The path to a configuration file to use. This
28
                        overrides the default location of the configuration
29
                        file.
30
  -s [stdout|file|all|none], --trace-sip=[stdout|file|all|none]
31
                        Dump the raw contents of incoming and outgoing SIP
32
                        messages. The argument specifies where the messages
33
                        are to be dumped.
34
  -j [stdout|file|all|none], --trace-pjsip=[stdout|file|all|none]
35
                        Print PJSIP logging output. The argument specifies
36 1 Adrian Georgescu
                        where the messages are to be dumped.
37 5 Adrian Georgescu
  -S, --disable-sound   Disables initializing the sound card.
38
  --auto-answer         Interval after which to answer an incoming call
39
                        (disabled by default). If the option is specified but
40
                        the interval is not, it defaults to 0 (answer the call
41
                        as soon as it starts ringing).
42 1 Adrian Georgescu
  --auto-hangup         Interval after which to hangup an on-going call
43
                        (applies only to outgoing calls, disabled by default).
44
                        If the option is specified but the interval is not, it
45
                        defaults to 0 (hangup the call as soon as it
46
                        connects).
47
}}}
48
49
50
=== Example for incoming session ===
51
52
{{{
53
adigeo@ag-imac3:~/Business/Personal$sip_audio_session 
54
Accounts available: 'alice', 'as', 'bob', 'ew', 'ewt', 'mrg', 'pbx', 's', 'tf', 'umts', 'umts_test', 'unet', 'unet_test', default
55
Using default account: 31208005169@ag-projects.com
56
Registering ""Adrian G." <sip:31208005169@ag-projects.com>" at 81.23.228.129:5060
57
REGISTER was successful
58
Contact: sip:HZ1BYFQtHR@192.168.1.6:49421;transport=udp (expires in 300 seconds)
59
Available control keys:
60
  h: hang-up the active session
61
  r: toggle audio recording
62
  t: toggle SIP trace on the console
63
  <> : adjust echo cancellation
64
  SPACE: hold/on-hold
65
  Ctrl-d: quit the program
66
  ?: display this help message
67
Waiting for incoming session...
68
Detected NAT type: Port Restricted
69
Incoming session...
70
Incoming audio session from "sip:adi@umts.ro", do you want to accept? (y/n)
71
Session established, using "speex" codec at 32000Hz
72
Audio RTP endpoints 192.168.1.6:40064 <-> 81.23.228.150:56618
73
Remote SIP User Agent is "sip2sip-0.4.0-pjsip-1.0.1-r2453"
74
Call is put on hold
75
Call is taken out of hold
76
Ending session...
77
Session ended by local party.
78
Session duration was 6 seconds
79
}}}
80
81
=== Example for outgoing session ===
82
83
{{{
84
adigeo@ag-imac3:~$sip -a umts ag@ag-projects.com
85
Accounts available: 'alice', 'as', 'bob', 'ew', 'ewt', 'mrg', 'pbx', 's', 'tf', 'umts', 'umts_test', 'unet', 'unet_test', default
86
Using account 'umts': adi@umts.ro
87
Call from "Adi UMTS" <sip:adi@umts.ro> to sip:ag@ag-projects.com through proxy udp:85.17.186.7:5060
88
Available control keys:
89
  h: hang-up the active session
90
  r: toggle audio recording
91
  t: toggle SIP trace on the console
92
  <> : adjust echo cancellation
93
  SPACE: hold/on-hold
94
  Ctrl-d: quit the program
95
  ?: display this help message
96
Ringing...
97
Ringing...
98
Ringing...
99
Session established, using "speex" codec at 32000Hz
100
Audio RTP endpoints 192.168.1.6:40048 <-> 81.23.228.150:56616
101
Remote SIP User Agent is "sip2sip-0.4.0-pjsip-1.0.1-r2453"
102
Remote party has put the call on hold
103
Remote party has taken the call out of hold
104
Session ended by remote party.
105
Session duration was 6 seconds
106
107
}}}
108
109
110
=== Ongoing sessions ===
111
112
During an ongoing session you can record the audio stream in a file by pressing r. You can hangup by pressing h.