updateBitrate method

dynamic updateBitrate({
  1. num bitrate = 0,
})

Set SDP information to remote peer with bandwidth restriction.

bitrate - New bitrate value in kbps or 0 unlimited bitrate. Returns Future object which resolves when bitrate was successfully updated.

Implementation

updateBitrate({num bitrate = 0}) async {
  if (peer == null) {
    _logger.e('Cannot update bitrate. No peer found.');
    throw Exception('Cannot update bitrate. No peer found.');
  }

  _logger.i('Updating bitrate to value: ', bitrate);
  sessionDescription = await peer!.createOffer();
  await peer?.setLocalDescription(sessionDescription!);
  String? sdp = updateBandwidthRestriction(
      (await peer!.getRemoteDescription())?.sdp, bitrate);
  await setRTCRemoteSDP(sdp);
  _logger.i(
      '''Bitrate restrictions updated:  ${bitrate > 0 ? bitrate : 'unlimited'} kbps''');
}