setMaxBandwidth method

void setMaxBandwidth(
  1. int? bandwidth
)

Implementation

void setMaxBandwidth(int? bandwidth) {
  senders.then((senders) {
    for (final sender in senders) {
      final parameters = sender.parameters;
      var encodings = parameters.encodings;

      if (encodings == null || encodings.isEmpty) {
        encodings = List.of([RTCRtpEncoding()]);
      }

      for (final encoding in encodings) {
        if (bandwidth == null || bandwidth == 0) {
          encoding.maxBitrate = null;
        } else {
          encoding.maxBitrate = bandwidth * 1000;
        }
      }

      parameters.encodings = encodings;
      sender.setParameters(parameters);
    }
  });
}