Welcome to my GitHub

https://github.com/zq2599/blog_demos

Content: Classification and summary of all original articles and supporting source code, involving Java, Docker, Kubernetes, DevOPS, etc.;

About the "Kurento Actual Combat" series

"Kurento Actual Combat" series is Xinchen's original audio and video field actual combat topic. It aims to learn mainstream real-time audio and video technology through actual combat. I am honored to start this wonderful journey with you;

About Kurento

  • Kurento consists of a WebRTC media server and a series of client applications to simplify the development of real-time audio and video on the web and smart devices;
  • The official architecture diagram is as follows. The purple area at the top is the end side, the red area in the lower left corner is the Kurento Media Server (KMS) that provides audio and video services, and the green area in the lower right corner is the business service. Provide signaling and control services (for example, find each other during point-to-point chat, multi-person chat is to provide the business logic of the room):

在这里插入图片描述

About WebRTC (Web Real-Time Communication)

WebRTC is a technology for real-time video and audio communication inside the browser. It was acquired by Google in 2010 when it acquired VoIP software developer Global IT Solutions for US$68.2 million. It can carry out real-time video and audio communication inside the browser. Google open sourced the project on June 3, 2011. Knowledge about WebRTC is not covered in this article, but the following figure is a typical real-time communication process, which is very important:

在这里插入图片描述

Overview of this article

As the beginning of "Kurento Actual Combat", today we will try to deploy the core service Kurento Media Server (KMS), and then run a demo application to verify that KMS is available;

Version Information

  1. Operating system: Ubuntu 16.04.5 LTS
  2. KMS:6.13.0
  3. JDK:1.8.0_191
  4. SpringBoot:2.3.3.RELEASE
  • Note: The <font color="red">root</font> account will be used throughout the actual combat
  • Next, start to deploy KMS;

    operating

  • Turn off the firewall;
  • Install <font color="red">gnupg</font>:
apt-get install --no-install-recommends --yes gnupg
  1. Set environment variables:
DISTRO="xenial"
  1. Download the key from the key server to the trusted key list to prepare for the following installation:
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 5AFA7A83
  1. Add kurentu source address:
tee "/etc/apt/sources.list.d/kurento.list" >/dev/null <<EOF
deb [arch=amd64] http://ubuntu.openvidu.io/6.13.0 $DISTRO kms6
EOF
  1. Install kms:
apt-get update && apt-get install --yes kurento-media-server
  1. Start kms:
service kurento-media-server start
  1. Check the status of kms, as shown below, it can be seen that the service started successfully (active):
root@docker:~# service kurento-media-server status
● kurento-media-server.service - LSB: Kurento Media Server daemon
   Loaded: loaded (/etc/init.d/kurento-media-server; bad; vendor preset: enabled)
   Active: active (running) since Fri 2021-01-01 05:39:24 PST; 2s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 4815 ExecStart=/etc/init.d/kurento-media-server start (code=exited, status=0/SUCCESS)
    Tasks: 24
   Memory: 17.3M
      CPU: 242ms
   CGroup: /system.slice/kurento-media-server.service
           └─4828 /usr/bin/kurento-media-server

Jan 01 05:39:24 docker systemd[1]: Starting LSB: Kurento Media Server daemon...
Jan 01 05:39:24 docker kurento-media-server[4815]:  * Start Kurento Media Server
Jan 01 05:39:24 docker kurento-media-server[4815]:  * Configure Kernel resource limits for Kurento Media Server
Jan 01 05:39:24 docker kurento-media-server[4815]:    ...done.
Jan 01 05:39:24 docker systemd[1]: Started LSB: Kurento Media Server daemon.
  1. Execute the following command to confirm whether the response is normal:
curl -i -N \
    -H "Connection: Upgrade" \
    -H "Upgrade: websocket" \
    -H "Host: 127.0.0.1:8888" \
    -H "Origin: 127.0.0.1" \
    http://127.0.0.1:8888/kurento
  1. If the console responds with the following content, it proves that KMS can already serve normally:
HTTP/1.1 500 Internal Server Error
Server: WebSocket++/0.7.0
  1. At this point, the KMS deployment and start-up have been completed. Next, let's quickly experience the basic capabilities of KMS;

Experience KMS

  • Next, deploy a SpringBoot application and experience KMS through the application's web service. This application is deployed on another computer (and there is no problem with KMS deployment). The entire environment is as follows:

在这里插入图片描述

  1. Log in to the <font color="blue">192.168.133.208</font> computer in the above picture and turn off the firewall;
  2. Install JDK8 on the <font color="blue">192.168.133.208</font> computer;
  3. The focus of this article is KMS deployment. There is no need to develop SpringBoot applications. Just download the jar file I prepared. The address is: https://download.csdn.net/download/boling_cavalry/14012545
  4. Download <font color="red">helloworld-0.0.1-SNAPSHOT.jar</font> to <font color="blue">192.168.133.208</font>, and then execute the following command to start the application. Note The IP of the parameter <font color="blue">-Dkms.url</font> is the address of the KMS computer:
java -Dkms.url=ws://192.168.133.207:8888/kurento -jar helloworld-0.0.1-SNAPSHOT.jar
  1. The console outputs the following content, indicating that the startup is successful:
[root@centos7 ~]# java -Dkms.url=ws://192.168.133.207:8888/kurento -jar helloworld-0.0.1-SNAPSHOT.jar

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.3.3.RELEASE)

2021-01-03 12:30:56.702  WARN 24669 --- [           main] o.s.boot.StartupInfoLogger               : InetAddress.getLocalHost().getHostName() took 10004 milliseconds to respond. Please verify your network configuration.
2021-01-03 12:31:06.719  INFO 24669 --- [           main] c.b.helloworld.HelloWorldApplication     : Starting HelloWorldApplication on centos7 with PID 24669 (/root/helloworld-0.0.1-SNAPSHOT.jar started by root in /root)
2021-01-03 12:31:06.719  INFO 24669 --- [           main] c.b.helloworld.HelloWorldApplication     : No active profile set, falling back to default profiles: default
2021-01-03 12:31:07.970  INFO 24669 --- [rbeatExec-e1-t0] o.k.j.c.JsonRpcClientNettyWebSocket      : [KurentoClient]  Connecting native client
2021-01-03 12:31:07.974  INFO 24669 --- [rbeatExec-e1-t0] o.k.j.c.JsonRpcClientNettyWebSocket      : [KurentoClient]  Creating new NioEventLoopGroup
2021-01-03 12:31:23.159  INFO 24669 --- [ntLoopGroup-2-1] o.k.j.c.JsonRpcClientNettyWebSocket      : [KurentoClient]  Initiating new Netty channel. Will create new handler too!
2021-01-03 12:31:23.267  WARN 24669 --- [           main] org.kurento.client.KurentoClient         : Connected to KMS in 15294 millis (> 5000 millis)
2021-01-03 12:31:24.241  INFO 24669 --- [           main] c.b.helloworld.HelloWorldApplication     : Started HelloWorldApplication in 53.092 seconds (JVM running for 53.509)
  1. Visit the address in the browser: https://192.168.133.208:8443 used, the browser will have a security prompt, click the button in the red box below:

在这里插入图片描述

  1. Click the link in the red box below to access the home page of the SpringBoot application:
    在这里插入图片描述
  2. The homepage effect is as follows. This is the official hello-world project of Kurento. Make sure that the microphone and camera on your current computer are normal, and then click the <font color="blue">Start</font> button in the red box in the figure below. Start the WebRTC process:

在这里插入图片描述

  1. For security reasons, the browser will pop up a confirmation window, as shown in the red box as shown below. After clicking confirm, the camera will start to capture the screen:

在这里插入图片描述

  1. As shown in the figure below, WebRTC has started to work normally:

    在这里插入图片描述

  2. Smart, you should have discovered that the function of this application is to send the data of the local camera to KMS, and then take the video from KMS to the local display. The official flow chart is as follows:

在这里插入图片描述

  1. If the browser you are using is Chrome, open another tab and enter the address: chrome://webrtc-internals/, you can view the details of WebRTC, as shown in the figure below, you can see the detailed information of PeerConnection:

在这里插入图片描述

  1. As shown in the red box in the following figure, the video stream output locally to KMS is encoded in <font color="blue">VP8</font>:

在这里插入图片描述

  1. You can continue to try, log in to the KMS machine and execute the following command to stop the KMS service. When you return to the web page, you will find that the preview window on the left is still working, but the remote video window on the right has stopped moving:
service kurento-media-server stop
  • At this point, the operation of KMS from deployment to experience has been completed. I hope this article can help you complete the most basic kurento experience. In the next article, let's continue to write the code for actual combat, and learn kurento while doing it;

You are not lonely, Xinchen is with you all the way

  1. Java series
  2. Spring series
  3. Docker series
  4. kubernetes series
  5. database + middleware series
  6. DevOps series

Welcome to pay attention to the public account: programmer Xin Chen

Search "Programmer Xin Chen" on WeChat, I am Xin Chen, and I look forward to traveling the Java world with you...
https://github.com/zq2599/blog_demos

程序员欣宸
147 声望24 粉丝

热爱Java和Docker