CSipsimple是依赖pjsip协议,官网http://code.google.com/p/csipsimple/,官网上也有已经编译好的apk,对于编译CSipsimple有两种方式,一种就是要编译jni,另一种编译jni,直接使用已经编译好的这两种我都会说一下,首先说比较简单的一种,这个在官网上 也有介绍http://code.google.com/p/csipsimple/wiki/HowToBuild 介绍如何编译CSipsimple。
第一种方法,不编译jni
1.首先也是下载源码,由于CSipsimple依赖ActionBarSherlock,所以你导入到eclipse的时候也要把ActionBarSherlock导入进去。
[java] view plain copy print ?
- svn checkout http:
svn checkout http://csipsimple.googlecode.com/svn/trunk/ CSipSimple-trunk
里面会有5个文件夹
ActionBarSherlock CSipSimpleBranded CSipSimpleCodecPack
CSipSimple CSipSimpleCodecG729 CSipSimpleVideoPlugin
2.下载org.tar.gz,由于你没有编译jni部分,所以CSipsimple源码里面的src下面的org.pjsip里面是空的,所以我们要下载部分内容,下载后解压对应目录拷贝进去
3.到官网http://nightlies.csipsimple.com/stable/1.01.00/(这个是最新的版本)下载CSipSimple-1.01.00-trunk.apk 然后把后缀的apk换成rar,解压把里面的lib内容拷贝到你的项目libs下面
4.clean一下项目,源码就不会报错了,可以正常运行。
第二种方法,编译jni
这个方法比较麻烦,主要是要下载各种依赖的库的源码,方法如下:
1。首先下载源码
[java] view plain copy print ?
- svn checkout http:
svn checkout http://csipsimple.googlecode.com/svn/trunk/ CSipSimple-trunk
2。进入CSipSimple下面,我们可以看看Makefile文件,它大体要做的内容:
首先下载依赖源码,总共6个分别是silk opus zrtp4pj openssl libvpx fdk_aac,所以要保持网络的畅通,而且时间也比较长
然后就是打补丁,对于这个我一开始使用的ndk的版本是r9,在这步一直出错,所以我就换成了r8d
其次我们make的选项也有几个,分别如下:
[java] view plain copy print ?
- CodecPackLibs :
- @(ndk-build -j6 APP_MODULES="pj_g7221_codec pj_codec2_codec pj_g726_codec pj_opus_codec pj_aac_codec")
- @(./dispatch_shared_libs.sh)
-
- CodecG729 :
- @(ndk-build -j6 APP_MODULES="pj_g729_codec")
- @(./dispatch_shared_libs.sh)
-
- VideoLibs : ffmpeg-lib
- @(ndk-build -j6 APP_MODULES="pj_video_android pj_vpx")
- @(./dispatch_shared_libs.sh)
-
- ScreenSharingLibs :
- @(ndk-build -j6 APP_MODULES="pj_screen_capture_android")
- @(./dispatch_shared_libs.sh)
CodecPackLibs :
@(ndk-build -j6 APP_MODULES="pj_g7221_codec pj_codec2_codec pj_g726_codec pj_opus_codec pj_aac_codec")
@(./dispatch_shared_libs.sh)
CodecG729 :
@(ndk-build -j6 APP_MODULES="pj_g729_codec")
@(./dispatch_shared_libs.sh)
VideoLibs : ffmpeg-lib
@(ndk-build -j6 APP_MODULES="pj_video_android pj_vpx")
@(./dispatch_shared_libs.sh)
ScreenSharingLibs :
@(ndk-build -j6 APP_MODULES="pj_screen_capture_android")
@(./dispatch_shared_libs.sh)
添加不同的功能,要编译的模块也不同,我一开始是先make的,这样先看看基本的模块编译是否有问题。
3.首先检查一下你的系统中是否安装如下工具:
[java] view plain copy print ?
- git quilt unzip wget swig2.0 python make yasm
git quilt unzip wget swig2.0 python make yasm
其中swig最好自己到官网下载一个最新的,现在好像是2.0.11
4.配置你的SDK,NDK环境变量,然后加到/ect/bash.bashrc下面,这部份自己到网上搜索一下。
5.make带着把,挺长的时间,这里声明一下我的环境:ubuntu12.04 ndk为r8d 32为系统,最后出现:
[java] view plain copy print ?
- # Dispatch to external projects
- Moving libpj_g7221_codec.so to CSipSimpleCodecPack project ... [--] - plugin not built
- Moving libpj_codec2_codec.so to CSipSimpleCodecPack project ... [--] - plugin not built
- Moving libpj_opus_codec.so to CSipSimpleCodecPack project ... [--] - plugin not built
- Moving libpj_g726_codec.so to CSipSimpleCodecPack project ... [--] - plugin not built
- Moving libpj_aac_codec.so to CSipSimpleCodecPack project ... [--] - plugin not built
- Moving libpj_g729_codec.so to CSipSimpleCodecG729 project ... [--] - plugin not built
- Moving libcrypto.so to CSipSimpleCrypto project ... [OK]
- Moving libssl.so to CSipSimpleCrypto project ... [OK]
- Moving libpj_video_android.so to CSipSimpleVideoPlugin project ... [--] - plugin not built
- Moving libpj_screen_capture_android.so to CSipSimpleVideoPlugin project ... [--] - plugin not built
- Moving libpj_vpx.so to CSipSimpleVideoPlugin project ... [--] - plugin not built
- # Build native library SUCCESSFUL
# Dispatch to external projects
Moving libpj_g7221_codec.so to CSipSimpleCodecPack project ... [--] - plugin not built
Moving libpj_codec2_codec.so to CSipSimpleCodecPack project ... [--] - plugin not built
Moving libpj_opus_codec.so to CSipSimpleCodecPack project ... [--] - plugin not built
Moving libpj_g726_codec.so to CSipSimpleCodecPack project ... [--] - plugin not built
Moving libpj_aac_codec.so to CSipSimpleCodecPack project ... [--] - plugin not built
Moving libpj_g729_codec.so to CSipSimpleCodecG729 project ... [--] - plugin not built
Moving libcrypto.so to CSipSimpleCrypto project ... [OK]
Moving libssl.so to CSipSimpleCrypto project ... [OK]
Moving libpj_video_android.so to CSipSimpleVideoPlugin project ... [--] - plugin not built
Moving libpj_screen_capture_android.so to CSipSimpleVideoPlugin project ... [--] - plugin not built
Moving libpj_vpx.so to CSipSimpleVideoPlugin project ... [--] - plugin not built
# Build native library SUCCESSFUL
说明编译成功了,这时你再到src目录下面查看org.pjsip下面就会有之前pjsua的目录,这个就是编译生成的,同时你也会看见插件
6.在上面的基础上我添加视频支持,所以在终端上 make VideoLibs来添加视频的支持,视频的支持需要ffmpeg第三方库,所以这是会编译ffmpeg添加h264的支持。
期间可能出错例如:
[java] view plain copy print ?
- make[1]: Leaving directory `/CSipSimple-trunk_new/CSipSimple/jni/ffmpeg'
- make: *** [ffmpeg-lib] Error 2
make[1]: Leaving directory `/CSipSimple-trunk_new/CSipSimple/jni/ffmpeg'
make: *** [ffmpeg-lib] Error 2
这个不用管,再一次运行make VideoLibs,最后经过了很长时间,最后如下:
[java] view plain copy print ?
- make[1]: Leaving directory `/CSipSimple-trunk_new/CSipSimple'
- Moving libpj_g7221_codec.so to CSipSimpleCodecPack project ... [--] - plugin not built
- Moving libpj_codec2_codec.so to CSipSimpleCodecPack project ... [--] - plugin not built
- Moving libpj_opus_codec.so to CSipSimpleCodecPack project ... [--] - plugin not built
- Moving libpj_g726_codec.so to CSipSimpleCodecPack project ... [--] - plugin not built
- Moving libpj_aac_codec.so to CSipSimpleCodecPack project ... [--] - plugin not built
- Moving libpj_g729_codec.so to CSipSimpleCodecG729 project ... [--] - plugin not built
- Moving libcrypto.so to CSipSimpleCrypto project ... [OK]
- Moving libssl.so to CSipSimpleCrypto project ... [OK]
- Moving libpj_video_android.so to CSipSimpleVideoPlugin project ... [OK]
- Moving libpj_screen_capture_android.so to CSipSimpleVideoPlugin project ... [--] - plugin not built
- Moving libpj_vpx.so to CSipSimpleVideoPlugin project ... [OK]
make[1]: Leaving directory `/CSipSimple-trunk_new/CSipSimple'
Moving libpj_g7221_codec.so to CSipSimpleCodecPack project ... [--] - plugin not built
Moving libpj_codec2_codec.so to CSipSimpleCodecPack project ... [--] - plugin not built
Moving libpj_opus_codec.so to CSipSimpleCodecPack project ... [--] - plugin not built
Moving libpj_g726_codec.so to CSipSimpleCodecPack project ... [--] - plugin not built
Moving libpj_aac_codec.so to CSipSimpleCodecPack project ... [--] - plugin not built
Moving libpj_g729_codec.so to CSipSimpleCodecG729 project ... [--] - plugin not built
Moving libcrypto.so to CSipSimpleCrypto project ... [OK]
Moving libssl.so to CSipSimpleCrypto project ... [OK]
Moving libpj_video_android.so to CSipSimpleVideoPlugin project ... [OK]
Moving libpj_screen_capture_android.so to CSipSimpleVideoPlugin project ... [--] - plugin not built
Moving libpj_vpx.so to CSipSimpleVideoPlugin project ... [OK]
我们需要的视频模块就编进去了,我们克隆的时候,出现5个文件,对应的也就是插件,编译出来的库并不在CSipSimple里面而且在CSipSimpleVideoPlugin文件夹下面,我们把相应的库拷贝到CSipSimple下的libs下面就可以了。
7.把项目导入到eclipse里面,运行一下结果如下:
自己也可以下载miniSIPServer来自己搭建一个服务器,我的测试效果如下: