PJSUA2 linux分段故障



我使用PJSUA2制作了一个用于调用的python3脚本,我的脚本正在进行注册和调用,但我得到了"zsh:分段故障";我想知道是否有人能帮我,这是我的代码

python
import time
import pjsua2 as pj
distAddrs = "192.168.1.202"
port = 5060
ext = "101"
passwd = "123456"
# Create my endpoint
endPoint = pj.Endpoint()
endPointConfig = pj.EpConfig()
endPoint.libCreate()
endPoint.libInit(endPointConfig)
# Create SIP transport
sipTransportConfig = pj.TransportConfig()
sipTransportConfig.port = port
endPoint.transportCreate(pj.PJSIP_TRANSPORT_UDP, sipTransportConfig)
# Setting my audio device
endPoint.audDevManager().setNullDev()
for codec in endPoint.codecEnum2():
priority = 0
if "PCMA/8000" in codec.codecId:
priority = 255
endPoint.codecSetPriority(codec.codecId, priority)

# Start the library
endPoint.libStart()

#扩展呼叫和获取通知等的子类

class Call(pj.Call):
def onRegState(self, prm):
print("***onRegState == " + prm.reason)
# pjsua2 registration and calling function
def pbxReg(distAddrs, ext, passwd):
accountConfig = pj.AccountConfig()
accountConfig.idUri = "sip:%s@%s" % (ext,distAddrs,)
accountConfig.regConfig.registrarUri = "sip:%s" % (distAddrs,)
credentials = pj.AuthCredInfo("digest","*",ext,0,passwd,)
accountConfig.sipConfig.authCreds.append(credentials)

#创建账户

account = pj.Account()
account.create(accountConfig)
time.sleep(1)
if account.getInfo().regIsActive == True:
call = Call(account)
prm = pj.CallOpParam(True)
prm.opt.audioCount = 1
prm.opt.videoCount = 0
call.makeCall("sip:103@192.168.1.202", prm)
time.sleep(1)
prm = pj.CallOpParam()
call.hangup(prm)
endPoint.hangupAllCalls()

# Destroy the library
def libDestroy():
endPoint.libDestroy()   
def main():
pbxReg(distAddrs, ext, passwd)
libDestroy()
main()

我能看到的第一件明显的事情是,您使用的是time.sleep(1(而不是endPoint.libHandleEvents(1000(,这对我来说是个问题。

# your code
time.sleep(1)
# possible fix
endPoint.libHandleEvents(1000)

相关内容

  • 没有找到相关文章

最新更新