简体   繁体   中英

How to use G729 of CSipSimple in android

I have got some source of G729 of CSipSimple from here

Now I want to add it in my android application in order to add support for G729 audio codec.

How can I achieve this?

If you're not planing on using pjsip, then, you would need to generate a shared library that you can use from your own project. To do this, I suggest that you create a jni folder and add an Android.mk file similar to:

LOCAL_PATH := $(call my-dir)

### Glue for pjsip codec ###
include $(CLEAR_VARS)
LOCAL_MODULE := g729_codec

G729_PATH := $(LOCAL_PATH)/../sources

# g729
LOCAL_C_INCLUDES += $(G729_PATH)/include
G729_FILES := $(wildcard $(G729_PATH)/src/*.c)
LOCAL_SRC_FILES += $(G729_FILES:$(LOCAL_PATH)/%=%) 

LOCAL_ALLOW_UNDEFIND_SYMBOLS    := false
LOCAL_CFLAGS := -frtti -fexceptions

include $(BUILD_SHARED_LIBRARY)

This is just a modification from android_toolchain/Android.mk . You will find all functions needed to properly manage this g729 implementation in file sources/include/g729a.h and a good example about how to use them in file pj_sources/pj_g729.c

On the other hand, if you're planing to use pjsip, only thing that you should do is to register CSipSimple's implementation as an external codec (Regis has done almost all the work), this is, adding following lines to your project:

status = pjmedia_codec_g729_init(pjsua_var.med_endpt);
if (status != PJ_SUCCESS)
{   
    PJ_LOG(1,(THIS_FILE, "Error: Failed to init G729 codec"));
}

And use android_toolchain/Android.mk to build a library that you can link with your solution.

Download CSipSimpleCodecG729 From svn checkout http://csipsimple.googlecode.com/svn/trunk/ CSipSimple-trunk and build it as library then plug this library in sipHome project

you have to also write this code in Manifest file

 <!--G729 codec --> <receiver android:name="com.csipsimple.plugins.codecs.ReceiverG729" android:exported="false" > <meta-data android:name="lib_name" android:value="libpj_g729_codec.so" /> <meta-data android:name="init_factory" android:value="pjmedia_codec_g729_init" /> <intent-filter> <action android:name="com.csipsimple.codecs.action.REGISTER_CODEC" /> </intent-filter> </receiver> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM