Reformat the WebRTC code base
Running clang-format with chromium's style guide.
The goal is n-fold:
* providing consistency and readability (that's what code guidelines are for)
* preventing noise with presubmit checks and git cl format
* building on the previous point: making it easier to automatically fix format issues
* you name it
Please consider using git-hyper-blame to ignore this commit.
Bug: webrtc:9340
Change-Id: I694567c4cdf8cee2860958cfe82bfaf25848bb87
Reviewed-on: https://webrtc-review.googlesource.com/81185
Reviewed-by: Patrik Höglund <phoglund@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23660}
diff --git a/media/base/rtputils_unittest.cc b/media/base/rtputils_unittest.cc
index a71eac7..08b4d4f 100644
--- a/media/base/rtputils_unittest.cc
+++ b/media/base/rtputils_unittest.cc
@@ -10,78 +10,68 @@
#include <vector>
-#include "media/base/rtputils.h"
#include "media/base/fakertp.h"
+#include "media/base/rtputils.h"
#include "rtc_base/asyncpacketsocket.h"
#include "rtc_base/gunit.h"
namespace cricket {
static const uint8_t kRtpPacketWithMarker[] = {
- 0x80, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01
-};
+ 0x80, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
// 3 CSRCs (0x01020304, 0x12345678, 0xAABBCCDD)
// Extension (0xBEDE, 0x1122334455667788)
static const uint8_t kRtpPacketWithMarkerAndCsrcAndExtension[] = {
0x93, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x01, 0x02, 0x03, 0x04, 0x12, 0x34, 0x56, 0x78, 0xAA, 0xBB, 0xCC, 0xDD,
- 0xBE, 0xDE, 0x00, 0x02, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88
-};
-static const uint8_t kInvalidPacket[] = { 0x80, 0x00 };
+ 0xBE, 0xDE, 0x00, 0x02, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88};
+static const uint8_t kInvalidPacket[] = {0x80, 0x00};
static const uint8_t kInvalidPacketWithCsrc[] = {
0x83, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
- 0x01, 0x02, 0x03, 0x04, 0x12, 0x34, 0x56, 0x78, 0xAA, 0xBB, 0xCC
-};
+ 0x01, 0x02, 0x03, 0x04, 0x12, 0x34, 0x56, 0x78, 0xAA, 0xBB, 0xCC};
static const uint8_t kInvalidPacketWithCsrcAndExtension1[] = {
- 0x93, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
- 0x01, 0x02, 0x03, 0x04, 0x12, 0x34, 0x56, 0x78, 0xAA, 0xBB, 0xCC, 0xDD,
- 0xBE, 0xDE, 0x00
-};
+ 0x93, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x01, 0x01, 0x02, 0x03, 0x04, 0x12, 0x34,
+ 0x56, 0x78, 0xAA, 0xBB, 0xCC, 0xDD, 0xBE, 0xDE, 0x00};
static const uint8_t kInvalidPacketWithCsrcAndExtension2[] = {
0x93, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x01, 0x02, 0x03, 0x04, 0x12, 0x34, 0x56, 0x78, 0xAA, 0xBB, 0xCC, 0xDD,
- 0xBE, 0xDE, 0x00, 0x02, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77
-};
+ 0xBE, 0xDE, 0x00, 0x02, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77};
// PT = 206, FMT = 1, Sender SSRC = 0x1111, Media SSRC = 0x1111
// No FCI information is needed for PLI.
static const uint8_t kNonCompoundRtcpPliFeedbackPacket[] = {
- 0x81, 0xCE, 0x00, 0x0C, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x11, 0x11
-};
+ 0x81, 0xCE, 0x00, 0x0C, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x11, 0x11};
// Packet has only mandatory fixed RTCP header
// PT = 204, SSRC = 0x1111
-static const uint8_t kNonCompoundRtcpAppPacket[] = {
- 0x81, 0xCC, 0x00, 0x0C, 0x00, 0x00, 0x11, 0x11
-};
+static const uint8_t kNonCompoundRtcpAppPacket[] = {0x81, 0xCC, 0x00, 0x0C,
+ 0x00, 0x00, 0x11, 0x11};
// PT = 202, Source count = 0
-static const uint8_t kNonCompoundRtcpSDESPacket[] = {
- 0x80, 0xCA, 0x00, 0x00
-};
+static const uint8_t kNonCompoundRtcpSDESPacket[] = {0x80, 0xCA, 0x00, 0x00};
-static uint8_t kFakeTag[4] = { 0xba, 0xdd, 0xba, 0xdd };
+static uint8_t kFakeTag[4] = {0xba, 0xdd, 0xba, 0xdd};
static uint8_t kTestKey[] = "12345678901234567890";
-static uint8_t kTestAstValue[3] = { 0xaa, 0xbb, 0xcc };
+static uint8_t kTestAstValue[3] = {0xaa, 0xbb, 0xcc};
// Valid rtp Message with 2 byte header extension.
static uint8_t kRtpMsgWith2ByteExtnHeader[] = {
+ // clang-format off
+ // clang formatting doesn't respect inline comments.
0x90, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0xAA, 0xBB, 0xCC, 0XDD, // SSRC
0x10, 0x00, 0x00, 0x01, // 2 Byte header extension
0x01, 0x00, 0x00, 0x00
+ // clang-format on
};
// RTP packet with single byte extension header of length 4 bytes.
// Extension id = 3 and length = 3
static uint8_t kRtpMsgWithAbsSendTimeExtension[] = {
- 0x90, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xBE, 0xDE, 0x00, 0x02,
- 0x22, 0x00, 0x02, 0x1c,
- 0x32, 0xaa, 0xbb, 0xcc,
+ 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xBE, 0xDE, 0x00, 0x02, 0x22, 0x00, 0x02, 0x1c, 0x32, 0xaa, 0xbb, 0xcc,
};
// Index of AbsSendTimeExtn data in message |kRtpMsgWithAbsSendTimeExtension|.
@@ -123,11 +113,10 @@
}
TEST(RtpUtilsTest, SetRtpHeader) {
- uint8_t packet[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
- };
+ uint8_t packet[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
- RtpHeader header = { 9, 1111, 2222u, 3333u };
+ RtpHeader header = {9, 1111, 2222u, 3333u};
EXPECT_TRUE(SetRtpHeader(packet, sizeof(packet), header));
// Bits: 10 0 0 0000
@@ -172,33 +161,31 @@
uint32_t ssrc;
EXPECT_TRUE(GetRtcpSsrc(kNonCompoundRtcpPliFeedbackPacket,
- sizeof(kNonCompoundRtcpPliFeedbackPacket),
- &ssrc));
+ sizeof(kNonCompoundRtcpPliFeedbackPacket), &ssrc));
EXPECT_TRUE(GetRtcpSsrc(kNonCompoundRtcpAppPacket,
- sizeof(kNonCompoundRtcpAppPacket),
- &ssrc));
+ sizeof(kNonCompoundRtcpAppPacket), &ssrc));
EXPECT_FALSE(GetRtcpSsrc(kNonCompoundRtcpSDESPacket,
- sizeof(kNonCompoundRtcpSDESPacket),
- &ssrc));
+ sizeof(kNonCompoundRtcpSDESPacket), &ssrc));
}
// Invalid RTP packets.
TEST(RtpUtilsTest, InvalidRtpHeader) {
// Rtp message with invalid length.
const uint8_t kRtpMsgWithInvalidLength[] = {
+ // clang-format off
+ // clang formatting doesn't respect inline comments.
0x94, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xAA, 0xBB, 0xCC, 0XDD, // SSRC
0xDD, 0xCC, 0xBB, 0xAA, // Only 1 CSRC, but CC count is 4.
+ // clang-format on
};
EXPECT_FALSE(ValidateRtpHeader(kRtpMsgWithInvalidLength,
sizeof(kRtpMsgWithInvalidLength), nullptr));
// Rtp message with single byte header extension, invalid extension length.
const uint8_t kRtpMsgWithInvalidExtnLength[] = {
- 0x90, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xBE, 0xDE, 0x0A, 0x00, // Extn length - 0x0A00
+ 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xBE, 0xDE, 0x0A, 0x00, // Extn length - 0x0A00
};
EXPECT_FALSE(ValidateRtpHeader(kRtpMsgWithInvalidExtnLength,
sizeof(kRtpMsgWithInvalidExtnLength),
@@ -232,6 +219,8 @@
// A valid STUN indication message with a valid RTP header in data attribute
// payload field and no extension bit set.
uint8_t message_without_extension[] = {
+ // clang-format off
+ // clang formatting doesn't respect inline comments.
0x00, 0x16, 0x00, 0x18, // length of
0x21, 0x12, 0xA4, 0x42, // magic cookie
'0', '1', '2', '3', // transaction id
@@ -243,6 +232,7 @@
0x80, 0x00, 0x00, 0x00, // RTP packet.
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
+ // clang-format on
};
EXPECT_TRUE(UpdateRtpAbsSendTimeExtension(
message_without_extension, sizeof(message_without_extension), 3, 0));
@@ -250,6 +240,8 @@
// A valid STUN indication message with a valid RTP header and a extension
// header.
uint8_t message[] = {
+ // clang-format off
+ // clang formatting doesn't respect inline comments.
0x00, 0x16, 0x00, 0x24, // length of
0x21, 0x12, 0xA4, 0x42, // magic cookie
'0', '1', '2', '3', // transaction id
@@ -261,6 +253,7 @@
0x90, 0x00, 0x00, 0x00, // RTP packet.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBE, 0xDE,
0x00, 0x02, 0x22, 0xaa, 0xbb, 0xcc, 0x32, 0xaa, 0xbb, 0xcc,
+ // clang-format on
};
EXPECT_TRUE(UpdateRtpAbsSendTimeExtension(message, sizeof(message), 3, 0));
}
@@ -349,5 +342,4 @@
sizeof(kExpectedTimestamp)));
}
-
} // namespace cricket