Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Estimate bandwidth in connection and don't limit by REMBs #1726

Merged
merged 17 commits into from
Jun 18, 2021

Conversation

lodoyun
Copy link
Contributor

@lodoyun lodoyun commented Jun 17, 2021

Description
This PR fundamentally changes the way maxVideoBW works:

  1. The bitrate estimation for the receiver is no longer done at the mediaStream level but at the connection level.
  2. We no longer limit the publishers bitrate by using REMBs but by modifying the encoder sender parameters.

[] It needs and includes Unit Tests

Changes in Client or Server public APIs

The APIs are the same but maxVideoBW in the publisher now has a slightly different meaning, particularly in simulcast. Now that bandwidth will limit the top layer instead of limiting the whole stream (the addition of all the layers bitrates). When not in simulcast the result is more or less the same since we only have one layer.

If more control over layer bitrate is needed, apps should use updateSimulcastLayersBitrate to set the bitrate for each layer.

[] It includes documentation for these changes in /doc.

Copy link
Contributor

@jcague jcague left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I only have some minor comments but overall functionality looks right and it's quite promising to improve quality

@@ -57,32 +58,25 @@ void BandwidthEstimationHandler::disable() {
}

void BandwidthEstimationHandler::notifyUpdate() {
ELOG_DEBUG("NotifyUPDATE");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we use a more descriptive message?

@@ -229,19 +223,39 @@ void BandwidthEstimationHandler::pickEstimator() {
}

void BandwidthEstimationHandler::sendREMBPacket() {
sink_ssrc_ = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to use a class variable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right. I kept if for consistency but it does make more sense to have it as a local variable.

});

if (sink_ssrc_ == 0) {
ELOG_WARN("No SSRC available to send REMB");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if there could be cases where we should not notify with a warning here.

@@ -252,6 +266,7 @@ void BandwidthEstimationHandler::sendREMBPacket() {

void BandwidthEstimationHandler::OnReceiveBitrateChanged(const std::vector<uint32_t>& ssrcs,
uint32_t bitrate) {
ELOG_WARN("Onreceive bitrate %lu", bitrate);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider using ELOG_DEBUG here

@@ -68,6 +77,77 @@ const Stream = (altConnectionHelpers, specInput) => {
that.local = true;
}

const setMaxVideoBW = (maxVideoBW) => {
if (that.local) {
const translated = (maxVideoBW * 1000 * 0.90) - (50 * 40 * 8);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could add a reference here to know where this formula comes from

@@ -14,7 +14,7 @@ const BaseStack = (specInput) => {
};
that.getNegotiationLogs = () => logs.reduce((a, b) => `${a}'\n'${b}`);

log.debug(`message: Starting Base stack, spec: ${JSON.stringify(specBase)}`);
log.warning(`message: Starting Base stack, spec: ${JSON.stringify(specBase)}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider using log.debug here again


for (std::size_t i = 0; i < source_ssrcs_.size(); i++) {
ELOG_DEBUG("Setting REMBFeedSSRC %u to ssrc %u, size %u", i, source_ssrcs_[i], source_ssrcs_.size());
remb_packet_.setREMBFeedSSRC(i, source_ssrcs_[i]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

const nativeSenderParameters = [];
const requestedLayers = Object.keys(videoSenderLicodeParameters).length ||
defaultSimulcastSpatialLayers;
const isScreenshare = that.hasScreen();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

that.maxVideoBW = translated;
} else {
that.maxVideoBW = maxVideoBW;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we reapply the encoder parameters here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't always want to apply it immediately. For instance, if you specify a maxVideoBW in room.publish we then generate the initial configuration and then include those in the transceiver.

nativeStream.transceivers.push(transceiver);
const parameters = transceiver.sender.getParameters() || {};
parameters.encodings = streamInput.generateEncoderParameters();
console.warn('parameters to set', parameters);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider removing this line

@lodoyun lodoyun merged commit f3ccb54 into lynckia:master Jun 18, 2021
@lodoyun lodoyun deleted the add/estimateBandwidthInConnection branch June 18, 2021 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants