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

Unified Diff: webrtc/modules/rtp_rtcp/source/rtcp_packet/fir_unittest.cc

Issue 2023803002: [rtcp] Fir/Sli/Rpsi updated not to use RTCPUtility (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 7 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_packet/fir_unittest.cc
diff --git a/webrtc/modules/rtp_rtcp/source/rtcp_packet/fir_unittest.cc b/webrtc/modules/rtp_rtcp/source/rtcp_packet/fir_unittest.cc
index a4032538c8cb898ec13338443fc6b1ff288818e4..8c48a83a7fe43077113803b37e567b8b551d61dd 100644
--- a/webrtc/modules/rtp_rtcp/source/rtcp_packet/fir_unittest.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtcp_packet/fir_unittest.cc
@@ -12,6 +12,7 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "webrtc/test/rtcp_packet_parser.h"
using testing::AllOf;
using testing::ElementsAre;
@@ -20,32 +21,24 @@ using testing::Eq;
using testing::Field;
using testing::make_tuple;
using webrtc::rtcp::Fir;
-using webrtc::RTCPUtility::RtcpCommonHeader;
-using webrtc::RTCPUtility::RtcpParseCommonHeader;
namespace webrtc {
namespace {
-const uint32_t kSenderSsrc = 0x12345678;
-const uint32_t kRemoteSsrc = 0x23456789;
-const uint8_t kSeqNr = 13;
+constexpr uint32_t kSenderSsrc = 0x12345678;
+constexpr uint32_t kRemoteSsrc = 0x23456789;
+constexpr uint8_t kSeqNr = 13;
// Manually created Fir packet matching constants above.
-const uint8_t kPacket[] = {0x84, 206, 0x00, 0x04,
- 0x12, 0x34, 0x56, 0x78,
- 0x00, 0x00, 0x00, 0x00,
- 0x23, 0x45, 0x67, 0x89,
- 0x0d, 0x00, 0x00, 0x00};
-
-bool ParseFir(const uint8_t* buffer, size_t length, Fir* fir) {
- RtcpCommonHeader header;
- EXPECT_TRUE(RtcpParseCommonHeader(buffer, length, &header));
- EXPECT_THAT(header.BlockSize(), Eq(length));
- return fir->Parse(header, buffer + RtcpCommonHeader::kHeaderSizeBytes);
-}
+constexpr uint8_t kPacket[] = {0x84, 206, 0x00, 0x04,
+ 0x12, 0x34, 0x56, 0x78,
+ 0x00, 0x00, 0x00, 0x00,
+ 0x23, 0x45, 0x67, 0x89,
+ 0x0d, 0x00, 0x00, 0x00};
+} // namespace
TEST(RtcpPacketFirTest, Parse) {
Fir mutable_parsed;
- EXPECT_TRUE(ParseFir(kPacket, sizeof(kPacket), &mutable_parsed));
+ EXPECT_TRUE(test::ParseSinglePacket(kPacket, &mutable_parsed));
const Fir& parsed = mutable_parsed; // Read values from constant object.
EXPECT_EQ(kSenderSsrc, parsed.sender_ssrc());
@@ -73,7 +66,7 @@ TEST(RtcpPacketFirTest, TwoFciEntries) {
rtc::Buffer packet = fir.Build();
Fir parsed;
- EXPECT_TRUE(ParseFir(packet.data(), packet.size(), &parsed));
+ EXPECT_TRUE(test::ParseSinglePacket(packet, &parsed));
EXPECT_EQ(kSenderSsrc, parsed.sender_ssrc());
EXPECT_THAT(parsed.requests(),
@@ -84,42 +77,23 @@ TEST(RtcpPacketFirTest, TwoFciEntries) {
}
TEST(RtcpPacketFirTest, ParseFailsOnZeroFciEntries) {
- Fir fir;
- fir.From(kSenderSsrc);
- fir.WithRequestTo(kRemoteSsrc, kSeqNr);
-
- rtc::Buffer packet = fir.Build();
-
- RtcpCommonHeader header;
- RtcpParseCommonHeader(packet.data(), packet.size(), &header);
- ASSERT_EQ(16u, header.payload_size_bytes); // Common: 8, 1xfci: 8.
- header.payload_size_bytes = 8; // Common: 8, 0xfcis.
-
+ constexpr uint8_t kPacketWithoutFci[] = {0x84, 206, 0x00, 0x02,
+ 0x12, 0x34, 0x56, 0x78,
+ 0x00, 0x00, 0x00, 0x00};
Fir parsed;
- EXPECT_FALSE(parsed.Parse(
- header, packet.data() + RtcpCommonHeader::kHeaderSizeBytes));
+ EXPECT_FALSE(test::ParseSinglePacket(kPacketWithoutFci, &parsed));
}
TEST(RtcpPacketFirTest, ParseFailsOnFractionalFciEntries) {
- Fir fir;
- fir.From(kSenderSsrc);
- fir.WithRequestTo(kRemoteSsrc, kSeqNr);
- fir.WithRequestTo(kRemoteSsrc + 1, kSeqNr + 1);
+ constexpr uint8_t kPacketWithOneAndHalfFci[] = {0x84, 206, 0x00, 0x05,
+ 0x12, 0x34, 0x56, 0x78,
+ 0x00, 0x00, 0x00, 0x00,
+ 0x23, 0x45, 0x67, 0x89,
+ 0x0d, 0x00, 0x00, 0x00,
+ 'h', 'a', 'l', 'f'};
- rtc::Buffer packet = fir.Build();
-
- RtcpCommonHeader header;
- RtcpParseCommonHeader(packet.data(), packet.size(), &header);
- ASSERT_EQ(24u, header.payload_size_bytes); // Common: 8, 2xfcis: 16.
-
- const uint8_t* payload = packet.data() + RtcpCommonHeader::kHeaderSizeBytes;
- Fir good;
- EXPECT_TRUE(good.Parse(header, payload));
- for (size_t i = 1; i < 8; ++i) {
- header.payload_size_bytes = 16 + i;
- Fir bad;
- EXPECT_FALSE(bad.Parse(header, payload));
- }
+ Fir parsed;
+ EXPECT_FALSE(test::ParseSinglePacket(kPacketWithOneAndHalfFci, &parsed));
}
-} // namespace
+
} // namespace webrtc
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtcp_packet/fir.cc ('k') | webrtc/modules/rtp_rtcp/source/rtcp_packet/psfb.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698