Ubuntu16.04安装Kurento6.7.1媒体服务器

第一步: 安装Kurento媒体服务器

 

KMS明确支持Ubuntu的两个长期支持(LTS)发行版:Ubuntu 14.04(Trusty)Ubuntu 16.04(Xenial)。仅支持64位版本。

目前,KMS的主要开发环境是Ubuntu 16.04(Xenial)。

 

 

本地安装(Ubuntu 16.04)

1. 打开一个终端并复制以下命令:

 
  1. #KMS for Ubuntu 16.04(Xenial)

  2. DISTRO = “xenial”

2. 在上一步中使用的相同终端中运行这两个命令,将Kurento存储库添加到您的系统配置中。

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 5AFA7A83
 
  1. sudo tee "/etc/apt/sources.list.d/kurento.list" >/dev/null <<EOF

  2. # Kurento Media Server - Release packages

  3. deb [arch=amd64] http://ubuntu.openvidu.io/6.7.1 $DISTRO kms6

  4. EOF

3. 安装KMS:

 
  1. sudo apt-get update

  2. sudo apt-get install kurento-media-server

使用以下命令来启动和停止它:

 
  1. sudo service kurento-media-server start

  2. sudo service kurento-media-server stop

STUN和TURN服务器

如果Kurento媒体服务器部署在NAT后面的话,就需要STUN和 TURN来提供穿透服务。大部分情况下使用STUN就够了,TURN仅在对称NAT的情况下使用。

 

STUN服务器

如果要在KMS中配置STUN服务器,请取消注释位于以下位置的WebRtcEndpoint配置文件中的以下行:

/etc/kurento/modules/kurento/WebRtcEndpoint.conf.ini:

 
  1. stunServerAddress=<serverIp>

  2. stunServerPort=<serverPort>

参数serverIp应该是STUN服务器的IP地址而不是域名,可以找到如下一些免费的公共STUN服务器:

 
  1. 173.194.66.127:19302

  2. 173.194.71.127:19302

  3. 74.125.200.127:19302

  4. 74.125.204.127:19302

  5. 173.194.72.127:19302

  6. 74.125.23.127:3478

  7. 77.72.174.163:3478

  8. 77.72.174.165:3478

  9. 77.72.174.167:3478

  10. 77.72.174.161:3478

  11. 208.97.25.20:3478

  12. 62.71.2.168:3478

  13. 212.227.67.194:3478

  14. 212.227.67.195:3478

  15. 107.23.150.92:3478

  16. 77.72.169.155:3478

  17. 77.72.169.156:3478

  18. 77.72.169.164:3478

  19. 77.72.169.166:3478

  20. 77.72.174.162:3478

  21. 77.72.174.164:3478

  22. 77.72.174.166:3478

  23. 77.72.174.160:3478

  24. 54.172.47.69:3478

使用vim或者gedit进入上述文件,进行如下修改:(使用sudo指令可以实现编辑保存)

stunServerAddress= 77.72.169.166
stunServerPort=3478

 

TURN服务器

如果要在KMS中配置TURN服务器,请取消注释位于以下位置的WebRtcEndpoint配置文件中的以下行:

/etc/kurento/modules/kurento/WebRtcEndpoint.conf.ini:

turnURL = <用户>:<密码> @ <serverIp>:<serverPort>

可进行如下修改:

turnURL = user:password@66.228.45.110:3478

 

检查安装

要验证KMS已启动并正在运行,请使用此命令并查找kurento-media-server过程:

 
  1. ps -ef | grep kurento-media-server

  2.  
  3. > nobody 1270 1 0 08:52 ? 00:01:00 /usr/bin/kurento-media-server

除非另行配置,否则KMS将打开端口8888以接收请求并通过Kurento协议发送响应。使用此命令验证此端口是否侦听传入数据包:

 
  1. sudo netstat -tupan | grep kurento

  2.  
  3. > 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

在打开的文件的末尾输入

 
  1. export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_152

  2. export CLASSPATH=".:$JAVA_HOME/lib:$CLASSPATH"

  3. export PATH="$JAVA_HOME/bin:$PATH

设置系统默认JDK

 
  1. sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.8.0_152/bin/java 300

  2. sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.8.0_152/bin/javac 300

  3. sudo update-alternatives --config java

验证JDK

java -version

 

第三步: Hello World

1.首先从github上获取代码(如果已经获取可以跳过,获取的代码已经包括后面的示例代码了)

git clone https://github.com/Kurento/kurento-tutorial-java.git

2. 进入目录,编译执行

 
  1. cd kurento-tutorial-java / kurento -hello-world

  2. git checkout 6.7.1

  3. 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

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.

  1. 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"
    
  2. 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 <<EOF
    # Kurento Media Server - Release packages
    deb [arch=amd64] http://ubuntu.openvidu.io/6.7.1 $DISTRO kms6
    EOF
    
  3. 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

STUN and TURN servers

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.

STUN 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=<serverIp>
stunServerPort=<serverPort>

Note

Be careful since comments inline (with ;) are not allowed for parameters in the configuration files. Thus, the following line is not correct:

stunServerAddress=<serverIp> ; Only IP addresses are supported

… and must be changed to something like this:

; Only IP addresses are supported
stunServerAddress=<serverIp>

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

TURN server

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=<user>:<password>@<serverIp>:<serverPort>

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:kurento@111.222.333.444:3478

… or using a free access Numb TURN/STUN server:

turnURL=user:password@66.228.45.110: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.

Check your installation

To verify that KMS is up and running, use this command and look for the kurento-media-serverprocess:

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
  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

非ban必选

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值