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

RtpStreamSend: just call to PacketRepaired() if sendTimes == 1

上级 baea9fad
......@@ -18,14 +18,7 @@ namespace RTC
RTC::RtpStreamSend* rtpStream, RTC::RtpPacket* packet) = 0;
};
private:
struct StorageItem
{
// Allow some more space for RTX encoding.
uint8_t store[RTC::MtuSize + 200];
};
private:
public:
struct BufferItem
{
uint16_t seq{ 0 }; // RTP seq.
......@@ -35,6 +28,13 @@ namespace RTC
bool rtxEncoded{ false }; // Whether the packet has already been RTX encoded.
};
private:
struct StorageItem
{
// Allow some more space for RTX encoding.
uint8_t store[RTC::MtuSize + 200];
};
public:
RtpStreamSend(
RTC::RtpStreamSend::Listener* listener, RTC::RtpStream::Params& params, size_t bufferSize);
......
......@@ -13,7 +13,7 @@ namespace RTC
// 17: 16 bit mask + the initial sequence number.
static constexpr size_t MaxRequestedPackets{ 17 };
static std::vector<RTC::RtpPacket*> RetransmissionContainer(MaxRequestedPackets + 1);
static std::vector<RTC::RtpStreamSend::BufferItem*> RetransmissionContainer(MaxRequestedPackets + 1);
// Don't retransmit packets older than this (ms).
static constexpr uint32_t MaxRetransmissionDelay{ 2000 };
static constexpr uint32_t DefaultRtt{ 100 };
......@@ -80,17 +80,17 @@ namespace RTC
FillRetransmissionContainer(item->GetPacketId(), item->GetLostPacketBitmask());
auto it2 = RetransmissionContainer.begin();
for (; it2 != RetransmissionContainer.end(); ++it2)
for (auto it2 = RetransmissionContainer.begin(); it2 != RetransmissionContainer.end(); ++it2)
{
// Note that this is an already RTX encoded packet if RTX is used
// (FillRetransmissionContainer() did it).
RTC::RtpPacket* packet = *it2;
auto* bufferItem = *it2;
if (packet == nullptr)
if (bufferItem == nullptr)
break;
// Note that this is an already RTX encoded packet if RTX is used
// (FillRetransmissionContainer() did it).
auto* packet = bufferItem->packet;
// Retransmit the packet.
static_cast<RTC::RtpStreamSend::Listener*>(this->listener)
->OnRtpStreamRetransmitRtpPacket(this, packet);
......@@ -98,8 +98,8 @@ namespace RTC
// Mark the packet as retransmitted.
RTC::RtpStream::PacketRetransmitted(packet);
// Mark the packet as repaired.
// TODO: Only if this is the first retransmission.
// Mark the packet as repaired (only if this is the first retransmission).
if (bufferItem->sentTimes == 1)
RTC::RtpStream::PacketRepaired(packet);
}
}
......@@ -333,11 +333,6 @@ namespace RTC
uint16_t firstSeq = seq;
uint16_t lastSeq = firstSeq + MaxRequestedPackets - 1;
// Number of requested packets cannot be greater than the container size - 1.
MS_ASSERT(
RetransmissionContainer.size() - 1 >= MaxRequestedPackets, "RtpPacket container is too small");
auto bufferIt = this->buffer.begin();
auto bufferItReverse = this->buffer.rbegin();
uint16_t bufferFirstSeq = (*bufferIt).seq;
......@@ -438,11 +433,13 @@ namespace RTC
(*bufferIt).rtxEncoded = true;
}
// Store the packet in the container and then increment its index.
RetransmissionContainer[containerIdx++] = currentPacket;
// Store the buffer item in the container and then increment its index.
RetransmissionContainer[containerIdx++] = std::addressof(*bufferIt);
// Save when this packet was resent.
(*bufferIt).resentAtTime = now;
// Increase the number of times this packet was sent.
(*bufferIt).sentTimes++;
sent = true;
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论