优化webrtc nack算法:#2249

This commit is contained in:
ziyue
2023-02-25 00:19:00 +08:00
parent a15053ff01
commit a981ce8cb3
3 changed files with 126 additions and 74 deletions

View File

@@ -15,20 +15,38 @@ using namespace std;
using namespace toolkit;
using namespace mediakit;
extern void testFCI();
int main() {
Logger::Instance().add(std::make_shared<ConsoleChannel>());
Logger::Instance().setWriter(std::make_shared<AsyncLogWriter>());
srand((unsigned) time(NULL));
srand((unsigned)time(NULL));
NackContext ctx;
for (int i = 1; i < 1000; ++i) {
if (i % (1 + (rand() % 30)) == 0) {
DebugL << "drop:" << i;
ctx.setOnNack([](const FCI_NACK &nack){
InfoL << nack.dumpString();
});
auto drop_start = 0;
auto drop_len = 0;
uint16_t offset = 0xFFFF - 200 - 50;
for (int i = 1; i < 10000; ++i) {
if (i % 100 == 0) {
drop_start = i + rand() % 16;
drop_len = 4 + rand() % 16;
InfoL << "start drop:" << (uint16_t)(drop_start + offset) << " -> "
<< (uint16_t)(drop_start + offset + drop_len);
}
uint16_t seq = i + offset;
if ((i >= drop_start && i <= drop_start + drop_len) || seq == 65535 || seq == 0 || seq == 1) {
TraceL << "drop:" << (uint16_t)(i + offset);
} else {
ctx.received(i);
static auto last_seq = seq;
if (seq - last_seq > 16) {
ctx.received(last_seq);
ctx.received(seq);
DebugL << "seq reduce:" << last_seq;
last_seq = seq;
} else {
ctx.received(seq);
}
}
}
sleep(1);