SIP UserAgent Application(B2BUA client) —— libosip2+libeXosip2+jrtplib

1. libosip2 libeXosip2

http://www.antisip.com/download/exosip2/

Features:
--------
eXosip2 has support for:
 * registrations. (REGISTER)
 * call initiation and modification. (INVITE, re-INVITE)
 * other methods within calls (INFO, OPTIONS, UPDATE)
 * call transfer. (REFER)
 * reliability for provisionnal response. (PRACK)
 * sip event package. (SUBSCRIBE/NOTIFY)
 * event state publication. (PUBLISH)
 * instant messaging. (MESSAGE)
 * ...

eXosip2 does not contain:
 * RTP.
 * audio interface
 * sdp negotiation.
 * ...

 

2. Build libexosip2-5.1.0.tar.gz + libosip2-5.1.0.tar.gz

ln -s /usr/lib/x86_64-linux-gnu/libssl.so.1.0.0 /usr/lib/libssl.so
ln -s /usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0 /usr/lib/libcrypto.so

_install.sh

#compiler setup
if [[ $1 = 'arm' ]]; then
compiler=`CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++`
host=arm-linux-gnueabihf
elif [[ $1 = 'himix100' ]]; then
compiler=`CC=arm-himix100-linux-gcc CXX=arm-himix100-linux-g++`
host=arm-himix100-linux
elif [[ $1 = 'himix200' ]]; then
compiler=`CC=arm-himix200-linux-gcc CXX=arm-himix200-linux-g++`
host=arm-himix200-linux
else
:
fi

#Preinstalled directory
install=${HOME}/_install

#library path
pkg_config=${install}/lib/pkgconfig
lib_config=`CPPFLAGS=-I${install}/include CFLAGS=-I${install}/include LDFLAGS=-L${install}/lib`
#http://www.mirrorservice.org/pub/gnu/osip/
tar xvf libosip2-*
cd libosip2-*
./configure --prefix=${install} ${compiler} PKG_CONFIG_PATH=${pkg_config} ${lib_config} --host=${host} --enable-static --enable-shared --disable-openssl CFLAGS=-fPIC
make && make install
cd ..

#http://mirror.ossplanet.net/nongnu/exosip/
tar xvf libexosip2-*
cd libexosip2-*
./configure --prefix=${install} ${compiler} PKG_CONFIG_PATH=${pkg_config} ${lib_config} --host=${host} --enable-static --enable-shared --disable-openssl CFLAGS=-fPIC
make && make install
cd ..

媒体库

#JRTPLIB-3.11.1.tar.gz
cmake -DCMAKE_INSTALL_PREFIX=./_install -DCMAKE_C_COMPILER=/usr/local/gcc-linaro-arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc -DCMAKE_CXX_COMPILER=/usr/local/gcc-linaro-arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++
make
make install

#faac-1.29.9.2.tar.gz
./configure CXX=arm-linux-gnueabihf-g++ CC=arm-linux-gnueabihf-gcc --prefix=${PWD}/_install --host=arm-linux-gnueabihf --with-mp4v2=no --enable-shared --enable-static
make
make install

#h264bitstream-0.2.0.tar.gz
sudo apt-get install build-essential libtool
autoreconf -i
./configure CXX=arm-linux-gnueabihf-g++ CC=arm-linux-gnueabihf-gcc --prefix=${PWD}/_install --host=arm-linux-gnueabihf --enable-shared --enable-static
make
make install

 

 

dong@ubuntu:~/libexosip2-5.1.0$ su
Password:
root@ubuntu:/home/dong/libexosip2-5.1.0# ./_install.sh
root@ubuntu:~# tar cvf _install.tar.gz _install/
root@ubuntu:~# mv _install.tar.gz /home/dong/
dong@ubuntu:~$ sudo chmod 777 _install.tar.gz

 

3. example

Freepbx or freeswitch can be used as SIP server

libexosip2-5.1.0/tools/sip_reg.c

add eXosip event 

    /*zhoudd add*/         
    case EXOSIP_CALL_CANCELLED:
        syslog_wrapper (LOG_INFO, "call cancelled");
        break;
    case EXOSIP_CALL_ACK:         
        syslog_wrapper (LOG_INFO, "call ack");                  
        break;
    case EXOSIP_CALL_CLOSED:
        syslog_wrapper (LOG_INFO, "call closed");        
        break;
    case EXOSIP_CALL_PROCEEDING:
        syslog_wrapper (LOG_INFO, "call proceeding");
        break;
    case EXOSIP_CALL_RINGING:
        syslog_wrapper (LOG_INFO, "call ringing");
        break;
    case EXOSIP_CALL_ANSWERED:                   
        syslog_wrapper (LOG_INFO, "call answered");                                               
        break;
    case EXOSIP_CALL_SERVERFAILURE:    
    case EXOSIP_CALL_RELEASED:                     
        syslog_wrapper (LOG_INFO, "call release");    
        break;

compile example

export LD_LIBRARY_PATH=$(pwd)/_install/lib:$LD_LIBRARY_PATH
gcc -O2 -I./_install/include -L./_install/lib sip_reg.c \
-o sip_reg \
-leXosip2 -losip2 -losipparser2 -lpthread

 

or static lib

INCLUDE = \
-I ${lib}/exosip2/include \
-I ${lib}/exosip2/include/eXosip2 \
-I ${lib}/exosip2/include/osip2 \
-I ${lib}/exosip2/include/osipparser2 \
-I ${lib}/exosip2/include/osipparser2/headers \

LIB = \
${lib}/exosip2/lib/libeXosip2.a \
${lib}/exosip2/lib/libosip2.a \
${lib}/exosip2/lib/libosipparser2.a 

 

test.sh

./sip_reg \
-r sip:182.61.147.213:5060 \
-u sip:1002@182.61.147.213 \
-c sip:1002@182.61.147.213:5060 \
-U 1002 \
-P 1234  \
-p 5060 \
-e 1800 \
-d

caller mode

dong@ubuntu:~/doing/demo$ ./test.sh 
SipReg v1.0 up and running
proxy: sip:182.61.147.213:5060
fromuser: sip:1002@182.61.147.213
contact: sip:1002@182.61.147.213:5060
expiry: 3600
local port: 5060
transport: UDP
username: 1002
password: [removed]
r   register
u   unregister
i   call
h   hangup
a   answer
q   quit
f   info
m   message
Please input the command:

registrered failure
registrered successfully
registrered successfully
registrered successfully
i
Please input the command:

call proceeding
call requestfailure
call proceeding
call ringing
call answered
call message new
BYE
recieved message eXosip event (type, did, cid) = (14, 2, 1)
call closed
call release


Please input the command:

q
dong@ubuntu:~/doing/demo$

 callee mode

dong@ubuntu:~/doing/demo$ ./test.sh 
SipReg v1.0 up and running
proxy: sip:182.61.147.213:5060
fromuser: sip:1002@182.61.147.213
contact: sip:1002@182.61.147.213:5060
expiry: 3600
local port: 5060
transport: UDP
username: 1002
password: [removed]
r   register
u   unregister
i   call
h   hangup
a   answer
q   quit
f   info
m   message
Please input the command:

registrered failure
registrered successfully
registrered successfully
registrered successfully
call invite
call cancelled
call closed


Please input the command:

call release
q
dong@ubuntu:~/doing/demo$

 

4. rport && contact

    case EXOSIP_CALL_INVITE:
      {       
        eXosip_masquerade_contact (context_eXosip, event->request->req_uri->host, atoi(event->request->req_uri->port));
                     
        osip_message_t *answer = NULL;
        int i;
        /*180 ring*/  
        ...

        /*200 ok*/      
        ...
       
        break;
      }

    case EXOSIP_CALL_ACK:
      {  
        /*ack*/
        ...

        conference_bridge_creat_run(remote_audio_ip, atoi(remote_audio_port), local_audio_ip, atoi(local_audio_port));
        break;
      }

    case EXOSIP_CALL_ANSWERED:
      {                   
        /*ack*/
        ...

        /*200 ok*/
        ...      
    
        conference_bridge_creat_run(remote_audio_ip, atoi(remote_audio_port), local_audio_ip, atoi(local_audio_port));
        break;
      }

 

#register into gb28181 server

34020000001320000001.sh

./sip_reg  \
-r sip:182.61.45.xxx:5060 \
-u sip:34020000001320000001@192.168.127.128 \
-c sip:34020000002000000001@192.168.127.128:5060 \
-U 34020000001320000001 \
-P 12345678  \
-p 5060 \
-e 1800 \
-d

 

5. User Agent Application
1) register
libexosip2-5.1.0/tools/sip_reg.c

2) invite
libexosip2-5.1.0/help/doxygen/ht0-initialize.dox
libexosip2-5.1.0/help/doxygen/ht1-callcontrol.dox
libexosip2-5.1.0/help/doxygen/ht2-registration.dox

3) rtp mediastream
rtp_over_udp: jrtplib-3.11.1/examples/example1.cpp
rtp_over_tcp:  jrtplib-3.11.1/tests/tcptest.cpp


4) audio encode/decode && conference bridge
https://trac.pjsip.org/repos/wiki/media-flow?from=groupmessage

posted @ 2019-01-12 00:41  dong1  阅读(1210)  评论(0编辑  收藏  举报