300 likes | 758 Vues
Setup oSIP and example. Speaker: Yi-Ji Jheng Date: 2007.11.07. Outline. Setup oSIP and example Setup eXoSIP and example Program - SIP_Call. Setup oSIP and example. Install libosip2. #tar zxvf libosip2-2.2.1.tar.gz #cd ./libosip2-2.2.1 #./configure #make #make install
E N D
Setup oSIP and example Speaker: Yi-Ji Jheng Date: 2007.11.07
Outline • Setup oSIP and example • Setup eXoSIP and example • Program - SIP_Call
Install libosip2 • #tar zxvf libosip2-2.2.1.tar.gz • #cd ./libosip2-2.2.1 • #./configure • #make • #make install • Library default install in /usr/local/lib • libosip2 • osipparser2
Make oSIP of example – via parser (1/3) • #cd ./src/test • #gcc tvia.c -o tvia * • #gcc tvia.c -o tvia -I../../include * • #gcc tvia.c -o tvia \ -I../../include \ -losipparser2 \ -L/usr/local/lib
Make oSIP of example – via parser (2/3) • #./tvia * • #./tvia * • #./tvia ./res/vias.txt • Can see via of parser • To do another program if success
Make oSIP of example – via parser (3/3) • Tips • Can make all oSIP of examples when install • #./configure --enable-test • #make • All include *.txt for program are in ./src/test/res
Install libexosip (1/2) • #tar zxvf libeXosip-0.9.0.tar.gz • #cd ./libeXosip-0.9.0 • #./configure --disable-phapi --disable-miniua --disable-josua --disable-glib --disable-ms --disable-ortp --disable-gsm --disable-ilbc *
Install libexosip (2/2) • #make • #make install • Library default install in /usr/local/lib • libeXosip
Make eXoSIP of example - Register (1/3) • #cd ./tools • #gcc sip_reg.c -o sip_reg -leXosip -L/usr/local/lib * • #./sip_reg *
Make eXoSIP of example - Register (2/3) • #./sip_reg \ --proxy sip:<server ip> \ --from sip:<username>@<server ip> \ --contact sip:<username>@<ip> \ --port <port>\ --username <username> \ --password <password>
Make eXoSIP of example - Register (3/3) • Tips • Program would run background • Use #serctl ul show to see success or not with SIP server • Can make this program when install • #./configure --enable-test • #make
Make program of sip_call • #g++ test.cpp -o sip_call * • #g++ test.cpp -o sip_call * • #g++ test.cpp -o sip_call -leXosip -losip2 • /tmp/ccCRNT0p.o(.text+0x14): In function `__exit(int)': • : the `gets' function is dangerous and should not be used.
Modify program of sip_call • #vi test.cpp • Debug mode • //FILE* logfile = fopen( "logfile.txt", "w"); • //osip_trace_initialize( (_trace_level)8, logfile ); • osip_trace_initialize( (_trace_level)8, stdout ); • For us • i = eXosip_build_initial_invite(&invite, "sip:<ip>:[port]", //to "sip:<ip>:[port]", //from NULL, "hello");
Key options of sip_call • a - answering call • h – hangup call • r - ringing • c - call • q - quit
Homework • Modify sip_call bug • If Sip_call is caller, it cannot hangup call • Sip_call cannot dial two times more • Marge sip_call and sip_reg to be a easy softphone
Gcc example directly • error : tvia.c:28:28: osip2/internal.h: No such file or directory • #find / -name internal.h • /usr/src/osip/libosip2-2.2.1/include/osip2/internal.h
No library support (1/2) • error : /tmp/cc1oGZ3o.o(.text+0x5b): In function `main': : undefined reference to `osip_malloc_func' . . . /tmp/cc1oGZ3o.o(.text+0x201): In function `main': : undefined reference to `osip_free_func' collect2: ld returned 1 exit status
No library support (2/2) • Linker error • #gcc tvia.c -c -o tvia.o -I../../include • #ld tvia.o -o tvia –lc * • #ls -al /usr/local/lib • Which one to use (osip2 or osipparser2) • Look at program parser via • #vi tvia.c
Shared libraries • error : ./tvia: error while loading shared libraries: libosipparser2.so.3: cannot open shared object file: No such file or directory • #vi /etc/ld.so.conf • add : /usr/local/lib • #ldconfig
Failed to open • error : Failed to open (null) file. Usage: tvia vias.txt • #find / -name vias.txt • /usr/src/osip/libosip2-2.2.1/src/test/res/vias.txt
Other options • miniua : example • josua : example • phapi : softphone of button • glib : graphlib • ortp : rtp • ms : media streaming • ilbc : codec • gsm : codec
Update lib of path • #ldconfig • #ldconfig -v • To see lib of path
sip_reg of options • Complain no options • --proxy sip:proxyhost[:port] • --port • --from sip:proxyhost[:port] • --contact sip:proxyhost[:port] • --username • --password • --expiry
VC vs. GCC (1/2) • test.cpp:23:20: stdafx.h: No such file or directory • test.cpp:29:19: conio.h: No such file or directory • test.cpp: In function `void __exit(int)': • test.cpp:103: `exit' undeclared (first use this function) • test.cpp:103: (Each undeclared identifier is reported only once for each function it appears in.) • test.cpp: In function `int main(int, char**)': • test.cpp:520: `_kbhit' undeclared (first use this function) • test.cpp:522: `_getch' undeclared (first use this function)
VC vs. GCC (2/2) • #vi test.cpp • Comment stdafx.h and conio.h • Modify _getch() to getchar() • Delete if(_kbhit()){} • Include some header for osip • #include <stdio.h> • #include <stdlib.h> • #include <unistd.h> • #include <netdb.h> • #include <syslog.h> • #include <pthread.h>
Linker error • /tmp/ccMdnyE9.o(.text+0x14): In function `__exit(int)': • : the `gets' function is dangerous and should not be used. • /tmp/ccMdnyE9.o(.text+0x56): In function `josua_event_get()': • : undefined reference to `eXosip_event_wait‘ • /tmp/ccMdnyE9.o(.gnu.linkonce.t._ZN5jcall5buildEP12eXosip_event+0xef): In function `jcall::build(eXosip_event*)': • : undefined reference to `osip_strncpy' • /tmp/ccMdnyE9.o(.gnu.linkonce.t._ZN5jcall5buildEP12eXosip_event+0x11a): more undefined references to `osip_strncpy' follow • collect2: ld returned 1 exit status