Kurento Media Server源码编译

Build dependency

Module dependency graph

Kurento模块的依赖关系如下图所示
kms_module_dependency_graph

Module dependency list

Kurento模块依赖关系并不是严格的线性关系,所以编译顺序可以有多种组合,以下是其中一种可能的编译顺序:

Externals:

  • gstreamer
  • libsrtp
  • openh264
  • usrsctp
  • jsoncpp
  • gst-plugins-base
  • gst-plugins-good
  • gst-plugins-ugly
  • gst-plugins-bad
  • gst-libav
  • openwebrtc-gst-plugins
  • libnice

KMS Main + Extra:

  • kurento-module-creator
  • kms-cmake-utils
  • kms-jsonrpc
  • kms-core
  • kms-elements
  • kms-filters
  • kurento-media-server
  • kms-chroma
  • kms-crowddetector
  • kms-datachannelexample
  • kms-platedetector
  • kms-pointerdetector

Build

Note:

  1. 适用于Ubuntu和Centos
  2. 如果在Centos下编译,还需要升级glib,autotools等
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
# KMS源码目录
KMS_HOME=$HOME/kms_source
# KMS编译目录
KMS_BUILD_HOME=$KMS_HOME/build/kms

CMAKE_MODULES_PATH=${KMS_BUILD_HOME}/share/cmake-3.5/Modules

# 导入编译所需的环境变量
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)

# 创建所需目录
mkdir -p ${KMS_HOME}
mkdir -p ${KMS_BUILD_HOME}
mkdir -p ${KMS_BUILD_HOME}/bin

# ---- build externals ----
# gstreamer
cd ${KMS_HOME}
git clone https://github.com/Kurento/gstreamer.git
cd gstreamer
git checkout kms6.6.0
./autogen.sh
# introspection requires python >= 2.7
./configure --enable-introspection=no --prefix=$KMS_BUILD_HOME && make && make install
if [ $? -ne 0 ]; then exit -1; fi

# build 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 && make install
if [ $? -ne 0 ]; then exit -1; fi

# build libsrtp
cd ${KMS_HOME}
git clone https://github.com/Kurento/libsrtp.git
cd libsrtp
git checkout kms6.6.0
./configure --prefix=$KMS_BUILD_HOME && make && make install
if [ $? -ne 0 ]; then exit -1; fi

# build nasm
# required by openh264
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 --prefix=$KMS_BUILD_HOME && make && make install
if [ $? -ne 0 ]; then exit -1; fi

# build openh264
cd ${KMS_HOME}
git clone https://github.com/cisco/openh264.git
cd openh264
git checkout v1.4.0
make && make install PREFIX=$KMS_BUILD_HOME
if [ $? -ne 0 ]; then exit -1; fi

# build usrsctp
cd ${KMS_HOME}
git clone https://github.com/Kurento/usrsctp.git
cd usrsctp
git checkout kms6.6.0
./bootstrap
./configure --prefix=$KMS_BUILD_HOME
make && make install
if [ $? -ne 0 ]; then exit -1; fi

# build 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 --prefix=$KMS_BUILD_HOME && make && make install
if [ $? -ne 0 ]; then exit -1; fi

# build 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 --prefix=$KMS_BUILD_HOME && make && make install
if [ $? -ne 0 ]; then exit -1; fi

# build 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 ..
make && make install
if [ $? -ne 0 ]; then exit -1; fi
# 否则编译kms-jsonrpc会报错 fatal error: json/json.h: No such file or directory
sed -i 's/\/kmsjsoncpp//g' $KMS_BUILD_HOME/lib/pkgconfig/kmsjsoncpp.pc

# 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
./autogen.sh
./configure --enable-introspection=no --prefix=$KMS_BUILD_HOME && make && make install
if [ $? -ne 0 ]; then exit -1; fi

# gst-plugins-good
# for rtp
cd ${KMS_HOME}
git clone https://github.com/Kurento/gst-plugins-good.git
cd gst-plugins-good
git checkout kms6.6.0
./autogen.sh
./configure --enable-introspection=no --prefix=$KMS_BUILD_HOME && make && make install
if [ $? -ne 0 ]; then exit -1; fi

# 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
./autogen.sh
./configure --enable-introspection=no --prefix=$KMS_BUILD_HOME && make && make install
if [ $? -ne 0 ]; then exit -1; fi

# gst-plugins-bad
# for openh264+libsrtp
cd ${KMS_HOME}
git clone https://github.com/Kurento/gst-plugins-bad.git
cd gst-plugins-bad
git checkout kms6.6.0
./autogen.sh
./configure --enable-introspection=no --prefix=$KMS_BUILD_HOME && make && make install
if [ $? -ne 0 ]; then exit -1; fi

# gst-libav
cd ${KMS_HOME}
git clone https://github.com/Kurento/gst-libav.git
cd gst-libav
git checkout kms6.6.0
./autogen.sh
./configure --enable-introspection=no --prefix=$KMS_BUILD_HOME && make && make install
if [ $? -ne 0 ]; then exit -1; fi

# build openwebrtc-gst-plugins
cd ${KMS_HOME}
git clone https://github.com/Kurento/openwebrtc-gst-plugins.git
cd openwebrtc-gst-plugins
git checkout kms6.6.0
./autogen.sh
./configure --prefix=$KMS_BUILD_HOME && make && make install
if [ $? -ne 0 ]; then exit -1; fi

# build libnice
cd ${KMS_HOME}
git clone https://github.com/Kurento/libnice.git
cd libnice
git checkout kms6.6.1
./autogen.sh
./configure --enable-introspection=no --prefix=$KMS_BUILD_HOME && make && make install
if [ $? -ne 0 ]; then exit -1; fi

# build libevent
# required by kurento-media-server
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 --prefix=$KMS_BUILD_HOME && make && make install
if [ $? -ne 0 ]; then exit -1; fi

# build boost
cd ${KMS_HOME}
# boost>1.58.0不支持json配置注释
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
./b2 install --prefix=$KMS_BUILD_HOME
#if [ $? -ne 0 ]; then exit -1; fi

# ---- build kms main ----
# build kms-cmake-utils
cd ${KMS_HOME}
git clone https://github.com/Kurento/kms-cmake-utils.git
cd kms-cmake-utils
git checkout 6.7.0
mkdir -p build && cd build && cmake -DCMAKE_INSTALL_PREFIX=$KMS_BUILD_HOME $CMAKE_OPTS .. && make && make install
if [ $? -ne 0 ]; then exit -1; fi

# build kurento-module-creator
cd ${KMS_HOME}
git clone https://github.com/Kurento/kurento-module-creator.git
cd kurento-module-creator
git checkout 6.7.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
if [ $? -ne 0 ]; then exit -1; fi

# build kms-jsonrpc
cd ${KMS_HOME}
git clone https://github.com/Kurento/kms-jsonrpc.git
cd kms-jsonrpc
git checkout 6.7.0
rm -rf build && mkdir -p build && cd build
cmake -DCMAKE_INSTALL_PREFIX=$KMS_BUILD_HOME $CMAKE_OPTS ..
make && make install
if [ $? -ne 0 ]; then exit -1; fi

# build kms-core
cd ${KMS_HOME}
git clone https://github.com/Kurento/kms-core.git
cd kms-core
git checkout 6.7.1
rm -rf build && mkdir -p build && cd build
cmake -DCMAKE_INSTALL_PREFIX=$KMS_BUILD_HOME $CMAKE_OPTS .. && make && make install
if [ $? -ne 0 ]; then exit -1; fi

# build kms-elements
cd ${KMS_HOME}
git clone https://github.com/Kurento/kms-elements.git
cd kms-elements
git checkout 6.7.1
rm -rf build && mkdir -p build && cd build
cmake -DCMAKE_INSTALL_PREFIX=$KMS_BUILD_HOME $CMAKE_OPTS .. && make && make install
if [ $? -ne 0 ]; then exit -1; fi

# build kurento-media-server
cd ${KMS_HOME}
git clone https://github.com/Kurento/kurento-media-server.git
cd kurento-media-server
git checkout 6.7.1
rm -rf build && mkdir -p build && cd build
cmake -DCMAKE_INSTALL_PREFIX=$KMS_BUILD_HOME $CMAKE_OPTS ..
make && make install
if [ $? -ne 0 ]; then exit -1; fi

Run

1
2
3
4
5
KMS_HOME=$HOME/kms_source
KMS_BUILD_HOME=$KMS_HOME/build/kms
export LD_LIBRARY_PATH=$KMS_BUILD_HOME/lib:$LD_LIBRARY_PATH

$KMS_BUILD_HOME/bin/kurento-media-server -f $KMS_BUILD_HOME/etc/kurento/kurento.conf.json -c $KMS_BUILD_HOME/etc/kurento/modules/kurento

Reference

  1. Kurento Developer Guide
感谢你的阅读,如果文章对你有帮助,可以请作者喝杯茶!