提交 8802f5a4 authored 作者: José Luis Millán's avatar José Luis Millán

RtpStream: redo counters

上级 cec8d495
......@@ -55,6 +55,7 @@ namespace RTC
virtual uint32_t UseBandwidth(uint32_t availableBandwidth) = 0;
void ProducerPaused();
void ProducerResumed();
// TODO: Update signature to RTC::RtpStreamRecv.
virtual void ProducerRtpStream(RTC::RtpStream* rtpStream, uint32_t mappedSsrc) = 0;
virtual void ProducerNewRtpStream(RTC::RtpStream* rtpStream, uint32_t mappedSsrc) = 0;
virtual void ProducerRtpStreamScore(RTC::RtpStream* rtpStream, uint8_t score) = 0;
......
......@@ -104,6 +104,7 @@ namespace RTC
uint8_t fractionLost{ 0 };
size_t packetsDiscarded{ 0 };
size_t packetsRepaired{ 0 };
size_t packetsRetransmitted{ 0 };
size_t nackCount{ 0 };
size_t nackRtpPacketCount{ 0 };
size_t pliCount{ 0 };
......@@ -111,7 +112,6 @@ namespace RTC
size_t repairedPrior{ 0 }; // Packets repaired at last interval.
uint32_t expectedPrior{ 0 }; // Packets expected at last interval.
RTC::RtpDataCounter transmissionCounter;
RTC::RtpDataCounter retransmissionCounter;
private:
// Score related.
......@@ -185,7 +185,7 @@ namespace RTC
inline uint32_t RtpStream::GetRate(uint64_t now)
{
return this->transmissionCounter.GetRate(now) + this->retransmissionCounter.GetRate(now);
return this->transmissionCounter.GetRate(now);
}
inline uint8_t RtpStream::GetFractionLost() const
......
......@@ -32,6 +32,7 @@ namespace RTC
uint64_t resentAtTime{ 0 };
RTC::RtpPacket* packet{ nullptr };
bool rtxEncoded{ false }; // Whether the packet has already been RTX encoded.
size_t sentTimes{ 0 };
};
public:
......
......@@ -105,9 +105,6 @@ namespace RTC
return false;
}
// Increase counters.
this->transmissionCounter.Update(packet);
// Update highest seen RTP timestamp.
if (RTC::SeqManager<uint32_t>::IsSeqHigherThan(packet->GetTimestamp(), this->maxPacketTs))
{
......@@ -274,11 +271,11 @@ namespace RTC
}
}
void RtpStream::PacketRetransmitted(RTC::RtpPacket* packet)
void RtpStream::PacketRetransmitted(RTC::RtpPacket* /*packet*/)
{
MS_TRACE();
this->retransmissionCounter.Update(packet);
this->packetsRetransmitted++;
}
void RtpStream::PacketRepaired(RTC::RtpPacket* /*packet*/)
......
......@@ -71,8 +71,12 @@ namespace RTC
RTC::Codecs::ProcessRtpPacket(packet, GetMimeType());
// Pass the packet to the NackGenerator.
if (this->params.useNack)
this->nackGenerator->ReceivePacket(packet);
if (this->params.useNack && this->nackGenerator->ReceivePacket(packet))
{
// Mark the packet as retransmitted and repaired.
RTC::RtpStream::PacketRepaired(packet);
RTC::RtpStream::PacketRetransmitted(packet);
}
// Ensure the inactivityCheckPeriodicTimer runs (unless DTX is enabled).
if (!this->params.useDtx && !this->inactivityCheckPeriodicTimer->IsActive())
......@@ -81,6 +85,8 @@ namespace RTC
this->inactivityCheckPeriodicTimer->Restart();
}
this->transmissionCounter.Update(packet);
return true;
}
......@@ -152,14 +158,19 @@ namespace RTC
if (packet->GetPayloadType() == GetPayloadType())
RTC::Codecs::ProcessRtpPacket(packet, GetMimeType());
// Mark the packet as retransmitted.
RTC::RtpStream::PacketRetransmitted(packet);
// Pass the packet to the NackGenerator and return true just if this was a
// NACKed packet.
if (this->nackGenerator->ReceivePacket(packet))
{
// Mark the packet as retransmitted and repaired.
RTC::RtpStream::PacketRetransmitted(packet);
// Mark the packet as repaired.
RTC::RtpStream::PacketRepaired(packet);
// Increase transmission counter.
this->transmissionCounter.Update(packet);
return true;
}
......
......@@ -99,6 +99,7 @@ namespace RTC
RTC::RtpStream::PacketRetransmitted(packet);
// Mark the packet as repaired.
// TODO: Only if this is the first retransmission.
RTC::RtpStream::PacketRepaired(packet);
}
}
......@@ -442,6 +443,7 @@ namespace RTC
// Save when this packet was resent.
(*bufferIt).resentAtTime = now;
(*bufferIt).sentTimes++;
sent = true;
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论