Unverified 提交 0ebe37b1 authored 作者: José Luis Millán's avatar José Luis Millán 提交者: GitHub

RtpStreamRecv: Enhance jitter calculation (#525)

* Don't set any value until at least two packets have arrived.
* Reset the value when pausing.
* Relative transit time variable is signed by definition:
  https://tools.ietf.org/html/rfc3550#appendix-A.8
上级 553f5f07
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
* Update `nlohmann/json` to 3.9.1. * Update `nlohmann/json` to 3.9.1.
* Update `usrsctp`. * Update `usrsctp`.
* Update NPM deps. * Update NPM deps.
* Enhance Jitter calculation.
### 3.6.32 ### 3.6.32
......
...@@ -96,7 +96,7 @@ namespace RTC ...@@ -96,7 +96,7 @@ namespace RTC
// sender report. // sender report.
uint64_t lastSrReceived{ 0u }; // Wallclock time representing the most recent uint64_t lastSrReceived{ 0u }; // Wallclock time representing the most recent
// sender report arrival. // sender report arrival.
uint32_t transit{ 0u }; // Relative transit time for prev packet. int32_t transit{ 0u }; // Relative transit time for prev packet.
uint32_t jitter{ 0u }; uint32_t jitter{ 0u };
uint8_t firSeqNumber{ 0u }; uint8_t firSeqNumber{ 0u };
uint32_t reportedPacketLost{ 0u }; uint32_t reportedPacketLost{ 0u };
......
...@@ -623,6 +623,10 @@ namespace RTC ...@@ -623,6 +623,10 @@ namespace RTC
if (this->params.useNack) if (this->params.useNack)
this->nackGenerator->Reset(); this->nackGenerator->Reset();
// Reset jitter.
this->transit = 0;
this->jitter = 0;
} }
void RtpStreamRecv::Resume() void RtpStreamRecv::Resume()
...@@ -644,6 +648,14 @@ namespace RTC ...@@ -644,6 +648,14 @@ namespace RTC
static_cast<int>(DepLibUV::GetTimeMs() - (rtpTimestamp * 1000 / this->params.clockRate)); static_cast<int>(DepLibUV::GetTimeMs() - (rtpTimestamp * 1000 / this->params.clockRate));
int d = transit - this->transit; int d = transit - this->transit;
// First transit calculation, save and return.
if (this->transit == 0)
{
this->transit = transit;
return;
}
this->transit = transit; this->transit = transit;
if (d < 0) if (d < 0)
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论