Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(488)

Unified Diff: webrtc/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc

Issue 1870573004: Fixed rtcp rpsi parsing of invalid packets. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc
diff --git a/webrtc/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc b/webrtc/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc
index 507f835bc3fb118e4a1cd1f8a379dc5fd770b0be..08f109bc297882cd578b16d4945f35249a8c277a 100644
--- a/webrtc/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc
@@ -29,6 +29,7 @@
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/pli.h"
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/receiver_report.h"
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/remb.h"
+#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rpsi.h"
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sdes.h"
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sender_report.h"
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sli.h"
@@ -165,6 +166,50 @@ TEST_F(RtcpReceiverTest, InvalidFeedbackPacketIsIgnored) {
EXPECT_EQ(0U, rtcp_packet_info_.rtcpPacketTypeFlags);
}
+TEST_F(RtcpReceiverTest, RpsiWithFractionalPaddingIsIgnored) {
+ // Padding size represent fractional number of bytes.
+ const uint8_t kPaddingSizeBits = 0x0b;
+ const uint8_t bad_packet[] = {0x83, RTCPUtility::PT_PSFB, 0, 3,
+ 0x12, 0x34, 0x56, 0x78,
+ 0x98, 0x76, 0x54, 0x32,
+ kPaddingSizeBits, 0x00, 0x00, 0x00};
+ EXPECT_EQ(0, InjectRtcpPacket(bad_packet, sizeof(bad_packet)));
+ EXPECT_EQ(0U, rtcp_packet_info_.rtcpPacketTypeFlags);
+}
+
+TEST_F(RtcpReceiverTest, RpsiWithTooLargePaddingIsIgnored) {
+ // Padding size exceeds packet size.
+ const uint8_t kPaddingSizeBits = 0xa8;
+ const uint8_t bad_packet[] = {0x83, RTCPUtility::PT_PSFB, 0, 3,
+ 0x12, 0x34, 0x56, 0x78,
+ 0x98, 0x76, 0x54, 0x32,
+ kPaddingSizeBits, 0x00, 0x00, 0x00};
+ EXPECT_EQ(0, InjectRtcpPacket(bad_packet, sizeof(bad_packet)));
+ EXPECT_EQ(0U, rtcp_packet_info_.rtcpPacketTypeFlags);
+}
+
+// With parsing using rtcp classes this test will make no sense.
+// With current stateful parser this test was failing.
+TEST_F(RtcpReceiverTest, TwoHalfValidRpsiAreIgnored) {
+ const uint8_t bad_packet[] = {0x83, RTCPUtility::PT_PSFB, 0, 2,
+ 0x12, 0x34, 0x56, 0x78,
+ 0x98, 0x76, 0x54, 0x32,
+ 0x83, RTCPUtility::PT_PSFB, 0, 2,
+ 0x12, 0x34, 0x56, 0x78,
+ 0x98, 0x76, 0x54, 0x32};
+ EXPECT_EQ(0, InjectRtcpPacket(bad_packet, sizeof(bad_packet)));
+ EXPECT_EQ(0U, rtcp_packet_info_.rtcpPacketTypeFlags);
+}
+
+TEST_F(RtcpReceiverTest, InjectRpsiPacket) {
+ const uint64_t kPictureId = 0x123456789;
+ rtcp::Rpsi rpsi;
+ rpsi.WithPictureId(kPictureId);
+ rtc::Buffer packet = rpsi.Build();
+ EXPECT_EQ(0, InjectRtcpPacket(packet.data(), packet.size()));
+ EXPECT_EQ(kRtcpRpsi, rtcp_packet_info_.rtcpPacketTypeFlags);
+}
+
TEST_F(RtcpReceiverTest, InjectSrPacket) {
const uint32_t kSenderSsrc = 0x10203;
rtcp::SenderReport sr;
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtcp_receiver.cc ('k') | webrtc/modules/rtp_rtcp/source/rtcp_sender_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698