提交 345327ca authored 作者: José Luis Millán's avatar José Luis Millán

#247. Calculate consumer score entirely based on the Receiver Reports

上级 df266f1b
...@@ -56,8 +56,8 @@ namespace RTC ...@@ -56,8 +56,8 @@ namespace RTC
void UpdateScore(RTC::RTCP::ReceiverReport* report); void UpdateScore(RTC::RTCP::ReceiverReport* report);
private: private:
uint32_t sourceLostPrior{ 0 }; // Packets lost in source at last interval. uint32_t lostPrior{ 0 }; // Packets lost at last interval.
uint32_t lostPrior{ 0 }; // Packets lost at last interval. uint32_t sentPrior{ 0 }; // Packets sent at last interval.
std::vector<StorageItem> storage; std::vector<StorageItem> storage;
std::list<BufferItem> buffer; std::list<BufferItem> buffer;
float rtt{ 0 }; float rtt{ 0 };
......
...@@ -529,64 +529,31 @@ namespace RTC ...@@ -529,64 +529,31 @@ namespace RTC
{ {
MS_TRACE(); MS_TRACE();
// Calculate number of packets lost in the source in this interval. // Calculate number of packets sent in this interval.
auto totalExpected = GetExpectedPackets(); auto totalSent = this->transmissionCounter.GetPacketCount();
auto expected = totalExpected - this->expectedPrior; auto sent = totalSent - this->sentPrior;
// We didn't send new packets. // We didn't send any packet.
if (expected == 0) if (sent == 0)
return; return;
this->expectedPrior = totalExpected; this->sentPrior = totalSent;
// TODO: REMOVE // Calculate number of packets lost in this interval.
// std::cout << "RtpStreamSend::UpdateScore() 1: totalExpected:" << totalExpected << ", uint32_t totalLost = report->GetTotalLost() > 0 ? report->GetTotalLost() : 0;
// expected:" << expected << "\n"; uint32_t lost;
auto totalSent = this->transmissionCounter.GetPacketCount();
auto totalSourceLost = totalExpected > totalSent ? totalExpected - totalSent : 0;
// Current lost may be less now than before.
if (totalSourceLost < this->sourceLostPrior)
totalSourceLost = this->sourceLostPrior;
auto sourceLost = totalSourceLost - this->sourceLostPrior;
this->sourceLostPrior = totalSourceLost;
// TODO: REMOVE
// std::cout << "RtpStreamSend::UpdateScore() 2: totalSent:" << totalSent << ",
// totalSourceLost:" << totalSourceLost << ", sourceLost:" << sourceLost << "\n";
// Calculate number of packets lost in the edge in this interval.
uint32_t totalLost = report->GetTotalLost();
// Do not trust whatever the received RR says.
if (totalLost < this->lostPrior) if (totalLost < this->lostPrior)
totalLost = this->lostPrior; lost = 0;
else
auto lost = totalLost - this->lostPrior; lost = totalLost - this->lostPrior;
this->lostPrior = totalLost; this->lostPrior = totalLost;
// TODO: REMOVE
// std::cout << "RtpStreamSend::UpdateScore() 3: totalLost:" << totalLost << ", lost:" << lost << "\n";
// Substract number of packets lost at the source.
if (lost > sourceLost)
lost = sourceLost;
// TODO: REMOVE
// std::cout << "RtpStreamSend::UpdateScore() 4: lost -= sourceLost:" << lost << "\n";
// Calculate number of packets repaired in this interval. // Calculate number of packets repaired in this interval.
auto totalRepaired = this->packetsRepaired; auto totalRepaired = this->packetsRepaired;
uint32_t repaired = totalRepaired - this->repairedPrior; uint32_t repaired = totalRepaired - this->repairedPrior;
// TODO: REMOVE
// std::cout << "RtpStreamSend::UpdateScore() 5: totalRepaired:" << totalRepaired << ",
// repaired:" << repaired << "\n";
this->repairedPrior = totalRepaired; this->repairedPrior = totalRepaired;
if (repaired >= lost) if (repaired >= lost)
...@@ -594,20 +561,8 @@ namespace RTC ...@@ -594,20 +561,8 @@ namespace RTC
else else
lost -= repaired; lost -= repaired;
// TODO: REMOVE // Calculate packet loss percentage in this interval.
// std::cout << "RtpStreamSend::UpdateScore() 6: lost:" << lost << "\n"; float lossPercentage = lost * 100 / (sent > lost ? sent : lost);
if (repaired > lost)
{
MS_DEBUG_TAG(
score, "repaired greater than lost [repaired:%" PRIu32 ", lost:%" PRIu32 "]", repaired, lost);
}
// Calculate packet loss percentage in this interva.
float lossPercentage = lost * 100 / expected;
// TODO: REMOVE
// std::cout << "RtpStreamSend::UpdateScore() 7: lossPercentage:" << lossPercentage << "\n";
/* /*
* Calculate score. Starting from a score of 100: * Calculate score. Starting from a score of 100:
...@@ -618,15 +573,9 @@ namespace RTC ...@@ -618,15 +573,9 @@ namespace RTC
base100Score -= (lossPercentage * 1.0f); base100Score -= (lossPercentage * 1.0f);
// TODO: REMOVE
// std::cout << "RtpStreamSend::UpdateScore() 8: base100Score:" << base100Score << "\n";
// Get base 10 score. // Get base 10 score.
auto score = static_cast<uint8_t>(std::lround(base100Score / 10)); auto score = static_cast<uint8_t>(std::lround(base100Score / 10));
// TODO: REMOVE
// std::cout << "RtpStreamSend::UpdateScore() 9: score:" << int{ score } << "\n";
#ifdef MS_LOG_DEV #ifdef MS_LOG_DEV
MS_DEBUG_TAG( MS_DEBUG_TAG(
score, score,
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论