鲲鹏920(ARM64) kurento-media-server移植指南 for Ubuntu 18.04
简介
Kurento是一个 WebRTC媒体服务器和一组客户端API,可简化Web和智能手机平台的高级视频应用程序的开发。其功能包括视听流的群组通信,转码,录制,混合,广播和路由。Kurento需要搭建kurento-media-server组件。
官方链接:https://doc-kurento.readthedocs.io
类别:媒体服务器
1 环境
类别 | 子项 | 版本 | 获取地址(方法) |
硬件 | CPU | 鲲鹏920 | -- |
网络 | Ethernet | -- | |
存储 | SAS 1.090T | -- | |
内存 | 254G 2666MHz | -- | |
OS | CentOS | Ubuntu 18.04 | |
Kernel | 4.15.0-29-generic | ||
软件 | GCC | 7.4.0 | |
kurento-media-server |
2 依赖安装
2.1 apt安装的依赖项
已经连接外网,且外网源可用。
apt安装相关依赖:
sudo apt-get install -y openjdk-11-jdk sudo apt-get install -y gcc sudo apt-get install -y pkg-config autoconf automake libtool autopoint gcc bison flex gtk-doc-tools cmake maven libboost-all-dev libbz2-dev libx11-dev libxext-dev libxfixes-dev libx264-dev libcairo2-dev libtheora-dev libvorbis-dev libxv-dev libvorbisidec-dev libvisual-0.4 libogg-dev libcairo-dev libflac-dev libjack-dev libcaca-dev libdv-dev libpng-dev libpulse-dev libraw1394-dev libiec61883-dev libshout-dev libspeex-dev libwavpack-dev libopencore-amrnb-dev libopencore-amrwb-dev libcdio-dev libx264-dev libopencv-dev sigc++ glibmm-2.4 libvpx-dev libsoup2.4-dev |
2.2 GCC增加全局编译选项(ARM和X86的区别)
在X86上建立的char类型默认是有符号的,而在ARM上建立char字符默认是无符号的,需要增加编译选项-fsigned-char防止后续出问题。
which gcc找到gcc,在gcc目录下
mv gcc gcc-impl vi gcc #增加如下内容 #! /bin/sh /usr/bin/gcc-impl -fsigned-char "$@" #:wq保存退出 chmod 755 gcc #增加执行权限 |
which g++找到g++,在g++目录下
mv g++ g++-impl vi g++ #增加如下内容 #! /bin/sh /usr/bin/g++-impl -fsigned-char "$@" #:wq保存退出 chmod 755 g++ #增加执行权限 |
which c++找到c++,在c++目录下
mv c++ c++-impl vi c++ #增加如下内容 #! /bin/sh /usr/bin/c++-impl -fsigned-char "$@" #:wq保存退出 chmod 755 c++ #增加执行权限 |
2.3 编译安装其它依赖项
这里所有的编译安装的路径都是非/usr/local或者/usr路径的,如果需要安装到/usr/local或者/usr,请将编译中指定的--prefix=$KMS_BUILD_HOME路径进行修改。
2.3.1 设置kms环境变量
2.3.1.1 在/etc/profile中增加如下字段:
export KMS_HOME=/home/test/kms_source #这里根据自己需求修改路径 # KMS编译目录 export KMS_BUILD_HOME=$KMS_HOME/build/kms export CMAKE_MODULES_PATH=${KMS_BUILD_HOME}/share/cmake-3.10/Modules #cmake-3.5要根据实际cmake版本号填 # 导入编译所需的环境变量 export CMAKE_OPTS="-DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_MODULE_PATH:STRING=${CMAKE_MODULES_PATH} -DKURENTO_MODULES_DIR:STRING=${KMS_BUILD_HOME}/share/kurento/modules" export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$KMS_BUILD_HOME/lib/pkgconfig export LIBRARY_PATH=$LIBRARY_PATH:$KMS_BUILD_HOME/lib export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$KMS_BUILD_HOME/lib export CPATH=$CPATH:$KMS_BUILD_HOME/include:$KMS_BUILD_HOME/include/gstreamer-1.5 export PATH=$PATH:$KMS_BUILD_HOME/bin JAVA_CMD=$(which java) |
2.3.1.2 创建需要的文件夹
mkdir -p ${KMS_HOME} mkdir -p ${KMS_BUILD_HOME} mkdir -p ${KMS_BUILD_HOME}/bin |
2.3.2 编译安装gstreamer
cd ${KMS_HOME} git clone https://github.com/Kurento/gstreamer.git cd gstreamer git checkout kms6.6.0 #安装相关依赖 for i in `cat debian/control|sed -n '/Build-Depends/,/Standards-Version/'p|sed s/Build-Depends://g |sed s/Build-Depends-Indep://g|grep -v Standards-Version|awk '{print $1}'|sed s/\,//g |grep -v gstreamer`; do sudo apt install $i -y;done ./autogen.sh # introspection requires python >= 2.7 ./configure --enable-introspection=no --prefix=$KMS_BUILD_HOME make -j 64&& make -j 64 install |
2.3.3 编译安装openssl
cd ${KMS_HOME} wget https://www.openssl.org/source/old/1.0.2/openssl-1.0.2g.tar.gz tar -zxvf openssl-1.0.2g.tar.gz cd openssl-1.0.2g ./config shared --prefix=$KMS_BUILD_HOME make -j 64&&make -j64 install |
2.3.4 编译安装libsrtp
cd ${KMS_HOME} git clone https://github.com/Kurento/libsrtp.git cd libsrtp ./configure --build=aarch64-unknown-linux-gnu --prefix=$KMS_BUILD_HOME make -j64 && make -j64 install |
2.3.5 编译安装nasm
cd ${KMS_HOME} wget https://www.nasm.us/pub/nasm/releasebuilds/2.13.02/nasm-2.13.02.tar.gz tar -xzvf nasm-2.13.02.tar.gz cd nasm-2.13.02 ./configure --build=aarch64-unknown-linux-gnu --prefix=$KMS_BUILD_HOME make -j64&& make -j64 install |
2.3.6 编译安装openh264
cd ${KMS_HOME} git clone https://github.com/cisco/openh264.git cd openh264 git checkout v1.4.0 make -j64&& make -j64 install PREFIX=$KMS_BUILD_HOME |
2.3.7 编译安装usrsctp
cd ${KMS_HOME} git clone https://github.com/Kurento/usrsctp.git cd usrsctp ./bootstrap ./configure --build=aarch64-unknown-linux-gnu --prefix=$KMS_BUILD_HOME #执行两遍是因为第一次执行./bootstrap可能不成功,需要执行./configure再次执行正常,如果没有报错,只执行一遍 ./bootstrap ./configure --build=aarch64-unknown-linux-gnu --prefix=$KMS_BUILD_HOME make -j64&& make -j64 install |
2.3.8 编译安装opus
cd ${KMS_HOME} wget https://archive.mozilla.org/pub/opus/opus-1.2.1.tar.gz tar -zxvf opus-1.2.1.tar.gz cd opus-1.2.1 ./configure --build=aarch64-unknown-linux-gnu --prefix=$KMS_BUILD_HOME make -j64 && make -j64 install |
2.3.9 编译安装orc
cd ${KMS_HOME} wget https://gstreamer.freedesktop.org/src/orc/orc-0.4.28.tar.xz tar -Jxvf orc-0.4.28.tar.xz cd orc-0.4.28 ./configure --build=aarch64-unknown-linux-gnu --prefix=$KMS_BUILD_HOME make -j64&& make -j64 install |
2.3.10 编译安装jsoncpp
cd ${KMS_HOME} git clone https://github.com/Kurento/jsoncpp.git cd jsoncpp git checkout kms6.6.0 mkdir -p build && cd build cmake -DCMAKE_INSTALL_PREFIX=$KMS_BUILD_HOME $CMAKE_OPTS .. sed -i s/"CXX_FLAGS = "/"CXX_FLAGS = \-fPIC "/g ./src/test_lib_json/CMakeFiles/jsoncpp_test.dir/flags.make sed -i s/"CXX_FLAGS = "/"CXX_FLAGS = \-fPIC "/g ./src/lib_json/CMakeFiles/jsoncpp_lib_static.dir/flags.make sed -i s/"CXX_FLAGS = "/"CXX_FLAGS = \-fPIC "/g ./src/jsontestrunner/CMakeFiles/jsontestrunner_exe.dir/flags.make #cmake编译选项中增加-fPIC,否则编译kms-jsonrpc有报错 make -j64&& make -j64 install sed -i 's/\/kmsjsoncpp//g' $KMS_BUILD_HOME/lib/pkgconfig/kmsjsoncpp.pc # 否则编译kms-jsonrpc会报错 fatal error: json/json.h: No such file or directory |
2.3.11 编译安装gst-plugins-base
cd ${KMS_HOME} git clone https://github.com/Kurento/gst-plugins-base.git cd gst-plugins-base git checkout kms6.6.0 #安装相关依赖 for i in `for i in \`cat debian/control|sed -n '/Build-Depends/,/Standards-Version/'p|sed s/Build-Depends://g |sed s/Build-Depends-Indep://g|grep -v Standards-Version|sed s/\,//g \`; do echo $i |grep -v gstreamer;done`;do sudo apt install $i -y;done ./autogen.sh ./configure --build=aarch64-unknown-linux-gnu --enable-introspection=no --prefix=$KMS_BUILD_HOME make -j64&& make -j64 install |
2.3.12 编译安装gst-plugins-good
cd ${KMS_HOME} git clone https://github.com/Kurento/gst-plugins-good.git cd gst-plugins-good git checkout kms6.6.0 #安装相关依赖 for i in `for i in \`cat debian/control|sed -n '/Build-Depends/,/Standards-Version/'p|sed s/Build-Depends://g |sed s/Build-Depends-Indep://g|grep -v Standards-Version|sed s/\,//g \`; do echo $i |grep -v gstreamer;done`;do sudo apt install $i -y;done ./autogen.sh ./configure --build=aarch64-unknown-linux-gnu --enable-introspection=no --prefix=$KMS_BUILD_HOME #执行两遍是因为第一次执行./autogen.sh可能不成功,需要执行./configure再次执行正常,如果没有报错,只执行一遍 ./autogen.sh ./configure --build=aarch64-unknown-linux-gnu --enable-introspection=no --prefix=$KMS_BUILD_HOME make -j64&& make -j64 install |
2.3.13 编译安装gst-plugins-ugly
cd ${KMS_HOME} git clone https://github.com/Kurento/gst-plugins-ugly.git cd gst-plugins-ugly git checkout kms6.6.0 #安装相关依赖 for i in `cat debian/control|sed -n '/Build-Depends/,/Standards-Version/'p|sed s/Build-Depends://g |sed s/Build-Depends-Indep://g|grep -v Standards-Version|awk '{print $1}'|sed s/\,//g |grep -v gstreamer`; do sudo apt install $i -y;done ./autogen.sh ./configure --build=aarch64-unknown-linux-gnu --enable-introspection=no --prefix=$KMS_BUILD_HOME #执行两遍是因为第一次执行./autogen.sh可能不成功,需要执行./configure再次执行正常,如果没有报错,只执行一遍 ./autogen.sh ./configure --build=aarch64-unknown-linux-gnu --enable-introspection=no --prefix=$KMS_BUILD_HOME make -j64&& make -j64 install |
2.3.14 编译安装gst-plugins-bad
cd ${KMS_HOME} git clone https://github.com/Kurento/gst-plugins-bad.git cd gst-plugins-bad git checkout kms6.6.0 #安装相关依赖 for i in `cat debian/control|sed -n '/Build-Depends/,/Standards-Version/'p|sed s/Build-Depends://g |sed s/Build-Depends-Indep://g|grep -v Standards-Version|awk '{print $1}'|sed s/\,//g |grep -v gstreamer`; do sudo apt install $i -y;done ./autogen.sh ./configure --build=aarch64-unknown-linux-gnu --enable-introspection=no --prefix=$KMS_BUILD_HOME #执行两遍是因为第一次执行./autogen.sh可能不成功,需要执行./configure再次执行正常,如果没有报错,只执行一遍 ./autogen.sh ./configure --build=aarch64-unknown-linux-gnu --enable-introspection=no --prefix=$KMS_BUILD_HOME make -j64 && make -j64 install |
2.3.15 编译安装gst-libav
cd ${KMS_HOME} git clone https://github.com/Kurento/gst-libav.git cd gst-libav git checkout kms6.6.0 #安装相关依赖 for i in `cat debian/control|sed -n '/Build-Depends/,/Standards-Version/'p|sed s/Build-Depends://g |sed s/Build-Depends-Indep://g|grep -v Standards-Version|awk '{print $1}'|sed s/\,//g |grep -v gstreamer`; do sudo apt install $i -y;done ./autogen.sh ./configure --build=aarch64-unknown-linux-gnu --enable-introspection=no --prefix=$KMS_BUILD_HOME #执行两遍是因为第一次执行./autogen.sh可能不成功,需要执行./configure再次执行正常,如果没有报错,只执行一遍 ./autogen.sh ./configure --build=aarch64-unknown-linux-gnu --enable-introspection=no --prefix=$KMS_BUILD_HOME && make -j64&& make -j64 installlinux-gnu --prefix=$KMS_BUILD_HOME make -j64&& make -j64 install |
2.3.16 编译安装openwebrtc-gst-plugins
cd ${KMS_HOME} git clone https://github.com/Kurento/openwebrtc-gst-plugins.git cd openwebrtc-gst-plugins libtoolize -v libtoolize --automake --copy --debug --force ./autogen.sh ./configure --build=aarch64-unknown-linux-gnu --prefix=$KMS_BUILD_HOME #执行两遍是因为第一次执行./autogen.sh可能不成功,需要执行./configure再次执行正常,如果没有报错,只执行一遍 ./autogen.sh ./configure --build=aarch64-unknown-linux-gnu --prefix=$KMS_BUILD_HOME && make -j64 && make -j64 install |
2.3.17 编译安装libnice
cd ${KMS_HOME} git clone https://github.com/Kurento/libnice.git cd libnice ./autogen.sh vi configure #如下图修改 # 或者执行如下修改configure,因为configure中只会找gstreamer1.0: sed -i s/gstreamer-1.0/gstreamer-1.5/g configure sed -i s/gstreamer-base-1.0/gstreamer-base-1.5/g configure sed -i s/gstreamer-check-1.0/gstreamer-check-1.5/g configure sed -i s/GST_MAJORMINOR=1.0/GST_MAJORMINOR=1.5/g configure ./configure --build=aarch64-unknown-linux-gnu --enable-introspection=no --prefix=$KMS_BUILD_HOME make -j64 install |
2.3.18 编译安装libevent
cd ${KMS_HOME} cd ${KMS_HOME} wget https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz tar -xzvf libevent-2.0.22-stable.tar.gz cd libevent-2.0.22-stable ./configure --build=aarch64-unknown-linux-gnu --prefix=$KMS_BUILD_HOME make -j64 && make -j64 install |
2.3.19 编译安装boost
cd ${KMS_HOME} wget "https://sourceforge.net/projects/boost/files/boost/1.58.0/boost_1_58_0.tar.gz/download" -O boost_1_58_0.tar.gz tar -zxvf boost_1_58_0.tar.gz cd boost_1_58_0 ./bootstrap.sh sed --i s/"\-m64"/"\-mabi=lp64"/g tools/build/src/tools/gcc.jam #-m64是X86的编译选项,ARM上需要修改为-mabi=lp64 ./b2 install #这里不安装在$KMS_BUILD_HOME目录下 |
3 组件编译安装
这里所有的编译安装的路径都是非/usr/local或者/usr路径的,如果需要安装到/usr/local或者/usr,请将编译中指定的--prefix=$KMS_BUILD_HOME路径进行修改。
3.1 编译安装kms-cmake-utils
cd ${KMS_HOME} git clone https://github.com/Kurento/kms-cmake-utils.git cd kms-cmake-utils git checkout 6.11.0 echo "add_compile_options(-fPIC)" >>./CMakeLists.txt echo "add_compile_options(-fPIC)" >>./test/version/CMakeLists.txt echo "add_compile_options(-fPIC)" >>./test/CMakeLists.txt #增加-fPIC编译选项 mkdir -p build && cd build && cmake -DCMAKE_INSTALL_PREFIX=$KMS_BUILD_HOME $CMAKE_OPTS .. make -j64 && make -j64 install |
3.2 编译安装kurento-module-creator
cd ${KMS_HOME} git clone https://github.com/Kurento/kurento-module-creator.git cd kurento-module-creator git checkout 6.11.0 mvn package cp target/classes/FindKurentoModuleCreator.cmake ${CMAKE_MODULES_PATH} cp target/kurento-module-creator-jar-with-dependencies.jar ${KMS_BUILD_HOME}/bin cp scripts/kurento-module-creator ${KMS_BUILD_HOME}/bin sed -i "s|JAVA_CMD=.*|JAVA_CMD=${JAVA_CMD}|g" $KMS_BUILD_HOME/bin/kurento-module-creator
#如下操作是因为安装在非/usr/local/目录下,后续组件编译有报错 ln -s ${CMAKE_MODULES_PATH}/bin/kurento-module-creator-jar-with-dependencies.jar /usr/bin cp ${CMAKE_MODULES_PATH}/bin/kurento-module-creator /usr/bin |
3.3 编译安装kms-jsonrpc
cd ${KMS_HOME} git clone https://github.com/Kurento/kms-jsonrpc.git cd kms-jsonrpc git checkout 6.11.0 echo "add_compile_options(-fPIC)" >>./src/CMakeLists.txt echo "add_compile_options(-fPIC)" >>./tests/CMakeLists.txt echo "add_compile_options(-fPIC)" >>./CMakeLists.txt rm -rf build && mkdir -p build && cd build cmake -DCMAKE_MODULES_PATH= -DCMAKE_INSTALL_PREFIX=$KMS_BUILD_HOME $CMAKE_OPTS .. make -j64 && make -j64 install |
3.4 编译安装kms-core
cd ${KMS_HOME} git clone https://github.com/Kurento/kms-core.git cd kms-core git checkout 6.11.0 echo "add_compile_options(-fPIC)" >>./src/gst-plugins/commons/CMakeLists.txt echo "add_compile_options(-fPIC)" >>./src/gst-plugins/commons/sdpagent/CMakeLists.txt echo "add_compile_options(-fPIC)" >>./src/gst-plugins/vp8parse/CMakeLists.txt echo "add_compile_options(-fPIC)" >>./src/gst-plugins/CMakeLists.txt echo "add_compile_options(-fPIC)" >>./src/CMakeLists.txt echo "add_compile_options(-fPIC)" >>./src/server/CMakeLists.txt echo "add_compile_options(-fPIC)" >>./tests/check/memory_leaks/CMakeLists.txt echo "add_compile_options(-fPIC)" >>./tests/check/CMakeLists.txt echo "add_compile_options(-fPIC)" >>./tests/check/general/CMakeLists.txt echo "add_compile_options(-fPIC)" >>./tests/check/element/CMakeLists.txt echo "add_compile_options(-fPIC)" >>./tests/CMakeLists.txt echo "add_compile_options(-fPIC)" >>./tests/server/CMakeLists.txt echo "add_compile_options(-fPIC)" >>./CMakeLists.txt #增加-fPIC编译选项 rm -rf build && mkdir -p build && cd build cmake -DCMAKE_INSTALL_PREFIX=$KMS_BUILD_HOME $CMAKE_OPTS .. make -j64 && make -j64 install |
3.5 编译安装kms-elements
cd ${KMS_HOME} git clone https://github.com/Kurento/kms-elements.git cd kms-elements git checkout 6.11.0 echo "add_compile_options(-fPIC)" >>./src/gst-plugins/webrtcendpoint/CMakeLists.txt echo "add_compile_options(-fPIC)" >>./src/gst-plugins/rtcpdemux/CMakeLists.txt echo "add_compile_options(-fPIC)" >>./src/gst-plugins/recorderendpoint/CMakeLists.txt echo "add_compile_options(-fPIC)" >>./src/gst-plugins/CMakeLists.txt echo "add_compile_options(-fPIC)" >>./src/gst-plugins/rtpendpoint/CMakeLists.txt echo "add_compile_options(-fPIC)" >>./src/CMakeLists.txt echo "add_compile_options(-fPIC)" >>./src/server/implementation/HttpServer/CMakeLists.txt echo "add_compile_options(-fPIC)" >>./src/server/CMakeLists.txt echo "add_compile_options(-fPIC)" >>./tests/check/integration/CMakeLists.txt echo "add_compile_options(-fPIC)" >>./tests/check/memory_leaks/CMakeLists.txt echo "add_compile_options(-fPIC)" >>./tests/check/CMakeLists.txt echo "add_compile_options(-fPIC)" >>./tests/check/element/CMakeLists.txt echo "add_compile_options(-fPIC)" >>./tests/CMakeLists.txt echo "add_compile_options(-fPIC)" >>./tests/server/CMakeLists.txt echo "add_compile_options(-fPIC)" >>./CMakeLists.txt #增加-fPIC编译选项 rm -rf build && mkdir -p build && cd build cmake -DCMAKE_INSTALL_PREFIX=$KMS_BUILD_HOME $CMAKE_OPTS .. make -j64 && make -j64 install |
3.6 编译安装kurento-media-server
cd ${KMS_HOME} git clone https://github.com/Kurento/kurento-media-server.git cd kurento-media-server git checkout 6.11.0 rm -rf build && mkdir -p build && cd build cmake -DCMAKE_INSTALL_PREFIX=$KMS_BUILD_HOME $CMAKE_OPTS .. make -j64&& make -j64 install |
4 测试
4.1 运行kurento-media-server
建立kurento-media-server的配置文件软连接
mkdir /etc/kurento/ ln -s /home/test/kms_source/build/kms/etc/kurento/kurento.conf.json /etc/kurento/kurento.conf.json |
运行kurento-media-server
5 FAQ
问题:测试播放客户端基于http协议实现与kurento通讯,在chrome浏览器播放视频失败。
原因分析:
新版Chrome不支持http进行调用摄像头麦克风,客户测试客户端依赖相关调用。
解决方案(一共三种):
1. 重新实现客户端,使客户端基于https协议实现与kurento通讯。Kurento官网测试客户端就是基于https协议实现的,可以参考官网实现:https://doc-kurento.readthedocs.io/en/6.11.0/tutorials/java/tutorial-player.html
2. 右键点击Chrome桌面快捷方式,打开属性
在快捷方式页-目标中的最后添加输入:
--unsafely-treat-insecure-origin-as-secure="http://128.5.68.93:8000"
注:http://128.5.68.93:8000为需要访问网站地址,根据实际情况修改
3. Chrome浏览器地址栏输入chrome://flags/, 搜索unsafely
enabled 并填入要授信的域名。
- 点赞
- 收藏
- 关注作者
评论(0)