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

前端 未结 2 509
终归单人心
终归单人心 2020-12-06 03:23

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

相关标签:
2条回答
  • 2020-12-06 04:11

    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.

    0 讨论(0)
  • 2020-12-06 04:14

    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

    0 讨论(0)
提交回复
热议问题