Sip audio session » History » Revision 3
Revision 2 (Adrian Georgescu, 02/23/2009 03:39 PM) → Revision 3/28 (Adrian Georgescu, 03/12/2009 08:07 PM)
== sip_audio_session == [[TOC(SipTesting*, sip_*, xcap*,depth=2)]] To use this script you must to have a valid [wiki:SipSettingsAPI configuration]. [wiki:SipConfiguration configuration file]. === Description === 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. Source code: [source:scripts/sip_audio_session.py scripts/sip_audio_session.py] {{{ adigeo@ag-imac3:~$sip_audio_session -h Usage: sip_audio_session [options] [target-user@target-domain.com] This script can sit idle waiting for an incoming audio call, or perform an outgoing audio call to the target SIP account. The program will close the session and quit when Ctrl+D is pressed. Options: -h, --help show this help message and exit -a NAME, --account-name=NAME The account name from which to read account settings. Corresponds to section Account_NAME in the configuration file. If not supplied, the section Account will be read. --sip-address=SIP_ADDRESS SIP address of the user in the form user@domain -p PASSWORD, --password=PASSWORD Password to use to authenticate the local account. This overrides the setting from the config file. -n DISPLAY_NAME, --display-name=DISPLAY_NAME Display name to use for the local account. This overrides the setting from the config file. -o IP[:PORT], --outbound-proxy=IP[:PORT] Outbound SIP proxy to use. By default a lookup of the domain is performed based on SRV and A records. This overrides the setting from the config file. -s, --trace-sip Dump the raw contents of incoming and outgoing SIP messages (disabled by default). The argument specifies where the messages are to be dumped. -t EC_TAIL_LENGTH, --ec-tail-length=EC_TAIL_LENGTH Echo cancellation tail length in ms, setting this to 0 will disable echo cancellation. Default is 50 ms. -r SAMPLE_RATE, --sample-rate=SAMPLE_RATE Sample rate in kHz, should be one of 8, 16 or 32kHz. Default is 32kHz. -c CODECS, --codecs=CODECS Comma separated list of codecs to be used. Default is "speex,g711,ilbc,gsm,g722". -S, --disable-sound Do not initialize the soundcard (by default the soundcard is enabled). -j, --trace-pjsip Print PJSIP logging output (disabled by default). --auto-hangup Interval after which to hangup an on-going call (applies only to outgoing calls, disabled by default). If the option is specified but the interval is not, it defaults to 0 (hangup the call as soon as it connects). --auto-answer Interval after which to answer an incoming call (disabled by default). If the option is specified but the interval is not, it defaults to 0 (answer the call as soon as it starts ringing). }}} === Example for incoming session === {{{ adigeo@ag-imac3:~/Business/Personal$sip_audio_session Accounts available: 'alice', 'as', 'bob', 'ew', 'ewt', 'mrg', 'pbx', 's', 'tf', 'umts', 'umts_test', 'unet', 'unet_test', default Using default account: 31208005169@ag-projects.com Registering ""Adrian G." <sip:31208005169@ag-projects.com>" at 81.23.228.129:5060 REGISTER was successful Contact: sip:HZ1BYFQtHR@192.168.1.6:49421;transport=udp (expires in 300 seconds) Available control keys: h: hang-up the active session r: toggle audio recording t: toggle SIP trace on the console <> : adjust echo cancellation SPACE: hold/on-hold Ctrl-d: quit the program ?: display this help message Waiting for incoming session... Detected NAT type: Port Restricted Incoming session... Incoming audio session from "sip:adi@umts.ro", do you want to accept? (y/n) Session established, using "speex" codec at 32000Hz Audio RTP endpoints 192.168.1.6:40064 <-> 81.23.228.150:56618 Remote SIP User Agent is "sip2sip-0.4.0-pjsip-1.0.1-r2453" Call is put on hold Call is taken out of hold Ending session... Session ended by local party. Session duration was 6 seconds }}} === Example for outgoing session === {{{ adigeo@ag-imac3:~$sip -a umts ag@ag-projects.com Accounts available: 'alice', 'as', 'bob', 'ew', 'ewt', 'mrg', 'pbx', 's', 'tf', 'umts', 'umts_test', 'unet', 'unet_test', default Using account 'umts': adi@umts.ro Call from "Adi UMTS" <sip:adi@umts.ro> to sip:ag@ag-projects.com through proxy udp:85.17.186.7:5060 Available control keys: h: hang-up the active session r: toggle audio recording t: toggle SIP trace on the console <> : adjust echo cancellation SPACE: hold/on-hold Ctrl-d: quit the program ?: display this help message Ringing... Ringing... Ringing... Session established, using "speex" codec at 32000Hz Audio RTP endpoints 192.168.1.6:40048 <-> 81.23.228.150:56616 Remote SIP User Agent is "sip2sip-0.4.0-pjsip-1.0.1-r2453" Remote party has put the call on hold Remote party has taken the call out of hold Session ended by remote party. Session duration was 6 seconds }}} === Ongoing sessions === During an ongoing session you can record the audio stream in a file by pressing r. You can hangup by pressing h.