Licode Simulcast

Licode Simulcast

licode enable simlcast

Publisher端创建stream的时候config参数添加simulcast

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

numSpatialLayers 是Publisher发送的spatial layers的最大数

目前web端的话只能是遵循原生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}
};

Subscriber 订阅流的时候可以直接按照普通subscriber订阅的方式直接订阅,比较nice的一点是,可以指定订阅spatialLayertemporalLayer,其中spatiaLayer为resolutions,temporalLayer为FrameRate,一般temporalLayer有三个可供选择,比如:

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

可以在room.on('stream-subscribed', function (streamEvent) 事件中设定

stream._setStaticQualityLayer(1, 2);

这样订阅的就是分辨率640 x 480帧率为14的流

你可能感兴趣的:(Licode Simulcast)