Licode Simulcast

Reprinted from: https://www.jianshu.com/p/aabda9369224

Add simulcast to the config parameter when creating a stream on the Publisher side

room.publish(localStream, {simulcast: {numSpatialLayers: 2}});

numSpatialLayers is the maximum number of spatial layers sent by Publisher

At present, the web side can only follow the settings of the original webrtc

struct SimulcastFormat {
  int width;
  int height;
  // The maximum number of simulcast layers can be used for
  // resolutions at |widthxheigh|.
  size_t max_layers;
  // The maximum bitrate for encoding stream at |widthxheight|, when we are
  // not sending the next higher spatial stream.
  int max_bitrate_kbps;
  // The target bitrate for encoding stream at |widthxheight|, when this layer
  // is not the highest layer (i.e., when we are sending another higher spatial
  // stream).
  int target_bitrate_kbps;
  // The minimum bitrate needed for encoding stream at |widthxheight|.
  int min_bitrate_kbps;
};

// These tables describe from which resolution we can use how many
// simulcast layers at what bitrates (maximum, target, and minimum).
// Important!! Keep this table from high resolution to low resolution.
// clang-format off
const SimulcastFormat kSimulcastFormats[] = {
  {1920, 1080, 3, 5000, 4000, 800},
  {1280, 720, 3,  2500, 2500, 600},
  {960, 540, 3, 900, 900, 450},
  {640, 360, 2, 700, 500, 150},
  {480, 270, 2, 450, 350, 150},
  {320, 180, 1, 200, 150, 30},
  {0, 0, 1, 200, 150, 30}
};

When Subscriber subscribes to the stream, it can directly subscribe in the same way as ordinary subscribers. The nice thing is that you can specify to subscribe to spatialLayer and temporalLayer, where spatialLayer is resolutions and temporalLayer is FrameRate. Generally, there are three options for temporalLayer, such as:

Spatial Layer (0): 320 240
Spatial Layer (1): 640 480
Spatial Layer (2): 0 0
Spatial Layer (3): 0 0
Temporal Layer (0): 3
Temporal Layer (1): 11
Temporal Layer (2): 14
Temporal Layer (3): 0
Temporal Layer (4): 0

Can be set in room.on('stream-subscribed', function (streamEvent) event

stream._setStaticQualityLayer(1, 2);

This subscribes to a stream with a resolution of 640 x 480 and a frame rate of 14

Guess you like

Origin blog.csdn.net/TopsLuo/article/details/101024251