<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to IntegrateExistingPjsipModule</title><link>https://sourceforge.net/p/csipsimple/wiki/IntegrateExistingPjsipModule/</link><description>Recent changes to IntegrateExistingPjsipModule</description><atom:link href="https://sourceforge.net/p/csipsimple/wiki/IntegrateExistingPjsipModule/feed" rel="self"/><language>en</language><lastBuildDate>Wed, 15 Apr 2015 13:53:43 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/csipsimple/wiki/IntegrateExistingPjsipModule/feed" rel="self" type="application/rss+xml"/><item><title>IntegrateExistingPjsipModule modified by Anonymous</title><link>https://sourceforge.net/p/csipsimple/wiki/IntegrateExistingPjsipModule/</link><description>&lt;div class="markdown_content"&gt;&lt;h1 id="introduction"&gt;Introduction&lt;/h1&gt;
&lt;p&gt;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. &lt;/p&gt;
&lt;p&gt;However due to the current build toolchain, it's not obvious to integrate with CSipSimple. &lt;/p&gt;
&lt;p&gt;This page should help to clarify how to do the best way. &lt;/p&gt;
&lt;h1 id="reference-module"&gt;Reference module&lt;/h1&gt;
&lt;p&gt;CSipSimple already include one sample that you can get inspiration from : &lt;strong&gt;&lt;a class="" href="http://code.google.com/p/csipsimple/source/browse/trunk/CSipSimple#CSipSimple%2Fjni%2Fpjsip_mod_reghandler" rel="nofollow"&gt;pjsip_mod_reghandler&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;h1 id="folder-structure"&gt;Folder structure&lt;/h1&gt;
&lt;p&gt;You should place your files in a new folder of &lt;em&gt;CSipSimple/jni&lt;/em&gt;. The folder structure of your module should be the following : &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;jni &lt;ul&gt;
&lt;li&gt;... &lt;/li&gt;
&lt;li&gt;pjsip_mod_your_module &lt;/li&gt;
&lt;li&gt;android_toolchain &lt;ul&gt;
&lt;li&gt;Android.mk &lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;src &lt;ul&gt;
&lt;li&gt;your source files &lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;include &lt;ul&gt;
&lt;li&gt;your include files &lt;/li&gt;
&lt;li&gt;a .i file to define swig interface &lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;... &lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h1 id="integration-to-toolchain"&gt;Integration to toolchain&lt;/h1&gt;
&lt;p&gt;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. &lt;/p&gt;
&lt;p&gt;To do that, you first need to have c/c++ files built. This is done using the android_toolchain/Android.mk file. &lt;/p&gt;
&lt;p&gt;If you are familiar with android ndk this should be easy. It's about creating a static lib. &lt;/p&gt;
&lt;p&gt;You can get inspired of &lt;a class="" href="http://code.google.com/p/csipsimple/source/browse/trunk/CSipSimple/jni/pjsip_mod_reghandler/android_toolchain/Android.mk" rel="nofollow"&gt;Android.mk&lt;/a&gt; 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) &lt;/p&gt;
&lt;p&gt;Once this file is ok, you need to integrate it with existing files. So, edit the &lt;a class="" href="http://code.google.com/p/csipsimple/source/browse/trunk/CSipSimple/jni/Android.mk" rel="nofollow"&gt;main Android.mk&lt;/a&gt; to list your new mk file. &lt;/p&gt;
&lt;p&gt;Then edit the dynamic lib of &lt;a class="" href="http://code.google.com/p/csipsimple/source/browse/trunk/CSipSimple/jni/csipsimple-wrapper/android_toolchain/Android.mk#60" rel="nofollow"&gt;pjsipjni Android.mk&lt;/a&gt; and add your lib as needed static lib by adding &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="n"&gt;LOCAL_STATIC_LIBRARIES&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;pjsip_mod_your_module&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;At this point you can try a build to check your c/c++ files are correctly built. &lt;/p&gt;
&lt;h1 id="integration-with-jni-swig-auto-bindings"&gt;Integration with jni swig auto bindings&lt;/h1&gt;
&lt;p&gt;CSipSimple takes advantage of swig tool to automatically generate java api based on C/C++ api. &lt;/p&gt;
&lt;p&gt;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. &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;make your .h files compatible with swig integration. &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can see &lt;a class="" href="http://code.google.com/p/csipsimple/source/browse/trunk/CSipSimple/jni/pjsip_mod_reghandler/include/pjsip_mobile_reg_handler.h" rel="nofollow"&gt;here an example&lt;/a&gt; (with a callback object too). &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;create a .i file to define swig interface. &lt;br /&gt;
You can see &lt;a class="" href="http://code.google.com/p/csipsimple/source/browse/trunk/CSipSimple/jni/pjsip_mod_reghandler/include/mod_reghandler.i" rel="nofollow"&gt;here an example&lt;/a&gt; (with a callback object too). &lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;integrate your .i and .h to &lt;a class="" href="http://code.google.com/p/csipsimple/source/browse/trunk/CSipSimple/jni/swig-glue/android_toolchain/Android.mk" rel="nofollow"&gt;swig makefile&lt;/a&gt;. It's basically to : &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Create your path shortcut &lt;code&gt;MOD_YOUR_MOD_ROOT_DIR := $(SWIG_GLUE_PATH)/../pjsip_mod_your_module&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Add your .h files to swig headers : &lt;code&gt;PJ_SWIG_HEADERS += ...&lt;/code&gt;. &lt;/li&gt;
&lt;li&gt;Add your interface file (.i) to &lt;code&gt;INTERFACES_FILES&lt;/code&gt;. &lt;/li&gt;
&lt;li&gt;Add your includes folder to swig generation includes in &lt;code&gt;$(SWIG) ... -I$(MOD_YOUR_MOD_ROOT_DIR)/include ...&lt;/code&gt;. &lt;/li&gt;
&lt;li&gt;Add your includes folder to native lib generation : &lt;code&gt;LOCAL_C_INCLUDES += $(MOD_YOUR_MOD_ROOT_DIR)/include&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;At this point you can now launch a &lt;code&gt;make&lt;/code&gt; build. Now the static lib should be built and the auto jni bindings done. &lt;/p&gt;
&lt;h1 id="integration-in-java-space"&gt;Integration in java space&lt;/h1&gt;
&lt;p&gt;You have now to implement a PjsipModule interface. See how it's done in &lt;a class="" href="http://code.google.com/p/csipsimple/source/browse/trunk/CSipSimple#CSipSimple%2Fsrc%2Fcom%2Fcsipsimple%2Fpjsip%2Freghandler" rel="nofollow"&gt;mod_reghandler&lt;/a&gt;. You have here just to implement the methods. Typically here you will add your module to pjsip endpoint here. &lt;/p&gt;
&lt;p&gt;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. &lt;/p&gt;
&lt;p&gt;You can call any native method in your project. You can also get callback from your own callbacks here too. &lt;/p&gt;
&lt;p&gt;And the little bit ugly addition. &lt;a class="" href="http://code.google.com/p/csipsimple/source/browse/trunk/CSipSimple/src/com/csipsimple/pjsip/PjSipService.java#2188" rel="nofollow"&gt;here&lt;/a&gt; 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. &lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Anonymous</dc:creator><pubDate>Wed, 15 Apr 2015 13:53:43 -0000</pubDate><guid>https://sourceforge.net3bc09d8b6d094c0104427f12a7c4be819b585000</guid></item></channel></rss>