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