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

(worker): Modification of Consumer bitrate allocation algorithm #708

Merged
merged 2 commits into from
Nov 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions worker/src/RTC/Transport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2362,15 +2362,17 @@ namespace RTC
if (multimapPriorityConsumer.empty())
return;

bool baseAllocation = true;
uint32_t availableBitrate = this->tccClient->GetAvailableBitrate();

this->tccClient->RescheduleNextAvailableBitrateEvent();

MS_DEBUG_DEV("before layer-by-layer iterations [availableBitrate:%" PRIu32 "]", availableBitrate);

// Redistribute the available bitrate by allowing Consumers to increase
// layer by layer. Take into account the priority of each Consumer to
// provide it with more bitrate.
// layer by layer. Initially try to spread the bitrate across all
// consumers. Then allocate the excess bitrate to Consumers starting
// with the highest priorty.
while (availableBitrate > 0u)
{
auto previousAvailableBitrate = availableBitrate;
Expand All @@ -2381,9 +2383,7 @@ namespace RTC
auto* consumer = it->second;
auto bweType = this->tccClient->GetBweType();

// If a Consumer has priority > 1, call IncreaseLayer() more times to
// provide it with more available bitrate to choose its preferred layers.
for (uint8_t i{ 1u }; i <= priority; ++i)
for (uint8_t i{ 1u }; i <= (baseAllocation ? 1u : priority); ++i)
{
uint32_t usedBitrate{ 0u };

Expand All @@ -2410,6 +2410,8 @@ namespace RTC
// If no Consumer used bitrate, exit the loop.
if (availableBitrate == previousAvailableBitrate)
break;

baseAllocation = false;
}

MS_DEBUG_DEV("after layer-by-layer iterations [availableBitrate:%" PRIu32 "]", availableBitrate);
Expand Down