pjsip library+native code on android

2,514 views
Skip to first unread message

Tarun

unread,
Jun 26, 2010, 1:56:47 PM6/26/10
to android-ndk
Hi

I've a C library (pjsip+pjmedia) and a C code that uses this library
(a sip client actually). I want to port this code on android. I know
JNI/NDK enough to port simple codes on android, calling c functions
from java and vice-versa. However, this is more complicated. I've
compiled phsip for linux and not android.

Could you please suggest what steps i should follow. Should i compile
the pjsip library again for android (is there a way to use ndk-build
in ndk r4 to do this). How can i tell ndk-build where to find the
library so that it's able to compile my code.

Thanks

Tarun

ismangil

unread,
Jun 28, 2010, 7:52:55 AM6/28/10
to android-ndk
Hi Tarun,

This has been done: http://code.google.com/p/csipsimple/

Hope this helps.

Tarun

unread,
Jun 28, 2010, 10:13:59 AM6/28/10
to android-ndk
Hi

Thank you very much for the reply and the link. However. my problem is
slightly different. The pjsip-jni project will allow me to write java
code to port on android. However i already have C code based on pjsip
library and i'm required to port this code (and the library if
required) on android. Might sound like an unnecessary hassle since
pjsip-jni could be used but it's my proj discription.

Also, i believe pjsip-jni supports only pjsua (please correct me if
i'm wrong) while i'm using (pjsip + pjmedia).

Thank you very much ones again

Tarun

Andy Savage

unread,
Jun 28, 2010, 9:21:08 PM6/28/10
to andro...@googlegroups.com
Hi there,

You'll need to cross compile your libraries for Android. You can do this on linux by simply linking to the cross compiler that comes with NDK.

I managed to do this for ffmpeg (I've attached my shell script) by simply using the bionic compiler that comes with the NDK.

Obviously this won't work for JNI but only if you want native binaries. In my example I was doing static compilation but you may want to do shared compilation. 

You'll need to change some of the flags and point it to your compiler. If you want shared libraries enabled you'll need to remove all the dynamic stuff. But I guess this might provide an o.k. starting point for you.

I'm very interested in anything SIP based for Android so would love to hear of your results (presuming it's open source?).

Simple Shell Script
------------------------------------------------------------------
#!/bin/bash

export ARM_ROOT=/stuff/android-ndk-r4
export ARM_INC=$ARM_ROOT/build/platforms/android-5/arch-arm/usr/include/
export ARM_LIB=$ARM_ROOT/build/platforms/android-5/arch-arm/usr/lib/
export ARM_TOOL=$ARM_ROOT/build/prebuilt/linux-x86/arm-eabi-4.4.0
export ARM_LIBO=$ARM_TOOL/lib/gcc/arm-eabi/4.4.0
export PATH=$ARM_TOOL/bin:$PATH
export ARM_PRE=arm-eabi

./configure --disable-gpac --prefix=/stuff/ffmpeg-android/build/ffmpeg \
        --extra-cflags=" -I$ARM_INC -fPIC -DANDROID -fpic -mthumb-interwork -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__  -Wno-psabi -march=armv5te -mtune=xscale -msoft-float -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -DANDROID  -Wa,--noexecstack -MMD -MP " --extra-ldflags="-nostdlib -Bdynamic -Wl,--no-undefined -Wl,-z,noexecstack  -Wl,-z,nocopyreloc -Wl,-soname,/system/lib/libz.so -Wl,-rpath-link=$ARM_LIB,-dynamic-linker=/system/bin/linker -L$ARM_LIB -nostdlib $ARM_LIB/crtbegin_dynamic.o $ARM_LIB/crtend_android.o -lc -lm -ldl -lgcc" \
        --cross-prefix=${ARM_PRE}- --disable-asm --host=arm-linux --disable-shared


--------------------------------------------------------
End Simple Shell Script


--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.


Tarun

unread,
Jun 29, 2010, 9:42:04 AM6/29/10
to android-ndk
Hi Andy

Thank you very much for the detailed procedure. I'm gono try it out
now.

My project is, unfortunately, not open source so i wont be able to
share the project details with you. However I should be able to share
the results of my work while being withing the company guidelines. I
hope we can be mutual help.

Thanks

Tarun
> > android-ndk...@googlegroups.com<android-ndk%2Bunsubscribe@googlegr oups.com>
> > .

Tarun

unread,
Jun 29, 2010, 3:14:56 PM6/29/10
to android-ndk
Just to confirm, the procedure mentioned in http://code.google.com/p/csipsimple/
actually uses pjsip-jni and converts pjsip to a .so library.

Have i gat it correct that this library (like any library produced my
standard NDK procedure, ie, ndk-built )is ment to be used by a Java
application and not a C application over it.

And the procedure mentioned by Andy compiles pjsip in to a library
that can be used by a C application over it (which we can call from a
java wrapper later on, probably using NDK and put it in android)

I just wanted to confirm because i though ndk-build, in background,
uses bionic compiler so i couldn't understand the different between
the two approaches.

Thank you very much

tarun

Andy Savage

unread,
Jun 29, 2010, 9:55:44 PM6/29/10
to andro...@googlegroups.com
Hi Tarun,

Just a small point regarding what you were saying about it not being opensource. 

You may want to be aware that pjsip is under GPL licence. This is a particularly viral licence in the fact that if you use it in any projects that you plan to use or sell then you must offer full source code of these projects including your own code you write.

Anybody in posession of a binary of your code which uses GPL components has the right to request the source.

Unless of course you have paid for and obtained a licence for pjsip under another lisencing model.

You may want to consider an LGPL licensed stack. In this case you would only need to share your instructions and source code for the Sip stack and not the rest of your code.

But iirc, as it stands pjsip is only licensed under GPL.

To unsubscribe from this group, send email to android-ndk...@googlegroups.com.

Tarun

unread,
Jun 30, 2010, 9:35:04 AM6/30/10
to android-ndk
Hi Andy

thank you very much for the heads up. I'm not very knowledgeable in
the matter. I'll let my superior know and make sure we are not
violating any policies.

Thank you very much ones again.

Tarun
Reply all
Reply to author
Forward
0 new messages