PJSIP Windows版をビルドする

PJSIP

PJSIPのWindows版をビルドし、動作確認を行います。

ビルド環境構築

開発ツールをダウンロードしインストールします。

Visual C++ 2005 Express Edition 日本語版
http://download.microsoft.com/download/8/E/8/8E85D539-2255-4CFD-AA97-440AE6C6F44A/vc.iso
vc.iso

DirectX Software Development Kit
http://www.microsoft.com/downloads/details.aspx?FamilyId=572BE8A6-263A-4424-A7FE-69CFF1A5B180&displaylang=en
dxsdk_march2008.exe

WindowsR Server 2003 SP1 Platform SDK Web Install
http://www.microsoft.com/downloads/details.aspx?FamilyId=A55B6B43-E24F-4EA3-A93E-40C0EC4F68E5&displaylang=en
PSDK-x86.exe

PJSIP Windows版のダウンロード

PJSIP - Open Source SIP Stack
http://www.pjsip.org/
pjproject-1.0.3.zip

準備

・pjproject-1.0.3.zipを解凍しC:\pjproject-1.0.3フォルダを作成します。
・pjlib/include/pj配下に空ファイルconfig_site.hを作成します。

・Visual C++ 2005 Express Edition 日本語版を起動します。
・ツール→オプション→プロジェクトおよびソリューション→VC++ディレクトリと選択し、「ライブラリ」に
C:\Program Files\Microsoft DirectX SDK (March 2008)\Lib\x86
C:\Program Files\Microsoft Platform SDK\Lib
「インクルード」に
C:\Program Files\Microsoft Platform SDK\Include
のパスを追加します。

ビルド

・「ファイル」→「開く」→「プロジェクト/ソリューション」で
C:\pjproject-1.0.3\pjproject-vs8.slnを開きます。
・ソリューションエクスプローラで「pusua」を選択し、「プロジェクト」→「スタートアッププロジェクトに設定」をクリックします。
・「pusua」を右クリックし「ビルド」をクリックします。

ビルド結果

ビルド中にエラーがなければ、
pjsip-apps/binにpjsua_vc8.exeが作成されます。

動作確認

・コマンドプロンプトからpjsua_vc8.exeを実行します。
・SIPサーバにREGISTされることを確認します。

<動作確認環境>

SIPサーバ 3CX PhoneSystem sip:192.168.1.202
IP Soft Phone sip:9001@192.168.1.202
PJSIP sip:6002@192.168.1.166

<起動操作例>

> cd c:\pjproject-1.0.3\pjsip-apps\bin\
> pjsua_vc8d.exe --id=sip:6002@192.168.1.166 --registrar=sip:asrterisk@192.168.1.202 --realm=* --username=6002 --password=6002 --local-port=5061

--id=ローカルのSIP URL
--registrar=SIPサーバのIP URL
--realm=* (不明な場合)
--username=ユーザ名
--password=パスワード

<電話をかける>

・「m」+ Enter キーを押します。
・相手先SIPアドレスを入力してEnterキーを押します。
(例)sip:9001@192.168.1.202+ Enter

<電話を受ける>

・「a」 + Enterキーを押します。
・コードをきかれるので「200 」+ Enterキーを押します。

<通話終了>

・「h」 + Enterキーを押します。

マニュアル

pjsua Manual Page
http://www.pjsip.org/pjsua.htm

--helpコマンド実行例

C:\pjproject-1.0.3\pjsip-apps\bin>pjsua_vc8d.exe --help
 14:20:04.744 os_core_win32.  pjlib 1.0.3 for win32 initialized
 14:20:04.744 sip_endpoint.c  Creating endpoint instance...
 14:20:04.744          pjlib  select() I/O Queue created (003DD068)
 14:20:04.744 sip_endpoint.c  Module "mod-msg-print" registered
 14:20:04.760 sip_transport.  Transport manager 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)
  --color             Use colorful logging (default yes on Win32)
  --no-color          Disable colorful logging
  --light-bg          Use dark colors for light background (default is dark b

SIP Account options:
  --use-ims           Enable 3GPP/IMS related settings on this account
  --use-srtp=N        Use SRTP?  0:disabled, 1:optional, 2:mandatory (def:0)
  --srtp-secure=N     SRTP require secure SIP? 0:no, 1:tls, 1:sips (def:1)
  --registrar=url     Set the URL of registrar server
  --id=url            Set the URL of local ID (used in From header)
  --contact=url       Optionally override the Contact information
  --contact-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 55)
  --realm=string      Set realm
  --username=string   Set authentication username
  --password=string   Set authentication password
  --publish           Send presence PUBLISH for this account
  --use-100rel        Require reliable provisional response (100rel)
  --auto-update-nat=N Where N is 0 or 1 to enable/disable SIP traversal behin
                      symmetric NAT (default 1)
  --next-cred         Add another credentials

SIP Account Control:
  --next-account      Add more account

Transport Options:
  --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)
  --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=name     Set STUN server host or domain

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-srv-name      Specify TLS server name for multi-hosting server (optio
)

Media 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 mod
  --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 it is idle for N seconds.
                      Specify N=-1 (default) 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=


Media Transport Options:
  --use-ice           Enable ICE (default:no)
  --ice-no-host       Disable ICE host candidates (default: no)
  --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:
  --tx-drop-pct=PCT   Drop PCT percent of TX RTP (for pkt lost sim, default:
  --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 transfering 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 (default), 2: ask

When URL is specified, pjsua will immediately initiate call to that URL


C:\pjproject-1.0.3\pjsip-apps\bin>

起動時表示例

C:\pjproject-1.0.3\pjsip-apps\bin>pjsua_vc8d.exe --id=sip:6002@192.168.1.166 --r
egistrar=sip:asrterisk@192.168.1.202 --realm=* --username=6002 --password=6002 -
-local-port=5061
 16:18:26.557 os_core_win32.  pjlib 1.0.3 for win32 initialized
 16:18:26.588 sip_endpoint.c  Creating endpoint instance...
 16:18:26.588          pjlib  select() I/O Queue created (003DD0F8)
 16:18:26.588 sip_endpoint.c  Module "mod-msg-print" registered
 16:18:26.588 sip_transport.  Transport manager created.
 16:18:26.588 sip_endpoint.c  Module "mod-pjsua-log" registered
 16:18:26.588 sip_endpoint.c  Module "mod-tsx-layer" registered
 16:18:26.588 sip_endpoint.c  Module "mod-stateful-util" registered
 16:18:26.588 sip_endpoint.c  Module "mod-ua" registered
 16:18:26.588 sip_endpoint.c  Module "mod-100rel" registered
 16:18:26.588 sip_endpoint.c  Module "mod-pjsua" registered
 16:18:26.604 sip_endpoint.c  Module "mod-invite" registered
 16:18:26.947      pasound.c  PortAudio sound library initialized, status=0
 16:18:26.963      pasound.c  PortAudio host api count=3
 16:18:26.963      pasound.c  Sound device count=8
 16:18:26.963          pjlib  select() I/O Queue created (00D0419C)
 16:18:26.963 sip_endpoint.c  Module "mod-evsub" registered
 16:18:26.979 sip_endpoint.c  Module "mod-presence" registered
 16:18:26.979 sip_endpoint.c  Module "mod-refer" registered
 16:18:26.979 sip_endpoint.c  Module "mod-pjsua-pres" registered
 16:18:26.979 sip_endpoint.c  Module "mod-pjsua-im" registered
 16:18:26.979 sip_endpoint.c  Module "mod-pjsua-options" registered
 16:18:26.979   pjsua_core.c  1 SIP worker threads created
 16:18:26.979   pjsua_core.c  pjsua version 1.0.3 for win32 initialized
 16:18:26.979 sip_endpoint.c  Module "mod-default-handler" registered
 16:18:27.025   pjsua_core.c  SIP UDP socket reachable at 192.168.1.166:5061
 16:18:27.025    udp00D14198  SIP UDP transport started, published address is 19
2.168.1.166:5061
 16:18:27.025    pjsua_acc.c  Account  added with id 0
 16:18:27.041    tcplis:5061  SIP TCP listener ready for incoming connections at
 192.168.1.166:5061
 16:18:27.041    pjsua_acc.c  Account  add
ed with id 1
 16:18:27.041    pjsua_acc.c  Account sip:6002@192.168.1.166 added with id 2
 16:18:27.041   pjsua_core.c  TX 428 bytes Request msg REGISTER/cseq=28070 (tdta
00D16DD8) to UDP 192.168.1.202:5060:
REGISTER sip:asrterisk@192.168.1.202 SIP/2.0
Via: SIP/2.0/UDP 192.168.1.166:5061;rport;branch=z9hG4bKPj0b2ac40e7b6545428ede95
2c801cde22
Max-Forwards: 70
From: ;tag=795fd7eeb0144b0fb8fad785c0192bea
To: 
Call-ID: a2210111bed9479883a4eb5fe4c4a988
CSeq: 28070 REGISTER
User-Agent: PJSUA v1.0.3/win32
Contact: 
Expires: 300
Content-Length:  0


--end msg--
 16:18:27.057    pjsua_acc.c  Registration sent
 16:18:27.072  pjsua_media.c  RTP socket reachable at 192.168.1.166:4000
 16:18:27.072  pjsua_media.c  RTCP socket reachable at 192.168.1.166:4001
 16:18:27.072  pjsua_media.c  RTP socket reachable at 192.168.1.166:4002
 16:18:27.072  pjsua_media.c  RTCP socket reachable at 192.168.1.166:4003
 16:18:27.088  pjsua_media.c  RTP socket reachable at 192.168.1.166:4004
 16:18:27.088  pjsua_media.c  RTCP socket reachable at 192.168.1.166:4005
 16:18:27.104  pjsua_media.c  RTP socket reachable at 192.168.1.166:4006
 16:18:27.104  pjsua_media.c  RTCP socket reachable at 192.168.1.166:4007
>
Account list:
  [ 0] : does not register
       Online status: Online
  [ 1] : does not register
       Online status: Online
 *[ 2] sip:6002@192.168.1.166: 100/In Progress (expires=0)
       Online status: Online
Buddy list:
 -none-

+=============================================================================+
|       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     |  f  Save config   |
+------------------------------+--------------------------+-------------------+
|  q  QUIT       sleep MS     echo [0|1|txt]        n: detect NAT type        |
+=============================================================================+
You have 0 active call
>  16:18:27.166   pjsua_core.c  RX 484 bytes Response msg 407/REGISTER/cseq=28
070 (rdata00D1465C) from UDP 192.168.1.202:5060:
SIP/2.0 407 Proxy Authentication Required
Via: SIP/2.0/UDP 192.168.1.166:5061;rport=5061;branch=z9hG4bKPj0b2ac40e7b6545428
ede952c801cde22
Proxy-Authenticate: Digest nonce="12897040705:3e0c3b0c9afe31ec660e833a23e7040f",
algorithm=MD5,realm="3CXPhoneSystem"
To: ;tag=9061cf04
From: ;tag=795fd7eeb0144b0fb8fad785c0192bea
Call-ID: a2210111bed9479883a4eb5fe4c4a988
CSeq: 28070 REGISTER
User-Agent: 3CXPhoneSystem
Content-Length: 0


--end msg--
 16:18:27.166   pjsua_core.c  TX 646 bytes Request msg REGISTER/cseq=28071 (tdta
00D16DD8) to UDP 192.168.1.202:5060:
REGISTER sip:asrterisk@192.168.1.202 SIP/2.0
Via: SIP/2.0/UDP 192.168.1.166:5061;rport;branch=z9hG4bKPj5f225d3c2a934d53bec117
c7f90278aa
Max-Forwards: 70
From: ;tag=795fd7eeb0144b0fb8fad785c0192bea
To: 
Call-ID: a2210111bed9479883a4eb5fe4c4a988
CSeq: 28071 REGISTER
User-Agent: PJSUA v1.0.3/win32
Contact: 
Expires: 300
Proxy-Authorization: Digest username="6002", realm="3CXPhoneSystem", nonce="1289
7040705:3e0c3b0c9afe31ec660e833a23e7040f", uri="sip:asrterisk@192.168.1.202", re
sponse="8f6a9f10c223fad3c2422a392f9f006b", algorithm=MD5
Content-Length:  0


--end msg--
 16:18:27.275   pjsua_core.c  RX 391 bytes Response msg 200/REGISTER/cseq=28071
(rdata00D1465C) from UDP 192.168.1.202:5060:
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.1.166:5061;rport=5061;branch=z9hG4bKPj5f225d3c2a934d53b
ec117c7f90278aa
Contact: ;expires=300
To: ;tag=4818f02d
From: ;tag=795fd7eeb0144b0fb8fad785c0192bea
Call-ID: a2210111bed9479883a4eb5fe4c4a988
CSeq: 28071 REGISTER
User-Agent: 3CXPhoneSystem
Content-Length: 0


--end msg--
 16:18:27.291    pjsua_acc.c  sip:6002@192.168.1.166: registration success, stat
us=200 (OK), will re-register in 300 seconds
 16:18:27.291    pjsua_acc.c  Keep-alive timer started for acc 2, destination:19
2.168.1.202:5060, interval:15s

2009.09.10