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

RtpStreamSend.cpp: cosmetic, use braces

上级 72794578
......@@ -49,12 +49,16 @@ namespace RTC
RtpStreamSend::StorageItem* RtpStreamSend::StorageItemBuffer::Get(uint16_t seq) const
{
if (RTC::SeqManager<uint16_t>::IsSeqLowerThan(seq, this->startSeq))
{
return nullptr;
}
auto idx{ static_cast<uint16_t>(seq - this->startSeq) };
if (this->buffer.empty() || idx > static_cast<uint16_t>(this->buffer.size() - 1))
{
return nullptr;
}
return this->buffer.at(idx);
}
......@@ -141,7 +145,9 @@ namespace RTC
for (auto* storageItem : this->buffer)
{
if (!storageItem)
{
continue;
}
// Reset the storage item (decrease RTP packet shared pointer counter).
storageItem->Reset();
......@@ -205,11 +211,15 @@ namespace RTC
// Call the parent method.
if (!RtpStream::ReceiveStreamPacket(packet))
{
return false;
}
// If NACK is enabled, store the packet into the buffer.
if (this->params.useNack)
{
StorePacket(packet, sharedPacket);
}
// Increase transmission counter.
this->transmissionCounter.Update(packet);
......@@ -234,7 +244,9 @@ namespace RTC
for (auto* storageItem : RetransmissionContainer)
{
if (!storageItem)
{
break;
}
// Note that this is an already RTX encoded packet if RTX is used
// (FillRetransmissionContainer() did it).
......@@ -249,7 +261,9 @@ namespace RTC
// Mark the packet as repaired (only if this is the first retransmission).
if (storageItem->sentTimes == 1)
{
RTC::RtpStream::PacketRepaired(packet.get());
}
if (HasRtx())
{
......@@ -302,7 +316,9 @@ namespace RTC
// If no Sender Report was received by the remote endpoint yet, ignore lastSr
// and dlsr values in the Receiver Report.
if (lastSr && dlsr && (compactNtp > dlsr + lastSr))
{
rtt = compactNtp - dlsr - lastSr;
}
// RTT in milliseconds.
this->rtt = static_cast<float>(rtt >> 16) * 1000;
......@@ -343,7 +359,9 @@ namespace RTC
MS_TRACE();
if (this->transmissionCounter.GetPacketCount() == 0u)
{
return nullptr;
}
auto ntp = Utils::Time::TimeMs2Ntp(nowMs);
auto* report = new RTC::RTCP::SenderReport();
......@@ -371,7 +389,9 @@ namespace RTC
MS_TRACE();
if (this->lastRrReceivedMs == 0u)
{
return nullptr;
}
// Get delay in milliseconds.
auto delayMs = static_cast<uint32_t>(nowMs - this->lastRrReceivedMs);
......@@ -469,7 +489,9 @@ namespace RTC
// RTP packet is older than the retransmission buffer size.
if (static_cast<uint32_t>(diffTs * 1000 / this->params.clockRate) >= this->retransmissionBufferSize)
{
return;
}
}
}
......@@ -483,7 +505,9 @@ namespace RTC
if (storageItem)
{
if (packet->GetTimestamp() == storageItem->timestamp)
{
return;
}
// Reset the storage item.
storageItem->Reset();
......@@ -527,11 +551,15 @@ namespace RTC
// Processing RTP packet is older than first one.
if (RTC::SeqManager<uint32_t>::IsSeqLowerThan(packet->GetTimestamp(), storageItem->timestamp))
{
break;
}
// First RTP packet is recent enough.
if (static_cast<uint32_t>(diffTs * 1000 / clockRate) < this->retransmissionBufferSize)
{
break;
}
// Unfill the buffer start item.
this->storageItemBuffer.RemoveFirst();
......@@ -603,7 +631,9 @@ namespace RTC
// Update MID RTP extension value.
if (!this->mid.empty())
{
packet->UpdateMid(mid);
}
const uint32_t diffTs = this->maxPacketTs - packet->GetTimestamp();
......@@ -670,7 +700,9 @@ namespace RTC
sent = true;
if (isFirstPacket)
{
firstPacketSent = true;
}
}
}
......@@ -728,9 +760,13 @@ namespace RTC
uint32_t lost;
if (totalLost < this->lostPriorScore)
{
lost = 0;
}
else
{
lost = totalLost - this->lostPriorScore;
}
this->lostPriorScore = totalLost;
......@@ -755,10 +791,14 @@ namespace RTC
}
if (lost > sent)
{
lost = sent;
}
if (repaired > lost)
{
repaired = lost;
}
#if MS_LOG_DEV_LEVEL == 3
MS_DEBUG_TAG(
......@@ -783,7 +823,9 @@ namespace RTC
MS_ASSERT(retransmitted >= repaired, "repaired packets cannot be more than retransmitted ones");
if (retransmitted > 0)
{
repairedWeight *= static_cast<float>(repaired) / retransmitted;
}
lost -= repaired * repairedWeight;
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论