Skip to content

Commit 3a2e7a7

Browse files
authored
Expose SIP ioqueue handle via pjsua2 Endpoint (#4599)
1 parent c8a6f92 commit 3a2e7a7

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

pjsip-apps/src/swig/pjsua2.i

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ using namespace pj;
2929
%template(ByteVector) std::vector<unsigned char>;
3030
%template(StringToStringMap) std::map<string, string>;
3131

32-
3332
#ifdef SWIGPYTHON
3433
%feature("director:except") {
3534
if( $error != NULL ) {
@@ -41,6 +40,12 @@ using namespace pj;
4140
}
4241
}
4342

43+
%typemap(out) void* {
44+
$result = PyLong_FromVoidPtr($1);
45+
}
46+
47+
%apply void* { pj_oshandle_t };
48+
4449
%extend std::vector<unsigned char> {
4550
void assign_from_bytes(PyObject* obj) {
4651
Py_buffer view;

pjsip/include/pjsua2/endpoint.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,6 +1545,15 @@ class Endpoint
15451545
*/
15461546
void libDestroy(unsigned prmFlags=0) PJSUA2_THROW(Error);
15471547

1548+
/**
1549+
* Get the OS handle pointer associated with pjsua's SIP IO queue.
1550+
*
1551+
* @return For epoll/kqueue backends a pointer to a POSIX file
1552+
* descriptor. For all other backends a pointer to a
1553+
* platform-specific handle. If the backend does not
1554+
* expose a handle NULL is returned.
1555+
*/
1556+
pj_oshandle_t libGetSipIoqueueHandle();
15481557

15491558
/*************************************************************************
15501559
* Utilities

pjsip/src/pjsua2/endpoint.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2244,6 +2244,13 @@ void Endpoint::libDestroy(unsigned flags) PJSUA2_THROW(Error)
22442244
PJSUA2_CHECK_RAISE_ERROR(status);
22452245
}
22462246

2247+
pj_oshandle_t Endpoint::libGetSipIoqueueHandle()
2248+
{
2249+
pjsip_endpoint* endp = pjsua_get_pjsip_endpt();
2250+
pj_ioqueue_t* ioq = pjsip_endpt_get_ioqueue(endp);
2251+
return pj_ioqueue_get_os_handle(ioq);
2252+
}
2253+
22472254
///////////////////////////////////////////////////////////////////////////////
22482255
/*
22492256
* Endpoint Utilities

0 commit comments

Comments
 (0)