How to use pjsip on android device in order to have G.729 codec functionality
Asked Answered
A

2

3

I want to use G.729 audio codec on my android application. I have did a lot research on this and came to know that pjsip is most promising solution for this. But I have not much idea about all this. can someone provide me complete steps for using pjsip in existing android application and how can i include support of G729 codec via pjsip.

Any help will be appreciated.

EDIT :

Here is my android.mk file. I want to know that,have i did this right? and how to use those C functions in my java code???

include $(CLEAR_VARS)
LOCAL_MODULE := pjsua-arm-unknown-linux-androideabi
LOCAL_SRC_FILES := $(MY_PJLIB_PATH)/libpjsua-arm-unknown-linux-androideabi.a

 PJSIP_LIBS := $(addprefix pjsip_libs/, \
 libg7221codec-arm-unknown-linux-androideabi.a \
 libg7221codec-i686-apple-darwin9.a \
 libgsmcodec-arm-unknown-linux-androideabi.a \
 libgsmcodec-i686-apple-darwin9.a \
 libilbccodec-arm-unknown-linux-androideabi.a \
 libmilenage-arm-unknown-linux-androideabi.a \
 libmilenage-i686-apple-darwin9.a \
 libpj-arm-unknown-linux-androideabi.a \
 libpj-i686-apple-darwin9.a \
 libpjlib-util-arm-unknown-linux-androideabi.a \
 libpjlib-util-i686-apple-darwin9.a \
 libpjmedia-audiodev-i686-apple-darwin9.a \
 libpjmedia-codec-i686-apple-darwin9.a \
 libpjmedia-i686-apple-darwin9.a \
 libpjmedia-videodev-i686-apple-darwin9.a \
 libpjnath-arm-unknown-linux-androideabi.a \
 libpjnath-i686-apple-darwin9.a \
 libpjsdp-i686-apple-darwin9.a \
 libpjsip-i686-apple-darwin9.a \
 libpjsip-simple-i686-apple-darwin9.a \
 libpjsip-ua-i686-apple-darwin9.a \
 libpjsua-i686-apple-darwin9.a \
 libportaudio-i686-apple-darwin9.a \
 libresample-arm-unknown-linux-androideabi.a \
 libresample-i686-apple-darwin9.a \
 libspeex-arm-unknown-linux-androideabi.a \
 libsrtp-arm-unknown-linux-androideabi.a \
 libsrtp-i686-apple-darwin9.a )

 LOCAL_STATIC_LIBRARIES := $(PJSIP_LIBS) 
 include $(PREBUILT_STATIC_LIBRARY)
Algicide answered 25/11, 2013 at 13:10 Comment(1)
can you put your Android.mk file here, so that we can referThorathoracic
D
6

First step is build pjsip source code for Android (steps for Ubuntu Linux):

  1. Set ANDROID_NDK_ROOT environment variable to your NDK's root folder.
  2. Go to pjsip 2.x folder and create pjlib/include/pj/config_site.h including config_site_sample.h (#include <pj/config_site_sample.h>)
  3. Run ./configure-android
  4. Run make clean && make depend && make

After these steps, you will have several static libraries in several folders. I suggest to group them in a same folder (better in your project) by:

mkdir <your_project_path>/pjsip_libs
find . -name *.a | xargs -I % cp % <your_project_path>/pjsip_libs/

Once you've all libraries, you need to add those libraries into your project's Android.mk file, this is done by including a new module section per library. This module section should be something like:

include $(CLEAR_VARS)
LOCAL_MODULE := pjsua-arm-unknown-linux-androideabi
LOCAL_SRC_FILES := $(MY_PJLIB_PATH)/libpjsua-arm-unknown-linux-androideabi.a
include $(PREBUILT_STATIC_LIBRARY)

And, in the section you're actually building your JNI project's source code, add all modules to your static library references:

 LOCAL_STATIC_LIBRARIES := pjsua-arm-unknown-linux-androideabi ...

This will include pjsip references into your JNI library. Now, you need to configure a pjsip UA instance.

You've a explanation about init and start pjsip's UA (pjsua) in pjsip/include/pjsua-lib/pjsua.h but main steps to follow are:

  1. Create a UA instance with pjsua_create
  2. Create a worker thread with pj_thread_create
  3. Set default configuration for UA instance:

    pjsua_config cfg; pjsua_logging_config log_cfg; pjsua_media_config media_cfg;

    pj_cli_cfg_default(&app_config.cli_cfg.cfg); pjsua_logging_config_default(&log_cfg); pjsua_media_config_default(&media_cfg);

  4. Init the stack with pjsua_init

  5. Start the stack with pjsua_start

From here, you've plenty of configuration options (log, media, transport, etc.)

You can find a basic PJSIP tutorial here and, inside pjsip's source root path, you've a basic (but complete enough for a basic SIP usage) at: pjsip-apps/src/samples/simple_pjsua.c

Edit: When building android project in pjsip-apps, you can face a problem because pjsua-app is not generated by default on the general build (more specifically, pjsua: target is not included on all: target at pjsip-apps/build/Makefile). To fix this just go to pjsip-apps/build and run:

make pjsua

This would create proper object files at: pjsip-apps/build/output/pjsua-arm-unknown-linux-androideabi/ (needed when building android sample).

Once you've all corresponding object files, you can run ndk-build again at pjsip-apps/src/pjsua/android

Distend answered 25/11, 2013 at 13:38 Comment(19)
will these steps remain same on mac machine?Algicide
I have downloaded the source from "svn.pjsip.org/repos/pjproject/trunk" of pjsip. but configure-android file don't have BUILD_MACHINE property.Algicide
got this in 4th step: compilation terminated. make[2]: *** [output/pjmedia-audiodev-arm-unknown-linux-androideabi/errno.o] Error 1 make[1]: *** [libpjmedia-audiodev-arm-unknown-linux-androideabi.a] Error 2 make: *** [all] Error 1Algicide
Following line will solve the issue, use it before make : "./aconfigure --host=i686-apple-darwin9 --disable-speex-aec --disable-speex-codec --disable-l16-codec --disable-ilbc-codec --disable-ssl"Algicide
Thanks jcm, I have added the libraries and created Android.mk file with 4 lines given by you. But i am not getting the next steps regarding " LOCAL_STATIC_LIBRARIES"?? what I have to do at this step ?Algicide
@I-droid Initially, this should have been done with configure-android (configure-iphone in your case as architecture is apple-darwing). On the other hand, you can also use these parameters with ./configure-iphone: configure-iphone --disable-speex-aec --disable-speex-codec --disable-l16-codec --disable-ilbc-codec --disable-ssl in step 1.Distend
I have successfully completed steps till LOCAL_STATIC_LIBRARIES. After that i'm not clear about what i have to do,and how exactly i will gonna use pjsip in my app. can you provide any tutorial or samples ????Algicide
@I-droid Please, check my last update to my response.Distend
@I-droid Finally updated the answer for completeness.Distend
@Distend I have build pjsip libs now I dint get you "Once you've all libraries, you need to add those libraries into your project's Android.mk file...." this step.what I need to do now ???please explainShortstop
@Bansal_Sneha What I mean is that, in order to use pjsip's functions in your project (initially, those in pjsua.h file), you would need to link with these libraries. With NDK this is done by including modules to your JNI project, this is what is explained in following code lines (in the original response).Distend
@Distend I have got files and I have collected all them in a folder of my project..Now where should I write that lines ??Shortstop
@Bansal_Sneha In order to properly interact with pjsip functions from your java application, you need to create a wrapper JNI library. Usually such a library is inside your own project (so I assumed it it was your case) that should be build using and Android.mk project file (these lines should go there). But this subject is really quite large and, if you need help with this, maybe, you can open a new question.Distend
@Distend sorry for this question but I am not getting how to implement pjsip lib in my so I have build csipsipmple project and it is well running .Can you please tell me how to use its jni or is it possible to use it or not ?Shortstop
@Distend I have learnt Jni creation for c fuctions.My questiom is do I have to create wrapper for .a file ????Shortstop
@Distend I am using Windows XP. ./configure-android command cannot be run. command prompt says that there is no such command. how can i build it on Windows platform?Kendallkendell
@Distend Have you ever build pjsip on Android Studio with Gradle?Believe
@astuter i'm stuck on this step $ make dep && make clean && make here are the logs paste.ee/p/O64gr . I'm using windows + CygwinNeill
@Bansal_Sneha could you please look into the issue as mentioned above!Neill
H
3

To integrate the G.729 codec into your PJSIP project, you just want to get Intel IPP compilers from Intel and you can integrate them into your project easily.

Follow this link.

Hemipode answered 3/12, 2016 at 1:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.