Index: webrtc/modules/rtp_rtcp/source/rtp_packet_unittest.cc |
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_packet_unittest.cc b/webrtc/modules/rtp_rtcp/source/rtp_packet_unittest.cc |
index bdf3aba7b00013ae8c20d3e0db6a732652f72659..1945b7b44cd8a25f01d45472286993cdb9e6a60c 100644 |
--- a/webrtc/modules/rtp_rtcp/source/rtp_packet_unittest.cc |
+++ b/webrtc/modules/rtp_rtcp/source/rtp_packet_unittest.cc |
@@ -363,4 +363,43 @@ TEST(RtpPacketTest, ParseWithoutExtensionManager) { |
EXPECT_EQ(time_offset, kTimeOffset); |
} |
+TEST(RtpPacketTest, ParseDynamicSizeExtension) { |
+ // clang-format off |
+ const uint8_t kPacket1[] = { |
+ 0x90, kPayloadType, 0x00, kSeqNum, |
+ 0x65, 0x43, 0x12, 0x78, // Timestamp. |
+ 0x12, 0x34, 0x56, 0x78, // Ssrc. |
+ 0xbe, 0xde, 0x00, 0x02, // Extensions block of size 2x32bit words. |
+ 0x21, 'H', 'D', // Extension with id = 2, size = (1+1). |
+ 0x12, 'r', 't', 'x', // Extension with id = 1, size = (2+1). |
+ 0x00}; // Extension padding. |
+ const uint8_t kPacket2[] = { |
+ 0x90, kPayloadType, 0x00, kSeqNum, |
+ 0x65, 0x43, 0x12, 0x78, // Timestamp. |
+ 0x12, 0x34, 0x56, 0x79, // Ssrc. |
+ 0xbe, 0xde, 0x00, 0x01, // Extensions block of size 1x32bit words. |
+ 0x11, 'H', 'D', // Extension with id = 1, size = (1+1). |
+ 0x00}; // Extension padding. |
+ // clang-format on |
+ RtpPacketReceived::ExtensionManager extensions; |
+ extensions.Register<RtpStreamId>(1); |
+ extensions.Register<RepairedRtpStreamId>(2); |
+ RtpPacketReceived packet(&extensions); |
+ ASSERT_TRUE(packet.Parse(kPacket1, sizeof(kPacket1))); |
+ |
+ std::string rsid; |
+ EXPECT_TRUE(packet.GetExtension<RtpStreamId>(&rsid)); |
+ EXPECT_EQ(rsid, "rtx"); |
+ |
+ std::string repaired_rsid; |
+ EXPECT_TRUE(packet.GetExtension<RepairedRtpStreamId>(&repaired_rsid)); |
+ EXPECT_EQ(repaired_rsid, "HD"); |
+ |
+ // Parse another packet with RtpStreamId extension of different size. |
+ ASSERT_TRUE(packet.Parse(kPacket2, sizeof(kPacket2))); |
+ EXPECT_TRUE(packet.GetExtension<RtpStreamId>(&rsid)); |
+ EXPECT_EQ(rsid, "HD"); |
+ EXPECT_FALSE(packet.GetExtension<RepairedRtpStreamId>(&repaired_rsid)); |
+} |
+ |
} // namespace webrtc |