提交 eb48652c authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

SimulcastConsumer.cpp: cosmetic changes and make code easier by taking into…

SimulcastConsumer.cpp: cosmetic changes and make code easier by taking into account that preferredSpatialLayer has always a valid value between 0 and N.
上级 69b283d0
...@@ -639,7 +639,8 @@ namespace RTC ...@@ -639,7 +639,8 @@ namespace RTC
uint8_t maxScore = 0; uint8_t maxScore = 0;
for (int idx = this->producerRtpStreams.size() - 1; idx >= 0; --idx) // Ignore spatial layers higher than the preferred one.
for (int idx = this->preferredSpatialLayer; idx >= 0; --idx)
{ {
auto spatialLayer = static_cast<int16_t>(idx); auto spatialLayer = static_cast<int16_t>(idx);
auto* producerRtpStream = this->producerRtpStreams[idx]; auto* producerRtpStream = this->producerRtpStreams[idx];
...@@ -648,10 +649,6 @@ namespace RTC ...@@ -648,10 +649,6 @@ namespace RTC
if (!producerRtpStream) if (!producerRtpStream)
continue; continue;
// Ignore spatial layers higher than the preferred one.
if (idx > this->preferredSpatialLayer)
return;
if (producerRtpStream->GetScore() >= maxScore) if (producerRtpStream->GetScore() >= maxScore)
{ {
std::cout << "RecalculateTargetSpatialLayer. we have something: " << spatialLayer std::cout << "RecalculateTargetSpatialLayer. we have something: " << spatialLayer
...@@ -659,11 +656,11 @@ namespace RTC ...@@ -659,11 +656,11 @@ namespace RTC
maxScore = producerRtpStream->GetScore(); maxScore = producerRtpStream->GetScore();
newTargetSpatialLayer = spatialLayer; newTargetSpatialLayer = spatialLayer;
if (producerRtpStream->GetScore() > 7) if (maxScore > 7)
{ {
std::cout << "RecalculateTargetSpatialLayer. score > 7, keep it : " << spatialLayer std::cout << "RecalculateTargetSpatialLayer. score > 7, keep it : " << spatialLayer
<< std::endl; << std::endl;
newTargetSpatialLayer = spatialLayer;
break; break;
} }
} }
...@@ -694,11 +691,11 @@ namespace RTC ...@@ -694,11 +691,11 @@ namespace RTC
maxScore = producerRtpStream->GetScore(); maxScore = producerRtpStream->GetScore();
newTargetSpatialLayer = spatialLayer; newTargetSpatialLayer = spatialLayer;
if (producerRtpStream->GetScore() > 7) if (maxScore > 7)
{ {
std::cout << "RecalculateTargetSpatialLayer. score > 7, keep it : " << spatialLayer std::cout << "RecalculateTargetSpatialLayer. score > 7, keep it : " << spatialLayer
<< std::endl; << std::endl;
newTargetSpatialLayer = spatialLayer;
break; break;
} }
} }
...@@ -709,16 +706,14 @@ namespace RTC ...@@ -709,16 +706,14 @@ namespace RTC
{ {
std::cout << "RecalculateTargetSpatialLayer. trying to upgrade..." << std::endl; std::cout << "RecalculateTargetSpatialLayer. trying to upgrade..." << std::endl;
size_t idx = this->currentSpatialLayer == -1 ? 0 : this->currentSpatialLayer + 1; int16_t idx = this->currentSpatialLayer == -1 ? 0 : this->currentSpatialLayer + 1;
for (; idx <= this->producerRtpStreams.size() - 1; ++idx)
// Ignore spatial layers above the preferred one.
for (; idx <= this->preferredSpatialLayer; ++idx)
{ {
auto spatialLayer = static_cast<int16_t>(idx); auto spatialLayer = idx;
auto* producerRtpStream = this->producerRtpStreams[idx]; auto* producerRtpStream = this->producerRtpStreams[idx];
// Ignore spatial layers above the preferred one.
if (spatialLayer > this->preferredSpatialLayer)
break;
// Ignore spatial layers for non existing Producer streams. // Ignore spatial layers for non existing Producer streams.
if (!producerRtpStream) if (!producerRtpStream)
continue; continue;
...@@ -729,6 +724,7 @@ namespace RTC ...@@ -729,6 +724,7 @@ namespace RTC
std::cout << "RecalculateTargetSpatialLayer. good enough spatial layer found: " std::cout << "RecalculateTargetSpatialLayer. good enough spatial layer found: "
<< spatialLayer << std::endl; << spatialLayer << std::endl;
newTargetSpatialLayer = spatialLayer; newTargetSpatialLayer = spatialLayer;
break; break;
} }
} }
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论