1. sip stacks

pjsip/bell-sip/sofia-sip/libeXosip/libre

https://github.com/staskobzar/sip_stacks_examples

2. sip user agent and server network architecture

3. Installing pjsip on Ubuntu

https://www.pjsip.org

sudo apt-get install libasound2-dev

Linux system has two audio drivers: alsa and oss,oss is old,pjsip supports both,deflaut is oss.

如果目标系统内核使用的是alsa驱动,运行例子程序的时候会出现以下问题。

alsa_dev.c ! ca_thread_func: error reading data!   解决方法 修改config_site.h文件 在pjproject\pjlib\include\pj目录下

add #define PJMEDIA_AUDIO_DEV_HAS_ALSA 1

4. cross-compile 

_install.sh

#compiler setup
if [[ $ = 'arm' ]]; then
compiler=`CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++`
host=arm-linux-gnueabihf
elif [[ $ = 'himix100' ]]; then
compiler=`CC=arm-himix100-linux-gcc CXX=arm-himix100-linux-g++`
host=arm-himix100-linux
elif [[ $ = 'himix200' ]]; then
compiler=`CC=arm-himix200-linux-gcc CXX=arm-himix200-linux-g++`
host=arm-himix200-linux
else
:
fi #Preinstalled directory
install=${HOME}/_install #Delete installed directory
rm -rf ${install} #library path
pkg_config=${install}/lib/pkgconfig
lib_config=`CPPFLAGS=-I${install}/include CFLAGS=-I${install}/include LDFLAGS=-L${install}/lib` #Delete compiled directory
for i in `ls .`
do
if [ -d $i ];then
rm -rf $i
fi
done tar xvf alsa-lib-*
cd alsa-lib-*
./configure ${compiler} --prefix=${install} --host=${host}
make && make install
cd .. tar xvf alsa-utils-*
cd alsa-utils-*
./configure ${compiler} --prefix=${install} --host=${host} PKG_CONFIG_PATH=${pkg_config} ${lib_config} --enable-static --enable-shared --disable-alsamixer --disable-xmlto
touch ./alsaconf/po/t-ja.gmo
touch ./alsaconf/po/t-ru.gmo
make && make install
cd .. tar xvf pjproject-*
cd pjproject-*
./configure ${compiler} --prefix=${install} --host=${host} PKG_CONFIG_PATH=${pkg_config} ${lib_config} --enable-static --enable-shared --disable-libwebrtc
make dep
make && make install
cd .. export PATH=$PATH:${install}/bin
export LD_LIBRARY_PATH=${install}/lib:$LD_LIBRARY_PATH
export ALSA_CONFIG_PATH=${install}/share/alsa/alsa.conf

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

4)如果用的海思arm-himix200-linux-gcc编译器,如果报错的话,可能需要将

alsa-utils-1.1.9/alsamixer/alsa-utils-1.1.9/alsamixer/volume_mapping.c里的三行exp10改成exp

5)声卡设备验证

#查看音频设备

dong@dong-ubuntu:~$ arecord -l
**** CAPTURE 硬體裝置清單 ****
card 0: PCH [HDA Intel PCH], device 0: ALC255 Analog [ALC255 Analog]
  子设备: 1/1
  子设备 #0: subdevice #0

#列举出机器所有的声卡
dong@dong-ubuntu:~$ cat /proc/asound/cards
 0 [PCH            ]: HDA-Intel - HDA Intel PCH
                      HDA Intel PCH at 0xa4220000 irq 132

#列举每个声卡的card number和device number
dong@dong-ubuntu:~$ aplay -l
**** PLAYBACK 硬體裝置清單 ****
card 0: PCH [HDA Intel PCH], device 0: ALC255 Analog [ALC255 Analog]
  子设备: 1/1
  子设备 #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 3: HDMI 0 [HDMI 0]
  子设备: 1/1
  子设备 #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 7: HDMI 1 [HDMI 1]
  子设备: 1/1
  子设备 #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 8: HDMI 2 [HDMI 2]
  子设备: 1/1
  子设备 #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 9: HDMI 3 [HDMI 3]
  子设备: 1/1
  子设备 #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 10: HDMI 4 [HDMI 4]
  子设备: 1/1
  子设备 #0: subdevice #0

#录音
dong@dong-ubuntu:~$ arecord -D "plughw:0,0" -f S16_LE -r 16000 -d 5 -t wav file.wav
正在录音 WAVE 'file.wav' : Signed 16 bit Little Endian, 频率16000Hz, Mono

#播放录音文件
dong@dong-ubuntu:~$ aplay file.wav
正在播放 WAVE 'file.wav' : Signed 16 bit Little Endian, 频率16000Hz, Mono

一般alsa设置了一个defaults设备,音频播放软件默认使用defaults设备输出声音。defaults设备定义在alsa.conf中,内容如下:

[plain]
#
# defaults
# # show all name hints also for definitions without hint {} section
defaults.namehint.showall off
# show just basic name hints
defaults.namehint.basic on
# show extended name hints
defaults.namehint.extended off
#
defaults.ctl.card 0
defaults.pcm.card 0
defaults.pcm.device 0
defaults.pcm.subdevice -1
……

defaults会默认匹配card number和device number比较小的声卡。
如果要修改,则修改/etc/asound.conf或~/.asoundrc。比如我要把defaults匹配到card 1,device 3上,则添加一下几行:

[plain]
$ sudo vim /etc/asound.conf
defaults.pcm.card 1
defaults.pcm.device 3
defaults.ctl.card 1

5) 添加声卡节点

if [ ! -d /dev/snd/ ]; then
    echo "make snd node."
    mkdir /dev/snd
    ln -s /dev/pcmC0D0c  /dev/snd/pcmC0D0c
    ln -s /dev/pcmC0D0p /dev/snd/pcmC0D0p
    ln -s /dev/timer /dev/snd/timer
    ln -s /dev/controlC0 /dev/snd/controlC0
    ln -s /dev/mixer /dev/snd/mixer
fi

5) 录音播音测试
arecord -D "plughw:0,0" -f S16_LE -r 16000 -d 5 -t wav file.wav
aplay file.wav

arecord -d 10 -f cd -r 8000 -c 2 -t wav test.wav
arecord -D "plughw:0,0" -f U16_LE -r 16000 -d 5 -t wav file.wav
arecord -d 10 -t raw -f S16_LE test.pcm
aplay -t raw -c 1 -f S16_LE -r 8000 test.pcm
arecord -d 10 -t raw -f U16_LE test.pcm
aplay -t raw -c 1 -f U16_LE -r 8000 test.pcm
arecord -d 10 -t raw -f U8 test.pcm
aplay -t raw -c 1 -f U8 -r 8000 test.pcm
aplay -t raw -r 8000 test.g711
arecord -D "plughw:0,0" -f U16_LE -r 16000 -d 5 -t wav file.wav
arecord -f S16_LE | aplay -f S16_LE

3、pjsua应用实例

pjsua Manual Page

https://www.pjsip.org/pjsua.htm

1) register --- make call
./pjsua-x86_64-unknown-linux-gnu --config-file paul.cfg
m
sip:alice@120.78.180.208:5060

2) peer to peer
./pjsua-x86_64-unknown-linux-gnu --null-audio
./pjsua-x86_64-unknown-linux-gnu sip:120.78.180.208 --null-audio

3) register cli
>>> +a
Your SIP URL: (empty to cancel):sip:100@120.78.180.208:5060
URL of the registrar: (empty to cancel):sip:120.78.180.208:5060
Auth Realm: (empty to cancel): *
Auth Username: (empty to cancel): 100
Auth Password: (empty to cancel): 100

sip:104@120.78.180.208

4) alice.cfg

# This is a comment in the config file.
--id sip:alice@xx.xxx.xx.236:5060
--registrar sip:xx.xxx.xx.236:5060
--realm *
--username alice
--password secret

启动程序,自动应答

./pjsua-arm-unknown-linux-gnueabihf --config-file alice.cfg --auto-answer 200

指定“紧凑模式”(去掉SIP协议的一些非必须的字段),采样率和编码优先级,我在cortex-a5上以默认参数启动,会出现pb和ca线程不同步underrun!

./pjsua-arm-unknown-linux-gnueabihf --config-file alice.cfg
--use-compact-form --clock-rate=8000 --add-codec=pcmu --auto-answer 200

其他配置参考官网应用手册https://www.pjsip.org/pjsua.htm

5) 临时建群,多方通话

查看pjsua应用手册https://www.pjsip.org/pjsua.htm

的Call Commands和Conference Commands

M

Make multiple calls Make multiple calls to the same destination.

cl

Conference List List all the ports registered to the conference bridge, and show the interconnection among these ports.

cc

Conference Connect Create a unidirectional connection between two ports.
For example, if you have a WAV player connected at slot #1 and a call
connected at slot #2, you can stream WAV file to the call by specifying
this command: cc 1 2.

cl查看已拨号的通道, 0是拨号的主叫号码本身,1和2分别是ringback和ring,3和4是被叫号码

M

2

sip:101@xx.xxx.xx.236:5060

sip:101@xx.xxx.xx.236:5060

cc 3 4

cc 4 3

6) freepbx语音会议

配置好freepbx语音会议后,直接拨号会议号,然后输入密码进入会议室

./pjsua-x86_64-unknown-linux-gnu --config-file 106.cfg --use-compact-form --clock-rate=8000 --add-codec=pcmu --auto-answer 200

也可以自动登陆会议室,auto-conf是自动登陆会议室

./pjsua-x86_64-unknown-linux-gnu --config-file 106.cfg
--use-compact-form --clock-rate=8000 --add-codec=pcmu --auto-answer 200
--auto-conf sip:2018@xx.xxx.xx.236:5060

PC/android/ios也是一样的操作

4、 py_pjsua应用实例

https://trac.pjsip.org/repos/wiki/Py_PJSUA

python实例在pjsip-apps/src/python/samples/

5、Python_SIP编译安装
1) ./configure CFLAGS='-O2 -fPIC' --enable-shared
https://trac.pjsip.org/repos/wiki/Python_SIP/Build_Install

2) pjsua2安装

sudo apt-get install -y software-properties-common # To make add-apt-repository work
sudo add-apt-repository ppa:dennis.guse/sip-tools
sudo apt-get update
sudo apt-get install python-pjsua
sudo apt-get install python-pjsua2

To check if everything went well:

python
import pjsua
https://stackoverflow.com/questions/20195542/python-how-to-get-the-import-pjsua-giving-no-module-named-pjsua

3)Building PJSUA2 and SWIG

The PJSUA2 C++ library will be built by default by PJSIP build system. Standard C++ library is required. If you intend to use Python SWIG module (see below), you need to configure PJSIP with --enable-shared option, i.e.:

./configure --enable-shared
make dep & make
sudo make install
https://www.pjsip.org/docs/book-latest/html/intro_pjsua2.html#building-python-and-java-swig-modules装好pjsua2就可以启动pygui测试了拨号了,这个例子带图形界面,ui用的Tkinter,另外一个带gui的例子是vidgui,ui用的qt

6、Using OpenCORE AMR NB and WB Codecs

https://trac.pjsip.org/repos/wiki/Using-OpenCORE-AMR-NB-WB-Codec

#opencore-amr 和 vo-amrwbenc
./configure --prefix=$(pwd)/_install --host=arm-linux-gnueabihf CC=/usr/local/arm/gcc-4.9.4-arm-buildroot-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc
make
make install

装好之后将两个库的_install目录合并,合并到opencore-amr-0.1.3/_install

#pjproject
./configure --prefix=/home/dong/pjproject-2.8/_install --host=arm-linux-gnueabihf CC=/usr/local/arm/gcc-4.9.4-arm-buildroot-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc --disable-libwebrtc CFLAGS=-I/home/dong/alsa/include LDFLAGS=-L/home/dong/alsa/lib --with-opencore-amr=$(pwd)/third_party/opencore-amr-0.1.3/_install

make dep
make
make install

ln -s libopencore-amrnb.so.0.0.3 libopencore-amrnb.so.0
 ln -s libopencore-amrwb.so.0.0.3 libopencore-amrwb.so.0
 ln -s libvo-amrwbenc.so.0.0.4 libvo-amrwbenc.so.0

7、Ubuntu 16.04 下编译pjsip,支持视频通话

https://blog.csdn.net/wywf4/article/details/82260582

https://blog.csdn.net/SUKHOI27SMK/article/details/18667465

https://github.com/sxcong/pjsipvideo_demo

2. js sip user agent

http://www.jssip.net/

https://sipjs.com/

基于pjsip实现p2p语音对讲

https://blog.csdn.net/voidreturn/article/details/65634390

Pjsip中一些有用的基本函数实现

https://blog.csdn.net/croop520/article/details/84634160

pjsua播放rtp音频包问题

https://blog.csdn.net/rankun1/article/details/52034323

可以推荐一些基于Sip协议的开源IP电话客户端吗?

https://www.zhihu.com/question/20093472?sort=created

freepbx对接gms网关

https://blog.csdn.net/weixin_30656145/article/details/97707013

freeswitch对接asterisk案例

https://blog.csdn.net/educast/article/details/25310819

end

SIP UserAgent (B2BUA client)——pjsip的更多相关文章

  1. SIP UserAgent (B2BUA client)——linphonec

    1.linphone编译 linphone一般用在android/ios/windows/mobile上,但是没有图形界面的linphonec命令行程序用在资源紧张的硬件平台上也跟pjsip命令行一样 ...

  2. SIP UserAgent (B2BUA client)——libosip2 libeXosip2

    1. libosip2 libeXosip2 http://www.antisip.com/download/exosip2/ Features:--------eXosip2 has support ...

  3. 介绍一个开源的SIP(VOIP)协议库PJSIP

    本文系转载,出处不可考. 假设你对SIP/VoIP技术感兴趣,哪希望你不要错过:),假设你对写出堪称优美的Code感兴趣 ,那么你也不可错过:) 这期间我想分析一下一个实际的协议栈的设计到实现的相关技 ...

  4. Simple GB28181 System

    I. Deployment  / Architecture Block Diagram II. Resources Used 1. freeswitch —— sip server and media ...

  5. Open Source VOIP applications, both clients and servers (开源sip server & sip client 和开发库)

    SIP Proxies SBO SIP Proxy Bypass All types of Internet Firewall JAIN-SIP Proxy Mini-SIP-Proxy A very ...

  6. 《FreeSWITCH: VoIP实战》:SIP 模块 - mod_sofia

    SIP 模块是 FreeSWITCH 的主要模块,所以,值得拿出专门一章来讲解. 在前几章时里,你肯定见过几次 sofia 这个词,只是或许还不知道是什么意思.是这样的,Sofia-SIP 是由诺基亚 ...

  7. sipp模拟电信运营商VoIP终端测试(SIP协议调试)

    三大运营商都有SIP服务器,用来支持语音对讲,多媒体调度等功能,他们的平台可能不是标准的SIP协议会话. 为了应对没完没了的对接各个厂商的平台,这里再整理了一套协议脚本,毕竟全都是没有意义的无用功,标 ...

  8. sipp模拟freepbx分机测试(SIP协议调试)

    1.sipp的安装 1) 在centos 7.2下安装 yum install make gcc gcc-c++ ncurses ncurses.x86_64 ncurses-devel ncurse ...

  9. UAC(User Agent Client) 和 UAS(User Agent Server)

    SIP协议采用Client/Server模型.每一个请求(Request)触发服务器的一个操作:每个操作被称为方法(Method):每个请求除了指明具体方法外,还携带了一系列的头域(Header fi ...

随机推荐

  1. 微信JS-SDK文档

    微信JS SDK 调用详解   微信JS SDK 调用详解... 1 概述... 2 使用说明... 2 接口调用说明... 4 基础接口... 4 判断当前客户端版本是否支持指定JS接口... 5 ...

  2. cssText方式写入css

    <div class="a" id="a">hello world</div> <script> //通过JS来覆写对象的样 ...

  3. PHPMailer发送邮箱

    1.可以参考的链接.http://www.helloweba.com/view-blog-205.html 2.下载最新的PHPMailer文件库 3.主要代码 class.phpmailer.php ...

  4. ThinkPHP项目笔记之控制器常用语法

    如,有数据表:tmp,以下以此为例. $a = M('Tmp'); $a -> select(); $a -> where(condition)->select(); $a -> ...

  5. 利用新浪云平台(SAE) 搭建 HUSTOJ 简易教程

    前言: OnlineJudge(OJ)是一种代码在线判定平台,这里有许多的编程题目供你选择,你可以选择题目提交代码,OJ会自动返回你的代码的判定结果.是一种很方便的编程.算法练习平台.详情可见:百度百 ...

  6. 怎么用ChemDraw连接两个结构片段

    作为最新版的ChemOffice 15.1的核心组件,ChemDraw几乎能解决所有平面化学结构中的绘制问题.如果用户想连接两个分开的结构片段,ChemDraw提供两种连接两个化学结构片段的方法,分别 ...

  7. 【代码备份】pocs.m

    超分辨率算法代码 POCS算法,凸集投影法. pocs.m,没有调用的代码,没看懂..只有这个函数..抱歉. function y = pocs(s,delta_est,factor) % POCS ...

  8. JavaScript的parseint()函数

    定义和用法 parseInt() 函数可解析一个字符串,并返回一个整数. 语法 parseInt(string, radix) 参数 描述 string 必选项.要转换为数字的字符串. radix 可 ...

  9. Hibernate_day02--课程安排_主键生成策略_对实体类crud操作_实体类对象状态

    Hibernate_day02 上节内容 今天内容 实体类编写规则 Hibernate主键生成策略 实体类操作 对实体类crud操作 添加操作 根据id查询 修改操作 删除操作 实体类对象状态(概念) ...

  10. 如何优化JAVA代码及提高执行效率

    可供程序利用的资源(内存.CPU时间.网络带宽等)是有限的,优化的目的就是让程序用尽可能少的资源完成预定的任务.优化通常包含两方面的内容:减小代码的体积,提高代码的运行效率.本文讨论的主要是如何提高代 ...