status = pjsip_tls_transport_start(self._obj, &tls_setting, &local_addr, NULL, 1, &self._tls_transport)
if status in (PJSIP_TLS_EUNKNOWN, PJSIP_TLS_EINVMETHOD, PJSIP_TLS_ECACERT, PJSIP_TLS_ECERTFILE, PJSIP_TLS_EKEYFILE, PJSIP_TLS_ECIPHER, PJSIP_TLS_ECTX):
raise PJSIPTLSError("Could not create TLS transport", status)
elif status != 0:
raise PJSIPError("Could not create TLS transport", status)
return 0
cdef int _stop_tls_transport(self) except -1:
self._tls_transport.destroy(self._tls_transport)
self._tls_transport = NULL
return 0
def __dealloc__(self):
if self._udp_transport != NULL:
self._stop_udp_transport()
if self._tcp_transport != NULL:
self._stop_tcp_transport()
if self._tls_transport != NULL:
self._stop_tls_transport()
if self._pool != NULL:
pjsip_endpt_release_pool(self._obj, self._pool)
if self._obj != NULL:
pjsip_endpt_destroy(self._obj)
cdef class PJMEDIAEndpoint:
def __cinit__(self, PJCachingPool caching_pool):
cdef int status
cdef int speex_options = 0
status = pjmedia_endpt_create(&caching_pool._obj.factory, NULL, 1, &self._obj)
if status != 0:
raise PJSIPError("Could not create PJMEDIA endpoint", status)
status = pjmedia_codec_speex_init(self._obj, speex_options, -1, -1)
if status != 0:
raise PJSIPError("Could not initialize speex codec", status)
self._has_speex = 1
status = pjmedia_codec_g722_init(self._obj)
if status != 0:
raise PJSIPError("Could not initialize G.722 codec", status)
self._has_g722 = 1
pjmedia_codec_g711_init(self._obj)
if status != 0:
raise PJSIPError("Could not initialize G.711 codecs", status)
self._has_g711 = 1
status = pjmedia_codec_ilbc_init(self._obj, 20)
if status != 0:
raise PJSIPError("Could not initialize iLBC codec", status)
self._has_ilbc = 1
status = pjmedia_codec_gsm_init(self._obj)
if status != 0:
raise PJSIPError("Could not initialize GSM codec", status)
self._has_gsm = 1
def __dealloc__(self):
if self._has_gsm:
pjmedia_codec_gsm_deinit()
if self._has_ilbc:
pjmedia_codec_ilbc_deinit()
if self._has_g711:
pjmedia_codec_g711_deinit()
if self._has_g722:
pjmedia_codec_g722_deinit()
if self._has_speex:
pjmedia_codec_speex_deinit()
if self._obj != NULL:
pjmedia_endpt_destroy(self._obj)
cdef list _get_codecs(self):
cdef unsigned int count = PJMEDIA_CODEC_MGR_MAX_CODECS