Sip audio session » History » Revision 12
Revision 11 (Adrian Georgescu, 03/30/2009 12:46 PM) → Revision 12/28 (Adrian Georgescu, 03/30/2009 12:46 PM)
== sip_audio_session == [[TOC(SipTesting*, sip_*, xcap*,depth=2)]] To use this script you must to have a valid [wiki:SipSettingsAPI configuration]. === 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. [[Image(http://www.tech-invite.com/img/cf3665/cf3665-32.gif)]] Source code: [source:scripts/sip_audio_session.py scripts/sip_audio_session.py] {{{ adigeo@ag-oxygen:~$sip_audio_session --help 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 The account name to use for any outgoing traffic. If not supplied, the default account will be used. -c [FILE], --config_file=[FILE] The path to a configuration file to use. This overrides the default location of the configuration file. -s [stdout|file|all|none], --trace-sip=[stdout|file|all|none] Dump the raw contents of incoming and outgoing SIP messages. The argument specifies where the messages are to be dumped. -j [stdout|file|all|none], --trace-pjsip=[stdout|file|all|none] Print PJSIP logging output. The argument specifies where the messages are to be dumped. -S, --disable-sound Disables initializing the sound card. --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). --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). }}} === Example for incoming session === {{{ adigeo@ag-imac3:~$sip_audio_session Using account 31208005169@ag-projects.com Available control keys: h: hang-up the active session r: toggle audio recording t: toggle SIP trace on the console j: toggle PJSIP trace on the console <> : adjust echo cancellation SPACE: hold/on-hold Ctrl-d: quit the program ?: display this help message Succesfully registered using contact "sip:cwntuzyl@192.168.1.6:61163" Detected NAT type: Port Restricted Incoming audio session from ""Adrian G." <sip:31208005169@ag-projects.com>", do you want to accept? (y/n) Session established, using "PCMU" codec at 8000Hz Audio RTP endpoints 192.168.1.6:50132 <-> 85.17.186.7:53358 Remote SIP User Agent is "CSCO/7" Session ended by remote party. Session duration was 3 seconds }}} === Example for outgoing session === {{{ adigeo@ag-imac3:~$sip_audio_session ag@ag-projects.com Using account 31208005169@ag-projects.com Initiating SIP session from "Adrian G." <sip:31208005169@ag-projects.com> to sip:ag@ag-projects.com via udp:81.23.228.150:5060 ... Available control keys: h: hang-up the active session r: toggle audio recording t: toggle SIP trace on the console j: toggle PJSIP trace on the console <> : adjust echo cancellation SPACE: hold/on-hold Ctrl-d: quit the program ?: display this help message Succesfully registered using contact "sip:ztomvpis@192.168.1.6:61215" Ringing... Session established, using "speex" codec at 32000Hz Audio RTP endpoints 192.168.1.6:50374 <-> 81.23.228.129:52156 Remote SIP User Agent is "sip2sip-0.9.0-pjsip-1.0.2-trunk-r2553" Detected NAT type: Port Restricted Ending session... Session ended by local party. Session duration was 12 seconds }}} === Example for bonjour mode === In bonjour mode no server is used. This mode is useful for serverless ad-hoc LAN operation. > The actual bonjour protocol that uses multicast DNS to broadcast the contact SIP URIs is not implemented. [[Image(http://www.tech-invite.com/img/cf3665/cf3665-31.gif)]] '''Called party''' {{{ adigeo@ag-imac3:~$sip_audio_session -a bonjour@local "sip:wjnrczhi@192.168.1.6:57624;transport=tls" Using account bonjour@local Listening on "sip:wjnrczhi@192.168.1.6:57624;transport=tls" "sip:imdyzosg@192.168.1.6:57626;transport=tls" Listening on "sip:wjnrczhi@192.168.1.6:57623;transport=tcp" "sip:imdyzosg@192.168.1.6:57625;transport=tcp" Listening on "sip:wjnrczhi@192.168.1.6:61994" "sip:imdyzosg@192.168.1.6:62008" 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 ... Available control keys: h: hang-up the active session r: toggle audio recording t: toggle SIP trace on the console j: toggle PJSIP trace on the console <> : adjust echo cancellation SPACE: hold/on-hold Ctrl-d: quit the program ?: display this help message Incoming audio session from "sip:imdyzosg@192.168.1.6", do you want to accept? (y/n) Ringing... Session established, using "speex" codec at 32000Hz Audio RTP endpoints 192.168.1.6:50100 <-> 192.168.1.6:50276 <-> 192.168.1.6:50100 RTP audio stream is encrypted Remote SIP User Agent is "sip2sip-0.9.0-pjsip-1.0.2-trunk-r2553" Ending session... Session ended by remote local party. Session duration was 5 seconds }}} '''Calling party''' {{{ adigeo@ag-imac3:~$sip_audio_session -a bonjour@local "sip:wjnrczhi@192.168.1.6:57624;transport=tls" Using account bonjour@local Listening on "sip:imdyzosg@192.168.1.6:57626;transport=tls" "sip:wjnrczhi@192.168.1.6:57624;transport=tls" Listening on "sip:imdyzosg@192.168.1.6:57625;transport=tcp" "sip:wjnrczhi@192.168.1.6:57623;transport=tcp" Listening on "sip:imdyzosg@192.168.1.6:62008" "sip:wjnrczhi@192.168.1.6:61994" 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 ... Available control keys: h: hang-up the active session r: toggle audio recording t: toggle SIP trace on the console j: toggle PJSIP trace on the console <> : adjust echo cancellation SPACE: hold/on-hold Ctrl-d: quit the program ?: display this help message Ringing... Incoming audio session from "sip:imdyzosg@192.168.1.6", do you want to accept? (y/n) Session established, using "speex" codec at 32000Hz Audio RTP endpoints 192.168.1.6:50276 <-> 192.168.1.6:50100 <-> 192.168.1.6:50276 RTP audio stream is encrypted Remote SIP User Agent is "sip2sip-0.9.0-pjsip-1.0.2-trunk-r2553" Ending session... Session ended by local remote party. Session duration was 5 seconds }}}