summaryrefslogtreecommitdiff
path: root/pjsip-apps/src/swig/pjsua2.i
diff options
context:
space:
mode:
Diffstat (limited to 'pjsip-apps/src/swig/pjsua2.i')
-rw-r--r--pjsip-apps/src/swig/pjsua2.i22
1 files changed, 21 insertions, 1 deletions
diff --git a/pjsip-apps/src/swig/pjsua2.i b/pjsip-apps/src/swig/pjsua2.i
index aff740b4..ae76bd51 100644
--- a/pjsip-apps/src/swig/pjsua2.i
+++ b/pjsip-apps/src/swig/pjsua2.i
@@ -102,7 +102,6 @@ using namespace pj;
%template(CodecInfoVector) std::vector<pj::CodecInfo*>;
%include "pjsua2/media.hpp"
-%include "pjsua2/endpoint.hpp"
%include "pjsua2/presence.hpp"
%include "pjsua2/account.hpp"
%include "pjsua2/call.hpp"
@@ -112,3 +111,24 @@ using namespace pj;
%ignore pj::JsonDocument::allocElement;
%ignore pj::JsonDocument::getPool;
%include "pjsua2/json.hpp"
+
+// Try force Java GC before destroying the lib:
+// - to avoid late destroy of PJ objects by GC
+// - to avoid destruction of PJ objects from a non-registered GC thread
+#ifdef SWIGJAVA
+%rename(libDestroy_) pj::Endpoint::libDestroy;
+%typemap(javacode) pj::Endpoint %{
+ public void libDestroy(long prmFlags) throws java.lang.Exception {
+ Runtime.getRuntime().gc();
+ libDestroy_(prmFlags);
+ }
+
+ public void libDestroy() throws java.lang.Exception {
+ Runtime.getRuntime().gc();
+ libDestroy_();
+ }
+%}
+#endif
+
+%include "pjsua2/endpoint.hpp"
+