Mediasoup study notes Server side [1]

I have introduced my study notes on the client side. Recently, I have had some time. I will go back and sort out the study notes on the server side.

Here we will follow the official demo code to sort out and learn step by step.
https://github.com/versatica/mediasoup-demo/tree/v3/server

At first glance, the code structure is quite a lot.
Insert picture description here
In fact, it can realize the server-side function of mediasoup by focusing on the following files;

  • config[.example].js
  • server.js
  • lib/Room.js

Let’s explain one by one below;

config.js

The main configuration here is the certificate port domain name ip address and so on. If you have some audio and video parameters, you can also configure it here. Here is a picture for reference only
Insert picture description here

  • routerOptions create routing related parameters
  • webRtcTransportOptions Create rtc channel related parameters
  • plainTransportOptions If you don't need to create the channel, you don't need to configure it here

server.js

This part of the code and the related functions of mediasoup can be simply understood as a unified control of room creation and deletion; getOrCreateRoom

I only pay attention here

  • runMediasoupWorkers medisoup service
  • runHttpsServer http service
  • runProtooWebSocketServer websocket service

As for createExpressApp, it can be regarded as a pure demo business function;

Room.js

The server part is to control the room, here is the control person, channel, and data.
Focus on learning points

*_handleProtooRequest handles the data through signaling, other methods are around


  • If handleProtooConnection can understand the function of the following code, the rest is the api problem.
peer.data.transports = new Map();
peer.data.producers = new Map();
peer.data.consumers = new Map();
peer.data.dataProducers = new Map();
peer.data.dataConsumers = new Map();

Let me briefly mention it here. For example, the first peer.data.transports can be simply understood as storing the rest of the total number of transports created by this user. The rest is easier to understand.
That's it for ok. I will talk about some important files, and we will introduce them in detail later.

Guess you like

Origin blog.csdn.net/uk_51/article/details/114785025