Skip to content

Commit

Permalink
Bugfix: Fix rtcp nack blp encode bug (#2966). v4.0.248
Browse files Browse the repository at this point in the history
Co-authored-by: Winlin <winlin@vip.126.com>
  • Loading branch information
chen-guanghua and winlinvip committed Mar 15, 2022
1 parent e26db69 commit ab81696
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
1 change: 1 addition & 0 deletions trunk/doc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ The changelog for SRS.

## SRS 4.0 Changelog

* v4.0, 2022-03-15, Merge [#2966](https://github.com/ossrs/srs/pull/2966): Bugfix: Fix rtcp nack blp encode bug (#2966). v4.0.248
* v4.0, 2022-03-07, RTC: Identify the WebRTC publisher in param for hooks. v4.0.247
* v4.0, 2022-03-07, SRT: Append vhost to stream, not app. v4.0.246
* v4.0, 2022-02-15, Fix warnings for uuid. v4.0.245
Expand Down
2 changes: 1 addition & 1 deletion trunk/src/core/srs_core_version4.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@

#define VERSION_MAJOR 4
#define VERSION_MINOR 0
#define VERSION_REVISION 247
#define VERSION_REVISION 248

#endif
6 changes: 4 additions & 2 deletions trunk/src/kernel/srs_kernel_rtc_rtcp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1346,9 +1346,11 @@ srs_error_t SrsRtcpNack::encode(SrsBuffer *buffer)
if((sn - pid) < 1) {
srs_info("skip seq %d", sn);
} else if( (sn - pid) > 16) {
// add new chunk
// append full chunk
chunks.push_back(chunk);
chunk.pid = sn;

// start new chunk
chunk.pid = sn;
chunk.blp = 0;
chunk.in_use = true;
pid = sn;
Expand Down
31 changes: 31 additions & 0 deletions trunk/src/utest/srs_utest_rtc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1169,6 +1169,36 @@ VOID TEST(KernelRTCTest, SyncTimestampBySenderReportConsecutive)
}
}

VOID TEST(KernelRTCTest, SrsRtcpNack)
{
uint32_t sender_ssrc = 0x0A;
uint32_t media_ssrc = 0x0B;

SrsRtcpNack nack_encoder(sender_ssrc);
nack_encoder.set_media_ssrc(media_ssrc);

for (uint16_t seq = 15; seq < 45; seq++) {
nack_encoder.add_lost_sn(seq);
}
EXPECT_FALSE(nack_encoder.empty());

char buf[kRtcpPacketSize];
SrsBuffer stream(buf, sizeof(buf));

srs_error_t err = srs_success;
err = nack_encoder.encode(&stream);
EXPECT_EQ(srs_error_code(err), srs_success);

SrsRtcpNack nack_decoder;
stream.skip(-stream.pos());
err = nack_decoder.decode(&stream);
EXPECT_EQ(srs_error_code(err), srs_success);

vector<uint16_t> actual_lost_sn = nack_encoder.get_lost_sns();
vector<uint16_t> req_lost_sns = nack_decoder.get_lost_sns();
EXPECT_EQ(actual_lost_sn.size(), req_lost_sns.size());
}

VOID TEST(KernelRTCTest, SyncTimestampBySenderReportDuplicated)
{
SrsRtcConnection s(NULL, SrsContextId());
Expand Down Expand Up @@ -1243,3 +1273,4 @@ VOID TEST(KernelRTCTest, SyncTimestampBySenderReportDuplicated)
}
}
}

0 comments on commit ab81696

Please sign in to comment.