问题描述
我想用 G.729
音频codeC在我的Android应用程序。我已经做了这个有很多研究,才知道, PJSIP
是这个最有前途的解决方案。但我对此都没有太多的想法。可有人向我提供完整的步骤,使用 PJSIP
在现有的Android应用程序,我怎么能包括支持 G729
$ C $通过CC PJSIP
。
任何帮助将AP preciated。
编辑:
下面是我的 android.mk
文件。我想知道的是,有我这样做对吗?以及如何使用这些 C
函数在我的Java code ???
包括$(CLEAR_VARS)
LOCAL_MODULE:= pjsua臂未知-Linux的androideabi
LOCAL_SRC_FILES:= $(MY_PJLIB_PATH)/libpjsua-arm-unknown-linux-androideabi.a
PJSIP_LIBS:= $(加preFIX pjsip_libs /,\
libg7221 codeC-手臂未知的Linux androideabi.a \
libg7221 codeC-i686的 - 苹果darwin9.a \
libgsm codeC-手臂未知的Linux androideabi.a \
libgsm codeC-i686的 - 苹果darwin9.a \
libilbc codeC-手臂未知的Linux androideabi.a \
libmilenage臂未知-Linux的androideabi.a \
libmilenage-i686的 - 苹果darwin9.a \
libpj臂未知-Linux的androideabi.a \
libpj-i686的 - 苹果darwin9.a \
libpjlib-UTIL-手臂未知的Linux androideabi.a \
libpjlib-UTIL-i686的 - 苹果darwin9.a \
libpjmedia-AUDIODEV-i686的 - 苹果darwin9.a \
libpjmedia- codeC-i686的 - 苹果darwin9.a \
libpjmedia-i686的 - 苹果darwin9.a \
libpjmedia-videodev-i686的 - 苹果darwin9.a \
libpjnath臂未知-Linux的androideabi.a \
libpjnath-i686的 - 苹果darwin9.a \
libpjsdp-i686的 - 苹果darwin9.a \
libpjsip-i686的 - 苹果darwin9.a \
libpjsip-简单的i686-苹果darwin9.a \
libpjsip-UA-i686的 - 苹果darwin9.a \
libpjsua-i686的 - 苹果darwin9.a \
libportaudio-i686的 - 苹果darwin9.a \
libresample臂未知-Linux的androideabi.a \
libresample-i686的 - 苹果darwin9.a \
libspeex臂未知-Linux的androideabi.a \
libsrtp臂未知-Linux的androideabi.a \
libsrtp-i686的 - 苹果darwin9.a)
LOCAL_STATIC_LIBRARIES:= $(PJSIP_LIBS)
包括$(preBUILT_STATIC_LIBRARY)
第一步是建立 PJSIP
源$ C $ C为Android(在Ubuntu Linux的步骤):
- 设置
ANDROID_NDK_ROOT
环境变量到你的NDK的根文件夹。 - 转到PJSIP 2.X文件夹并创建
pjlib /有/ PJ / config_site.h
包括config_site_sample.h
(的#include< PJ / config_site_sample.h>
) - 运行
./配置 - 机器人
- 运行
使清洁和放大器;&安培;使依赖和放大器;&安培;使
在这些步骤,你将不得不在多个文件夹中的几个静态库。我被建议将它们分组在同一个文件夹(在您的项目更好):
的mkdir< your_project_path> / pjsip_libs
发现 。 -name * .A | xargs的-I%CP%LT; your_project_path> / pjsip_libs /
一旦你所有的图书馆,你需要将这些库添加到项目的Android.mk文件,这是由包括每个库一个新的模块部分完成。该模块部分应该是这样的:
包括$(CLEAR_VARS)
LOCAL_MODULE:= pjsua臂未知-Linux的androideabi
LOCAL_SRC_FILES:= $(MY_PJLIB_PATH)/libpjsua-arm-unknown-linux-androideabi.a
包括$(preBUILT_STATIC_LIBRARY)
和,在部分你实际上构建JNI项目源$ C $ C,所有模块的静态库引用:
LOCAL_STATIC_LIBRARIES:= pjsua臂未知-Linux的androideabi ...
这将包括 PJSIP
引用到你的JNI库。现在,你需要配置一个 PJSIP
UA实例。
您已经对init和启动 PJSIP
的UA(pjsua)的 PJSIP /有/ pjsua-LIB / pjsua.h一个解释
,但主要的操作步骤如下:
- 创建与
pjsua_create
A UA实例 - 创建一个工作线程与
pj_thread_create
-
有关UA实例设置默认配置:
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);
-
初始化栈与
pjsua_init
- 启动堆栈
pjsua_start
在这里,你已经大量的配置选项(日志,媒体,运输等)
您可以找到一个基本的PJSIP教程这里和,PJSIP的源根路径里面,你已经基本(但对于一个基本的SIP使用不够完整),时间: PJSIP-应用程序/ src目录/样品/ simple_pjsua.c
编辑:当PJSIP-应用程序构建Android项目,你可以面对一个问题,因为pjsua-应用程序默认情况下,在常规构建不产生(更具体地说,pjsua:目标不包括在all:目标在PJSIP-应用程序/生成/ Makefile文件)。为了解决这个问题只要到PJSIP-应用程序/生成和运行:
请pjsua
这将在创建正确的对象文件:PJSIP-应用程序/生成/输出/ pjsua臂未知-Linux的androideabi /(建筑机器人样品在需要的时候)
一旦你所有对应的目标文件,你可以再次运行在PJSIP-应用程序/ src目录/ pjsua / Android的NDK-建立
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)
First step is build pjsip
source code for Android (steps for Ubuntu Linux):
- Set
ANDROID_NDK_ROOT
environment variable to your NDK's root folder. - Go to pjsip 2.x folder and create
pjlib/include/pj/config_site.h
includingconfig_site_sample.h
(#include <pj/config_site_sample.h>
) - Run
./configure-android
- 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:
- Create a UA instance with
pjsua_create
- Create a worker thread with
pj_thread_create
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);
Init the stack with
pjsua_init
- 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
这篇关于如何使用PJSIP的Android设备,以便有G.729 codeC功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!