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

- Improve key frame request logs

- Rename Transport::timer to Transport::rtcpTimer
上级 ca67ef70
......@@ -198,7 +198,7 @@ namespace RTC
RTC::SrtpSession* srtpRecvSession{ nullptr };
RTC::SrtpSession* srtpSendSession{ nullptr };
// Others.
Timer* timer{ nullptr };
Timer* rtcpTimer{ nullptr };
bool allocated{ false };
// Others (Producers and Consumers).
std::unordered_set<RTC::Producer*> producers;
......
......@@ -385,9 +385,7 @@ namespace RTC
this->syncRequired = false;
MS_DEBUG_TAG(
rtp,
"re-syncing Consumer stream [seqNum:%" PRIu16 "]", this->seqNum);
MS_DEBUG_TAG(rtp, "re-syncing Consumer stream [seqNum:%" PRIu16 "]", this->seqNum);
}
else
{
......@@ -397,8 +395,7 @@ namespace RTC
this->rtpTimestamp =
(packet->GetTimestamp() - this->rtpTimestampBase) + this->rtpTimestampPreviousBase + 1;
this->seqNum =
(packet->GetSequenceNumber() - this->seqNumBase) + this->seqNumPreviousBase + 1;
this->seqNum = (packet->GetSequenceNumber() - this->seqNumBase) + this->seqNumPreviousBase + 1;
// Save the received SSRC.
this->lastReceivedSsrc = packet->GetSsrc();
......
......@@ -199,6 +199,8 @@ namespace RTC
listener->OnProducerResumed(this);
}
MS_DEBUG_TAG(rtcp, "requesting full frame after resumed");
RequestKeyFrame(true);
}
......@@ -419,7 +421,7 @@ namespace RTC
}
else if (this->keyFrameRequestBlockTimer->IsActive())
{
MS_DEBUG_TAG(rtcp, "blocking key frame request until timer expires");
MS_DEBUG_TAG(rtcp, "blocking key frame due to flood protection");
// Set flag.
this->isKeyFrameRequested = true;
......@@ -863,7 +865,7 @@ namespace RTC
if (!this->isKeyFrameRequested)
return;
MS_DEBUG_TAG(rtcp, "requesting key frame after timer expires");
MS_DEBUG_TAG(rtcp, "key frame requested during flood protection, requesting it now");
RequestKeyFrame();
}
......
......@@ -245,6 +245,8 @@ namespace RTC
{
MS_TRACE();
MS_DEBUG_TAG(rtx, "requesting key frame [ssrc:%" PRIu32 "]", this->params.ssrc);
RequestKeyFrame();
}
......
......@@ -175,10 +175,10 @@ namespace RTC
this->dtlsTransport = new RTC::DtlsTransport(this);
// Create the RTCP timer.
this->timer = new Timer(this);
this->rtcpTimer = new Timer(this);
// Start the RTCP timer.
this->timer->Start(static_cast<uint64_t>(RTC::RTCP::MaxVideoIntervalMs / 2));
this->rtcpTimer->Start(static_cast<uint64_t>(RTC::RTCP::MaxVideoIntervalMs / 2));
// Hack to avoid that Destroy() above attempts to delete this.
this->allocated = true;
......@@ -189,7 +189,7 @@ namespace RTC
MS_TRACE();
// Destroy the RTCP timer.
this->timer->Destroy();
this->rtcpTimer->Destroy();
}
void Transport::Destroy()
......@@ -736,6 +736,14 @@ namespace RTC
break;
}
MS_DEBUG_TAG(
rtcp,
"%s received, requesting key frame for Consumer "
"[sender ssrc:%" PRIu32 ", media ssrc:%" PRIu32 "]",
RTCP::FeedbackPsPacket::MessageType2String(feedback->GetMessageType()).c_str(),
feedback->GetMediaSsrc(),
feedback->GetMediaSsrc());
consumer->RequestKeyFrame();
break;
......@@ -1559,7 +1567,7 @@ namespace RTC
static_cast<double>(effectiveBitrate) / static_cast<double>(this->effectiveMaxBitrate) <
EffectiveMaxBitrateThresholdBeforeKeyFrame)
{
MS_WARN_TAG(rbe, "uplink effective max bitrate abruptly decrease, requesting key frames");
MS_WARN_TAG(rbe, "uplink effective max bitrate abruptly decreased, requesting key frames");
// Request key frame for all the Producers.
for (auto* producer : this->producers)
......@@ -1636,39 +1644,42 @@ namespace RTC
// Do nothing.
}
void Transport::OnTimer(Timer* /*timer*/)
void Transport::OnTimer(Timer* timer)
{
uint64_t interval = RTC::RTCP::MaxVideoIntervalMs;
uint32_t now = DepLibUV::GetTime();
SendRtcp(now);
// Recalculate next RTCP interval.
if (!this->consumers.empty())
if (timer == this->rtcpTimer)
{
// Transmission rate in kbps.
uint32_t rate = 0;
uint64_t interval = RTC::RTCP::MaxVideoIntervalMs;
uint32_t now = DepLibUV::GetTime();
SendRtcp(now);
// Get the RTP sending rate.
for (auto& consumer : this->consumers)
// Recalculate next RTCP interval.
if (!this->consumers.empty())
{
rate += consumer->GetTransmissionRate(now) / 1000;
}
// Transmission rate in kbps.
uint32_t rate = 0;
// Calculate bandwidth: 360 / transmission bandwidth in kbit/s
if (rate != 0u)
interval = 360000 / rate;
// Get the RTP sending rate.
for (auto& consumer : this->consumers)
{
rate += consumer->GetTransmissionRate(now) / 1000;
}
if (interval > RTC::RTCP::MaxVideoIntervalMs)
interval = RTC::RTCP::MaxVideoIntervalMs;
}
// Calculate bandwidth: 360 / transmission bandwidth in kbit/s
if (rate != 0u)
interval = 360000 / rate;
/*
* The interval between RTCP packets is varied randomly over the range
* [0.5,1.5] times the calculated interval to avoid unintended synchronization
* of all participants.
*/
interval *= static_cast<float>(Utils::Crypto::GetRandomUInt(5, 15)) / 10;
this->timer->Start(interval);
if (interval > RTC::RTCP::MaxVideoIntervalMs)
interval = RTC::RTCP::MaxVideoIntervalMs;
}
/*
* The interval between RTCP packets is varied randomly over the range
* [0.5,1.5] times the calculated interval to avoid unintended synchronization
* of all participants.
*/
interval *= static_cast<float>(Utils::Crypto::GetRandomUInt(5, 15)) / 10;
this->rtcpTimer->Start(interval);
}
}
} // namespace RTC
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论