pjsip allows to add "modules" that extends pjsip features. As CSipSimple uses pjsip as backend it can benefit of existing modules already developed for pjsip.
However due to the current build toolchain, it's not obvious to integrate with CSipSimple.
This page should help to clarify how to do the best way.
CSipSimple already include one sample that you can get inspiration from : pjsip_mod_reghandler
You should place your files in a new folder of CSipSimple/jni. The folder structure of your module should be the following :
The first step is to have your native files built into the dynamic lib loaded by csipsimple so that it can be resolved later when loading it in java space.
To do that, you first need to have c/c++ files built. This is done using the android_toolchain/Android.mk file.
If you are familiar with android ndk this should be easy. It's about creating a static lib.
You can get inspired of Android.mk if you are not familiar with NDK. Don't forget to name your module (in next steps I'll call your module pjsip_mod_your_module)
Once this file is ok, you need to integrate it with existing files. So, edit the main Android.mk to list your new mk file.
Then edit the dynamic lib of pjsipjni Android.mk and add your lib as needed static lib by adding
LOCAL_STATIC_LIBRARIES += pjsip_mod_your_module
At this point you can try a build to check your c/c++ files are correctly built.
CSipSimple takes advantage of swig tool to automatically generate java api based on C/C++ api.
You can use the same or do your own bindings based on standard jni if you are familiar with it. Next steps explains how to use swig with your stuff.
You can see here an example (with a callback object too).
create a .i file to define swig interface.
You can see here an example (with a callback object too).
integrate your .i and .h to swig makefile. It's basically to :
MOD_YOUR_MOD_ROOT_DIR := $(SWIG_GLUE_PATH)/../pjsip_mod_your_module
PJ_SWIG_HEADERS += ...
. INTERFACES_FILES
. $(SWIG) ... -I$(MOD_YOUR_MOD_ROOT_DIR)/include ...
. LOCAL_C_INCLUDES += $(MOD_YOUR_MOD_ROOT_DIR)/include
At this point you can now launch a make
build. Now the static lib should be built and the auto jni bindings done.
You have now to implement a PjsipModule interface. See how it's done in mod_reghandler. You have here just to implement the methods. Typically here you will add your module to pjsip endpoint here.
The files here can be in a package of your own project and it's advised to not pollute csipsimple folders here and rather create your own folder.
You can call any native method in your project. You can also get callback from your own callbacks here too.
And the little bit ugly addition. here in initModules() method you have to add your module you created in previous step just like it's done for the reghandler module. This might change in the future to make it more flexible.