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

Merge branch 'master' of github.com:versatica/mediasoup

...@@ -57,7 +57,6 @@ namespace RTC ...@@ -57,7 +57,6 @@ namespace RTC
uint32_t GetRate(uint64_t now); uint32_t GetRate(uint64_t now);
size_t GetPacketCount() const; size_t GetPacketCount() const;
size_t GetBytes() const; size_t GetBytes() const;
void Reset();
private: private:
RateCalculator rate; RateCalculator rate;
...@@ -70,14 +69,14 @@ namespace RTC ...@@ -70,14 +69,14 @@ namespace RTC
inline RateCalculator::RateCalculator(size_t windowSize, float scale) inline RateCalculator::RateCalculator(size_t windowSize, float scale)
: windowSize(windowSize), scale(scale) : windowSize(windowSize), scale(scale)
{ {
uint64_t now = DepLibUV::GetTime(); Reset();
Reset(now);
} }
inline void RateCalculator::Reset() inline void RateCalculator::Reset()
{ {
Reset(this->oldestTime); uint64_t now = DepLibUV::GetTime();
Reset(now);
} }
inline void RateCalculator::Reset(uint64_t now) inline void RateCalculator::Reset(uint64_t now)
...@@ -102,13 +101,6 @@ namespace RTC ...@@ -102,13 +101,6 @@ namespace RTC
{ {
return this->bytes; return this->bytes;
} }
inline void RtpDataCounter::Reset()
{
rate.Reset();
this->packets = 0;
this->bytes = 0;
}
} // namespace RTC } // namespace RTC
#endif #endif
...@@ -15,7 +15,7 @@ namespace RTC ...@@ -15,7 +15,7 @@ namespace RTC
if (now < this->oldestTime) if (now < this->oldestTime)
return; return;
this->RemoveOldData(now); RemoveOldData(now);
// Set data in the index before the oldest index. // Set data in the index before the oldest index.
uint32_t offset = this->windowSize - 1; uint32_t offset = this->windowSize - 1;
...@@ -32,10 +32,9 @@ namespace RTC ...@@ -32,10 +32,9 @@ namespace RTC
{ {
MS_TRACE(); MS_TRACE();
this->RemoveOldData(now); RemoveOldData(now);
int64_t nominalWindowSize = now - this->oldestTime; float scale = this->scale / this->windowSize;
float scale = this->scale / nominalWindowSize;
return static_cast<uint32_t>(std::trunc(this->totalCount * scale + 0.5f)); return static_cast<uint32_t>(std::trunc(this->totalCount * scale + 0.5f));
} }
...@@ -48,7 +47,13 @@ namespace RTC ...@@ -48,7 +47,13 @@ namespace RTC
// Should never happen. // Should never happen.
if (newOldestTime < this->oldestTime) if (newOldestTime < this->oldestTime)
{
MS_ERROR(
"current time [%" PRIu64 "] is older than a previous [%" PRIu64 "]",
newOldestTime,
this->oldestTime);
return; return;
}
// We are in the same time unit (ms) as the last entry. // We are in the same time unit (ms) as the last entry.
if (newOldestTime == this->oldestTime) if (newOldestTime == this->oldestTime)
...@@ -57,7 +62,7 @@ namespace RTC ...@@ -57,7 +62,7 @@ namespace RTC
// A whole window size time has elapsed since last entry. Reset the buffer. // A whole window size time has elapsed since last entry. Reset the buffer.
if (newOldestTime > this->oldestTime + this->windowSize) if (newOldestTime > this->oldestTime + this->windowSize)
{ {
this->Reset(newOldestTime); Reset(now);
return; return;
} }
......
...@@ -119,7 +119,7 @@ namespace RTC ...@@ -119,7 +119,7 @@ namespace RTC
if (ssrc != 0u) if (ssrc != 0u)
{ {
if (!this->HasSsrc(ssrc, producer)) if (!HasSsrc(ssrc, producer))
{ {
this->ssrcTable[ssrc] = producer; this->ssrcTable[ssrc] = producer;
} }
...@@ -138,7 +138,7 @@ namespace RTC ...@@ -138,7 +138,7 @@ namespace RTC
if (ssrc != 0u) if (ssrc != 0u)
{ {
if (!this->HasSsrc(ssrc, producer)) if (!HasSsrc(ssrc, producer))
{ {
this->ssrcTable[ssrc] = producer; this->ssrcTable[ssrc] = producer;
} }
...@@ -157,7 +157,7 @@ namespace RTC ...@@ -157,7 +157,7 @@ namespace RTC
if (ssrc != 0u) if (ssrc != 0u)
{ {
if (!this->HasSsrc(ssrc, producer)) if (!HasSsrc(ssrc, producer))
{ {
this->ssrcTable[ssrc] = producer; this->ssrcTable[ssrc] = producer;
} }
...@@ -178,7 +178,7 @@ namespace RTC ...@@ -178,7 +178,7 @@ namespace RTC
{ {
auto& muxId = rtpParameters.muxId; auto& muxId = rtpParameters.muxId;
if (!this->HasMuxId(muxId, producer)) if (!HasMuxId(muxId, producer))
{ {
this->muxIdTable[muxId] = producer; this->muxIdTable[muxId] = producer;
} }
...@@ -201,7 +201,7 @@ namespace RTC ...@@ -201,7 +201,7 @@ namespace RTC
if (rid.empty()) if (rid.empty())
continue; continue;
if (!this->HasRid(rid, producer)) if (!HasRid(rid, producer))
{ {
this->ridTable[rid] = producer; this->ridTable[rid] = producer;
} }
......
...@@ -115,7 +115,7 @@ namespace RTC ...@@ -115,7 +115,7 @@ namespace RTC
score += repairedPercentage * RepairedPercentageWeight; score += repairedPercentage * RepairedPercentageWeight;
// Add score to histogram. // Add score to histogram.
this->AddScore(static_cast<uint8_t>(score / 10 + 0.5f)); AddScore(static_cast<uint8_t>(score / 10 + 0.5f));
#ifdef MS_LOG_DEV #ifdef MS_LOG_DEV
MS_DEBUG_TAG( MS_DEBUG_TAG(
...@@ -129,7 +129,7 @@ namespace RTC ...@@ -129,7 +129,7 @@ namespace RTC
score); score);
report->Dump(); report->Dump();
this->Dump(); Dump();
#endif #endif
} }
......
...@@ -261,7 +261,7 @@ namespace RTC ...@@ -261,7 +261,7 @@ namespace RTC
if (timer == this->statusCheckTimer) if (timer == this->statusCheckTimer)
{ {
this->CheckStatus(); CheckStatus();
} }
} }
} // namespace RTC } // namespace RTC
...@@ -27,15 +27,15 @@ namespace RTC ...@@ -27,15 +27,15 @@ namespace RTC
std::string ip; std::string ip;
uint16_t port; uint16_t port;
Utils::IP::GetAddressInfo(this->GetLocalAddress(), &ipFamily, ip, &port); Utils::IP::GetAddressInfo(GetLocalAddress(), &ipFamily, ip, &port);
json[JsonStringLocalIp] = ip; json[JsonStringLocalIp] = ip;
json[JsonStringLocalPort] = Json::UInt{ port }; json[JsonStringLocalPort] = Json::UInt{ port };
if (this->GetProtocol() == RTC::TransportTuple::Protocol::UDP) if (GetProtocol() == RTC::TransportTuple::Protocol::UDP)
json[JsonStringProtocol] = JsonStringUdp; json[JsonStringProtocol] = JsonStringUdp;
else else
json[JsonStringProtocol] = JsonStringTcp; json[JsonStringProtocol] = JsonStringTcp;
Utils::IP::GetAddressInfo(this->GetRemoteAddress(), &ipFamily, ip, &port); Utils::IP::GetAddressInfo(GetRemoteAddress(), &ipFamily, ip, &port);
json[JsonStringRemoteIp] = ip; json[JsonStringRemoteIp] = ip;
json[JsonStringRemotePort] = Json::UInt{ port }; json[JsonStringRemotePort] = Json::UInt{ port };
......
...@@ -1251,7 +1251,7 @@ namespace RTC ...@@ -1251,7 +1251,7 @@ namespace RTC
packet.SetBitrate(effectiveBitrate); packet.SetBitrate(effectiveBitrate);
packet.SetSsrcs(ssrcs); packet.SetSsrcs(ssrcs);
packet.Serialize(RTC::RTCP::Buffer); packet.Serialize(RTC::RTCP::Buffer);
this->SendRtcpPacket(&packet); SendRtcpPacket(&packet);
if (now - this->lastEffectiveMaxBitrateAt > EffectiveMaxBitrateCheckInterval) if (now - this->lastEffectiveMaxBitrateAt > EffectiveMaxBitrateCheckInterval)
{ {
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论