属性错误:'_pjsua.Transport_配置'对象没有属性''u cvt'u to_pjsua'

2024-06-01 00:43:37 发布

您现在位置:Python中文网/ 问答频道 /正文

我目前正在尝试在python中使用pjsipapipjsua,因此研究这个Hello World示例:http://trac.pjsip.org/repos/wiki/Python_SIP/Hello_World

我复制了代码,根据http://trac.pjsip.org/repos/wiki/Python_SIP/Accounts等集成了帐户配置。但是当我运行示例时,我得到以下输出:

Traceback (most recent call last):
    File "/home/dmeli/workspace/eit.cubiephone.sip_test/eit/cubiephone/sip_test/hello.py", line 48, in <module>
        acc = lib.create_account(acc_cfg)
    File "/usr/local/lib/python2.7/dist-packages/pjsua.py", line 2300, in create_account
        err, acc_id = _pjsua.acc_add(acc_config._cvt_to_pjsua(), set_default)
    File "/usr/local/lib/python2.7/dist-packages/pjsua.py", line 900, in _cvt_to_pjsua
        cfg.rtp_transport_cfg = self.rtp_transport_cfg._cvt_to_pjsua()
    AttributeError: '_pjsua.Transport_Config' object has no attribute '_cvt_to_pjsua'

因为我不是一个真正的python专家,也从来没有使用过PJSIP,所以我真的无法找出错误所在。对我来说,它看起来实际上是pjsippython包装器中的一个错误。但我知道什么?在

代码:

^{pr2}$

发生错误的行pjsua.py公司名称:

cfg.rtp_transport_cfg = self.rtp_transport_cfg._cvt_to_pjsua()

rtp_transport_cfg似乎没有成员_cvt_to_pjsua()??)在


Tags: toinpyhelloworldlib错误line
1条回答
网友
1楼 · 发布于 2024-06-01 00:43:37

有关进一步的工作,请查看pjsipapi(pjsua.py)他在等待秩序和结构!!!

## start lib.
def start(self):
    try:
        self._start_lib()
        self._start_acc()
    except pj.Error:
        print "Error starting lib."



def _bind(self):
    try:
        t = pj.TransportConfig()
        t.bound_addr = '0.0.0.0'
        t.port = 5060 
        acc_transport = "udp" # depend if you need.
        if  acc_transport == "tcp":
            self.transport = self.lib.create_transport(pj.TransportType.TCP, t)
            # or this pj.TransportConfig(0) is creating random port ... 
            #self.transport = self.lib.create_transport(pj.TransportType.TCP, pj.TransportConfig(0))
        else:
            self.transport = self.lib.create_transport(pj.TransportType.UDP, t)
            #self.transport = self.lib.create_transport(pj.TransportType.UDP, pj.TransportConfig(0))
    except pj.Error:
        print "Error creating transport."

    #you need create callbacks for app, to work incoming calls, check on the server that returns the error code 200, and such a way your program will know that you are logged on correctly
    #from callback.acc_cb import acc_cb
    #self.acc_t = self.lib.create_account_for_transport(self.transport, cb=acc_cb())

def _start_lib(self):
    self.lib.init(log_cfg = pj.LogConfig(level=3, callback=log_cb))
    self.lib.start()
    self._bind()
    #codecs.load_codecs()


def _start_acc(self):
    #from callback.acc_cb import acc_cb
    try:
            proxy = "sip server ip" # or proxy = socket.gethostbyname(unicode("sip.serverdnsname.com")) is needed to import socket
            login = "Atrotygma" # real username
            password = "Atrotygma_password" # real username
            lib.create_account(acc_config=pj.AccountConfig(proxy, login, password))
    except Exception, e:
        print "Error creating account", e

相关问题 更多 >