ubuntu 18.04下编译最新版本的KMS

时间:2023-02-06 20:30:56

KMS:kurento媒体服务,即 kurento media server

很庞大的一个WEBRTC项目,GIT库主项目:https://github.com/Kurento

基础实现,修改了gst-plugin-bad,打开了openh264的插件(依赖于openh264)

然后在其上实现了kms-core, kms-elements, kms-filters,然后实现了相应的服务KMS

官方版本一直只支持ubuntu 16.04,相应docker也是16.04

最新ubuntu编译时遇到了很多问题,相应修改/调整顺序如下:

编译命令:
  dpkg-buildpackage -rfakeroot

编译链接过程:
1.编译kurento-module-creator
   需要安装debhelper default-jdk maven-debian-helper junit4 libcommons-cli-java libfreemarker-java libgoogle-gson-java libhamcrest-java libmaven-assembly-plugin-java libslf4j-java libwagon-java
   需要修改debian/install文件,插入一行
           target/classes/FindKurentoModuleCreator.cmake /usr/share/cmake-3.10/Modules/
       ubuntu 18.04 的CMAKE版本是3.10
   编译完成后可以删除
2.安装kurento-module-creator
    需要安装libcommons-cli-java libfreemarker-java libgoogle-gson-java libslf4j-java

3.编译kms-cmake-utils
4.安装kms-cmake-utils
5.编译kmsjsoncpp
    需要取kurento下的jsoncpp库
    会在打包时signfile kmsjsoncpp_1.6.2.dsc失败,使用dpkg-buildpackage -uc -us避免此错误
6.安装kmsjsoncpp
    需要同时安装kmsjsoncpp-dev包
7.编译kms-jsonrpc
   需要安装libboost-dev libboost-test-dev
   其中的kmsjsoncpp-dev,由上一个流程编译生成
8.安装kms-jsonrpc
    需要同时安装kms-jsonrpc-dev包
9.编译kms-core
    编译依赖:libboost-filesystem-dev libboost-regex-dev libboost-system-dev libglibmm-2.4-dev libsigc++-2.0-dev libvpx-dev
    修改debian/control中,所有gstreamer-1.5相关字符全部修改为1.0
    a.CMakeLists.txt中gstreamer-1.5相关字符全部修改为1.0
generic_find(LIBNAME gstreamer-1.0 VERSION ${GST_REQUIRED} REQUIRED)
generic_find(LIBNAME gstreamer-base-1.0 VERSION ${GST_REQUIRED} REQUIRED)
generic_find(LIBNAME gstreamer-video-1.0 VERSION ${GST_REQUIRED} REQUIRED)
generic_find(LIBNAME gstreamer-check-1.0 VERSION ${GST_REQUIRED})
generic_find(LIBNAME gstreamer-sdp-1.0 VERSION ${GST_REQUIRED} REQUIRED)
generic_find(LIBNAME gstreamer-pbutils-1.0 VERSION ${GST_REQUIRED} REQUIRED)
generic_find(LIBNAME gstreamer-rtp-1.0 VERSION ${GST_REQUIRED} REQUIRED)
    b.一堆CMakeLists.txt中的1.5修改为1.0
    c.修复编译问题GF::GF():
       BOOST_GLOBAL_FIXTURE (GF)后需要加;号
      调用了std::cerr的,需要包含#include <iostream>
    d. 临时注释掉CMakelists.txt中的add_subdirectory(tests)
    e. 修改debian下kms-core.install,将1.5修改成1.0
10.安装kms-core/kms-core-dev
11.编译usrsctp
   usrsctplib下的CMakeLists.txt中的
include_directories(${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/netinet ${PROJECT_SOURCE_DIR}/netinet6)
   修改为:
include_directories(${PROJECT_SOURCE_DIR}/usrsctplib ${PROJECT_SOURCE_DIR}/usrsctplib/netinet ${PROJECT_SOURCE_DIR}/usrsctplib/netinet6)
error: ‘%s’ directive output truncated writing 73 bytes into a region of size 58 [-Werror=format-truncation=]
    snprintf(msg, sizeof(msg), "OOTB, %s:%d at %s", __FILE__, __LINE__, __func__);
   的修复办法,在usrsctplib的CMakeLists.txt中插入
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -D__FILENAME__='\"$(subst ${CMAKE_SOURCE_DIR}/usrsctplib/netinet/,,$(abspath $<))\"'")
   在usrsctplib的CMakeLists.txt中插入
   set(CMAKE_POSITION_INDEPENDENT_CODE ON)
   解决openwebrtc-gst-plugins报告usrsctp的fPIC编译问题
   同时修改所有sctp_input.c/sctp_output.c/sctp_pcb.c中的__FILE__为__FILENAME__
   删除programs下的datachan_serv.c,datachan.h,同时需要删除此目录下CMakeLists.txt中编译datachan_serv.c处
   修改libusrsctp.install,将其中的usr/lib/*/lib*.so.*修改为usr/lib/*.so.*
   修改libusrsctp-dev.install,将其中的usr/lib/*/*.so修改为usr/lib/*.a
   会在打包时signfile时失败,使用dpkg-buildpackage -uc -us避免此错误

12.安装usrsctp
13.编译openwebrtc-gst-plugins
    修改debian/control,将1.5修改为1.0;修改debain/openwebrtc-gst-plugins.install,将1.5修改为1.0;修改debain/openwebrtc-gst-plugins-dev.install,将1.5修改为1.0
    修改debian/openwebrtc-gst-plugins-dev.install,将其中的so修改为a,1.5修改为1.0
    修改debian/rules,在dh_auto_configure --上插入一行NOCONFIGURE=1 ./autogen.sh(注意对齐)
    修改debian/rules,在之前插入三行
export DEB_CFLAGS_MAINT_APPEND = -fPIC
export DEB_CXXFLAGS_MAINT_APPEND = -fPIC
export DEB_LDFLAGS_MAINT_APPEND = -fPIC
    修改configure.ac,将其中的1.5修改为1.0,将-lusrsctp修改为-lusrsctp -lpthread
    修改gstreamer-sctp-1.5.pc.in文件名为gstreamer-sctp-1.0.pc.in
    修改gstreamer-sctp-1.5-uninstalled.pc.in文件名为gstreamer-sctp-1.0-uninstalled.pc.in
    修改gst-libs/gst/sctp下的Makefile.am,将其中的1_5修改为1_0
    修改ext/gst/sctp下的Makefile.am,将其中的1.5修改为1.0
    修改gst/videorepair,将其中的1.5修改为1.0
    修改Makefile.am,将其中的1.5修改为1.0
    修改gstreamer-sctp-1.0.pc.in,将其中的1.5修改为1.0
   会在打包时signfile时失败,使用dpkg-buildpackage -uc -us避免此错误

14.安装openwebrtc-gst-plugins

15.编译openh264
     需要编译Kurento提供的openh264,github/gitlib上是openh264-1
16.安装openh264

17.编译openh264-gst-plugins-bad-1.0
    编译依赖:cdbs flite-dev gobject-introspection libasound2-dev libcdaudio-dev libdc1394-22-dev libgudev-1.0-dev libusb-1.0-0-dev libbluetooth-dev libsbc-dev gstreamer1.0-doc gstreamer1.0-plugins-base-doc gtk-doc-tools ladspa-sdk libass-dev libbs2b-dev libbz2-dev libchromaprint-dev libcurl4-gnutls-dev libdca-dev libde265-dev libdvdnav-dev libexempi-dev libexif-dev libfaad-dev libfluidsynth-dev libgirepository1.0-dev libgme-dev libgsm1-dev libiptcdata0-dev libkate-dev liblilv-dev libmjpegtools-dev libmms-dev libmodplug-dev libmpcdec-dev libofa0-dev  libopenal-dev libopencv-dev libopenexr-dev libopenjp2-7-dev libopus-dev librsvg2-dev librtmp-dev libsndfile1-dev libsoundtouch-dev libspandsp-dev libsrtp0-dev libvo-aacenc-dev libvo-amrwbenc-dev libwebp-dev libwebrtc-audio-processing-dev libwildmidi-dev libx265-dev libxvidcore-dev libzbar-dev libzvbi-dev libpcap-dev libvulkan-dev libgstreamer-plugins-good1.0-dev libopenmpt-dev libsrtp2-dev
    需要从ubuntu 18.04版本对应的取gst-plugins-bad1.0_1.14.1.orig.tar.xz,gst-plugins-bad1.0_1.14.1-1ubuntu1_ubuntu18.04.1.debian.tar.xz
    从kurentu中的gst-plugins-bad库,取得debain目录下的openh264-gst-plugins-bad-1.0.install/
    修改debain/build-deps.in,其后添加依赖openh264, libpcap-dev
    修改debian/control.in,其后添加一段
Package: openh264-gst-plugins-bad-@GST_ABI@
Architecture: any
Multi-Arch: same
Pre-Depends: ${misc:Pre-Depends}
Depends: ${misc:Depends},
         ${shlibs:Depends},
         gstreamer@GST_ABI@-plugins-base,
         openh264,
         libgstreamer-plugins-bad@GST_DEB_ABI@ (= ${binary:Version}),
Description: GStreamer plugins from openh264

18.安装openh264-gst-plugins-bad-1.0

19.编译kms-elements
    编译依赖:
    修改debian/control中,所有gstreamer-1.5相关字符全部修改为1.0
    a.CMakeLists.txt中gstreamer-1.5相关字符全部修改为1.0
generic_find(LIBNAME gstreamer-1.0 VERSION ${GST_REQUIRED} REQUIRED)
generic_find(LIBNAME gstreamer-base-1.0 VERSION ${GST_REQUIRED} REQUIRED)
generic_find(LIBNAME gstreamer-video-1.0 VERSION ${GST_REQUIRED} REQUIRED)
generic_find(LIBNAME gstreamer-app-1.0 VERSION ${GST_REQUIRED} REQUIRED)
generic_find(LIBNAME gstreamer-check-1.0 VERSION ${GST_REQUIRED} REQUIRED)
generic_find(LIBNAME gstreamer-sdp-1.0 VERSION ${GST_REQUIRED} REQUIRED)
generic_find(LIBNAME gstreamer-rtp-1.0 VERSION ${GST_REQUIRED} REQUIRED)
generic_find(LIBNAME gstreamer-pbutils-1.0 VERSION ${GST_REQUIRED} REQUIRED)
generic_find(LIBNAME gstreamer-sctp-1.0 REQUIRED)
    b.搜索名下一堆的CMakeLists.txt中,将其中的1.5改成1.0
    c.修复编译问题GF::GF():
       BOOST_GLOBAL_FIXTURE (GF)后需要加;号
    d.临时注释掉tests目录的编译,在CMakeLists.txt中修改
	# add_subdirectory(tests)

20.安装kms-elements

21.编译kms-filters
      编译依赖:libopencv-dev
      修改CMakeLists.txt中,所有gstreamer-1.5相关字符全部修改为1.0,同时添加两行:
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHAVE_OPENCV_IMGCODECS")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_OPENCV_IMGCODECS")
      搜索名下一堆的CMakeLists.txt中,将其中的1.5改成1.0
      classifier.cpp文件中Mat frame (img);修改为Mat frame = cvarrToMat(img);
      临时注释掉add_subdirectory(tests)这一行
      修改debian/kms-filters.install,将其中的1.5改成1.0

22.安装kms-filters

23.编译kurento-media-server
      编译依赖:libopencv-dev kms-filters-dev libboost-log-dev libboost-program-options-dev libboost-thread-dev libssl1.0-dev
     修改CMakeLists.txt中,所有gstreamer-1.5相关字符全部修改为1.0
     调用了std::cout的,需要包含#include <iostream>
     临时注释掉tests目录的编译,在CMakeLists.txt中修改
	# add_subdirectory(tests)


24.资料信息:
  If tests fail, packages are not generated. To skip tests, edit the file debian/rules and change -DGENERATE_TESTS=TRUE to -DGENERATE_TESTS=FALSE -DDISABLE_TESTS=TRUE.
  测试失败有更简便的修改办法了