import pjsua2 as pj
import time
class Account(pj.Account):
def onRegState(self, prm):
print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~***OnRegState: " + prm.reason
ep = pj.Endpoint()
ep.libCreate()
ep_cfg = pj.EpConfig()
ep_cfg.uaConfig.threadCnt = 0#erroe
ep_cfg.uaConfig.mainThreadOnly = True
ep_cfg.logConfig.level = 5
ep_cfg.logConfig.consoleLevel = 0
ep.libInit(ep_cfg)
transport_cfg = pj.TransportConfig()
transport_cfg.port = 5068
ep.transportCreate(pj.PJSIP_TRANSPORT_UDP,transport_cfg)
ep.libStart()
acc_cfg = pj.AccountConfig()
acc_cfg.idUri = "sip:8004@192.168.1.200"
acc_cfg.regConfig.registrarUri = "sip:192.168.1.200"
auth_info = pj.AuthCredInfo("digest", "*", "8004", 0, "8004")
acc_cfg.sipConfig.authCreds.append(auth_info)
acc = Account()
acc.create(acc_cfg)
while True:
ep.libHandleEvents(10)
#time.sleep(1)
ep.libDestroy()
python pjsua2-1:注册代码
最新推荐文章于 2023-08-28 20:54:49 发布