环境 centos7
附编译脚本,资源位置配置好运行即可
资源准备
1.在root下新建pjsip,上传以下资源解压
pjproject-2.7.1,(pjsip源码)
openh264-1.7.0(视频编码解码包)
swig-3.0.12,(swig包)
2.在opt目录下上传解压
ndk,(android-ndk-r13b-linux-x86_64,此处使用该版本,高版本与pjsip配置不兼容,不宜过高)
3.在 /usr/lib 下创建文件夹jvm 上传 并解压
jdk-8u77-linux-x64.tar.gz
到/etc/profile文件末尾添加
export PATH=/opt/android-ndk-r13b:$PATH
5.安装gcc/g++编辑器
已有可无视
[root@localhost pjmedia-audiodev]# yum install gcc*
[root@localhost pjmedia-audiodev]# yum install cc*
6.安装swig
[root@localhost pjsip]# tar -zxvf swig-3.0.12.tar.gz
[root@localhost pjsip]# yum install pcre*
[root@localhost swig-3.0.12]# cd swig-3.0.12
[root@localhost swig-3.0.12]# ./configure
[root@localhost swig-3.0.12]# make
[root@localhost swig-3.0.12]# make install
开始编译
1.pjsip/pjproject-2.7.1 修改configure-android 在首行添加如下配置
ANDROID_NDK_ROOT=/opt/android-ndk-r13b
2.进入/root/pjsip/pjproject-2.7.1/pjlib/include/pj 下
添加文件config_site.h
[root@localhost pj]# touch config_site.h
写入以下内容
#define PJ_CONFIG_ANDROID 1
//To enable video
#define PJMEDIA_HAS_VIDEO 1
//To enable libyuv
#define PJMEDIA_HAS_LIBYUV 1
//To enable TCP transport
#define PJ_HAS_TCP 1
#include
3.在pjmedia/src/pjmedia-audiodev下面有coreaudio_dev.m文件,没有对应的.c文件,添加coreaudio_dev.c
[root@localhost pjmedia-audiodev]# touch coreaudio_dev.c
复制
[root@localhost pjmedia-audiodev]# cat coreaudio_dev.m > coreaudio_dev.c
4.编译openh264.so
进入目录/root/pjsip/openh264-1.7.0执行 :make OS=android NDKROOT=/opt/android-ndk-r13b \
TARGET=android-22 NDKLEVEL=22 ARCH=arm APP_ABI=armeabi-v7a \
PREFIX=/root/pjsip/armeabi-v7a \
install-shared
生成目录:/root/pjsip/armeabi-v7a
5.编译pjsip+openh264的libpjsua2.so以及对应java文件
进入目录/root/pjsip/pjproject-2.7.1
执行 :NDK_TOOLCHAIN_VERSION=4.9 TARGET_ABI=armeabi-v7aTARGET_NAME=name APP_PLATFORM=android-22 ./configure-android --use-ndk-cflags --with-openh264=/root/pjsip/armeabi-v7a/
执行 :make dep && make clean && make
进入目录/root/pjsip/pjproject-2.7.1/pjsip-apps/src/swig
执行:make
生成libpjsua2.so目录:pjproject-2.7.1/pjsip-apps/src/swig/java/android/app/src/main/jniLibs
生成java目录:pjproject-2.7.1/pjsip-apps/src/swig/java/android/app/src/main
脚本编译
#! /bin/bash
#pjsip项目位置
pjsip_project_path='/root/pjsip/pjproject-2.7.1'
#ndk位置
ndk_path='/opt/android-ndk-r13b'
#目标版本
target='android-21'
#目标版本对应ndklevel
ndklevel='21'
#openh264 项目位置
openh264_path='/root/pjsip/openh264-master'
#openh264.so 生成位置
openh264abi_path='/root/pjsip/openh264abi'
#最终openh264.so以及libpjsua2.so位置
result_path='/root/pjsip/android'
echo -e "\n\n\n...........start check create pjsipabi dir....................."
if [ -d $result_path ];
then
echo $result_path "exists"
#do something
rm -rf $result_path
mkdir $result_path
mkdir $result_path/{x86,armeabi,arm64-v8a,x86_64,armeabi-v7a}
else
mkdir $result_path
mkdir $result_path/{x86,armeabi,arm64-v8a,x86_64,armeabi-v7a}
fi
echo -e "\n\n\n...........end check create pjsipabi dir....................."
sleep 3
echo -e "\n\n\n...........start check create openh264abi dir....................."
sleep 1
if [ -d $openh264abi_path ];
then
echo $openh264abi_path "exists"
#do something
rm -rf $openh264abi_path
mkdir $openh264abi_path
mkdir $openh264abi_path/{x86,armeabi,arm64-v8a,x86_64,armeabi-v7a}
else
mkdir $openh264abi_path
mkdir $openh264abi_path/{x86,armeabi,arm64-v8a,x86_64,armeabi-v7a}
fi
echo -e "\n\n\n...........end check create openh264abi dir....................."
#编译 x86
#编译openh264
cd $openh264_path
make clean
#清除未清理文件
if [ -f $openh264_path/codec/common/src/cpu-features.d ];then
rm -f $openh264_path/codec/common/src/cpu-features.d
else
echo -e "\n\n\n........... openh264 features....................."
fi
if [ -f $openh264_path/codec/common/src/cpu-features.o ];then
rm -f $openh264_path/codec/common/src/cpu-features.o
else
echo -e "\n\n\n........... openh264 features....................."
fi
sleep 5
echo -e "\n\n\n...........start openh264 x86....................."
export PATH = /root/pjsip/android-sdk-linux/tools:$PATH
make OS=android NDKROOT=$ndk_path TARGET=$target NDKLEVEL=$ndklevel ARCH=x86 APP_ABI=x86 PREFIX=$openh264abi_path/x86 install-shared
#编译pjsip
if [ ! -d $openh264abi_path/x86/lib ]; then
echo -e "\n\n\n...........error openh264 x86....................."
else
cd $pjsip_project_path
make clean
cd $pjsip_project_path/pjsip-apps/src/pjsua/android/jni
make clean
cd $pjsip_project_path/pjsip-apps/src/swig
make clean
cd $pjsip_project_path
NDK_TOOLCHAIN_VERSION=4.9 TARGET_ABI=x86 APP_PLATFORM=$target ./configure-android --use-ndk-cflags --with-openh264=$openh264abi_path/x86/
make dep && make clean && make
cd $pjsip_project_path/pjsip-apps/src/swig
make
cd $pjsip_project_path/pjsip-apps/src/swig/java/android/app/src/main/jniLibs/armeabi
cp libpjsua2.so $result_path/x86
if [ $?=0 ];then
echo "cp libpjsua2.so ok"
cd $openh264abi_path/x86/lib
cp libopenh264.so $result_path/x86
if [ $?=0 ];then
echo "cp libopenh264.so ok"
else
echo "cp libopenh264.so error"
fi
else
echo "cp libpjsua2.so error"
fi
fi
echo -e "\n\n\n...........end x86....................."
sleep 10
#编译 armeabi
#编译openh264
cd $openh264_path
make clean
#清除未清理文件
if [ -f $openh264_path/codec/common/src/cpu-features.d ];then
rm -f $openh264_path/codec/common/src/cpu-features.d
else
echo -e "\n\n\n........... openh264 features....................."
fi
if [ -f $openh264_path/codec/common/src/cpu-features.o ];then
rm -f $openh264_path/codec/common/src/cpu-features.o
else
echo -e "\n\n\n........... openh264 features....................."
fi
sleep 5
echo -e "\n\n\n...........start openh264 armeabi....................."
export PATH = /root/pjsip/android-sdk-linux/tools:$PATH
make OS=android NDKROOT=$ndk_path TARGET=$target NDKLEVEL=$ndklevel ARCH=arm APP_ABI=armeabi PREFIX=$openh264abi_path/armeabi install-shared
#编译pjsip
if [ ! -d $openh264abi_path/armeabi/lib ]; then
echo -e "\n\n\n...........error openh264 armeabi....................."
else
cd $pjsip_project_path
make clean
cd $pjsip_project_path/pjsip-apps/src/pjsua/android/jni
make clean
cd $pjsip_project_path/pjsip-apps/src/swig
make clean
cd $pjsip_project_path
NDK_TOOLCHAIN_VERSION=4.9 TARGET_ABI=armeabi APP_PLATFORM=$target ./configure-android --use-ndk-cflags --with-openh264=$openh264abi_path/armeabi/
make dep && make clean && make
cd $pjsip_project_path/pjsip-apps/src/swig
make
cd $pjsip_project_path/pjsip-apps/src/swig/java/android/app/src/main/jniLibs/armeabi
cp libpjsua2.so $result_path/armeabi
if [ $?=0 ];then
echo "cp libpjsua2.so ok"
cd $openh264abi_path/armeabi/lib
cp libopenh264.so $result_path/armeabi
if [ $?=0 ];then
echo "cp libopenh264.so ok"
else
echo "cp libopenh264.so error"
fi
else
echo "cp libpjsua2.so error"
fi
fi
echo -e "\n\n\n...........end armeabi....................."
sleep 10
#编译 armeabi-v7a
#编译openh264
cd $openh264_path
make clean
#清除未清理文件
if [ -f $openh264_path/codec/common/src/cpu-features.d ];then
rm -f $openh264_path/codec/common/src/cpu-features.d
else
echo -e "\n\n\n........... openh264 features....................."
fi
if [ -f $openh264_path/codec/common/src/cpu-features.o ];then
rm -f $openh264_path/codec/common/src/cpu-features.o
else
echo -e "\n\n\n........... openh264 features....................."
fi
sleep 5
echo -e "\n\n\n...........start openh264 armeabi-v7a....................."
export PATH = /root/pjsip/android-sdk-linux/tools:$PATH
make OS=android NDKROOT=$ndk_path TARGET=$target NDKLEVEL=$ndklevel ARCH=arm APP_ABI=armeabi-v7a PREFIX=$openh264abi_path/armeabi-v7a install-shared
#编译pjsip
if [ ! -d $openh264abi_path/armeabi-v7a/lib ]; then
echo -e "\n\n\n...........error openh264 armeabi-v7a....................."
else
cd $pjsip_project_path
make clean
cd $pjsip_project_path/pjsip-apps/src/pjsua/android/jni
make clean
cd $pjsip_project_path/pjsip-apps/src/swig
make clean
cd $pjsip_project_path
NDK_TOOLCHAIN_VERSION=4.9 TARGET_ABI=armeabi-v7a APP_PLATFORM=$target ./configure-android --use-ndk-cflags --with-openh264=$openh264abi_path/armeabi-v7a/
make dep && make clean && make
cd $pjsip_project_path/pjsip-apps/src/swig
make
cd $pjsip_project_path/pjsip-apps/src/swig/java/android/app/src/main/jniLibs/armeabi
cp libpjsua2.so $result_path/armeabi-v7a
if [ $?=0 ];then
echo "cp libpjsua2.so ok"
cd $openh264abi_path/armeabi-v7a/lib
cp libopenh264.so $result_path/armeabi-v7a
if [ $?=0 ];then
echo "cp libopenh264.so ok"
else
echo "cp libopenh264.so error"
fi
else
echo "cp libpjsua2.so error"
fi
fi
echo -e "\n\n\n...........end armeabi-v7a....................."
sleep 10
#编译 arm64
#编译openh264
cd $openh264_path
make clean
#清除未清理文件
if [ -f $openh264_path/codec/common/src/cpu-features.d ];then
rm -f $openh264_path/codec/common/src/cpu-features.d
else
echo -e "\n\n\n........... openh264 features....................."
fi
if [ -f $openh264_path/codec/common/src/cpu-features.o ];then
rm -f $openh264_path/codec/common/src/cpu-features.o
else
echo -e "\n\n\n........... openh264 features....................."
fi
sleep 5
echo -e "\n\n\n...........start openh264 arm64....................."
export PATH = /root/pjsip/android-sdk-linux/tools:$PATH
make OS=android NDKROOT=$ndk_path TARGET=$target NDKLEVEL=$ndklevel ARCH=arm64 APP_ABI=arm64-v8a PREFIX=$openh264abi_path/arm64-v8a install-shared
#编译pjsip
if [ ! -d $openh264abi_path/arm64-v8a/lib ]; then
echo -e "\n\n\n...........error openh264 arm64....................."
else
cd $pjsip_project_path
make clean
cd $pjsip_project_path/pjsip-apps/src/pjsua/android/jni
make clean
cd $pjsip_project_path/pjsip-apps/src/swig
make clean
cd $pjsip_project_path
NDK_TOOLCHAIN_VERSION=4.9 TARGET_ABI=arm64-v8a APP_PLATFORM=$target ./configure-android --use-ndk-cflags --with-openh264=$openh264abi_path/arm64-v8a/
make dep && make clean && make
cd $pjsip_project_path/pjsip-apps/src/swig
make
cd $pjsip_project_path/pjsip-apps/src/swig/java/android/app/src/main/jniLibs/armeabi
cp libpjsua2.so $result_path/arm64-v8a
if [ $?=0 ];then
echo "cp libpjsua2.so ok"
cd $openh264abi_path/arm64-v8a/lib
cp libopenh264.so $result_path/arm64-v8a
if [ $?=0 ];then
echo "cp libopenh264.so ok"
else
echo "cp libopenh264.so error"
fi
else
echo "cp libpjsua2.so error"
fi
fi
echo -e "\n\n\n...........end arm64....................."
sleep 10
#编译 x86_64
#编译openh264
cd $openh264_path
make clean
#清除未清理文件
if [ -f $openh264_path/codec/common/src/cpu-features.d ];then
rm -f $openh264_path/codec/common/src/cpu-features.d
else
echo -e "\n\n\n........... openh264 features....................."
fi
if [ -f $openh264_path/codec/common/src/cpu-features.o ];then
rm -f $openh264_path/codec/common/src/cpu-features.o
else
echo -e "\n\n\n........... openh264 features....................."
fi
sleep 5
echo -e "\n\n\n...........start openh264 x86_64....................."
export PATH = /root/pjsip/android-sdk-linux/tools:$PATH
make OS=android NDKROOT=$ndk_path TARGET=$target NDKLEVEL=$ndklevel ARCH=x86_64 APP_ABI=x86_64 PREFIX=$openh264abi_path/x86_64 install-shared
#编译pjsip
if [ ! -d $openh264abi_path/x86_64/lib ]; then
echo -e "\n\n\n...........error openh264 x86_64....................."
else
cd $pjsip_project_path
make clean
cd $pjsip_project_path/pjsip-apps/src/pjsua/android/jni
make clean
cd $pjsip_project_path/pjsip-apps/src/swig
make clean
cd $pjsip_project_path
NDK_TOOLCHAIN_VERSION=4.9 TARGET_ABI=x86_64 APP_PLATFORM=$target ./configure-android --use-ndk-cflags --with-openh264=$openh264abi_path/x86_64/
make dep && make clean && make
cd $pjsip_project_path/pjsip-apps/src/swig
make
cd $pjsip_project_path/pjsip-apps/src/swig/java/android/app/src/main/jniLibs/armeabi
cp libpjsua2.so $result_path/x86_64
if [ $?=0 ];then
echo "cp libpjsua2.so ok"
cd $openh264abi_path/x86_64/lib
cp libopenh264.so $result_path/x86_64
if [ $?=0 ];then
echo "cp libopenh264.so ok"
else
echo "cp libopenh264.so error"
fi
else
echo "cp libpjsua2.so error"
fi
fi
echo -e "\n\n\n...........end x86_64....................."
脚本链接:https://pan.baidu.com/s/13g1_blWuqjEEx_MUeYO75w 提取码:znto