Mediasoup source code analysis (7) consumer creation process

1. Introduction to consumer types

There are four types of consumers in mediasoup, SimpleConsumer, PipeConsumer, SvcConsumer, and SimucastConsumer.

The type of consumer is created based on the type of producer.

SimpleConsumer: Consumer of ordinary RTP data, corresponding to PlainTransport.

PipeConsumer: The data flow between Routers between different Workers is to receive or consume the data passed from the Router in another Worker.

SvcConsumer: The transmission is generally divided into 3 layers (core layer, expansion layer, edge layer) for transmission, then it processes and consumes multiple layers of data.

SimulcastConsumer: Simulcast multicast mode, that is, when the sharer uses multiple streams, it is used to receive.

Second, the creation process

See the consume function of Transport.ts

async consume(
{
   producerId,
   rtpCapabilities,
   paused = false,
   preferredLayers,
   appData = {}
}: ConsumerOptions
): Promise<Consumer>
{
....
....
  //创建Consumer
  const reqData =
 {
	 kind : producer.kind,
	 rtpParameters,
	 //创建consumer时,type类型来自producer的类型  
	 //对应 Producer中的_data.type ,在Producer构造函数中创建
	 type  : producer.type,  
	 consumableRtpEncodings : producer.consumableRtpParameters.encodings,
	

Guess you like

Origin blog.csdn.net/lcalqf/article/details/108010534
Recommended