mac安装pjsua2,进行sip注册

1.首先下载swig:https://www.swig.org/
进入你下载的swig文件
在根目录执行 configure
make
make install
能查出来版本说明安装好了 Swig -version

2.安装好后,创建一个目录 /PJSUA2/pjproject/src
在src目录下执行 wget http://svn.pjsip.org/repos/pjproject/trunk pjproject
也可以去官网下载下载下来如下:在这里插入图片描述
下载好后进入这个project
cd pjproject
./configure --enable-shared CFLAGS=“-fPIC”
在pjproject执行
make dep
make
make install
最好前面加sudo
再进入python目录 cd pjsip-apps/src/swig/python
make dep
make
make install


mkdir /PJSUA2/pjproject/src
wget http://svn.pjsip.org/repos/pjproject/trunk pjproject
cd pjproject
./configure --enable-shared CFLAGS=“-fPIC”
make dep
make
make install


官网的代码:

import pjsua2 as pj

# Subclass to extend the Account and get notifications etc.
class Account(pj.Account):
  def onRegState(self, prm):
      print("***OnRegState: " + prm.reason)

# pjsua2 test function
def pjsua2_test():
  # Create and initialize the library
  ep_cfg = pj.EpConfig()
  ep = pj.Endpoint()
  ep.libCreate()
  ep.libInit(ep_cfg)

  # Create SIP transport. Error handling sample is shown
  sipTpConfig = pj.TransportConfig();
  sipTpConfig.port = 5060;
  ep.transportCreate(pj.PJSIP_TRANSPORT_UDP, sipTpConfig);
  # Start the library
  ep.libStart();

  acfg = pj.AccountConfig();
  acfg.idUri = "sip:test@sip.pjsip.org";
  acfg.regConfig.registrarUri = "sip:sip.pjsip.org";
  cred = pj.AuthCredInfo("digest", "*", "test", 0, "pwtest");
  acfg.sipConfig.authCreds.append( cred );
  # Create the account
  acc = Account();
  acc.create(acfg);
  # Here we don't have anything else to do..
  time.sleep(10);

  # Destroy the library
  ep.libDestroy()

#
# main()
#
if __name__ == "__main__":
  pjsua2_test()

参考:
https://www.cnblogs.com/lianghe01/p/7577182.html

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值