Android 下 libvpx &&H264编译 以及集成进 pjsip

编译libvpx(Linux下)

1下载libvpx原代码
https://github.com/webmproject/libvpx/releases

2 下载Android NDK 最新版
https://developer.android.google.cn/ndk/downloads/

3下载Java jdk
https://pan.baidu.com/s/1BK65e5Qr5UsghepfXoWbXA
提取码 java

4 配置java jdk

 $tar zxvf jdk-8u77-linux-x64.tar.gz
   
 将解压好的jdk1.8.0_77文件夹用最高权限复制到 /usr/lib/jvm/jdk1.8.0_77 目录里。jvm/jdk1.8.0_77目录自己新建。
  
 $sudo cp -r  ./jdk1.8.0_77/   /usr/lib/jvm/jdk1.8.0_77/
 
 拷贝完后,进入/usr/lib/jvm/jdk1.8.0_77目录,查看jdk文件是否都拷贝到该目录下
 配置环境变量,保存成env.sh,env.sh后面经常会用到,保存成文件,用时会方便点。
 #!/bin/sh
  export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_77
  export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
    export PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin:
           保存成env.sh文件后执行,当然你不嫌累,可以一条的执行:
 $source env.sh
 将系统默认的JDK修改成自己的JDK
$sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.8.0_77/bin/java 300
$sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.8.0_77/bin/javac 300
$sudo update-alternatives --config java
$sudo update-alternatives --config javac

查看JDK安装是否成功
 $java -version
 如果成功,显示如下信息,如果不显示下面信息,请检查前面设置安装是否正确:
 java version "1.8.0_77"
Java(TM) SE Runtime Environment (build 1.8.0_77-b03)
Java HotSpot(TM) 64-Bit Server VM (build 25.77-b03, mixed mode)
 

5配置环境变量
export NDK=/path/to/Android-NDK
export HOST_TAG=linux-x86_64 # adjust to your building host
export TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/$HOST_TAG
export AR=$TOOLCHAIN/bin/aarch64-linux-android-ar
export AS=$TOOLCHAIN/bin/aarch64-linux-android-as
export CC=$TOOLCHAIN/bin/aarch64-linux-android21-clang
export CXX=$TOOLCHAIN/bin/aarch64-linux-android21-clang++
export LD=$TOOLCHAIN/bin/aarch64-linux-android-ld
export RANLIB=$TOOLCHAIN/bin/aarch64-linux-android-ranlib
export STRIP=$TOOLCHAIN/bin/aarch64-linux-android-strip

4编译命令 进入libvpx根目录
./configure --target=arm64-android-gcc --enable-pic --disable-examples
–disable-tools --disable-docs --enable-realtime-only
–disable-install-bins --disable-unit-tests --disable-webm-io
–disable-libyuv
–prefix=/path/to/target/installation
生成静态文件库,安装路径后面集成有用

编译H264

1 下载 h264原代码
https://codeload.github.com/cisco/openh264/zip/v1.6.0

2 下载 Android sdk
android-sdk_r24.4.1-linux.tgz

3 配置环境变量
export ANDROID_SDK_ROOT=/home/xxx/PJSIP/android-sdk-linux
export PATH=$ANDROID_SDK_ROOT/tools:$PATH
上面中xxx为我的工作目录。ANDROID_SDK_ROOT变量请根据自己的SDK路径配置。

4 下载ndk 版本13rb (h264 需要使用老版本ndk编译)
android-ndk-r13b-linux-x86_64.zip

5编译
$make OS=android NDKROOT=/home/xxx/PJSIP/android-ndk-r13b TARGET=android-22 PREFIX=./androidlib install-shared
安装的路径androidlib 后面集成进pjsip 有用,
生成的openh264也有用

集成libvpx && h264 进pjsip

1 下载pjsip2.10
https://github.com/pjsip/pjproject/releases
链接2
https://pjsip.org/download.htm

2 修改配置文件 进入目录/pjlib/include/pj/ 创建文件 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:编译

TARGET_ABI=armeabi-v7a  
APP_PLATFORM=android-22 
./configure-android --use-ndk-cflags 
--with-vpx=/path/to/target/installation
--with-openh264=./androidlib 

注意:
--with-vpx =编译libvpx 后j静态库安装的路径
--with-openh264=编译openh264后安装的路径
两个集成 可单独执行,集成单独一个

根据提示执行:
make dep && make clean && make

最后进入 cd pjsip-apps/src/swig 执行make 命令 生成 jni 文件
以及so库


重新编译一次 需要 clean三个地方
$ cd /path/to/your/pjsip/dir
$ make clean

# cleanup pjsua sample app
$ cd pjsip-apps/src/pjsua/android/jni
$ make clean

# also cleanup pjsua2 sample app (SWIG)
$ cd /path/to/your/pjsip/dir
$ cd pjsip-apps/src/swig
$ make clean

注意

如果系统默认安装的swig 版本不能低于2.05 可使用 swig -version 查看
可使用linux 4.02
链接:https://pan.baidu.com/s/1NQBxMrqdQJFzlQLdcKGsHg
提取码:java
复制这段内容后打开百度网盘手机App,操作更方便哦

我在ubuntu 中执行编译 2.10的代码会报错,

pjmedia_format_id.java
pjmedia_event_type.java
使用老版本直接替换

 * This file was automatically generated by SWIG (http://www.swig.org).
 * Version 4.0.1
 *
 * Do not make changes to this file unless you know what you are doing--modify
 * the SWIG interface file instead.
 * ----------------------------------------------------------------------------- */

package org.pjsip.pjsua2;

public final class pjmedia_format_id {
  public final static int PJMEDIA_FORMAT_L16 = 0;
  public final static int PJMEDIA_FORMAT_PCM = PJMEDIA_FORMAT_L16;
  public final static int PJMEDIA_FORMAT_PCMA = ((('W' << 24)|('A' << 16))|('L' << 8))|'A';
  public final static int PJMEDIA_FORMAT_ALAW = PJMEDIA_FORMAT_PCMA;
  public final static int PJMEDIA_FORMAT_PCMU = ((('W' << 24)|('A' << 16))|('L' << 8))|'u';
  public final static int PJMEDIA_FORMAT_ULAW = PJMEDIA_FORMAT_PCMU;
  public final static int PJMEDIA_FORMAT_AMR = ((('R' << 24)|('M' << 16))|('A' << 8))|' ';
  public final static int PJMEDIA_FORMAT_G729 = ((('9' << 24)|('2' << 16))|('7' << 8))|'G';
  public final static int PJMEDIA_FORMAT_ILBC = ((('C' << 24)|('B' << 16))|('L' << 8))|'I';
  public final static int PJMEDIA_FORMAT_RGB24 = ((('3' << 24)|('B' << 16))|('G' << 8))|'R';
  public final static int PJMEDIA_FORMAT_RGBA = ((('A' << 24)|('B' << 16))|('G' << 8))|'R';
  public final static int PJMEDIA_FORMAT_BGRA = ((('A' << 24)|('R' << 16))|('G' << 8))|'B';
  public final static int PJMEDIA_FORMAT_RGB32 = PJMEDIA_FORMAT_RGBA;
  public final static int PJMEDIA_FORMAT_DIB = (((' ' << 24)|('B' << 16))|('I' << 8))|'D';
  public final static int PJMEDIA_FORMAT_GBRP = ((('P' << 24)|('R' << 16))|('B' << 8))|'G';
  public final static int PJMEDIA_FORMAT_AYUV = ((('V' << 24)|('U' << 16))|('Y' << 8))|'A';
  public final static int PJMEDIA_FORMAT_YUY2 = ((('2' << 24)|('Y' << 16))|('U' << 8))|'Y';
  public final static int PJMEDIA_FORMAT_UYVY = ((('Y' << 24)|('V' << 16))|('Y' << 8))|'U';
  public final static int PJMEDIA_FORMAT_YVYU = ((('U' << 24)|('Y' << 16))|('V' << 8))|'Y';
  public final static int PJMEDIA_FORMAT_I420 = ((('0' << 24)|('2' << 16))|('4' << 8))|'I';
  public final static int PJMEDIA_FORMAT_IYUV = PJMEDIA_FORMAT_I420;
  public final static int PJMEDIA_FORMAT_YV12 = ((('2' << 24)|('1' << 16))|('V' << 8))|'Y';
  public final static int PJMEDIA_FORMAT_NV21 = ((('1' << 24)|('2' << 16))|('V' << 8))|'N';
  public final static int PJMEDIA_FORMAT_I422 = ((('2' << 24)|('2' << 16))|('4' << 8))|'I';
  public final static int PJMEDIA_FORMAT_I420JPEG = ((('0' << 24)|('2' << 16))|('4' << 8))|'J';
  public final static int PJMEDIA_FORMAT_I422JPEG = ((('2' << 24)|('2' << 16))|('4' << 8))|'J';
  public final static int PJMEDIA_FORMAT_H261 = ((('1' << 24)|('6' << 16))|('2' << 8))|'H';
  public final static int PJMEDIA_FORMAT_H263 = ((('3' << 24)|('6' << 16))|('2' << 8))|'H';
  public final static int PJMEDIA_FORMAT_H263P = ((('3' << 24)|('6' << 16))|('2' << 8))|'P';
  public final static int PJMEDIA_FORMAT_H264 = ((('4' << 24)|('6' << 16))|('2' << 8))|'H';
  public final static int PJMEDIA_FORMAT_MJPEG = ((('G' << 24)|('P' << 16))|('J' << 8))|'M';
  public final static int PJMEDIA_FORMAT_MPEG1VIDEO = ((('V' << 24)|('1' << 16))|('P' << 8))|'M';
  public final static int PJMEDIA_FORMAT_MPEG2VIDEO = ((('V' << 24)|('2' << 16))|('P' << 8))|'M';
  public final static int PJMEDIA_FORMAT_MPEG4 = ((('4' << 24)|('G' << 16))|('P' << 8))|'M';
}
 * Version 4.0.1
 *
 * Do not make changes to this file unless you know what you are doing--modify
 * the SWIG interface file instead.
 * ----------------------------------------------------------------------------- */

package org.pjsip.pjsua2;

public final class pjmedia_event_type {
  public final static int PJMEDIA_EVENT_NONE = 0;
  public final static int PJMEDIA_EVENT_FMT_CHANGED = ((('H' << 24)|('C' << 16))|('M' << 8))|'F';
  public final static int PJMEDIA_EVENT_WND_CLOSING = ((('L' << 24)|('C' << 16))|('N' << 8))|'W';
  public final static int PJMEDIA_EVENT_WND_CLOSED = ((('O' << 24)|('C' << 16))|('N' << 8))|'W';
  public final static int PJMEDIA_EVENT_WND_RESIZED = ((('Z' << 24)|('R' << 16))|('N' << 8))|'W';
  public final static int PJMEDIA_EVENT_MOUSE_BTN_DOWN = ((('N' << 24)|('D' << 16))|('S' << 8))|'M';
  public final static int PJMEDIA_EVENT_KEYFRAME_FOUND = ((('F' << 24)|('R' << 16))|('F' << 8))|'I';
  public final static int PJMEDIA_EVENT_KEYFRAME_MISSING = ((('M' << 24)|('R' << 16))|('F' << 8))|'I';
  public final static int PJMEDIA_EVENT_ORIENT_CHANGED = ((('T' << 24)|('N' << 16))|('R' << 8))|'O';
  public final static int PJMEDIA_EVENT_RX_RTCP_FB = ((('B' << 24)|('F' << 16))|('T' << 8))|'R';
  public final static int PJMEDIA_EVENT_AUD_DEV_ERROR = ((('R' << 24)|('R' << 16))|('E' << 8))|'A';
  public final static int PJMEDIA_EVENT_VID_DEV_ERROR = ((('R' << 24)|('R' << 16))|('E' << 8))|'V';
  public final static int PJMEDIA_EVENT_MEDIA_TP_ERR = ((('R' << 24)|('R' << 16))|('E' << 8))|'T';
}


上一篇:AIR串口通信


下一篇:Python – 如何获取导入pjsua?没有给出名为pjsua的模块