RTC: Fix nack encode seqnum (#2766)

* fix nack encode seqnum

* add nack encode utest

* change Variable naming

Co-authored-by: liyalong1 <liyalong1@100tal.com>
pull/2771/head
long 3 years ago committed by GitHub
parent 5ccd63dec3
commit 4decc1fa6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1348,7 +1348,10 @@ srs_error_t SrsRtcpNack::encode(SrsBuffer *buffer)
} else if( (sn - pid) > 16) {
// add new chunk
chunks.push_back(chunk);
chunk.in_use = false;
chunk.pid = sn;
chunk.blp = 0;
chunk.in_use = true;
pid = sn;
} else {
chunk.blp |= 1 << (sn-pid-1);
}

@ -744,6 +744,32 @@ VOID TEST(KernelRTCTest, NACKFetchRTPPacket)
}
}
VOID TEST(KernelRTCTest, NACKEncode)
{
uint32_t ssrc = 123;
char buf_before[kRtcpPacketSize];
SrsBuffer stream_before(buf_before, sizeof(buf_before));
SrsRtcpNack rtcp_nack_encode(ssrc);
for(uint16_t i = 16; i < 50; ++i) {
rtcp_nack_encode.add_lost_sn(i);
}
srs_error_t err_before = rtcp_nack_encode.encode(&stream_before);
EXPECT_TRUE(err_before == 0);
char buf_after[kRtcpPacketSize];
memcpy(buf_after, buf_before, kRtcpPacketSize);
SrsBuffer stream_after(buf_after, sizeof(buf_after));
SrsRtcpNack rtcp_nack_decode(ssrc);
srs_error_t err_after = rtcp_nack_decode.decode(&stream_after);
EXPECT_TRUE(err_after == 0);
vector<uint16_t> before = rtcp_nack_encode.get_lost_sns();
vector<uint16_t> after = rtcp_nack_decode.get_lost_sns();
EXPECT_TRUE(before.size() == after.size());
for(int i = 0; i < before.size() && i < after.size(); ++i) {
EXPECT_TRUE(before.at(i) == after.at(i));
}
}
extern bool srs_is_stun(const uint8_t* data, size_t size);
extern bool srs_is_dtls(const uint8_t* data, size_t len);
extern bool srs_is_rtp_or_rtcp(const uint8_t* data, size_t len);

Loading…
Cancel
Save