In simulcast consumer, we will calculate the desired bitrate.
uint32_t SimulcastConsumer::GetDesiredBitrate() const
{
MS_TRACE();
MS_ASSERT(this->externallyManagedBitrate, "bitrate is not externally managed");
if (!IsActive())
return 0u;
auto nowMs = DepLibUV::GetTimeMs();
uint32_t desiredBitrate{ 0u };
for (int sIdx{ static_cast<int>(this->producerRtpStreams.size()) - 1 }; sIdx >= 0; --sIdx)
{
auto* producerRtpStream = this->producerRtpStreams.at(sIdx);
if (!producerRtpStream)
continue;
desiredBitrate = producerRtpStream->GetBitrate(nowMs);
if (desiredBitrate)
break;
}
// If consumer.rtpParameters.encodings[0].maxBitrate was given and it's
// greater than computed one, then use it.
auto maxBitrate = this->rtpParameters.encodings[0].maxBitrate;
if (maxBitrate > desiredBitrate)
desiredBitrate = maxBitrate;
return desiredBitrate;
}
The function try to find out the highest active layer, and get it’s bitrate as desiredBitrate.
My question is why don’t we use the bitrate of preferred layer ?
In some situations, we only want to watch the speaker in big picture, and the others in small picture.