Why learn Mediasoup lightweight, easy to get started, strong scalability, support point-to-point, support server forwarding.
Environment set up
1. Install the VM
If you have the ability to support the legitimate version
- VMware Workstation 15x is used for virtual machines
Download address: dl.pconline.com.cn/download/21…
- The system image uses Ubuntu 20X
Download it at www.oschina.net/p/ubuntu
-
Installation guide: zhuanlan.zhihu.com/p/41940739
-
VMwareTools installation of Shared folder configuration: blog.csdn.net/yangsong435…
-
The solution of virtual machine full screen: blog.csdn.net/u013554213/…
2. Switch to user root
Configure the root user first
-
Ctrl+Alt+T opens the console
-
Type the command
sudo passwd root
Copy the code
- Enter your password as prompted
Switch to user root
- Type the command
su root
Copy the code
-
Enter your password as prompted
-
If the front of the command line changes to root@xx, the switchover is successful
3. Development environment construction
- NVM installation (for managing Nodes)
www.cnblogs.com/lizhanzhou/…
/ / installation
wget -qO- https:/ / raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
// Refresh the environment
source ~/.bashrc
/ / verification
nvm -v
Copy the code
- Install the node
www.cnblogs.com/kyun/p/1231…
/ / the node installation
nvm install v1016.3.
/ / update the NPM
npm -g install npm@6.134.
// Switch ali mirror (easy to install later)
npm config set registry "http://registry.npm.taobao.org/"
// Install the daemon
npm install forever -g
// Daemon-related operations
https://www.cnblogs.com/dingxiaoyue/p/4834514.html
Copy the code
- Install git
www.cnblogs.com/luosongchao…
/ / installation
sudo apt-get install git
/ / verification
git --version
Copy the code
- Install python
www.cnblogs.com/yjp37292857…
/ / update the apt
sudo apt update
sudo apt install software-properties-common
/ / DeadsnakesPPA source added
sudo add-apt-repository ppa:deadsnakes/ppa
/ / installation
sudo apt install python38.
/ / verification
python38. --version
Copy the code
- Install the make
// Update the list
apt-get update
/ / installation
apt-get install make
/ / verification
make -v
Copy the code
- Install GCC and g++
www.cnblogs.com/gu-qiu/p/13…
Sudo apt install build-essential // check GCC --versionCopy the code
4. Mediasoup deployment
After configuring all the above environments, we finally came to the deployment of Mediasoup, which was not easy.
- Pull the project
/ / use the git clone git pull project https://github.com/versatica/mediasoup-demo.git / / if the network speed too slow, Git Checkout v3: // Git Checkout v3Copy the code
- Specify the python environment variable mediasoup.org/documentati…
PYTHON=python3 npm install mediasoup@3 --save
Copy the code
- The service side
CD server // Install NPM install // If the Python command is not found during installation, Use the following command to install PYTHON=python3 NPM install mediasoup@3 --saveCopy the code
- Obtain the server configuration file
// Copy the config file cp config.example.js config.js // open the config file sudo gedit config.jsCopy the code
- Modify Obtaining the configuration file
WebRtcTransportOptions: and plainTransportOptions: can be found in about 123 and 140 lines in config.js, respectively. WebRtcTransportOptions: {listenIps: [{IP: AnnouncedIp: null}],} plainTransportOptions: {listenIp: {IP: '192.168.0.103', announcedIp: Null}} virtual machine environment can't see the other side of the video can refer to: https://blog.csdn.net/jiayp004/article/details/106017712 cloud host configuration may refer to: https://blog.csdn.net/gjy_it/article/details/104423353? https://www.avdancedu.com/5a9f427c/Copy the code
- Generation of HTTPS certificates (for local debugging only)
www.cnblogs.com/azhqiang/p/…
Generate the key openssl rsa -in server.key -out server.key // You can cancel the password of the key openssl rsa -in server.key -out server.key 2. CRT openssl req -new -x509 -key server.key -out ca. CRT -days 3650 3 Generate CRS openSSL req -new -key server.key -out server.csr 4. CRT -csr-ca ca. CRT -cakey server.key -cacreateserial -out server. CRT 5. CRT > server.pem 6. The result is server.key and server.pemCopy the code
- Certificate Installation
Create a cerTS folder under the server. 2. Store the certificate generated in the previous step in the certs folder 3. Certificate can be found about 26 line configuration address TLS: {cert: process. The env. HTTPS_CERT_FULLCHAIN | | ` ${__dirname} / certs/server. The pem `, key: process.env.HTTPS_CERT_PRIVKEY || `${__dirname}/certs/server.key` } 4. Change server.pem and server.key to your relevant certificatesCopy the code
- The client (app)
Go to the app folder // Go to the server (server folder) CD server // Install NPMCopy the code
- Starting the server
Debug ="*mediasoup* *ERROR* *WARN*" INTERACTIVE="true" node server.jsCopy the code
- Start the client
// Go to app (client folder) CD app // Start NPM startCopy the code
- Start-up success
After the success of the launch There will be a similar information -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - Local: https://localhost:3000/? Info = true External: https://192.168.37.131:3000/? info=true --------------------------------------------------- UI: http://localhost:3001 UI External: http://localhost:3001 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - go to https://localhost:3000/? Info =true to see the screenCopy the code
conclusion
It shouldn’t be a problem if you follow my steps step by step.
If an exception occurs, check whether the VM environment is correct. Most of the problems I have with debugging are due to the lack of environment.
Have fun at the end
Next: Using WebView to achieve communication with Android terminal