pjsip+openh264 for Android 编译2019-03-04

环境 centos7 

附编译脚本,资源位置配置好运行即可

资源准备

1.在root下新建pjsip,上传以下资源解压

pjproject-2.7.1,(pjsip源码)

openh264-1.7.0(视频编码解码包)

https://github.com/cisco/openh264/archive/v1.7.0.tar.gz

swig-3.0.12,(swig包)

https://pan.baidu.com/s/1aGv8cUzAngzeWZ5xLAXzOQ

2.在opt目录下上传解压

ndk,(android-ndk-r13b-linux-x86_64,此处使用该版本,高版本与pjsip配置不兼容,不宜过高)

https://pan.baidu.com/s/1V-kSEwBfUcdbleqSPNzbsQ

3.在 /usr/lib 下创建文件夹jvm 上传 并解压

jdk-8u77-linux-x64.tar.gz

https://pan.baidu.com/s/1KnBlVMksJADQZ-2GMNcHbg

到/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 <pj/config_site_sample.h>

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

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 203,772评论 6 477
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,458评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,610评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,640评论 1 276
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,657评论 5 365
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,590评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,962评论 3 395
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,631评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,870评论 1 297
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,611评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,704评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,386评论 4 319
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,969评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,944评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,179评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 44,742评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,440评论 2 342

推荐阅读更多精彩内容