I'm trying to call the PJSUA2 library from Python, it works fine but I hit a snag trying to call
void utilAddPendingJob(PendingJob *job)
which results in the following error
TypeError: in method 'Endpoint_utilAddPendingJob', argument 2 of type 'pj::PendingJob *'
The Python code is as follows:
import pjsua2 as pj
class MyJob(pj.PendingJob):
def __init__(self, text):
self.text = text
def execute(self, is_pending = False):
print(text)
<<SNIP>>
job = MyJob("test")
pj.Endpoint.instance().utilAddPendingJob(job)
The only difference I see is that this function takes a pointer instead of a reference on the C++ side. However, looking through the SWIG manual this shouldn't matter.
Edit: Here is the PendingJob SWIG generated Python class:
class PendingJob(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, PendingJob, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, PendingJob, name)
def __init__(self, *args, **kwargs):
raise AttributeError("No constructor defined - class is abstract")
__repr__ = _swig_repr
def execute(self, is_pending):
return _pjsua2.PendingJob_execute(self, is_pending)
__swig_destroy__ = _pjsua2.delete_PendingJob
__del__ = lambda self: None
PendingJob_swigregister = _pjsua2.PendingJob_swigregister
PendingJob_swigregister(PendingJob)
And the method signature, again SWIG generated Python code:
def utilAddPendingJob(self, job):
return _pjsua2.Endpoint_utilAddPendingJob(self, job)