Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transport-cc parsing to be compliant with libwebrtc, make transport-cc reference time to be unsigned, therefore fix 357. #899

Merged
merged 14 commits into from
Sep 19, 2022
219 changes: 219 additions & 0 deletions worker/test/src/RTC/RTCP/TestFeedbackRtpTransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,4 +571,223 @@ SCENARIO("RTCP Feeback RTP transport", "[parser][rtcp][feedback-rtp][transport]"

delete packet;
}

SECTION("parse FeedbackRtpTransportPacket generated by Chrome with libwebrtc as a reference")
{
typedef struct {
uint32_t baseTimeRaw;
uint64_t baseTimeMs;
uint16_t baseSequence;
size_t packetStatusCount;
std::vector<int16_t> deltas;
std::vector<uint8_t> buffer;
} FeedbackPacketsMeta;

// Metadata collected by parsing buffers with libwebrtc, buffers itself.
// were generated by chrome in direction of mediasoup.
std::vector<FeedbackPacketsMeta> feedbackPacketsMeta = {
{
.baseTimeRaw = 35504,
.baseTimeMs = 1076014080,
.baseSequence = 13,
.packetStatusCount = 1,
.deltas = std::vector<int16_t>{57},
.buffer = std::vector<uint8_t> {
0xaf, 0xcd, 0x00, 0x05, 0xfa, 0x17, 0xfa, 0x17,
0x00, 0x00, 0x04, 0xd2, 0x00, 0x0d, 0x00, 0x01,
0x00, 0x8A, 0xB0, 0x00, 0x20, 0x01, 0xE4, 0x01
}
},
{
.baseTimeRaw = 35504,
.baseTimeMs = 1076014080,
.baseSequence = 14,
.packetStatusCount = 4,
.deltas = std::vector<int16_t>{58, 2, 3, 55},
.buffer = std::vector<uint8_t> {
0xaf, 0xcd, 0x00, 0x06, 0xFA, 0x17, 0xFA, 0x17,
0x1C, 0xB7, 0xDA, 0xF3, 0x00, 0x0E, 0x00, 0x04,
0x00, 0x8A, 0xB0, 0x01, 0x20, 0x04, 0xE8, 0x08,
0x0C, 0xDC, 0x00, 0x02
}
},
{
.baseTimeRaw = 35505,
.baseTimeMs = 1076014144,
.baseSequence = 18,
.packetStatusCount = 5,
.deltas = std::vector<int16_t>{60, 6, 5, 9, 22},
.buffer = std::vector<uint8_t> {
0xAF, 0xCD, 0x00, 0x06, 0xFA, 0x17, 0xFA, 0x17,
0x1C, 0xB7, 0xDA, 0xF3, 0x00, 0x12, 0x00, 0x05,
0x00, 0x8A, 0xB1, 0x02, 0x20, 0x05, 0xF0, 0x18,
0x14, 0x24, 0x58, 0x01
}
},

{
.baseTimeRaw = 617873,
.baseTimeMs = 1113285696,
.baseSequence = 2924,
.packetStatusCount = 22,
.deltas = std::vector<int16_t>{3, 5, 5, 0, 10, 0, 0, 4, 0, 1, 0, 2, 0, 2, 0, 2, 0, 2, 0, 1, 0, 4},
.buffer = std::vector<uint8_t> {
0x8F, 0xCD, 0x00, 0x0A, 0xFA, 0x17, 0xFA, 0x17,
0x06, 0xF5, 0x11, 0x4C, 0x0B, 0x6C, 0x00, 0x16,
0x09, 0x6D, 0x91, 0xEE, 0x20, 0x16, 0x0C, 0x14,
0x14, 0x00, 0x28, 0x00, 0x00, 0x10, 0x00, 0x04,
0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08,
0x00, 0x04, 0x00, 0x10
}
},

{
.baseTimeRaw = 12408746,
.baseTimeMs = 1867901568,
.baseSequence = 1,
.packetStatusCount = 2,
.deltas = std::vector<int16_t>{35, 17},
.buffer = std::vector<uint8_t> {
0x8F, 0xCD, 0x00, 0x05, 0xFA, 0x17, 0xFA, 0x17,
0x39, 0xE9, 0x42, 0x38, 0x00, 0x01, 0x00, 0x02,
0xBD, 0x57, 0xAA, 0x00, 0x20, 0x02, 0x8C, 0x44
}
},

{
.baseTimeRaw = 818995,
.baseTimeMs = 1126157504,
.baseSequence = 930,
.packetStatusCount = 5,
.deltas = std::vector<int16_t>{62, 18, 5, 6, 19},
.buffer = std::vector<uint8_t> {
0xAF, 0xCD, 0x00, 0x06, 0xFA, 0x17, 0xFA, 0x17,
0x26, 0x9E, 0x8E, 0x50, 0x03, 0xA2, 0x00, 0x05,
0x0C, 0x7F, 0x33, 0x9F, 0x20, 0x05, 0xF8, 0x48,
0x14, 0x18, 0x4C, 0x01
}
},
{
.baseTimeRaw = 818996,
.baseTimeMs = 1126157568,
.baseSequence = 921,
.packetStatusCount = 7,
.deltas = std::vector<int16_t>{14, 5, 6, 6, 7, 14, 5},
.buffer = std::vector<uint8_t> {
0xAF, 0xCD, 0x00, 0x07, 0xFA, 0x17, 0xFA, 0x17,
0x33, 0xB0, 0x4A, 0xE8, 0x03, 0x99, 0x00, 0x07,
0x0C, 0x7F, 0x34, 0x9F, 0x20, 0x07, 0x38, 0x14,
0x18, 0x18, 0x1C, 0x38, 0x14, 0x00, 0x00, 0x03
}
},
{
.baseTimeRaw = 818996,
.baseTimeMs = 1126157568,
.baseSequence = 935,
.packetStatusCount = 7,
.deltas = std::vector<int16_t>{57, 0, 6, 5, 5, 24, 0},
.buffer = std::vector<uint8_t> {
0xAF, 0xCD, 0x00, 0x07, 0xFA, 0x17, 0xFA, 0x17,
0x26, 0x9E, 0x8E, 0x50, 0x03, 0xA7, 0x00, 0x07,
0x0C, 0x7F, 0x34, 0xA0, 0x20, 0x07, 0xE4, 0x00,
0x18, 0x14, 0x14, 0x60, 0x00, 0x00, 0x00, 0x03
}
},
{
.baseTimeRaw = 818996,
.baseTimeMs = 1126157568,
.baseSequence = 928,
.packetStatusCount = 5,
.deltas = std::vector<int16_t>{63, 11, 21, 6, 0},
.buffer = std::vector<uint8_t> {
0xAF, 0xCD, 0x00, 0x06, 0xFA, 0x17, 0xFA, 0x17,
0x33, 0xB0, 0x4A, 0xE8, 0x03, 0xA0, 0x00, 0x05,
0x0C, 0x7F, 0x34, 0xA0, 0x20, 0x05, 0xFC, 0x2C,
0x54, 0x18, 0x00, 0x01
}
},
{
.baseTimeRaw = 818997,
.baseTimeMs = 1126157632,
.baseSequence = 942,
.packetStatusCount = 6,
.deltas = std::vector<int16_t>{39, 13, 9, 5, 4, 13},
.buffer = std::vector<uint8_t> {
0x8F, 0xCD, 0x00, 0x06, 0xFA, 0x17, 0xFA, 0x17,
0x26, 0x9E, 0x8E, 0x50, 0x03, 0xAE, 0x00, 0x06,
0x0C, 0x7F, 0x35, 0xA1, 0x20, 0x06, 0x9C, 0x34,
0x24, 0x14, 0x10, 0x34
}
},
{
.baseTimeRaw = 821523,
.baseTimeMs = 1126319296,
.baseSequence = 10,
.packetStatusCount = 7,
.deltas = std::vector<int16_t>{25, 2, 2, 3, 1, 1, 3},
.buffer = std::vector<uint8_t> {
0xAF, 0xCD, 0x00, 0x07, 0xFA, 0x17, 0xFA, 0x17,
0x00, 0x00, 0x04, 0xD2, 0x00, 0x0A, 0x00, 0x07,
0x0C, 0x89, 0x13, 0x00, 0x20, 0x07, 0x64, 0x08,
0x08, 0x0C, 0x04, 0x04, 0x0C, 0x00, 0x00, 0x03
}
},
{
.baseTimeRaw = 821524,
.baseTimeMs = 1126319360,
.baseSequence = 17,
.packetStatusCount = 2,
.deltas = std::vector<int16_t>{44, 18},
.buffer = std::vector<uint8_t> {
0x8F, 0xCD, 0x00, 0x05, 0xFA, 0x17, 0xFA, 0x17,
0x08, 0xEB, 0x06, 0xD7, 0x00, 0x11, 0x00, 0x02,
0x0C, 0x89, 0x14, 0x01, 0x20, 0x02, 0xB0, 0x48
}
},
{
.baseTimeRaw = 821524,
.baseTimeMs = 1126319360,
.baseSequence = 17,
.packetStatusCount = 1,
.deltas = std::vector<int16_t>{62},
.buffer = std::vector<uint8_t> {
0xAF, 0xCD, 0x00, 0x05, 0xFA, 0x17, 0xFA, 0x17,
0x20, 0x92, 0x5E, 0xB7, 0x00, 0x11, 0x00, 0x01,
0x0C, 0x89, 0x14, 0x00, 0x20, 0x01, 0xF8, 0x01
}
},
{
.baseTimeRaw = 821526,
.baseTimeMs = 1126319488,
.baseSequence = 19,
.packetStatusCount = 4,
.deltas = std::vector<int16_t>{4, 0, 4, 0},
.buffer = std::vector<uint8_t> {
0xAF, 0xCD, 0x00, 0x06, 0xFA, 0x17, 0xFA, 0x17,
0x08, 0xEB, 0x06, 0xD7, 0x00, 0x13, 0x00, 0x04,
0x0C, 0x89, 0x16, 0x02, 0x20, 0x04, 0x10, 0x00,
0x10, 0x00, 0x00, 0x02
}
}
};

for (const auto &packetMeta: feedbackPacketsMeta) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please run make lint in worker/ directory. It should complain. make format will fix it.

auto buffer = packetMeta.buffer;
auto *feedback = FeedbackRtpTransportPacket::Parse(buffer.data(), buffer.size());

REQUIRE(feedback->GetReferenceTime() == packetMeta.baseTimeRaw);
REQUIRE(feedback->GetReferenceTimestamp() == packetMeta.baseTimeMs);
REQUIRE(feedback->GetBaseSequenceNumber() == packetMeta.baseSequence);
REQUIRE(feedback->GetPacketStatusCount() == packetMeta.packetStatusCount);

auto packetsResults = feedback->GetPacketResults();

int deltasIt = 0;
for (auto const &delta : packetMeta.deltas) {
auto resultDelta = packetsResults[deltasIt].delta;
REQUIRE(static_cast<int16_t>(resultDelta/ 4) == delta);
deltasIt++;
}
}
}
}