I am trying to limit the bitrate of a WebRTC video stream sent from the browser. With Chromium-based browsers, I simply set the maxBitrate
field of the sendEncodings
field at addTransceiver
time. Since Firefox doesn't support sendEncodings
, I need to call getParameters
on the sender, tweak its encodings
field, then call setParameters
.
This works quite well in the simulcast case; however, in the non-simulcast case (encodings
is an array containing a single entry), Firefox appears to ignore the maxBitrate
field, and always sends at its maximum bitrate (2.5kbit/s).
Is encodings[0].maxBitrate
supposed to work in Firefox in the non-simulcast case?
CodePudding user response:
After some investigation, it turns out that Firefox doesn't obey the bandwidth limitation in the non-simulcast case if the rid
field is set. So this works in both Chromium and Firefox:
let p = sender.getParameters();
p.encodings = [{maxBitrate: 700000}];
await sender.setParameters(p);
while this only works in Chromium:
let p = sender.getParameters();
p.encodings = [{rid: 'h', maxBitrate: 700000}];
await sender.setParameters(p);