Pjsip-pjsua: Difference between revisions
Line 298: | Line 298: | ||
=== --local-port === | === --local-port === | ||
포트를 지정한다. TCP/UDP 설정 모두 여기에 지정한 포트를 사용한다. | 포트를 지정한다. TCP/UDP 설정 모두 여기에 지정한 포트를 사용한다. 0으로 설정시, 랜덤하게 아무 사용가능한 포트를 자동으로 설정해서 사용한다. | ||
<pre> | <pre> | ||
--local-port=5064 | --local-port=5064 |
Latest revision as of 13:13, 7 November 2016
Overview
SIP open source framework pjsip-pjsua 프로그램 소개
pjsua 는 pjsip 에서 제공하는 CLI 기반 SIP Client 이다. 자세한 사용 설명은 이곳<ref>http://www.pjsip.org/pjsua.htm</ref> 에서 확인할 수 있다.
help
pchero@mywork:~/workspace/Study/Program/pjsip/scripts$ pjsua --help 11:01:27.842 os_core_unix.c !pjlib 2.3 for POSIX initialized 11:01:27.843 sip_endpoint.c .Creating endpoint instance... 11:01:27.843 pjlib .select() I/O Queue created (0xdf67e0) 11:01:27.843 sip_endpoint.c .Module "mod-msg-print" registered 11:01:27.843 sip_transport. .Transport manager created. 11:01:27.843 pjsua_core.c .PJSUA state changed: NULL --> CREATED Usage: pjsua [options] [SIP URL to call] General options: --config-file=file Read the config/arguments from file. --help Display this help screen --version Display version info Logging options: --log-file=fname Log to filename (default stderr) --log-level=N Set log max level to N (0(none) to 6(trace)) (default=5) --app-log-level=N Set log max level for stdout display (default=4) --log-append Append instead of overwrite existing log file. --color Use colorful logging (default yes on Win32) --no-color Disable colorful logging --light-bg Use dark colors for light background (default is dark bg) --no-stderr Disable stderr SIP Account options: --registrar=url Set the URL of registrar server --id=url Set the URL of local ID (used in From header) --realm=string Set realm --username=string Set authentication username --password=string Set authentication password --contact=url Optionally override the Contact information --contact-params=S Append the specified parameters S in Contact header --contact-uri-params=S Append the specified parameters S in Contact URI --proxy=url Optional URL of proxy server to visit May be specified multiple times --reg-timeout=SEC Optional registration interval (default 300) --rereg-delay=SEC Optional auto retry registration interval (default 300) --reg-use-proxy=N Control the use of proxy settings in REGISTER. 0=no proxy, 1=outbound only, 2=acc only, 3=all (default) --publish Send presence PUBLISH for this account --mwi Subscribe to message summary/waiting indication --use-ims Enable 3GPP/IMS related settings on this account --use-srtp=N Use SRTP? 0:disabled, 1:optional, 2:mandatory, 3:optional by duplicating media offer (def:0) --srtp-secure=N SRTP require secure SIP? 0:no, 1:tls, 2:sips (def:1) --use-100rel Require reliable provisional response (100rel) --use-timer=N Use SIP session timers? (default=1) 0:inactive, 1:optional, 2:mandatory, 3:always --timer-se=N Session timers expiration period, in secs (def:1800) --timer-min-se=N Session timers minimum expiration period, in secs (def:90) --outb-rid=string Set SIP outbound reg-id (default:1) --auto-update-nat=N Where N is 0 or 1 to enable/disable SIP traversal behind symmetric NAT (default 1) --disable-stun Disable STUN for this account --next-cred Add another credentials SIP Account Control: --next-account Add more account Transport Options: --set-qos Enable QoS tagging for SIP and media. --local-port=port Set TCP/UDP port. This implicitly enables both TCP and UDP transports on the specified port, unless if TCP or UDP is disabled. --ip-addr=IP Use the specifed address as SIP and RTP addresses. (Hint: the IP may be the public IP of the NAT/router) --bound-addr=IP Bind transports to this IP interface --no-tcp Disable TCP transport. --no-udp Disable UDP transport. --nameserver=NS Add the specified nameserver to enable SRV resolution This option can be specified multiple times. --outbound=url Set the URL of global outbound proxy server May be specified multiple times --stun-srv=FORMAT Set STUN server host or domain. This option may be specified more than once. FORMAT is hostdom[:PORT] TLS Options: --use-tls Enable TLS transport (default=no) --tls-ca-file Specify TLS CA file (default=none) --tls-cert-file Specify TLS certificate file (default=none) --tls-privkey-file Specify TLS private key file (default=none) --tls-password Specify TLS password to private key file (default=none) --tls-verify-server Verify server's certificate (default=no) --tls-verify-client Verify client's certificate (default=no) --tls-neg-timeout Specify TLS negotiation timeout (default=no) --tls-cipher Specify prefered TLS cipher (optional). May be specified multiple times Audio Options: --add-codec=name Manually add codec (default is to enable all) --dis-codec=name Disable codec (can be specified multiple times) --clock-rate=N Override conference bridge clock rate --snd-clock-rate=N Override sound device clock rate --stereo Audio device and conference bridge opened in stereo mode --null-audio Use NULL audio device --play-file=file Register WAV file in conference bridge. This can be specified multiple times. --play-tone=FORMAT Register tone to the conference bridge. FORMAT is 'F1,F2,ON,OFF', where F1,F2 are frequencies, and ON,OFF=on/off duration in msec. This can be specified multiple times. --auto-play Automatically play the file (to incoming calls only) --auto-loop Automatically loop incoming RTP to outgoing RTP --auto-conf Automatically put calls in conference with others --rec-file=file Open file recorder (extension can be .wav or .mp3 --auto-rec Automatically record conversation --quality=N Specify media quality (0-10, default=6) --ptime=MSEC Override codec ptime to MSEC (default=specific) --no-vad Disable VAD/silence detector (default=vad enabled) --ec-tail=MSEC Set echo canceller tail length (default=256) --ec-opt=OPT Select echo canceller algorithm (0=default, 1=speex, 2=suppressor) --ilbc-mode=MODE Set iLBC codec mode (20 or 30, default is 30) --capture-dev=id Audio capture device ID (default=-1) --playback-dev=id Audio playback device ID (default=-1) --capture-lat=N Audio capture latency, in ms (default=100) --playback-lat=N Audio playback latency, in ms (default=100) --snd-auto-close=N Auto close audio device when idle for N secs (default=1) Specify N=-1 to disable this feature. Specify N=0 for instant close when unused. --no-tones Disable audible tones --jb-max-size Specify jitter buffer maximum size, in frames (default=-1) --extra-audio Add one more audio stream Media Transport Options: --use-ice Enable ICE (default:no) --ice-regular Use ICE regular nomination (default: aggressive) --ice-max-hosts=N Set maximum number of ICE host candidates --ice-no-rtcp Disable RTCP component in ICE (default: no) --rtp-port=N Base port to try for RTP (default=4000) --rx-drop-pct=PCT Drop PCT percent of RX RTP (for pkt lost sim, default: 0) --tx-drop-pct=PCT Drop PCT percent of TX RTP (for pkt lost sim, default: 0) --use-turn Enable TURN relay with ICE (default:no) --turn-srv Domain or host name of TURN server ("NAME:PORT" format) --turn-tcp Use TCP connection to TURN server (default no) --turn-user TURN username --turn-passwd TURN password Buddy List (can be more than one): --add-buddy url Add the specified URL to the buddy list. User Agent options: --auto-answer=code Automatically answer incoming calls with code (e.g. 200) --max-calls=N Maximum number of concurrent calls (default:4, max:255) --thread-cnt=N Number of worker threads (default:1) --duration=SEC Set maximum call duration (default:no limit) --norefersub Suppress event subscription when transferring calls --use-compact-form Minimize SIP message size --no-force-lr Allow strict-route to be used (i.e. do not force lr) --accept-redirect=N Specify how to handle call redirect (3xx) response. 0: reject, 1: follow automatically, 2: follow + replace To header (default), 3: ask CLI options: --use-cli Use CLI as user interface --cli-telnet-port=N CLI telnet port --no-cli-console Disable CLI console When URL is specified, pjsua will immediately initiate call to that URL 11:01:27.845 pjsua_core.c Shutting down, flags=0... 11:01:27.845 pjsua_core.c PJSUA state changed: CREATED --> CLOSING 11:01:27.845 pjsua_call.c .Hangup all calls.. 11:01:27.845 pjsua_media.c .Call 0: deinitializing media.. 11:01:27.845 pjsua_media.c .Call 1: deinitializing media.. 11:01:27.845 pjsua_media.c .Call 2: deinitializing media.. 11:01:27.846 pjsua_media.c .Call 3: deinitializing media.. 11:01:27.846 pjsua_pres.c .Shutting down presence.. 11:01:28.849 pjsua_core.c .Destroying... 11:01:28.849 pjsua_media.c .Shutting down media.. 11:01:28.849 sip_endpoint.c .Destroying endpoing instance.. 11:01:28.849 sip_endpoint.c .Module "mod-msg-print" unregistered 11:01:28.849 sip_transport. .Destroying transport manager 11:01:28.849 sip_endpoint.c .Endpoint 0xdeba48 destroyed 11:01:28.849 pjsua_core.c .PJSUA state changed: CLOSING --> NULL 11:01:28.849 pjsua_core.c .PJSUA destroyed...
Logging options
Logging options: --log-file=fname Log to filename (default stderr) --log-level=N Set log max level to N (0(none) to 6(trace)) (default=5) --app-log-level=N Set log max level for stdout display (default=4) --log-append Append instead of overwrite existing log file.
--log-file
Log 파일 이름을 설정한다.
--log-file=/tmp/test.log
--app-log-level
Stdout 으로 출력되는 Log 레벨을 설정한다. (default=4)
--app-log-level=3
SIP Account options
--registrar=url Set the URL of registrar server --id=url Set the URL of local ID (used in From header) --realm=string Set realm --username=string Set authentication username --password=string Set authentication password --contact=url Optionally override the Contact information --contact-params=S Append the specified parameters S in Contact header --contact-uri-params=S Append the specified parameters S in Contact URI --proxy=url Optional URL of proxy server to visit May be specified multiple times --reg-timeout=SEC Optional registration interval (default 300) --rereg-delay=SEC Optional auto retry registration interval (default 300) --reg-use-proxy=N Control the use of proxy settings in REGISTER. 0=no proxy, 1=outbound only, 2=acc only, 3=all (default) --publish Send presence PUBLISH for this account --mwi Subscribe to message summary/waiting indication --use-ims Enable 3GPP/IMS related settings on this account --use-srtp=N Use SRTP? 0:disabled, 1:optional, 2:mandatory, 3:optional by duplicating media offer (def:0) --srtp-secure=N SRTP require secure SIP? 0:no, 1:tls, 2:sips (def:1) --use-100rel Require reliable provisional response (100rel) --use-timer=N Use SIP session timers? (default=1) 0:inactive, 1:optional, 2:mandatory, 3:always --timer-se=N Session timers expiration period, in secs (def:1800) --timer-min-se=N Session timers minimum expiration period, in secs (def:90) --outb-rid=string Set SIP outbound reg-id (default:1) --auto-update-nat=N Where N is 0 or 1 to enable/disable SIP traversal behind symmetric NAT (default 1) --disable-stun Disable STUN for this account --next-cred Add another credentials
--registar
Registrar 서버를 지정한다. "<서버 프로토콜>:<ip address/domain>" 의 형식으로 설정한다.
--registrar=sip:192.168.200.10
--id
local ID 로 사용할 URL 을 설정한다. SIP From header 에 사용한다.
--id=sip:agent-01@192.168.200.10
--realm
Realm 정보를 설정한다.
--realm=*
--username
인증시 사용하는 username 을 설정한다.
--username=agent-01
--password
인증시 사용하는 비밀번호를 설정한다.
--password="8c8c4179-0059-4c92-9ccd-64813fcfa6bf"
Transport options
Transport Options: --set-qos Enable QoS tagging for SIP and media. --local-port=port Set TCP/UDP port. This implicitly enables both TCP and UDP transports on the specified port, unless if TCP or UDP is disabled. --ip-addr=IP Use the specifed address as SIP and RTP addresses. (Hint: the IP may be the public IP of the NAT/router) --bound-addr=IP Bind transports to this IP interface --no-tcp Disable TCP transport. --no-udp Disable UDP transport. --nameserver=NS Add the specified nameserver to enable SRV resolution This option can be specified multiple times. --outbound=url Set the URL of global outbound proxy server May be specified multiple times --stun-srv=FORMAT Set STUN server host or domain. This option may be specified more than once. FORMAT is hostdom[:PORT]
--local-port
포트를 지정한다. TCP/UDP 설정 모두 여기에 지정한 포트를 사용한다. 0으로 설정시, 랜덤하게 아무 사용가능한 포트를 자동으로 설정해서 사용한다.
--local-port=5064
--no-tcp
TCP 전송을 disable 한다.
--no-tcp
Audio options
Audio Options: --add-codec=name Manually add codec (default is to enable all) --dis-codec=name Disable codec (can be specified multiple times) --clock-rate=N Override conference bridge clock rate --snd-clock-rate=N Override sound device clock rate --stereo Audio device and conference bridge opened in stereo mode --null-audio Use NULL audio device --play-file=file Register WAV file in conference bridge. This can be specified multiple times. --play-tone=FORMAT Register tone to the conference bridge. FORMAT is 'F1,F2,ON,OFF', where F1,F2 are frequencies, and ON,OFF=on/off duration in msec. This can be specified multiple times. --auto-play Automatically play the file (to incoming calls only) --auto-loop Automatically loop incoming RTP to outgoing RTP --auto-conf Automatically put calls in conference with others --rec-file=file Open file recorder (extension can be .wav or .mp3 --auto-rec Automatically record conversation --quality=N Specify media quality (0-10, default=6) --ptime=MSEC Override codec ptime to MSEC (default=specific) --no-vad Disable VAD/silence detector (default=vad enabled) --ec-tail=MSEC Set echo canceller tail length (default=256) --ec-opt=OPT Select echo canceller algorithm (0=default, 1=speex, 2=suppressor) --ilbc-mode=MODE Set iLBC codec mode (20 or 30, default is 30) --capture-dev=id Audio capture device ID (default=-1) --playback-dev=id Audio playback device ID (default=-1) --capture-lat=N Audio capture latency, in ms (default=100) --playback-lat=N Audio playback latency, in ms (default=100) --snd-auto-close=N Auto close audio device when idle for N secs (default=1) Specify N=-1 to disable this feature. Specify N=0 for instant close when unused. --no-tones Disable audible tones --jb-max-size Specify jitter buffer maximum size, in frames (default=-1) --extra-audio Add one more audio stream
--null-audio
Null audio device 를 사용한다.
한번에 여러개의 pjsua 를 사용할 경우, audio device 자원 접근에 문제가 발생하게 된다. 때문에 특정 client 만 audio 자원을 사용할 수 있도록 다른 client 에서 자우너에 접근하지 않도록 설정해주어야 한다. 이럴 때 이 옵션을 사용하면 된다.
--null-audio
Config-file
Pjsua 사용시, PBX 계정 정보를 config 파일에 설정해 놓고, pjsua 실행시 마다 자동으로 Registration 하게 할 수 있다.
설정가능한 옵션 내용은 CLI 의 옵션과 동일하다.
하나의 파일에 하나 이상의 계정정보를 등록해 놓을 수 있다.
주의사항으로 하나 이상의 계정 정보를 등록하기 위해서는 --next-account 구문을 추가해야한다.
Example
# This is a comment in the config file. #--id sip:alice@example.com --id sip:201@127.0.0.1 --registrar sip:127.0.0.1 --realm * --username 201 --password a9564ebc3289b7a14551baf8ad5ec60a --next-account --id sip:202@127.0.0.1 --registrar sip:127.0.0.1 --realm * --username 202 --password a9564ebc3289b7a14551baf8ad5ec60a
Using configfile
미리 계정을 설정해 놓은 Config file 을 사용할 수 있다.
$ pjsua --config-file=test.cfg
or
$ pjsua --config-file test.cfg
Pjsua 메뉴
+=============================================================================+ | Call Commands: | Buddy, IM & Presence: | Account: | | | | | | m Make new call | +b Add new buddy .| +a Add new accnt | | M Make multiple calls | -b Delete buddy | -a Delete accnt. | | a Answer call | i Send IM | !a Modify accnt. | | h Hangup call (ha=all) | s Subscribe presence | rr (Re-)register | | H Hold call | u Unsubscribe presence | ru Unregister | | v re-inVite (release hold) | t ToGgle Online status | > Cycle next ac.| | U send UPDATE | T Set online status | < Cycle prev ac.| | ],[ Select next/prev call +--------------------------+-------------------+ | x Xfer call | Media Commands: | Status & Config: | | X Xfer with Replaces | | | | # Send RFC 2833 DTMF | cl List ports | d Dump status | | * Send DTMF with INFO | cc Connect port | dd Dump detailed | | dq Dump curr. call quality | cd Disconnect port | dc Dump config | | | V Adjust audio Volume | f Save config | | S Send arbitrary REQUEST | Cp Codec priorities | | +-----------------------------------------------------------------------------+ | q QUIT L ReLoad sleep MS echo [0|1|txt] n: detect NAT type | +=============================================================================+
Make call
+=============================================================================+ You have 0 active call >>> m (You currently have 0 calls) Buddy list: -none- Choices: 0 For current dialog. -1 All 0 buddies in buddy list [1 - 0] Select from buddy list URL An URL <Enter> Empty input (or 'q') to cancel Make call: sip:501@127.0.0.1
Make call 시, sip:<sip_url> 구문을 입력해야 한다. 단순히 sip_url 입력만으로는 발신이 되지 않으니 참고하자.
이상하게 pjsua로 make call 실행 시, 사운드가 노트북 내장 스피커로 연결되어 굉장히 이상한 소리가 나는 현상이 있다.(Lenovo E540, ubuntu-14.04) -> 전체 재컴파일 후, 정상적으로 소리가 안나오는 문제 해결. 하지만 도킹시스템을 통한 외장 스피커 출력이 되지 않는다. 노트북에 있는 오디오 output 으로만 출력이 되는 현상 발생. 아마도 pjsua 는 gnome 스피커 출력 API 를 사용하지 않고 바로 출력 Device 잡고 나가기 때문에 발생하는 현상으로 보인다. 특별히 버그나 문제라고 볼 수는 없기에 그냥 넘어가기로 한다.
Reference
<references />