mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-07-06 11:38:11 +08:00
nack/rtx支持多次重传,提高抗丢包率
This commit is contained in:
@@ -36,22 +36,40 @@ private:
|
||||
|
||||
class NackContext {
|
||||
public:
|
||||
using Ptr = std::shared_ptr<NackContext>;
|
||||
using onNack = function<void(const FCI_NACK &nack)>;
|
||||
//最大保留的rtp丢包状态个数
|
||||
static constexpr auto kNackMaxSize = 100;
|
||||
//rtp丢包状态最长保留时间
|
||||
static constexpr auto kNackMaxMS = 3 * 1000;
|
||||
//nack最多请求重传10次
|
||||
static constexpr auto kNackMaxCount = 10;
|
||||
|
||||
NackContext() = default;
|
||||
~NackContext() = default;
|
||||
|
||||
void received(uint16_t seq);
|
||||
void received(uint16_t seq, bool is_rtx = false);
|
||||
void setOnNack(onNack cb);
|
||||
uint64_t reSendNack();
|
||||
|
||||
private:
|
||||
void eraseFrontSeq();
|
||||
void doNack(const FCI_NACK &nack);
|
||||
void doNack(const FCI_NACK &nack, bool record_nack);
|
||||
void recordNack(const FCI_NACK &nack);
|
||||
void onRtx(uint16_t seq);
|
||||
|
||||
private:
|
||||
int _rtt = 50;
|
||||
onNack _cb;
|
||||
set<uint16_t> _seq;
|
||||
uint16_t _last_max_seq = 0;
|
||||
|
||||
struct NackStatus{
|
||||
uint64_t first_stamp;
|
||||
uint64_t update_stamp;
|
||||
int nack_count = 0;
|
||||
};
|
||||
map<uint16_t/*seq*/, NackStatus > _nack_send_ntp;
|
||||
};
|
||||
|
||||
#endif //ZLMEDIAKIT_NACK_H
|
||||
|
||||
Reference in New Issue
Block a user