KMS明确支持Ubuntu的两个长期支持(LTS)发行版:Ubuntu 14.04(Trusty)和Ubuntu 16.04(Xenial)。仅支持64位版本。
目前,KMS的主要开发环境是Ubuntu 16.04(Xenial)。
1. 打开一个终端并复制以下命令:
#KMS for Ubuntu 16.04(Xenial)
DISTRO = “xenial”
2. 在上一步中使用的相同终端中运行这两个命令,将Kurento存储库添加到您的系统配置中。
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 5AFA7A83
sudo tee "/etc/apt/sources.list.d/kurento.list" >/dev/null <
# Kurento Media Server - Release packages
deb [arch=amd64] http://ubuntu.openvidu.io/6.7.1 $DISTRO kms6
EOF
3. 安装KMS:
sudo apt-get update
sudo apt-get install kurento-media-server
使用以下命令来启动和停止它:
sudo service kurento-media-server start
sudo service kurento-media-server stop
如果Kurento媒体服务器部署在NAT后面的话,就需要STUN和 TURN来提供穿透服务。大部分情况下使用STUN就够了,TURN仅在对称NAT的情况下使用。
如果要在KMS中配置STUN服务器,请取消注释位于以下位置的WebRtcEndpoint配置文件中的以下行:
/etc/kurento/modules/kurento/WebRtcEndpoint.conf.ini
:
stunServerAddress=
stunServerPort=
参数serverIp应该是STUN服务器的IP地址而不是域名,可以找到如下一些免费的公共STUN服务器:
173.194.66.127:19302
173.194.71.127:19302
74.125.200.127:19302
74.125.204.127:19302
173.194.72.127:19302
74.125.23.127:3478
77.72.174.163:3478
77.72.174.165:3478
77.72.174.167:3478
77.72.174.161:3478
208.97.25.20:3478
62.71.2.168:3478
212.227.67.194:3478
212.227.67.195:3478
107.23.150.92:3478
77.72.169.155:3478
77.72.169.156:3478
77.72.169.164:3478
77.72.169.166:3478
77.72.174.162:3478
77.72.174.164:3478
77.72.174.166:3478
77.72.174.160:3478
54.172.47.69:3478
使用vim或者gedit进入上述文件,进行如下修改:(使用sudo指令可以实现编辑保存)
stunServerAddress= 77.72.169.166
stunServerPort=3478
如果要在KMS中配置TURN服务器,请取消注释位于以下位置的WebRtcEndpoint配置文件中的以下行:
/etc/kurento/modules/kurento/WebRtcEndpoint.conf.ini
:
turnURL = <用户>:<密码> @ :
可进行如下修改:
turnURL = user:[email protected]:3478
要验证KMS已启动并正在运行,请使用此命令并查找kurento-media-server
过程:
ps -ef | grep kurento-media-server
> nobody 1270 1 0 08:52 ? 00:01:00 /usr/bin/kurento-media-server
除非另行配置,否则KMS将打开端口8888
以接收请求并通过Kurento协议发送响应。使用此命令验证此端口是否侦听传入数据包:
sudo netstat -tupan | grep kurento
> tcp6 0 0 :::8888 :::* LISTEN 1270/kurento-media-server
1.获取示例代码需要用到Git
,可以通过以下命令安装:
sudo apt-get install git
2.运行示例代码需要用到Maven 3.0
以上版本和JDK 7
以上的版本。Maven可以通过以下命令安装:
sudo apt-get install maven
3. JDK可以下载压缩文件传到Linux下,这里下载了jdk-8u152-linux-x64.tar.gz 版本
解压 JDK 到 /usr/lib/jvm
sudo tar zxvf jdk-8u152-linux-x64.tar.gz -C /usr/lib/jvm
设置环境变量
sudo gedit /etc/profile
在打开的文件的末尾输入
export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_152
export CLASSPATH=".:$JAVA_HOME/lib:$CLASSPATH"
export PATH="$JAVA_HOME/bin:$PATH
设置系统默认JDK
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.8.0_152/bin/java 300
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.8.0_152/bin/javac 300
sudo update-alternatives --config java
验证JDK
java -version
1.首先从github上获取代码(如果已经获取可以跳过,获取的代码已经包括后面的示例代码了)
git clone https://github.com/Kurento/kurento-tutorial-java.git
2. 进入目录,编译执行
cd kurento-tutorial-java / kurento -hello-world
git checkout 6.7.1
mvn clean compile exec:java -Dkms.url = ws:// localhost:8888 / kurento
3. 使用符合WebRTC的浏览器(Chrome,Firefox)打开演示页面:https:// localhost:8443 /
4. 点击开始开始演示
5. 授予访问您的摄像头
6. 协商并建立回送连接,您应该在本地和远程占位符中看到您的网络摄像头视频
7. 点击停止完成演示
有一定的延迟
官方安装文档 https://doc-kurento.readthedocs.io/en/stable/user/installation.html#local-installation
With this method, you will install KMS from the native Ubuntu package repositories made available by the Kurento project.
KMS has explicit support for two Long-Term Support (LTS) distributions of Ubuntu: Ubuntu 14.04 (Trusty) and Ubuntu 16.04 (Xenial). Only the 64-bits editions are supported.
Currently, the main development environment for KMS is Ubuntu 16.04 (Xenial), so if you are in doubt, this is the preferred Ubuntu distribution to choose. However, all features and bug fixes are still being backported and tested on Ubuntu 14.04 (Trusty), so you can continue running this version if required.
Define what version of Ubuntu is installed in your system. Open a terminal and copy only one of these commands:
# KMS for Ubuntu 14.04 (Trusty)
DISTRO="trusty"
# KMS for Ubuntu 16.04 (Xenial)
DISTRO="xenial"
Add the Kurento repository to your system configuration. Run these two commands in the same terminal you used in the previous step:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 5AFA7A83
sudo tee "/etc/apt/sources.list.d/kurento.list" >/dev/null <
Install KMS:
sudo apt-get update
sudo apt-get install kurento-media-server
This will install the KMS release version that was specified in the previous commands.
The server includes service files which integrate with the Ubuntu init system, so you can use the following commands to start and stop it:
sudo service kurento-media-server start
sudo service kurento-media-server stop
If Kurento Media Server or its client application are located behind a NAT (e.g. in any cloud provider), you need to use a STUN or a TURN server in order to achieve NAT traversal. In most cases, STUN is effective in addressing the NAT issue with most consumer network devices (routers). However, it doesn’t work for many corporate networks, so a TURN server becomes necessary.
Apart from that, you need to open all UDP ports in your system configuration, as STUN will use any random port from the whole [0-65535] range.
Note
The features provided by TURN are a superset of those provided by STUN. This means that you don’t need to configure a STUN server if you are already using a TURN server.
To configure a STUN server in KMS, uncomment the following lines in the WebRtcEndpoint configuration file, located at /etc/kurento/modules/kurento/WebRtcEndpoint.conf.ini
:
stunServerAddress=
stunServerPort=
Note
Be careful since comments inline (with ;
) are not allowed for parameters in the configuration files. Thus, the following line is not correct:
stunServerAddress= ; Only IP addresses are supported
… and must be changed to something like this:
; Only IP addresses are supported
stunServerAddress=
The parameter serverIp
should be the public IP address of the STUN server. It must be an IP address, not a domain name.
It should be easy to find some public STUN servers that are made available for free. For example:
173.194.66.127:19302
173.194.71.127:19302
74.125.200.127:19302
74.125.204.127:19302
173.194.72.127:19302
74.125.23.127:3478
77.72.174.163:3478
77.72.174.165:3478
77.72.174.167:3478
77.72.174.161:3478
208.97.25.20:3478
62.71.2.168:3478
212.227.67.194:3478
212.227.67.195:3478
107.23.150.92:3478
77.72.169.155:3478
77.72.169.156:3478
77.72.169.164:3478
77.72.169.166:3478
77.72.174.162:3478
77.72.174.164:3478
77.72.174.166:3478
77.72.174.160:3478
54.172.47.69:3478
To configure a TURN server in KMS, uncomment the following lines in the WebRtcEndpoint configuration file, located at /etc/kurento/modules/kurento/WebRtcEndpoint.conf.ini
:
turnURL=:@:
The parameter serverIp
should be the public IP address of the TURN server. It must be an IP address, not a domain name.
See some examples of TURN configuration below:
turnURL=kurento:[email protected]:3478
… or using a free access Numb TURN/STUN server:
turnURL=user:[email protected]:3478
Note that it is somewhat easy to find free STUN servers available on the net, because their functionality is pretty limited and it is not costly to keep them working for free. However, this doesn’t happen with TURN servers, which act as a media proxy between peers and thus the cost of maintaining one is much higher.
It is rare to find a TURN server which works for free while offering good performance. Usually, each user opts to maintain their own private TURN server instances.
Coturn is an open source implementation of a TURN/STUN server. In the FAQ section there is a description about how to install and configure it.
To verify that KMS is up and running, use this command and look for the kurento-media-server
process:
ps -ef | grep kurento-media-server
> nobody 1270 1 0 08:52 ? 00:01:00 /usr/bin/kurento-media-server
Unless configured otherwise, KMS will open the port 8888
to receive requests and send responses by means of the Kurento Protocol. Use this command to verify that this port is listening for incoming packets:
sudo netstat -tupan | grep kurento
> tcp6 0 0 :::8888 :::* LISTEN 1270/kurento-media-server