forked from mirrors/linphone-iphone
Add LCSipTransports wrapper in the Python module.
This commit is contained in:
parent
2ff5e8612b
commit
395448491a
5 changed files with 140 additions and 3 deletions
|
|
@ -47,8 +47,6 @@ blacklisted_functions = [
|
|||
'linphone_core_can_we_add_call', # private function
|
||||
'linphone_core_enable_log_collection', # need to handle class properties
|
||||
'linphone_core_get_audio_port_range', # to be handwritten because of result via arguments
|
||||
'linphone_core_get_sip_transports', # missing LCSipTransports
|
||||
'linphone_core_get_sip_transports_used', # missing LCSipTransports
|
||||
'linphone_core_get_supported_video_sizes', # missing MSVideoSizeDef
|
||||
'linphone_core_get_video_policy', # missing LinphoneVideoPolicy
|
||||
'linphone_core_get_video_port_range', # to be handwritten because of result via arguments
|
||||
|
|
@ -61,7 +59,6 @@ blacklisted_functions = [
|
|||
'linphone_core_set_log_handler', # Hand-written but put directly in the linphone module
|
||||
'linphone_core_set_log_level', # There is no use to wrap this function
|
||||
'linphone_core_set_video_policy', # missing LinphoneVideoPolicy
|
||||
'linphone_core_set_sip_transports', # missing LCSipTransports
|
||||
'linphone_proxy_config_get_privacy', # missing LinphonePrivacyMask
|
||||
'linphone_proxy_config_normalize_number', # to be handwritten because of result via arguments
|
||||
'linphone_proxy_config_set_file_transfer_server', # defined but not implemented in linphone core
|
||||
|
|
|
|||
|
|
@ -2,15 +2,26 @@ static PyObject * pylinphone_Core_get_sound_devices(PyObject *self, void *closur
|
|||
static PyObject * pylinphone_Core_get_video_devices(PyObject *self, void *closure);
|
||||
|
||||
static PyTypeObject pylinphone_VideoSizeType;
|
||||
static PyTypeObject pylinphone_SipTransportsType;
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
MSVideoSize vs;
|
||||
} pylinphone_VideoSizeObject;
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
LCSipTransports lcst;
|
||||
} pylinphone_SipTransportsObject;
|
||||
|
||||
int PyLinphoneVideoSize_Check(PyObject *p);
|
||||
MSVideoSize PyLinphoneVideoSize_AsMSVideoSize(PyObject *obj);
|
||||
PyObject * PyLinphoneVideoSize_FromMSVideoSize(MSVideoSize vs);
|
||||
|
||||
int PyLinphoneSipTransports_Check(PyObject *p);
|
||||
LCSipTransports * PyLinphoneSipTransports_AsLCSipTransports(PyObject *obj);
|
||||
PyObject * PyLinphoneSipTransports_FromLCSipTransports(LCSipTransports lcst);
|
||||
|
||||
time_t PyDateTime_As_time_t(PyObject *obj);
|
||||
PyObject * PyDateTime_From_time_t(time_t t);
|
||||
|
||||
|
|
|
|||
|
|
@ -431,6 +431,125 @@ PyObject * PyLinphoneVideoSize_FromMSVideoSize(MSVideoSize vs) {
|
|||
}
|
||||
|
||||
|
||||
|
||||
static void pylinphone_SipTransports_dealloc(PyObject *self) {
|
||||
pylinphone_trace(1, "[PYLINPHONE] >>> %s(%p)", __FUNCTION__, self);
|
||||
self->ob_type->tp_free(self);
|
||||
pylinphone_trace(-1, "[PYLINPHONE] <<< %s", __FUNCTION__);
|
||||
}
|
||||
|
||||
static PyObject * pylinphone_SipTransports_new(PyTypeObject *type, PyObject *args, PyObject *kw) {
|
||||
pylinphone_SipTransportsObject *self = (pylinphone_SipTransportsObject *)type->tp_alloc(type, 0);
|
||||
pylinphone_trace(1, "[PYLINPHONE] >>> %s()", __FUNCTION__);
|
||||
pylinphone_trace(-1, "[PYLINPHONE] <<< %s -> %p", __FUNCTION__, self);
|
||||
return (PyObject *)self;
|
||||
}
|
||||
|
||||
static int pylinphone_SipTransports_init(PyObject *self, PyObject *args, PyObject *kw) {
|
||||
pylinphone_SipTransportsObject *sto = (pylinphone_SipTransportsObject *)self;
|
||||
int udp_port;
|
||||
int tcp_port;
|
||||
int tls_port;
|
||||
int dtls_port;
|
||||
if (!PyArg_ParseTuple(args, "iiii", &udp_port, &tcp_port, &tls_port, &dtls_port)) {
|
||||
return -1;
|
||||
}
|
||||
sto->lcst.udp_port = udp_port;
|
||||
sto->lcst.tcp_port = tcp_port;
|
||||
sto->lcst.tls_port = tls_port;
|
||||
sto->lcst.dtls_port = dtls_port;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static PyMemberDef pylinphone_SipTransports_members[] = {
|
||||
{ "udp_port", T_INT, offsetof(pylinphone_SipTransportsObject, lcst) + offsetof(LCSipTransports, udp_port), 0, "[int] The port used for UDP SIP transport" },
|
||||
{ "tcp_port", T_INT, offsetof(pylinphone_SipTransportsObject, lcst) + offsetof(LCSipTransports, tcp_port), 0, "[int] The port used for TCP SIP transport" },
|
||||
{ "tls_port", T_INT, offsetof(pylinphone_SipTransportsObject, lcst) + offsetof(LCSipTransports, tls_port), 0, "[int] The port used for TLS SIP transport" },
|
||||
{ "dtls_port", T_INT, offsetof(pylinphone_SipTransportsObject, lcst) + offsetof(LCSipTransports, dtls_port), 0, "[int] The port used for DTLS SIP transport" },
|
||||
{ NULL, 0, 0, 0, NULL } /* Sentinel */
|
||||
};
|
||||
|
||||
static PyTypeObject pylinphone_SipTransportsType = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
"linphone.SipTransports", /* tp_name */
|
||||
sizeof(pylinphone_SipTransportsObject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
pylinphone_SipTransports_dealloc, /* tp_dealloc */
|
||||
0, /* tp_print */
|
||||
0, /* tp_getattr */
|
||||
0, /* tp_setattr */
|
||||
0, /* tp_compare */
|
||||
0, /* tp_repr */
|
||||
0, /* tp_as_number */
|
||||
0, /* tp_as_sequence */
|
||||
0, /* tp_as_mapping */
|
||||
0, /* tp_hash */
|
||||
0, /* tp_call */
|
||||
0, /* tp_str */
|
||||
0, /* tp_getattro */
|
||||
0, /* tp_setattro */
|
||||
0, /* tp_as_buffer */
|
||||
Py_TPFLAGS_DEFAULT, /* tp_flags */
|
||||
"Object representing the SIP transports: its UDP, TCP, TLS and DTLS ports.", /* tp_doc */
|
||||
0, /* tp_traverse */
|
||||
0, /* tp_clear */
|
||||
0, /* tp_richcompare */
|
||||
0, /* tp_weaklistoffset */
|
||||
0, /* tp_iter */
|
||||
0, /* tp_iternext */
|
||||
0, /* tp_methods */
|
||||
pylinphone_SipTransports_members, /* tp_members */
|
||||
0, /* tp_getset */
|
||||
0, /* tp_base */
|
||||
0, /* tp_dict */
|
||||
0, /* tp_descr_get */
|
||||
0, /* tp_descr_set */
|
||||
0, /* tp_dictoffset */
|
||||
pylinphone_SipTransports_init, /* tp_init */
|
||||
0, /* tp_alloc */
|
||||
pylinphone_SipTransports_new, /* tp_new */
|
||||
0, /* tp_free */
|
||||
};
|
||||
|
||||
int PyLinphoneSipTransports_Check(PyObject *p) {
|
||||
return PyObject_IsInstance(p, (PyObject *)&pylinphone_SipTransportsType);
|
||||
}
|
||||
|
||||
LCSipTransports * PyLinphoneSipTransports_AsLCSipTransports(PyObject *obj) {
|
||||
return &((pylinphone_SipTransportsObject *)obj)->lcst;
|
||||
}
|
||||
|
||||
PyObject * PyLinphoneSipTransports_FromLCSipTransports(LCSipTransports lcst) {
|
||||
PyObject *linphone_module;
|
||||
PyObject *pyret = NULL;
|
||||
PyGILState_STATE gstate;
|
||||
|
||||
gstate = PyGILState_Ensure();
|
||||
linphone_module = PyImport_ImportModule("linphone.linphone");
|
||||
if (linphone_module != NULL) {
|
||||
PyObject *cls = PyObject_GetAttrString(linphone_module, "SipTransports");
|
||||
if (cls != NULL) {
|
||||
PyObject *args = Py_BuildValue("iiii", lcst.udp_port, lcst.tcp_port, lcst.tls_port, lcst.dtls_port);
|
||||
pyret = PyEval_CallObject(cls, args);
|
||||
if (pyret == NULL) {
|
||||
PyErr_Print();
|
||||
}
|
||||
Py_DECREF(args);
|
||||
Py_DECREF(cls);
|
||||
}
|
||||
Py_DECREF(linphone_module);
|
||||
}
|
||||
PyGILState_Release(gstate);
|
||||
|
||||
if (pyret == NULL) {
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
return pyret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
time_t PyDateTime_As_time_t(PyObject *obj) {
|
||||
time_t ret = -1;
|
||||
PyObject *utctimetuple = PyObject_GetAttrString(obj, "utctimetuple");
|
||||
|
|
|
|||
|
|
@ -194,6 +194,14 @@ class ArgumentType:
|
|||
self.fmt_str = 'O'
|
||||
self.cfmt_str = '%p'
|
||||
self.cast_convert_func_result = False
|
||||
elif self.basic_type == 'LCSipTransports':
|
||||
self.type_str = 'linphone.SipTransports'
|
||||
self.check_func = 'PyLinphoneSipTransports_Check'
|
||||
self.convert_func = 'PyLinphoneSipTransports_AsLCSipTransports'
|
||||
self.convert_from_func = 'PyLinphoneSipTransports_FromLCSipTransports'
|
||||
self.fmt_str = 'O'
|
||||
self.cfmt_str = '%p'
|
||||
self.cast_convert_func_result = False
|
||||
else:
|
||||
if strip_leading_linphone(self.basic_type) in self.linphone_module.enum_names:
|
||||
self.type_str = 'int'
|
||||
|
|
|
|||
|
|
@ -326,6 +326,8 @@ PyMODINIT_FUNC initlinphone(void) {
|
|||
/* Hand-written classes. */
|
||||
Py_INCREF(&pylinphone_VideoSizeType);
|
||||
PyModule_AddObject(m, "VideoSize", (PyObject *)&pylinphone_VideoSizeType);
|
||||
Py_INCREF(&pylinphone_SipTransportsType);
|
||||
PyModule_AddObject(m, "SipTransports", (PyObject *)&pylinphone_SipTransportsType);
|
||||
|
||||
pylinphone_init_testing_module(m);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue