constexpr-ify unit tests

starting with
  git grep "^const char k" | grep unittest.cc | awk -F ':' '{print $1}' | sort | uniq | xargs sed -i 's/^const char /constexpr char /g'
and then repeating the same with each of
  uint8_t, uint32_t, uint16_t, size_t, int8_t, int16_t, int32_t, int64_t, double, uint64_t, unsigned int, float

The remainder can be seen with
  git grep "^const .* k" | grep unittest.cc  | awk '{print $2}' | sort | uniq -c | sort -b -n

Follow-up from
  https://webrtc-review.googlesource.com/c/src/+/398220

Bug: webrtc:429563452
No-Iwyu: large scale change
Change-Id: I04e8f35c001a159f006c8897dccf35f77bc9cacb
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/398647
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Philipp Hancke <phancke@meta.com>
Cr-Commit-Position: refs/heads/main@{#45111}
This commit is contained in:
Philipp Hancke 2025-07-07 11:57:09 -07:00 committed by WebRTC LUCI CQ
parent c544c1630f
commit 81f4e7805b
125 changed files with 798 additions and 807 deletions

View File

@ -37,7 +37,7 @@ namespace {
// clang-format off
// clang formatting doesn't respect inline comments.
const uint8_t kStunMessageWithIPv6MappedAddress[] = {
constexpr uint8_t kStunMessageWithIPv6MappedAddress[] = {
0x00, 0x01, 0x00, 0x18, // message header
0x21, 0x12, 0xa4, 0x42, // transaction id
0x29, 0x1f, 0xcd, 0x7c,
@ -51,7 +51,7 @@ const uint8_t kStunMessageWithIPv6MappedAddress[] = {
0xfe, 0xe5, 0x00, 0xc3
};
const uint8_t kStunMessageWithIPv4MappedAddress[] = {
constexpr uint8_t kStunMessageWithIPv4MappedAddress[] = {
0x01, 0x01, 0x00, 0x0c, // binding response, length 12
0x21, 0x12, 0xa4, 0x42, // magic cookie
0x29, 0x1f, 0xcd, 0x7c, // transaction ID
@ -63,7 +63,7 @@ const uint8_t kStunMessageWithIPv4MappedAddress[] = {
};
// Test XOR-mapped IP addresses:
const uint8_t kStunMessageWithIPv6XorMappedAddress[] = {
constexpr uint8_t kStunMessageWithIPv6XorMappedAddress[] = {
0x01, 0x01, 0x00, 0x18, // message header (binding response)
0x21, 0x12, 0xa4, 0x42, // magic cookie (rfc5389)
0xe3, 0xa9, 0x46, 0xe1, // transaction ID
@ -77,7 +77,7 @@ const uint8_t kStunMessageWithIPv6XorMappedAddress[] = {
0xaa, 0xed, 0x01, 0xc3
};
const uint8_t kStunMessageWithIPv4XorMappedAddress[] = {
constexpr uint8_t kStunMessageWithIPv4XorMappedAddress[] = {
0x01, 0x01, 0x00, 0x0c, // message header (binding response)
0x21, 0x12, 0xa4, 0x42, // magic cookie
0x29, 0x1f, 0xcd, 0x7c, // transaction ID
@ -89,7 +89,7 @@ const uint8_t kStunMessageWithIPv4XorMappedAddress[] = {
};
// ByteString Attribute (username)
const uint8_t kStunMessageWithByteStringAttribute[] = {
constexpr uint8_t kStunMessageWithByteStringAttribute[] = {
0x00, 0x01, 0x00, 0x0c,
0x21, 0x12, 0xa4, 0x42,
0xe3, 0xa9, 0x46, 0xe1,
@ -102,7 +102,7 @@ const uint8_t kStunMessageWithByteStringAttribute[] = {
// Message with an unknown but comprehensible optional attribute.
// Parsing should succeed despite this unknown attribute.
const uint8_t kStunMessageWithUnknownAttribute[] = {
constexpr uint8_t kStunMessageWithUnknownAttribute[] = {
0x00, 0x01, 0x00, 0x14,
0x21, 0x12, 0xa4, 0x42,
0xe3, 0xa9, 0x46, 0xe1,
@ -116,7 +116,7 @@ const uint8_t kStunMessageWithUnknownAttribute[] = {
};
// ByteString Attribute (username) with padding byte
const uint8_t kStunMessageWithPaddedByteStringAttribute[] = {
constexpr uint8_t kStunMessageWithPaddedByteStringAttribute[] = {
0x00, 0x01, 0x00, 0x08,
0x21, 0x12, 0xa4, 0x42,
0xe3, 0xa9, 0x46, 0xe1,
@ -127,7 +127,7 @@ const uint8_t kStunMessageWithPaddedByteStringAttribute[] = {
};
// Message with an Unknown Attributes (uint16_t list) attribute.
const uint8_t kStunMessageWithUInt16ListAttribute[] = {
constexpr uint8_t kStunMessageWithUInt16ListAttribute[] = {
0x00, 0x01, 0x00, 0x0c,
0x21, 0x12, 0xa4, 0x42,
0xe3, 0xa9, 0x46, 0xe1,
@ -139,7 +139,7 @@ const uint8_t kStunMessageWithUInt16ListAttribute[] = {
};
// Error response message (unauthorized)
const uint8_t kStunMessageWithErrorAttribute[] = {
constexpr uint8_t kStunMessageWithErrorAttribute[] = {
0x01, 0x11, 0x00, 0x14,
0x21, 0x12, 0xa4, 0x42,
0x29, 0x1f, 0xcd, 0x7c,
@ -155,9 +155,9 @@ const uint8_t kStunMessageWithErrorAttribute[] = {
// Sample messages with an invalid length Field
// The actual length in bytes of the invalid messages (including STUN header)
const int kRealLengthOfInvalidLengthTestCases = 32;
constexpr int kRealLengthOfInvalidLengthTestCases = 32;
const uint8_t kStunMessageWithZeroLength[] = {
constexpr uint8_t kStunMessageWithZeroLength[] = {
0x00, 0x01, 0x00, 0x00, // length of 0 (last 2 bytes)
0x21, 0x12, 0xA4, 0x42, // magic cookie
'0', '1', '2', '3', // transaction id
@ -168,7 +168,7 @@ const uint8_t kStunMessageWithZeroLength[] = {
0x21, 0x12, 0xA4, 0x53,
};
const uint8_t kStunMessageWithExcessLength[] = {
constexpr uint8_t kStunMessageWithExcessLength[] = {
0x00, 0x01, 0x00, 0x55, // length of 85
0x21, 0x12, 0xA4, 0x42, // magic cookie
'0', '1', '2', '3', // transaction id
@ -179,7 +179,7 @@ const uint8_t kStunMessageWithExcessLength[] = {
0x21, 0x12, 0xA4, 0x53,
};
const uint8_t kStunMessageWithSmallLength[] = {
constexpr uint8_t kStunMessageWithSmallLength[] = {
0x00, 0x01, 0x00, 0x03, // length of 3
0x21, 0x12, 0xA4, 0x42, // magic cookie
'0', '1', '2', '3', // transaction id
@ -190,7 +190,7 @@ const uint8_t kStunMessageWithSmallLength[] = {
0x21, 0x12, 0xA4, 0x53,
};
const uint8_t kStunMessageWithBadHmacAtEnd[] = {
constexpr uint8_t kStunMessageWithBadHmacAtEnd[] = {
0x00, 0x01, 0x00, 0x14, // message length exactly 20
0x21, 0x12, 0xA4, 0x42, // magic cookie
'0', '1', '2', '3', // transaction ID
@ -205,7 +205,7 @@ const uint8_t kStunMessageWithBadHmacAtEnd[] = {
// RTCP packet, for testing we correctly ignore non stun packet types.
// V=2, P=false, RC=0, Type=200, Len=6, Sender-SSRC=85, etc
const uint8_t kRtcpPacket[] = {
constexpr uint8_t kRtcpPacket[] = {
0x80, 0xc8, 0x00, 0x06, 0x00, 0x00, 0x00, 0x55,
0xce, 0xa5, 0x18, 0x3a, 0x39, 0xcc, 0x7d, 0x09,
0x23, 0xed, 0x19, 0x07, 0x00, 0x00, 0x01, 0x56,
@ -218,30 +218,30 @@ const uint8_t kRtcpPacket[] = {
// Software name (response): "test vector" (without quotes)
// Username: "evtj:h6vY" (without quotes)
// Password: "VOkJxbRl1RmTxUk/WvJxBt" (without quotes)
const uint8_t kRfc5769SampleMsgTransactionId[] = {
constexpr uint8_t kRfc5769SampleMsgTransactionId[] = {
0xb7, 0xe7, 0xa7, 0x01, 0xbc, 0x34, 0xd6, 0x86, 0xfa, 0x87, 0xdf, 0xae
};
const char kRfc5769SampleMsgClientSoftware[] = "STUN test client";
const char kRfc5769SampleMsgServerSoftware[] = "test vector";
const char kRfc5769SampleMsgUsername[] = "evtj:h6vY";
const char kRfc5769SampleMsgPassword[] = "VOkJxbRl1RmTxUk/WvJxBt";
constexpr char kRfc5769SampleMsgClientSoftware[] = "STUN test client";
constexpr char kRfc5769SampleMsgServerSoftware[] = "test vector";
constexpr char kRfc5769SampleMsgUsername[] = "evtj:h6vY";
constexpr char kRfc5769SampleMsgPassword[] = "VOkJxbRl1RmTxUk/WvJxBt";
const SocketAddress kRfc5769SampleMsgMappedAddress(
"192.0.2.1", 32853);
const SocketAddress kRfc5769SampleMsgIPv6MappedAddress(
"2001:db8:1234:5678:11:2233:4455:6677", 32853);
const uint8_t kRfc5769SampleMsgWithAuthTransactionId[] = {
constexpr uint8_t kRfc5769SampleMsgWithAuthTransactionId[] = {
0x78, 0xad, 0x34, 0x33, 0xc6, 0xad, 0x72, 0xc0, 0x29, 0xda, 0x41, 0x2e
};
const char kRfc5769SampleMsgWithAuthUsername[] =
constexpr char kRfc5769SampleMsgWithAuthUsername[] =
"\xe3\x83\x9e\xe3\x83\x88\xe3\x83\xaa\xe3\x83\x83\xe3\x82\xaf\xe3\x82\xb9";
const char kRfc5769SampleMsgWithAuthPassword[] = "TheMatrIX";
const char kRfc5769SampleMsgWithAuthNonce[] =
constexpr char kRfc5769SampleMsgWithAuthPassword[] = "TheMatrIX";
constexpr char kRfc5769SampleMsgWithAuthNonce[] =
"f//499k954d6OL34oL9FSTvy64sA";
const char kRfc5769SampleMsgWithAuthRealm[] = "example.org";
constexpr char kRfc5769SampleMsgWithAuthRealm[] = "example.org";
// 2.1. Sample Request
const uint8_t kRfc5769SampleRequest[] = {
constexpr uint8_t kRfc5769SampleRequest[] = {
0x00, 0x01, 0x00, 0x58, // Request type and message length
0x21, 0x12, 0xa4, 0x42, // Magic cookie
0xb7, 0xe7, 0xa7, 0x01, // }
@ -272,7 +272,7 @@ const uint8_t kRfc5769SampleRequest[] = {
};
// 2.1. Sample Request
const uint8_t kSampleRequestMI32[] = {
constexpr uint8_t kSampleRequestMI32[] = {
0x00, 0x01, 0x00, 0x48, // Request type and message length
0x21, 0x12, 0xa4, 0x42, // Magic cookie
0xb7, 0xe7, 0xa7, 0x01, // }
@ -299,7 +299,7 @@ const uint8_t kSampleRequestMI32[] = {
};
// 2.2. Sample IPv4 Response
const uint8_t kRfc5769SampleResponse[] = {
constexpr uint8_t kRfc5769SampleResponse[] = {
0x01, 0x01, 0x00, 0x3c, // Response type and message length
0x21, 0x12, 0xa4, 0x42, // Magic cookie
0xb7, 0xe7, 0xa7, 0x01, // }
@ -323,7 +323,7 @@ const uint8_t kRfc5769SampleResponse[] = {
};
// 2.3. Sample IPv6 Response
const uint8_t kRfc5769SampleResponseIPv6[] = {
constexpr uint8_t kRfc5769SampleResponseIPv6[] = {
0x01, 0x01, 0x00, 0x48, // Response type and message length
0x21, 0x12, 0xa4, 0x42, // Magic cookie
0xb7, 0xe7, 0xa7, 0x01, // }
@ -350,7 +350,7 @@ const uint8_t kRfc5769SampleResponseIPv6[] = {
};
// 2.4. Sample Request with Long-Term Authentication
const uint8_t kRfc5769SampleRequestLongTermAuth[] = {
constexpr uint8_t kRfc5769SampleRequestLongTermAuth[] = {
0x00, 0x01, 0x00, 0x60, // Request type and message length
0x21, 0x12, 0xa4, 0x42, // Magic cookie
0x78, 0xad, 0x34, 0x33, // }
@ -385,7 +385,7 @@ const uint8_t kRfc5769SampleRequestLongTermAuth[] = {
// Length parameter is changed to 0x38 from 0x58.
// AddMessageIntegrity will add MI information and update the length param
// accordingly.
const uint8_t kRfc5769SampleRequestWithoutMI[] = {
constexpr uint8_t kRfc5769SampleRequestWithoutMI[] = {
0x00, 0x01, 0x00, 0x38, // Request type and message length
0x21, 0x12, 0xa4, 0x42, // Magic cookie
0xb7, 0xe7, 0xa7, 0x01, // }
@ -409,7 +409,7 @@ const uint8_t kRfc5769SampleRequestWithoutMI[] = {
// This HMAC differs from the RFC 5769 SampleRequest message. This differs
// because spec uses 0x20 for the padding where as our implementation uses 0.
const uint8_t kCalculatedHmac1[] = {
constexpr uint8_t kCalculatedHmac1[] = {
0x79, 0x07, 0xc2, 0xd2, // }
0xed, 0xbf, 0xea, 0x48, // }
0x0e, 0x4c, 0x76, 0xd8, // } HMAC-SHA1 fingerprint
@ -421,14 +421,14 @@ const uint8_t kCalculatedHmac1[] = {
// above since the sum is computed including header
// and the header is different since the message is shorter
// than when MESSAGE-INTEGRITY is used.
const uint8_t kCalculatedHmac1_32[] = {
constexpr uint8_t kCalculatedHmac1_32[] = {
0xda, 0x39, 0xde, 0x5d, // }
};
// Length parameter is changed to 0x1c from 0x3c.
// AddMessageIntegrity will add MI information and update the length param
// accordingly.
const uint8_t kRfc5769SampleResponseWithoutMI[] = {
constexpr uint8_t kRfc5769SampleResponseWithoutMI[] = {
0x01, 0x01, 0x00, 0x1c, // Response type and message length
0x21, 0x12, 0xa4, 0x42, // Magic cookie
0xb7, 0xe7, 0xa7, 0x01, // }
@ -445,7 +445,7 @@ const uint8_t kRfc5769SampleResponseWithoutMI[] = {
// This HMAC differs from the RFC 5769 SampleResponse message. This differs
// because spec uses 0x20 for the padding where as our implementation uses 0.
const uint8_t kCalculatedHmac2[] = {
constexpr uint8_t kCalculatedHmac2[] = {
0x5d, 0x6b, 0x58, 0xbe, // }
0xad, 0x94, 0xe0, 0x7e, // }
0xef, 0x0d, 0xfc, 0x12, // } HMAC-SHA1 fingerprint
@ -457,7 +457,7 @@ const uint8_t kCalculatedHmac2[] = {
// above since the sum is computed including header
// and the header is different since the message is shorter
// than when MESSAGE-INTEGRITY is used.
const uint8_t kCalculatedHmac2_32[] = {
constexpr uint8_t kCalculatedHmac2_32[] = {
0xe7, 0x5c, 0xd3, 0x16, // }
};
@ -465,14 +465,14 @@ const uint8_t kCalculatedHmac2_32[] = {
// A transaction ID without the 'magic cookie' portion
// pjnat's test programs use this transaction ID a lot.
const uint8_t kTestTransactionId1[] = {0x029, 0x01f, 0x0cd, 0x07c,
0x0ba, 0x058, 0x0ab, 0x0d7,
0x0f2, 0x041, 0x001, 0x000};
constexpr uint8_t kTestTransactionId1[] = {0x029, 0x01f, 0x0cd, 0x07c,
0x0ba, 0x058, 0x0ab, 0x0d7,
0x0f2, 0x041, 0x001, 0x000};
// They use this one sometimes too.
const uint8_t kTestTransactionId2[] = {0x0e3, 0x0a9, 0x046, 0x0e1,
0x07c, 0x000, 0x0c2, 0x062,
0x054, 0x008, 0x001, 0x000};
constexpr uint8_t kTestTransactionId2[] = {0x0e3, 0x0a9, 0x046, 0x0e1,
0x07c, 0x000, 0x0c2, 0x062,
0x054, 0x008, 0x001, 0x000};
const in6_addr kIPv6TestAddress1 = {
{{0x24, 0x01, 0xfa, 0x00, 0x00, 0x04, 0x10, 0x00, 0xbe, 0x30, 0x5b, 0xff,
@ -487,17 +487,17 @@ const in_addr kIPv4TestAddress1 = {0xe64417ac};
// Windows in_addr has a union with a uchar[] array first.
const in_addr kIPv4TestAddress1 = {{{0x0ac, 0x017, 0x044, 0x0e6}}};
#endif
const char kTestUserName1[] = "abcdefgh";
const char kTestUserName2[] = "abc";
const char kTestErrorReason[] = "Unauthorized";
const int kTestErrorClass = 4;
const int kTestErrorNumber = 1;
const int kTestErrorCode = 401;
constexpr char kTestUserName1[] = "abcdefgh";
constexpr char kTestUserName2[] = "abc";
constexpr char kTestErrorReason[] = "Unauthorized";
constexpr int kTestErrorClass = 4;
constexpr int kTestErrorNumber = 1;
constexpr int kTestErrorCode = 401;
const int kTestMessagePort1 = 59977;
const int kTestMessagePort2 = 47233;
const int kTestMessagePort3 = 56743;
const int kTestMessagePort4 = 40444;
constexpr int kTestMessagePort1 = 59977;
constexpr int kTestMessagePort2 = 47233;
constexpr int kTestMessagePort3 = 56743;
constexpr int kTestMessagePort4 = 40444;
} // namespace
class StunTest : public ::testing::Test {

View File

@ -53,13 +53,16 @@ using ::testing::_;
using ::testing::Return;
using ::testing::ValuesIn;
const int kWidth = 320;
const int kHeight = 240;
const int kNumCores = 2;
const uint32_t kFramerate = 30;
const size_t kMaxPayloadSize = 800;
const int kLowThreshold = 10;
const int kHighThreshold = 20;
constexpr int kWidth = 320;
constexpr int kHeight = 240;
constexpr int kNumCores = 2;
constexpr uint32_t kFramerate = 30;
constexpr size_t kMaxPayloadSize = 800;
constexpr int kLowThreshold = 10;
constexpr int kHighThreshold = 20;
constexpr int kBitrateKbps = 200;
constexpr int kMinPixelsPerFrame = 1;
constexpr char kFieldTrial[] = "WebRTC-VP8-Forced-Fallback-Encoder-v2";
const VideoEncoder::Capabilities kCapabilities(false);
const VideoEncoder::Settings kSettings(kCapabilities,
@ -90,6 +93,7 @@ class FakeEncodedImageCallback : public EncodedImageCallback {
}
int callback_count_ = 0;
};
} // namespace
class VideoEncoderSoftwareFallbackWrapperTestBase : public ::testing::Test {
@ -486,12 +490,6 @@ TEST_F(VideoEncoderSoftwareFallbackWrapperTest,
fake_sw_encoder_->last_video_frame_->height());
}
namespace {
const int kBitrateKbps = 200;
const int kMinPixelsPerFrame = 1;
const char kFieldTrial[] = "WebRTC-VP8-Forced-Fallback-Encoder-v2";
} // namespace
class ForcedFallbackTest : public VideoEncoderSoftwareFallbackWrapperTestBase {
public:
explicit ForcedFallbackTest(const Environment& env)

View File

@ -65,14 +65,14 @@ AudioDecodingCallStats MakeAudioDecodeStatsForTest() {
return audio_decode_stats;
}
const uint32_t kRemoteSsrc = 1234;
const uint32_t kLocalSsrc = 5678;
const int kJitterBufferDelay = -7;
const int kPlayoutBufferDelay = 302;
const unsigned int kSpeechOutputLevel = 99;
const double kTotalOutputEnergy = 0.25;
const double kTotalOutputDuration = 0.5;
const int64_t kPlayoutNtpTimestampMs = 5678;
constexpr uint32_t kRemoteSsrc = 1234;
constexpr uint32_t kLocalSsrc = 5678;
constexpr int kJitterBufferDelay = -7;
constexpr int kPlayoutBufferDelay = 302;
constexpr unsigned int kSpeechOutputLevel = 99;
constexpr double kTotalOutputEnergy = 0.25;
constexpr double kTotalOutputDuration = 0.5;
constexpr int64_t kPlayoutNtpTimestampMs = 5678;
const CallReceiveStatistics kCallStats = {678, 234, -12, 567, 78, 890, 123};
const std::pair<int, SdpAudioFormat> kReceiveCodec = {

View File

@ -76,28 +76,28 @@ using ::testing::Return;
using ::testing::StrEq;
using ::testing::WithArg;
const float kTolerance = 0.0001f;
constexpr float kTolerance = 0.0001f;
const uint32_t kSsrc = 1234;
constexpr uint32_t kSsrc = 1234;
const char* kCName = "foo_name";
const std::array<uint32_t, 2> kCsrcs = {5678, 9012};
const int kAudioLevelId = 2;
const int kTransportSequenceNumberId = 4;
const int32_t kEchoDelayMedian = 254;
const int32_t kEchoDelayStdDev = -3;
const double kDivergentFilterFraction = 0.2f;
const double kEchoReturnLoss = -65;
const double kEchoReturnLossEnhancement = 101;
const double kResidualEchoLikelihood = -1.0f;
const double kResidualEchoLikelihoodMax = 23.0f;
constexpr int kAudioLevelId = 2;
constexpr int kTransportSequenceNumberId = 4;
constexpr int32_t kEchoDelayMedian = 254;
constexpr int32_t kEchoDelayStdDev = -3;
constexpr double kDivergentFilterFraction = 0.2f;
constexpr double kEchoReturnLoss = -65;
constexpr double kEchoReturnLossEnhancement = 101;
constexpr double kResidualEchoLikelihood = -1.0f;
constexpr double kResidualEchoLikelihoodMax = 23.0f;
const CallSendStatistics kCallStats = {112, 12, 13456, 17890};
constexpr int kFractionLost = 123;
constexpr int kCumulativeLost = 567;
constexpr uint32_t kInterarrivalJitter = 132;
const int kTelephoneEventPayloadType = 123;
const int kTelephoneEventPayloadFrequency = 65432;
const int kTelephoneEventCode = 45;
const int kTelephoneEventDuration = 6789;
constexpr int kTelephoneEventPayloadType = 123;
constexpr int kTelephoneEventPayloadFrequency = 65432;
constexpr int kTelephoneEventCode = 45;
constexpr int kTelephoneEventDuration = 6789;
constexpr int kIsacPayloadType = 103;
const SdpAudioFormat kIsacFormat = {"isac", 16000, 1};
const SdpAudioFormat kOpusFormat = {"opus", 48000, 2};

View File

@ -40,8 +40,8 @@ namespace {
using ::testing::Eq;
const int kDefaultFrameRate = 30;
const int kDefaultFrameSize = 1280 * 720;
constexpr int kDefaultFrameRate = 30;
constexpr int kDefaultFrameSize = 1280 * 720;
constexpr TimeDelta kDefaultTimeout = TimeDelta::Seconds(5);
class VideoSourceRestrictionsListenerForTesting

View File

@ -18,7 +18,7 @@ namespace webrtc {
namespace {
const size_t kHdPixels = 1280 * 720;
constexpr size_t kHdPixels = 1280 * 720;
const VideoSourceRestrictions kUnlimited;
const VideoSourceRestrictions k15fps(std::nullopt, std::nullopt, 15.0);

View File

@ -38,14 +38,14 @@ using ::testing::Return;
namespace {
const int kBalancedHighResolutionPixels = 1280 * 720;
const int kBalancedHighFrameRateFps = 30;
constexpr int kBalancedHighResolutionPixels = 1280 * 720;
constexpr int kBalancedHighFrameRateFps = 30;
const int kBalancedMediumResolutionPixels = 640 * 480;
const int kBalancedMediumFrameRateFps = 20;
constexpr int kBalancedMediumResolutionPixels = 640 * 480;
constexpr int kBalancedMediumFrameRateFps = 20;
const int kBalancedLowResolutionPixels = 320 * 240;
const int kBalancedLowFrameRateFps = 10;
constexpr int kBalancedLowResolutionPixels = 320 * 240;
constexpr int kBalancedLowFrameRateFps = 10;
std::string BalancedFieldTrialConfig() {
return "WebRTC-Video-BalancedDegradationSettings/pixels:" +

View File

@ -100,7 +100,7 @@ class TestContributingBitrateObserver : public TestBitrateObserver {
};
constexpr int64_t kDefaultProbingIntervalMs = 3000;
const double kDefaultBitratePriority = 1.0;
constexpr double kDefaultBitratePriority = 1.0;
TargetTransferRate CreateTargetRateMessage(uint32_t target_bitrate_bps,
uint8_t fraction_loss,

View File

@ -54,14 +54,14 @@ using ::testing::SizeIs;
using GenericDescriptorInfo = RTPVideoHeader::GenericDescriptorInfo;
const uint32_t kSsrc1 = 12345;
const uint32_t kSsrc2 = 23456;
const int16_t kPictureId = 123;
const int16_t kTl0PicIdx = 20;
const uint8_t kTemporalIdx = 1;
const int16_t kInitialPictureId1 = 222;
const int16_t kInitialTl0PicIdx1 = 99;
const int64_t kDontCare = 0;
constexpr uint32_t kSsrc1 = 12345;
constexpr uint32_t kSsrc2 = 23456;
constexpr int16_t kPictureId = 123;
constexpr int16_t kTl0PicIdx = 20;
constexpr uint8_t kTemporalIdx = 1;
constexpr int16_t kInitialPictureId1 = 222;
constexpr int16_t kInitialTl0PicIdx1 = 99;
constexpr int64_t kDontCare = 0;
TEST(RtpPayloadParamsTest, InfoMappedToRtpVideoHeader_Vp8) {
RtpPayloadState state2;

View File

@ -85,19 +85,19 @@ using ::testing::NotNull;
using ::testing::SaveArg;
using ::testing::SizeIs;
const int8_t kPayloadType = 96;
const int8_t kPayloadType2 = 98;
const uint32_t kSsrc1 = 12345;
const uint32_t kSsrc2 = 23456;
const uint32_t kRtxSsrc1 = 34567;
const uint32_t kRtxSsrc2 = 45678;
const int16_t kInitialPictureId1 = 222;
const int16_t kInitialPictureId2 = 44;
const int16_t kInitialTl0PicIdx1 = 99;
const int16_t kInitialTl0PicIdx2 = 199;
const int64_t kRetransmitWindowSizeMs = 500;
const int kTransportsSequenceExtensionId = 7;
const int kDependencyDescriptorExtensionId = 8;
constexpr int8_t kPayloadType = 96;
constexpr int8_t kPayloadType2 = 98;
constexpr uint32_t kSsrc1 = 12345;
constexpr uint32_t kSsrc2 = 23456;
constexpr uint32_t kRtxSsrc1 = 34567;
constexpr uint32_t kRtxSsrc2 = 45678;
constexpr int16_t kInitialPictureId1 = 222;
constexpr int16_t kInitialPictureId2 = 44;
constexpr int16_t kInitialTl0PicIdx1 = 99;
constexpr int16_t kInitialTl0PicIdx2 = 199;
constexpr int64_t kRetransmitWindowSizeMs = 500;
constexpr int kTransportsSequenceExtensionId = 7;
constexpr int kDependencyDescriptorExtensionId = 8;
class MockRtcpIntraFrameObserver : public RtcpIntraFrameObserver {
public:

View File

@ -17,9 +17,9 @@ namespace webrtc {
namespace {
const size_t kNumFrames = 480u;
const size_t kStereo = 2u;
const size_t kMono = 1u;
constexpr size_t kNumFrames = 480u;
constexpr size_t kStereo = 2u;
constexpr size_t kMono = 1u;
void ExpectNumChannels(const IFChannelBuffer& ifchb, size_t num_channels) {
EXPECT_EQ(ifchb.ibuf_const()->num_channels(), num_channels);

View File

@ -25,7 +25,7 @@ namespace webrtc {
namespace {
// Almost all conversions have an RMS error of around -14 dbFS.
const double kResamplingRMSError = -14.42;
constexpr double kResamplingRMSError = -14.42;
// Used to convert errors to dbFS.
template <typename T>

View File

@ -21,11 +21,11 @@ namespace webrtc {
namespace {
// Rates we must support.
const int kMaxRate = 96000;
const int kRates[] = {8000, 16000, 32000, 44000, 48000, kMaxRate};
const size_t kRatesSize = sizeof(kRates) / sizeof(*kRates);
const int kMaxChannels = 2;
const size_t kDataSize = static_cast<size_t>(kMaxChannels * kMaxRate / 100);
constexpr int kMaxRate = 96000;
constexpr int kRates[] = {8000, 16000, 32000, 44000, 48000, kMaxRate};
constexpr size_t kRatesSize = sizeof(kRates) / sizeof(*kRates);
constexpr int kMaxChannels = 2;
constexpr size_t kDataSize = static_cast<size_t>(kMaxChannels * kMaxRate / 100);
// TODO(andrew): should we be supporting these combinations?
bool ValidRates(int in_rate, int out_rate) {

View File

@ -17,16 +17,16 @@ namespace webrtc {
namespace {
// FFT order.
const int kOrder = 5;
constexpr int kOrder = 5;
// Lengths for real FFT's time and frequency bufffers.
// For N-point FFT, the length requirements from API are N and N+2 respectively.
const int kTimeDataLength = 1 << kOrder;
const int kFreqDataLength = (1 << kOrder) + 2;
constexpr int kTimeDataLength = 1 << kOrder;
constexpr int kFreqDataLength = (1 << kOrder) + 2;
// For complex FFT's time and freq buffer. The implementation requires
// 2*N 16-bit words.
const int kComplexFftDataLength = 2 << kOrder;
constexpr int kComplexFftDataLength = 2 << kOrder;
// Reference data for time signal.
const int16_t kRefData[kTimeDataLength] = {
constexpr int16_t kRefData[kTimeDataLength] = {
11739, 6848, -8688, 31980, -30295, 25242, 27085, 19410,
-26299, 15607, -10791, 11778, -23819, 14498, -25772, 10076,
1173, 6848, -8688, 31980, -30295, 2522, 27085, 19410,

View File

@ -21,7 +21,7 @@ extern "C" {
namespace webrtc {
namespace test {
const int kNumValidFrameLengths = 3;
constexpr int kNumValidFrameLengths = 3;
TEST_F(VadTest, vad_filterbank) {
VadInstT* self = reinterpret_cast<VadInstT*>(malloc(sizeof(VadInstT)));

View File

@ -26,14 +26,14 @@ namespace webrtc {
namespace {
// Contains enough of the image slice to contain slice QP.
const uint8_t kH264BitstreamChunk[] = {
constexpr uint8_t kH264BitstreamChunk[] = {
0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0x80, 0x20, 0xda, 0x01, 0x40, 0x16,
0xe8, 0x06, 0xd0, 0xa1, 0x35, 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x06,
0xe2, 0x00, 0x00, 0x00, 0x01, 0x65, 0xb8, 0x40, 0xf0, 0x8c, 0x03, 0xf2,
0x75, 0x67, 0xad, 0x41, 0x64, 0x24, 0x0e, 0xa0, 0xb2, 0x12, 0x1e, 0xf8,
};
const size_t kPpsBufferMaxSize = 256;
const uint32_t kIgnored = 0;
constexpr size_t kPpsBufferMaxSize = 256;
constexpr uint32_t kIgnored = 0;
} // namespace
void WritePps(const PpsParser::PpsState& pps,

View File

@ -35,15 +35,15 @@ enum SpsMode {
kRewriteRequired_VuiSuboptimal,
};
const size_t kSpsBufferMaxSize = 256;
const size_t kWidth = 640;
const size_t kHeight = 480;
constexpr size_t kSpsBufferMaxSize = 256;
constexpr size_t kWidth = 640;
constexpr size_t kHeight = 480;
const uint8_t kStartSequence[] = {0x00, 0x00, 0x00, 0x01};
const uint8_t kAud[] = {H264::NaluType::kAud, 0x09, 0x10};
const uint8_t kSpsNaluType[] = {H264::NaluType::kSps};
const uint8_t kIdr1[] = {H264::NaluType::kIdr, 0xFF, 0x00, 0x00, 0x04};
const uint8_t kIdr2[] = {H264::NaluType::kIdr, 0xFF, 0x00, 0x11};
constexpr uint8_t kStartSequence[] = {0x00, 0x00, 0x00, 0x01};
constexpr uint8_t kAud[] = {H264::NaluType::kAud, 0x09, 0x10};
constexpr uint8_t kSpsNaluType[] = {H264::NaluType::kSps};
constexpr uint8_t kIdr1[] = {H264::NaluType::kIdr, 0xFF, 0x00, 0x00, 0x04};
constexpr uint8_t kIdr2[] = {H264::NaluType::kIdr, 0xFF, 0x00, 0x11};
struct VuiHeader {
uint32_t vui_parameters_present_flag;

View File

@ -24,7 +24,7 @@ using ::testing::Optional;
namespace webrtc {
// VPS/SPS/PPS part of below chunk.
const uint8_t kH265VpsSpsPps[] = {
constexpr uint8_t kH265VpsSpsPps[] = {
0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x04, 0x08,
0x00, 0x00, 0x03, 0x00, 0x9d, 0x08, 0x00, 0x00, 0x03, 0x00, 0x00, 0x78,
0x95, 0x98, 0x09, 0x00, 0x00, 0x00, 0x01, 0x42, 0x01, 0x01, 0x04, 0x08,
@ -34,7 +34,7 @@ const uint8_t kH265VpsSpsPps[] = {
0x00, 0x00, 0x00, 0x01, 0x44, 0x01, 0xc1, 0x72, 0xb4, 0x62, 0x40};
// Contains enough of the image slice to contain slice QP.
const uint8_t kH265BitstreamChunk[] = {
constexpr uint8_t kH265BitstreamChunk[] = {
0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x04, 0x08,
0x00, 0x00, 0x03, 0x00, 0x9d, 0x08, 0x00, 0x00, 0x03, 0x00, 0x00, 0x78,
0x95, 0x98, 0x09, 0x00, 0x00, 0x00, 0x01, 0x42, 0x01, 0x01, 0x04, 0x08,
@ -48,13 +48,13 @@ const uint8_t kH265BitstreamChunk[] = {
};
// Contains enough of the image slice to contain slice QP.
const uint8_t kH265BitstreamNextImageSliceChunk[] = {
constexpr uint8_t kH265BitstreamNextImageSliceChunk[] = {
0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0xe0, 0x24, 0xbf, 0x82, 0x05,
0x21, 0x12, 0x22, 0xa3, 0x29, 0xb4, 0x21, 0x91, 0xa1, 0xaa, 0x40,
};
// Contains enough of the image slice to contain slice QP.
const uint8_t kH265SliceChunk[] = {
constexpr uint8_t kH265SliceChunk[] = {
0xa4, 0x04, 0x55, 0xa2, 0x6d, 0xce, 0xc0, 0xc3, 0xed, 0x0b, 0xac, 0xbc,
0x00, 0xc4, 0x44, 0x2e, 0xf7, 0x55, 0xfd, 0x05, 0x86, 0x92, 0x19, 0xdf,
0x58, 0xec, 0x38, 0x36, 0xb7, 0x7c, 0x00, 0x15, 0x33, 0x78, 0x03, 0x67,
@ -62,13 +62,13 @@ const uint8_t kH265SliceChunk[] = {
};
// Contains enough of data for the second slice of a frame.
const uint8_t kH265SecondSliceChunkInAFrame[] = {
constexpr uint8_t kH265SecondSliceChunkInAFrame[] = {
0x02, 0x01, 0x23, 0xfc, 0x20, 0x22, 0xad, 0x13, 0x68, 0xce, 0xc3, 0x5a,
0x00, 0xdc, 0xeb, 0x86, 0x4b, 0x0b, 0xa7, 0x6a, 0xe1, 0x9c, 0x5c, 0xea,
};
// Contains short term ref pic set slice to verify Log2Ceiling path.
const uint8_t kH265SliceStrChunk[] = {
constexpr uint8_t kH265SliceStrChunk[] = {
0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x00,
0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00,
0x00, 0x99, 0x94, 0x90, 0x24, 0x00, 0x00, 0x00, 0x01, 0x42, 0x01, 0x01,
@ -82,7 +82,7 @@ const uint8_t kH265SliceStrChunk[] = {
};
// Contains enough of the image slice to contain invalid slice QP -52.
const uint8_t kH265BitstreamInvalidQPChunk[] = {
constexpr uint8_t kH265BitstreamInvalidQPChunk[] = {
0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x04, 0x08,
0x00, 0x00, 0x03, 0x00, 0x9d, 0x08, 0x00, 0x00, 0x03, 0x00, 0x00, 0x78,
0x95, 0x98, 0x09, 0x00, 0x00, 0x00, 0x01, 0x42, 0x01, 0x01, 0x04, 0x08,
@ -94,7 +94,7 @@ const uint8_t kH265BitstreamInvalidQPChunk[] = {
};
// Contains enough of the image slice to contain invalid slice QP 52.
const uint8_t kH265BitstreamInvalidQPChunk52[] = {
constexpr uint8_t kH265BitstreamInvalidQPChunk52[] = {
0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x04, 0x08,
0x00, 0x00, 0x03, 0x00, 0x9d, 0x08, 0x00, 0x00, 0x03, 0x00, 0x00, 0x78,
0x95, 0x98, 0x09, 0x00, 0x00, 0x00, 0x01, 0x42, 0x01, 0x01, 0x04, 0x08,
@ -108,7 +108,7 @@ const uint8_t kH265BitstreamInvalidQPChunk52[] = {
// Bitstream that contains pred_weight_table. Contains enough data to parse
// over pred_weight_table for slice QP. This is bear.hevc from Chromium source,
// used for H265 hardware decoder's parser test, with some slices truncated.
const uint8_t kH265BitstreamWithPredWeightTable[] = {
constexpr uint8_t kH265BitstreamWithPredWeightTable[] = {
0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60,
0x00, 0x00, 0x03, 0x00, 0x80, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00,
0x3c, 0x95, 0xc0, 0x90, 0x00, 0x00, 0x00, 0x01, 0x42, 0x01, 0x01, 0x01,

View File

@ -19,11 +19,11 @@
namespace webrtc {
namespace {
// Max frame rate for VP8 and VP9 video.
const char kVPxFmtpMaxFrameRate[] = "max-fr";
constexpr char kVPxFmtpMaxFrameRate[] = "max-fr";
// Max frame size for VP8 and VP9 video.
const char kVPxFmtpMaxFrameSize[] = "max-fs";
constexpr char kVPxFmtpMaxFrameSize[] = "max-fs";
// Nonstandard per-layer PLI for video.
const char kCodecParamPerLayerPictureLossIndication[] =
constexpr char kCodecParamPerLayerPictureLossIndication[] =
"x-google-per-layer-pli";
} // namespace

View File

@ -152,26 +152,26 @@ using ::webrtc::test::FrameForwarder;
using ::webrtc::test::FunctionVideoDecoderFactory;
using ::webrtc::test::RtcpPacketParser;
const uint8_t kRedRtxPayloadType = 125;
constexpr uint8_t kRedRtxPayloadType = 125;
const uint32_t kSsrc = 1234u;
const uint32_t kSsrcs4[] = {1, 2, 3, 4};
const int kVideoWidth = 640;
const int kVideoHeight = 360;
const int kFramerate = 30;
constexpr uint32_t kSsrc = 1234u;
constexpr uint32_t kSsrcs4[] = {1, 2, 3, 4};
constexpr int kVideoWidth = 640;
constexpr int kVideoHeight = 360;
constexpr int kFramerate = 30;
constexpr TimeDelta kFrameDuration = TimeDelta::Millis(1000 / kFramerate);
const uint32_t kSsrcs1[] = {1};
const uint32_t kSsrcs3[] = {1, 2, 3};
const uint32_t kRtxSsrcs1[] = {4};
const uint32_t kFlexfecSsrc = 5;
const uint32_t kIncomingUnsignalledSsrc = 0xC0FFEE;
const int64_t kUnsignalledReceiveStreamCooldownMs = 500;
constexpr uint32_t kSsrcs1[] = {1};
constexpr uint32_t kSsrcs3[] = {1, 2, 3};
constexpr uint32_t kRtxSsrcs1[] = {4};
constexpr uint32_t kFlexfecSsrc = 5;
constexpr uint32_t kIncomingUnsignalledSsrc = 0xC0FFEE;
constexpr int64_t kUnsignalledReceiveStreamCooldownMs = 500;
constexpr uint32_t kRtpHeaderSize = 12;
constexpr size_t kNumSimulcastStreams = 3;
const char kUnsupportedExtensionName[] =
constexpr char kUnsupportedExtensionName[] =
"urn:ietf:params:rtp-hdrext:unsupported";
Codec RemoveFeedbackParams(Codec&& codec) {

View File

@ -122,13 +122,13 @@ const webrtc::Codec kTelephoneEventCodec2 =
const webrtc::Codec kUnknownCodec =
webrtc::CreateAudioCodec(127, "XYZ", 32000, 1);
const uint32_t kSsrc0 = 0;
const uint32_t kSsrc1 = 1;
const uint32_t kSsrcX = 0x99;
const uint32_t kSsrcY = 0x17;
const uint32_t kSsrcZ = 0x42;
const uint32_t kSsrcW = 0x02;
const uint32_t kSsrcs4[] = {11, 200, 30, 44};
constexpr uint32_t kSsrc0 = 0;
constexpr uint32_t kSsrc1 = 1;
constexpr uint32_t kSsrcX = 0x99;
constexpr uint32_t kSsrcY = 0x17;
constexpr uint32_t kSsrcZ = 0x42;
constexpr uint32_t kSsrcW = 0x02;
constexpr uint32_t kSsrcs4[] = {11, 200, 30, 44};
constexpr int kRtpHistoryMs = 5000;

View File

@ -41,9 +41,9 @@ using ::testing::SetArgPointee;
namespace webrtc {
namespace {
const size_t kMaxNumSamples = 48 * 10 * 2; // 10 ms @ 48 kHz stereo.
const size_t kMockReturnEncodedBytes = 17;
const int kCngPayloadType = 18;
constexpr size_t kMaxNumSamples = 48 * 10 * 2; // 10 ms @ 48 kHz stereo.
constexpr size_t kMockReturnEncodedBytes = 17;
constexpr int kCngPayloadType = 18;
} // namespace
class AudioEncoderCngTest : public ::testing::Test {

View File

@ -113,7 +113,7 @@ using ::testing::TestWithParam;
using ::testing::Values;
// Maximum number of bytes in output bitstream.
const size_t kMaxBytes = 2000;
constexpr size_t kMaxBytes = 2000;
class OpusTest
: public TestWithParam<::testing::tuple<size_t, int, bool, int, int>> {

View File

@ -43,8 +43,8 @@ using ::testing::SetArgPointee;
namespace webrtc {
namespace {
const size_t kMaxNumSamples = 48 * 10 * 2; // 10 ms @ 48 kHz stereo.
const size_t kRedLastHeaderLength =
constexpr size_t kMaxNumSamples = 48 * 10 * 2; // 10 ms @ 48 kHz stereo.
constexpr size_t kRedLastHeaderLength =
1; // 1 byte RED header for the last element.
} // namespace

View File

@ -28,6 +28,28 @@
namespace webrtc {
namespace {
class FakeStatisticsCalculator : public StatisticsCalculator {
public:
FakeStatisticsCalculator(TickTimer* tick_timer)
: StatisticsCalculator(tick_timer) {}
void LogDelayedPacketOutageEvent(int num_samples, int /* fs_hz */) override {
last_outage_duration_samples_ = num_samples;
}
int last_outage_duration_samples() const {
return last_outage_duration_samples_;
}
private:
int last_outage_duration_samples_ = 0;
};
// This is the same size that is given to the SyncBuffer object in NetEq.
constexpr size_t kNetEqSyncBufferLengthMs = 720;
} // namespace
TEST(Expand, CreateAndDestroy) {
int fs = 8000;
size_t channels = 1;
@ -54,28 +76,6 @@ TEST(Expand, CreateUsingFactory) {
delete expand;
}
namespace {
class FakeStatisticsCalculator : public StatisticsCalculator {
public:
FakeStatisticsCalculator(TickTimer* tick_timer)
: StatisticsCalculator(tick_timer) {}
void LogDelayedPacketOutageEvent(int num_samples, int /* fs_hz */) override {
last_outage_duration_samples_ = num_samples;
}
int last_outage_duration_samples() const {
return last_outage_duration_samples_;
}
private:
int last_outage_duration_samples_ = 0;
};
// This is the same size that is given to the SyncBuffer object in NetEq.
const size_t kNetEqSyncBufferLengthMs = 720;
} // namespace
class ExpandTest : public ::testing::Test {
protected:
ExpandTest()

View File

@ -43,7 +43,7 @@ TEST(Merge, CreateAndDestroy) {
namespace {
// This is the same size that is given to the SyncBuffer object in NetEq.
const size_t kNetEqSyncBufferLengthMs = 720;
constexpr size_t kNetEqSyncBufferLengthMs = 720;
} // namespace
class MergeTest : public testing::TestWithParam<size_t> {

View File

@ -23,10 +23,10 @@
namespace webrtc {
namespace {
const int kSampleRateHz = 16000;
const int kPacketSizeMs = 30;
const uint32_t kTimestampIncrement = 480; // 30 ms.
const int64_t kShortRoundTripTimeMs = 1;
constexpr int kSampleRateHz = 16000;
constexpr int kPacketSizeMs = 30;
constexpr uint32_t kTimestampIncrement = 480; // 30 ms.
constexpr int64_t kShortRoundTripTimeMs = 1;
bool IsNackListCorrect(const std::vector<uint16_t>& nack_list,
const uint16_t* lost_sequence_numbers,

View File

@ -28,7 +28,7 @@
namespace webrtc {
namespace {
const size_t kNumChannels = 1;
constexpr size_t kNumChannels = 1;
} // namespace
TEST(TimeStretch, CreateAndDestroy) {

View File

@ -25,7 +25,7 @@ namespace webrtc {
namespace test {
namespace {
const int kHeaderLengthBytes = 12;
constexpr int kHeaderLengthBytes = 12;
void MakeRtpHeader(int payload_type,
int seq_number,

View File

@ -28,9 +28,9 @@ using ::testing::Return;
namespace webrtc {
const int kSampleRate = 44100;
const int kChannels = 2;
const int kSamplesPer10Ms = kSampleRate * 10 / 1000;
constexpr int kSampleRate = 44100;
constexpr int kChannels = 2;
constexpr int kSamplesPer10Ms = kSampleRate * 10 / 1000;
// The fake audio data is 0,1,..SCHAR_MAX-1,0,1,... This is to make it easy
// to detect errors. This function verifies that the buffers contain such data.

View File

@ -45,7 +45,7 @@ namespace webrtc {
namespace {
constexpr int kDefaultSampleRateHz = 48000;
const char kSourceCountHistogramName[] =
constexpr char kSourceCountHistogramName[] =
"WebRTC.Audio.AudioMixer.NewHighestSourceCount";
// Utility function that resets the frame member variables with

View File

@ -33,7 +33,7 @@ struct InputOutput {
double loudness;
};
const double kRelativeErrTol = 1e-10;
constexpr double kRelativeErrTol = 1e-10;
class LoudnessHistogramTest : public ::testing::Test {
protected:

View File

@ -22,9 +22,9 @@ namespace webrtc {
namespace {
const size_t kSampleRateHz = 48000u;
const size_t kStereo = 2u;
const size_t kMono = 1u;
constexpr size_t kSampleRateHz = 48000u;
constexpr size_t kStereo = 2u;
constexpr size_t kMono = 1u;
void ExpectNumChannels(const AudioBuffer& ab, size_t num_channels) {
EXPECT_EQ(ab.num_channels(), num_channels);

View File

@ -85,7 +85,7 @@ using ::testing::WithoutArgs;
// All sample rates used by APM internally during processing. Other input /
// output rates are resampled to / from one of these.
const int kProcessSampleRates[] = {16000, 32000, 48000};
constexpr int kProcessSampleRates[] = {16000, 32000, 48000};
enum StreamDirection { kForward = 0, kReverse };

View File

@ -26,7 +26,7 @@ namespace {
// TODO(peah): Increase the number of frames to proces when the issue of
// non repeatable test results have been found.
const int kNumFramesToProcess = 200;
constexpr int kNumFramesToProcess = 200;
void SetupComponent(int sample_rate_hz,
EchoControlMobileImpl::RoutingMode routing_mode,

View File

@ -26,7 +26,7 @@
namespace webrtc {
namespace {
const int kNumFramesToProcess = 100;
constexpr int kNumFramesToProcess = 100;
void ProcessOneFrame(int sample_rate_hz,
AudioBuffer* render_audio_buffer,

View File

@ -21,8 +21,8 @@
namespace webrtc {
namespace {
const size_t kSamplesPer16kHzChannel = 160;
const size_t kSamplesPer48kHzChannel = 480;
constexpr size_t kSamplesPer16kHzChannel = 160;
constexpr size_t kSamplesPer48kHzChannel = 480;
} // namespace

View File

@ -30,11 +30,11 @@ constexpr int kHistorySize = kMaxDelay + kLookahead;
// Length of binary spectrum sequence.
constexpr int kSequenceLength = 400;
const int kDifferentHistorySize = 3;
const int kDifferentLookahead = 1;
constexpr int kDifferentHistorySize = 3;
constexpr int kDifferentLookahead = 1;
const int kEnable[] = {0, 1};
const size_t kSizeEnable = sizeof(kEnable) / sizeof(*kEnable);
constexpr int kEnable[] = {0, 1};
constexpr size_t kSizeEnable = sizeof(kEnable) / sizeof(*kEnable);
class DelayEstimatorTest : public ::testing::Test {
protected:

View File

@ -24,11 +24,11 @@
namespace webrtc {
namespace {
const int kStartTimeSec = 16;
const float kMeanSpeechProbability = 0.3f;
const float kMaxNoiseProbability = 0.1f;
const size_t kNumChunks = 300u;
const size_t kNumChunksPerIsacBlock = 3;
constexpr int kStartTimeSec = 16;
constexpr float kMeanSpeechProbability = 0.3f;
constexpr float kMaxNoiseProbability = 0.1f;
constexpr size_t kNumChunks = 300u;
constexpr size_t kNumChunksPerIsacBlock = 3;
void GenerateNoise(std::vector<int16_t>* data) {
for (size_t i = 0; i < data->size(); ++i) {

View File

@ -71,9 +71,9 @@ int CountBandwidthDips(std::queue<DataRate> bandwidth_history,
return dips;
}
const uint32_t kInitialBitrateKbps = 60;
constexpr uint32_t kInitialBitrateKbps = 60;
const DataRate kInitialBitrate = DataRate::KilobitsPerSec(kInitialBitrateKbps);
const float kDefaultPacingRate = 2.5f;
constexpr float kDefaultPacingRate = 2.5f;
CallClient* CreateVideoSendingClient(
Scenario* s,

View File

@ -42,7 +42,7 @@ constexpr double kDelayGradientThreshold = 0.01;
constexpr double kDelayGradientNegativeBound = 10;
const DataRate kTargetSendingRate = DataRate::KilobitsPerSec(300);
const double kEpsilon = 0.05;
constexpr double kEpsilon = 0.05;
const Timestamp kStartTime = Timestamp::Micros(0);
const TimeDelta kPacketsDelta = TimeDelta::Millis(1);
const TimeDelta kIntervalDuration = TimeDelta::Millis(1000);

View File

@ -33,15 +33,15 @@ namespace {
using testing::ElementsAre;
const int kFrameXCoord = 100;
const int kFrameYCoord = 200;
const int kScreenWidth = 100;
const int kScreenHeight = 100;
const int kCursorWidth = 10;
const int kCursorHeight = 10;
constexpr int kFrameXCoord = 100;
constexpr int kFrameYCoord = 200;
constexpr int kScreenWidth = 100;
constexpr int kScreenHeight = 100;
constexpr int kCursorWidth = 10;
constexpr int kCursorHeight = 10;
const int kTestCursorSize = 3;
const uint32_t kTestCursorData[kTestCursorSize][kTestCursorSize] = {
constexpr int kTestCursorSize = 3;
constexpr uint32_t kTestCursorData[kTestCursorSize][kTestCursorSize] = {
{
0xffffffff,
0x99990000,

View File

@ -28,7 +28,7 @@
using ::testing::_;
const int kTestSharedMemoryId = 123;
constexpr int kTestSharedMemoryId = 123;
namespace webrtc {

View File

@ -30,10 +30,10 @@ namespace {
const WCHAR kWindowTitle[] = L"WGC Capture Source Test Window";
const int kFirstXCoord = 25;
const int kFirstYCoord = 50;
const int kSecondXCoord = 50;
const int kSecondYCoord = 75;
constexpr int kFirstXCoord = 25;
constexpr int kFirstYCoord = 50;
constexpr int kSecondXCoord = 50;
constexpr int kSecondYCoord = 75;
} // namespace

View File

@ -25,7 +25,7 @@
namespace webrtc {
namespace {
const char kWindowThreadName[] = "window_capture_utils_test_thread";
constexpr char kWindowThreadName[] = "window_capture_utils_test_thread";
const WCHAR kWindowTitle[] = L"Window Capture Utils Test";
std::unique_ptr<Thread> SetUpUnresponsiveWindow(std::mutex& mtx,

View File

@ -54,7 +54,7 @@ constexpr DataRate kSecondClusterRate = DataRate::KilobitsPerSec(1800);
// For 1.8 Mbps, this comes to be about 120 kbps with 1200 probe packets.
constexpr DataRate kProbingErrorMargin = DataRate::KilobitsPerSec(150);
const float kPaceMultiplier = 2.5f;
constexpr float kPaceMultiplier = 2.5f;
constexpr uint32_t kAudioSsrc = 12345;
constexpr uint32_t kVideoSsrc = 234565;

View File

@ -29,8 +29,9 @@ enum {
kInterArrivalShift = kAbsSendTimeFraction + kAbsSendTimeInterArrivalUpshift,
};
const double kRtpTimestampToMs = 1.0 / 90.0;
const double kAstToMs = 1000.0 / static_cast<double>(1 << kInterArrivalShift);
constexpr double kRtpTimestampToMs = 1.0 / 90.0;
constexpr double kAstToMs =
1000.0 / static_cast<double>(1 << kInterArrivalShift);
class InterArrivalTest : public ::testing::Test {
protected:

View File

@ -26,7 +26,7 @@
namespace webrtc {
namespace testing {
const double kRtpTimestampToMs = 1.0 / 90.0;
constexpr double kRtpTimestampToMs = 1.0 / 90.0;
class OveruseDetectorTest : public ::testing::Test {
public:

View File

@ -40,7 +40,7 @@ using test::fec::AugmentedPacketGenerator;
constexpr int kFlexfecPayloadType = 123;
constexpr uint32_t kMediaSsrc = 1234;
constexpr uint32_t kFlexfecSsrc = 5678;
const char kNoMid[] = "";
constexpr char kNoMid[] = "";
const std::vector<RtpExtension> kNoRtpHeaderExtensions;
const std::vector<RtpExtensionSize> kNoRtpHeaderExtensionSizes;
// Assume a single protected media SSRC.

View File

@ -43,16 +43,16 @@
namespace webrtc {
const int kVideoNackListSize = 30;
const uint32_t kTestSsrc = 3456;
const uint32_t kTestRtxSsrc = kTestSsrc + 1;
const uint16_t kTestSequenceNumber = 2345;
const uint32_t kTestNumberOfPackets = 1350;
const int kTestNumberOfRtxPackets = 149;
const int kNumFrames = 30;
const int kPayloadType = 123;
const int kRtxPayloadType = 98;
const int64_t kMaxRttMs = 1000;
constexpr int kVideoNackListSize = 30;
constexpr uint32_t kTestSsrc = 3456;
constexpr uint32_t kTestRtxSsrc = kTestSsrc + 1;
constexpr uint16_t kTestSequenceNumber = 2345;
constexpr uint32_t kTestNumberOfPackets = 1350;
constexpr int kTestNumberOfRtxPackets = 149;
constexpr int kNumFrames = 30;
constexpr int kPayloadType = 123;
constexpr int kRtxPayloadType = 98;
constexpr int64_t kMaxRttMs = 1000;
class VerifyingMediaStream : public RtpPacketSinkInterface {
public:

View File

@ -31,12 +31,12 @@ namespace {
using ::testing::SizeIs;
using ::testing::UnorderedElementsAre;
const size_t kPacketSize1 = 100;
const size_t kPacketSize2 = 300;
const uint32_t kSsrc1 = 101;
const uint32_t kSsrc2 = 202;
const uint32_t kSsrc3 = 203;
const uint32_t kSsrc4 = 304;
constexpr size_t kPacketSize1 = 100;
constexpr size_t kPacketSize2 = 300;
constexpr uint32_t kSsrc1 = 101;
constexpr uint32_t kSsrc2 = 202;
constexpr uint32_t kSsrc3 = 203;
constexpr uint32_t kSsrc4 = 304;
RtpPacketReceived CreateRtpPacket(uint32_t ssrc,
size_t header_size,

View File

@ -25,9 +25,9 @@ using webrtc::rtcp::Bye;
namespace webrtc {
namespace {
const uint32_t kSenderSsrc = 0x12345678;
const uint32_t kCsrc1 = 0x22232425;
const uint32_t kCsrc2 = 0x33343536;
constexpr uint32_t kSenderSsrc = 0x12345678;
constexpr uint32_t kCsrc1 = 0x22232425;
constexpr uint32_t kCsrc2 = 0x33343536;
} // namespace
TEST(RtcpPacketByeTest, CreateAndParseWithoutReason) {

View File

@ -40,9 +40,9 @@ using webrtc::test::RtcpPacketParser;
namespace webrtc {
const uint32_t kSenderSsrc = 0x12345678;
const uint32_t kRemoteSsrc = 0x23456789;
const uint8_t kSeqNo = 13;
constexpr uint32_t kSenderSsrc = 0x12345678;
constexpr uint32_t kRemoteSsrc = 0x23456789;
constexpr uint8_t kSeqNo = 13;
TEST(RtcpCompoundPacketTest, AppendPacket) {
CompoundPacket compound;

View File

@ -22,12 +22,12 @@ using webrtc::rtcp::ReceiveTimeInfo;
namespace webrtc {
namespace {
const uint32_t kSsrc = 0x12345678;
const uint32_t kLastRR = 0x23344556;
const uint32_t kDelay = 0x33343536;
const uint8_t kBlock[] = {0x05, 0x00, 0x00, 0x03, 0x12, 0x34, 0x56, 0x78,
0x23, 0x34, 0x45, 0x56, 0x33, 0x34, 0x35, 0x36};
const size_t kBlockSizeBytes = sizeof(kBlock);
constexpr uint32_t kSsrc = 0x12345678;
constexpr uint32_t kLastRR = 0x23344556;
constexpr uint32_t kDelay = 0x33343536;
constexpr uint8_t kBlock[] = {0x05, 0x00, 0x00, 0x03, 0x12, 0x34, 0x56, 0x78,
0x23, 0x34, 0x45, 0x56, 0x33, 0x34, 0x35, 0x36};
constexpr size_t kBlockSizeBytes = sizeof(kBlock);
} // namespace
TEST(RtcpPacketDlrrTest, Empty) {

View File

@ -23,11 +23,11 @@ using webrtc::rtcp::Pli;
namespace webrtc {
namespace {
const uint32_t kSenderSsrc = 0x12345678;
const uint32_t kRemoteSsrc = 0x23456789;
constexpr uint32_t kSenderSsrc = 0x12345678;
constexpr uint32_t kRemoteSsrc = 0x23456789;
// Manually created Pli packet matching constants above.
const uint8_t kPacket[] = {0x81, 206, 0x00, 0x02, 0x12, 0x34,
0x56, 0x78, 0x23, 0x45, 0x67, 0x89};
constexpr uint8_t kPacket[] = {0x81, 206, 0x00, 0x02, 0x12, 0x34,
0x56, 0x78, 0x23, 0x45, 0x67, 0x89};
} // namespace
TEST(RtcpPacketPliTest, Parse) {

View File

@ -23,11 +23,11 @@ using webrtc::rtcp::RapidResyncRequest;
namespace webrtc {
namespace {
const uint32_t kSenderSsrc = 0x12345678;
const uint32_t kRemoteSsrc = 0x23456789;
constexpr uint32_t kSenderSsrc = 0x12345678;
constexpr uint32_t kRemoteSsrc = 0x23456789;
// Manually created packet matching constants above.
const uint8_t kPacket[] = {0x85, 205, 0x00, 0x02, 0x12, 0x34,
0x56, 0x78, 0x23, 0x45, 0x67, 0x89};
constexpr uint8_t kPacket[] = {0x85, 205, 0x00, 0x02, 0x12, 0x34,
0x56, 0x78, 0x23, 0x45, 0x67, 0x89};
} // namespace
TEST(RtcpPacketRapidResyncRequestTest, Parse) {

View File

@ -29,21 +29,21 @@ using webrtc::rtcp::ReportBlock;
namespace webrtc {
namespace {
const uint32_t kSenderSsrc = 0x12345678;
const uint32_t kRemoteSsrc = 0x23456789;
const uint8_t kFractionLost = 55;
const int32_t kCumulativeLost = 0x111213;
const uint32_t kExtHighestSeqNum = 0x22232425;
const uint32_t kJitter = 0x33343536;
const uint32_t kLastSr = 0x44454647;
const uint32_t kDelayLastSr = 0x55565758;
constexpr uint32_t kSenderSsrc = 0x12345678;
constexpr uint32_t kRemoteSsrc = 0x23456789;
constexpr uint8_t kFractionLost = 55;
constexpr int32_t kCumulativeLost = 0x111213;
constexpr uint32_t kExtHighestSeqNum = 0x22232425;
constexpr uint32_t kJitter = 0x33343536;
constexpr uint32_t kLastSr = 0x44454647;
constexpr uint32_t kDelayLastSr = 0x55565758;
// Manually created ReceiverReport with one ReportBlock matching constants
// above.
// Having this block allows to test Create and Parse separately.
const uint8_t kPacket[] = {0x81, 201, 0x00, 0x07, 0x12, 0x34, 0x56, 0x78,
0x23, 0x45, 0x67, 0x89, 55, 0x11, 0x12, 0x13,
0x22, 0x23, 0x24, 0x25, 0x33, 0x34, 0x35, 0x36,
0x44, 0x45, 0x46, 0x47, 0x55, 0x56, 0x57, 0x58};
constexpr uint8_t kPacket[] = {0x81, 201, 0x00, 0x07, 0x12, 0x34, 0x56, 0x78,
0x23, 0x45, 0x67, 0x89, 55, 0x11, 0x12, 0x13,
0x22, 0x23, 0x24, 0x25, 0x33, 0x34, 0x35, 0x36,
0x44, 0x45, 0x46, 0x47, 0x55, 0x56, 0x57, 0x58};
} // namespace
TEST(RtcpPacketReceiverReportTest, ParseWithOneReportBlock) {

View File

@ -28,15 +28,15 @@ using webrtc::rtcp::Remb;
namespace webrtc {
namespace {
const uint32_t kSenderSsrc = 0x12345678;
const uint32_t kRemoteSsrcs[] = {0x23456789, 0x2345678a, 0x2345678b};
const uint32_t kBitrateBps = 0x3fb93 * 2; // 522022;
const int64_t kBitrateBps64bit = int64_t{0x3fb93} << 30;
const uint8_t kPacket[] = {0x8f, 206, 0x00, 0x07, 0x12, 0x34, 0x56, 0x78,
0x00, 0x00, 0x00, 0x00, 'R', 'E', 'M', 'B',
0x03, 0x07, 0xfb, 0x93, 0x23, 0x45, 0x67, 0x89,
0x23, 0x45, 0x67, 0x8a, 0x23, 0x45, 0x67, 0x8b};
const size_t kPacketLength = sizeof(kPacket);
constexpr uint32_t kSenderSsrc = 0x12345678;
constexpr uint32_t kRemoteSsrcs[] = {0x23456789, 0x2345678a, 0x2345678b};
constexpr uint32_t kBitrateBps = 0x3fb93 * 2; // 522022;
constexpr int64_t kBitrateBps64bit = int64_t{0x3fb93} << 30;
constexpr uint8_t kPacket[] = {0x8f, 206, 0x00, 0x07, 0x12, 0x34, 0x56, 0x78,
0x00, 0x00, 0x00, 0x00, 'R', 'E', 'M', 'B',
0x03, 0x07, 0xfb, 0x93, 0x23, 0x45, 0x67, 0x89,
0x23, 0x45, 0x67, 0x8a, 0x23, 0x45, 0x67, 0x8b};
constexpr size_t kPacketLength = sizeof(kPacket);
} // namespace
TEST(RtcpPacketRembTest, Create) {

View File

@ -22,15 +22,15 @@ using webrtc::rtcp::ReportBlock;
namespace webrtc {
namespace {
const uint32_t kRemoteSsrc = 0x23456789;
const uint8_t kFractionLost = 55;
constexpr uint32_t kRemoteSsrc = 0x23456789;
constexpr uint8_t kFractionLost = 55;
// Use values that are streamed differently LE and BE.
const int32_t kCumulativeLost = 0x111213;
const uint32_t kExtHighestSeqNum = 0x22232425;
const uint32_t kJitter = 0x33343536;
const uint32_t kLastSr = 0x44454647;
const uint32_t kDelayLastSr = 0x55565758;
const size_t kBufferLength = ReportBlock::kLength;
constexpr int32_t kCumulativeLost = 0x111213;
constexpr uint32_t kExtHighestSeqNum = 0x22232425;
constexpr uint32_t kJitter = 0x33343536;
constexpr uint32_t kLastSr = 0x44454647;
constexpr uint32_t kDelayLastSr = 0x55565758;
constexpr size_t kBufferLength = ReportBlock::kLength;
TEST(RtcpPacketReportBlockTest, ParseChecksLength) {
uint8_t buffer[kBufferLength];

View File

@ -22,11 +22,11 @@ using webrtc::rtcp::Rrtr;
namespace webrtc {
namespace {
const uint32_t kNtpSec = 0x12345678;
const uint32_t kNtpFrac = 0x23456789;
const uint8_t kBlock[] = {0x04, 0x00, 0x00, 0x02, 0x12, 0x34,
0x56, 0x78, 0x23, 0x45, 0x67, 0x89};
const size_t kBlockSizeBytes = sizeof(kBlock);
constexpr uint32_t kNtpSec = 0x12345678;
constexpr uint32_t kNtpFrac = 0x23456789;
constexpr uint8_t kBlock[] = {0x04, 0x00, 0x00, 0x02, 0x12, 0x34,
0x56, 0x78, 0x23, 0x45, 0x67, 0x89};
constexpr size_t kBlockSizeBytes = sizeof(kBlock);
static_assert(
kBlockSizeBytes == Rrtr::kLength,
"Size of manually created Rrtr block should match class constant");

View File

@ -23,12 +23,12 @@ using webrtc::rtcp::Sdes;
namespace webrtc {
namespace {
const uint32_t kSenderSsrc = 0x12345678;
const uint8_t kPadding = 0;
const uint8_t kTerminatorTag = 0;
const uint8_t kCnameTag = 1;
const uint8_t kNameTag = 2;
const uint8_t kEmailTag = 3;
constexpr uint32_t kSenderSsrc = 0x12345678;
constexpr uint8_t kPadding = 0;
constexpr uint8_t kTerminatorTag = 0;
constexpr uint8_t kCnameTag = 1;
constexpr uint8_t kNameTag = 2;
constexpr uint8_t kEmailTag = 3;
} // namespace
TEST(RtcpPacketSdesTest, CreateAndParseWithoutChunks) {

View File

@ -29,16 +29,16 @@ using webrtc::rtcp::SenderReport;
namespace webrtc {
namespace {
const uint32_t kSenderSsrc = 0x12345678;
const uint32_t kRemoteSsrc = 0x23456789;
constexpr uint32_t kSenderSsrc = 0x12345678;
constexpr uint32_t kRemoteSsrc = 0x23456789;
const NtpTime kNtp(0x11121418, 0x22242628);
const uint32_t kRtpTimestamp = 0x33343536;
const uint32_t kPacketCount = 0x44454647;
const uint32_t kOctetCount = 0x55565758;
const uint8_t kPacket[] = {0x80, 200, 0x00, 0x06, 0x12, 0x34, 0x56,
0x78, 0x11, 0x12, 0x14, 0x18, 0x22, 0x24,
0x26, 0x28, 0x33, 0x34, 0x35, 0x36, 0x44,
0x45, 0x46, 0x47, 0x55, 0x56, 0x57, 0x58};
constexpr uint32_t kRtpTimestamp = 0x33343536;
constexpr uint32_t kPacketCount = 0x44454647;
constexpr uint32_t kOctetCount = 0x55565758;
constexpr uint8_t kPacket[] = {0x80, 200, 0x00, 0x06, 0x12, 0x34, 0x56,
0x78, 0x11, 0x12, 0x14, 0x18, 0x22, 0x24,
0x26, 0x28, 0x33, 0x34, 0x35, 0x36, 0x44,
0x45, 0x46, 0x47, 0x55, 0x56, 0x57, 0x58};
} // namespace
TEST(RtcpPacketSenderReportTest, CreateWithoutReportBlocks) {

View File

@ -29,13 +29,14 @@ using test::ParseSinglePacket;
constexpr uint32_t kSsrc = 0x12345678;
// clang-format off
const uint8_t kPacket[] = { TargetBitrate::kBlockType, // Block ID.
0x00, // Reserved.
0x00, 0x04, // Length = 4 words.
0x00, 0x01, 0x02, 0x03, // S0T0 0x010203 kbps.
0x01, 0x02, 0x03, 0x04, // S0T1 0x020304 kbps.
0x10, 0x03, 0x04, 0x05, // S1T0 0x030405 kbps.
0x11, 0x04, 0x05, 0x06 }; // S1T1 0x040506 kbps.
constexpr uint8_t kPacket[] = {
TargetBitrate::kBlockType, // Block ID.
0x00, // Reserved.
0x00, 0x04, // Length = 4 words.
0x00, 0x01, 0x02, 0x03, // S0T0 0x010203 kbps.
0x01, 0x02, 0x03, 0x04, // S0T1 0x020304 kbps.
0x10, 0x03, 0x04, 0x05, // S1T0 0x030405 kbps.
0x11, 0x04, 0x05, 0x06 }; // S1T1 0x040506 kbps.
constexpr size_t kPacketLengthBlocks = ((sizeof(kPacket) + 3) / 4) - 1;
// clang-format on

View File

@ -26,13 +26,13 @@ using webrtc::rtcp::Tmmbn;
namespace webrtc {
namespace {
const uint32_t kSenderSsrc = 0x12345678;
const uint32_t kRemoteSsrc = 0x23456789;
const uint32_t kBitrateBps = 312000;
const uint16_t kOverhead = 0x1fe;
const uint8_t kPacket[] = {0x84, 205, 0x00, 0x04, 0x12, 0x34, 0x56,
0x78, 0x00, 0x00, 0x00, 0x00, 0x23, 0x45,
0x67, 0x89, 0x0a, 0x61, 0x61, 0xfe};
constexpr uint32_t kSenderSsrc = 0x12345678;
constexpr uint32_t kRemoteSsrc = 0x23456789;
constexpr uint32_t kBitrateBps = 312000;
constexpr uint16_t kOverhead = 0x1fe;
constexpr uint8_t kPacket[] = {0x84, 205, 0x00, 0x04, 0x12, 0x34, 0x56,
0x78, 0x00, 0x00, 0x00, 0x00, 0x23, 0x45,
0x67, 0x89, 0x0a, 0x61, 0x61, 0xfe};
} // namespace
TEST(RtcpPacketTmmbnTest, Create) {

View File

@ -25,13 +25,13 @@ using webrtc::rtcp::Tmmbr;
namespace webrtc {
namespace {
const uint32_t kSenderSsrc = 0x12345678;
const uint32_t kRemoteSsrc = 0x23456789;
const uint32_t kBitrateBps = 312000;
const uint16_t kOverhead = 0x1fe;
const uint8_t kPacket[] = {0x83, 205, 0x00, 0x04, 0x12, 0x34, 0x56,
0x78, 0x00, 0x00, 0x00, 0x00, 0x23, 0x45,
0x67, 0x89, 0x0a, 0x61, 0x61, 0xfe};
constexpr uint32_t kSenderSsrc = 0x12345678;
constexpr uint32_t kRemoteSsrc = 0x23456789;
constexpr uint32_t kBitrateBps = 312000;
constexpr uint16_t kOverhead = 0x1fe;
constexpr uint8_t kPacket[] = {0x83, 205, 0x00, 0x04, 0x12, 0x34, 0x56,
0x78, 0x00, 0x00, 0x00, 0x00, 0x23, 0x45,
0x67, 0x89, 0x0a, 0x61, 0x61, 0xfe};
} // namespace
TEST(RtcpPacketTmmbrTest, Create) {

View File

@ -26,7 +26,7 @@ using ::testing::MockFunction;
using ::webrtc::rtcp::ReceiverReport;
using ::webrtc::rtcp::ReportBlock;
const uint32_t kSenderSsrc = 0x12345678;
constexpr uint32_t kSenderSsrc = 0x12345678;
TEST(RtcpPacketTest, BuildWithTooSmallBuffer) {
ReportBlock rb;

View File

@ -55,15 +55,15 @@ using ::testing::Optional;
namespace webrtc {
namespace {
const uint32_t kSenderSsrc = 0x12345;
const uint32_t kReceiverSsrc = 0x23456;
constexpr uint32_t kSenderSsrc = 0x12345;
constexpr uint32_t kReceiverSsrc = 0x23456;
constexpr TimeDelta kOneWayNetworkDelay = TimeDelta::Millis(100);
const uint8_t kBaseLayerTid = 0;
const uint8_t kHigherLayerTid = 1;
const uint16_t kSequenceNumber = 100;
const uint8_t kPayloadType = 100;
const int kWidth = 320;
const int kHeight = 100;
constexpr uint8_t kBaseLayerTid = 0;
constexpr uint8_t kHigherLayerTid = 1;
constexpr uint16_t kSequenceNumber = 100;
constexpr uint8_t kPayloadType = 100;
constexpr int kWidth = 320;
constexpr int kHeight = 100;
MATCHER_P2(Near, value, margin, "") {
return value - margin <= arg && arg <= value + margin;

View File

@ -39,9 +39,9 @@ enum : int { // The first valid value is 1.
kAbsoluteCaptureTimeExtensionId = 2,
};
const uint16_t kSeqNum = 33;
const uint32_t kSsrc = 725242;
const uint64_t kStartTime = 123456789;
constexpr uint16_t kSeqNum = 33;
constexpr uint32_t kSsrc = 725242;
constexpr uint64_t kStartTime = 123456789;
using ::testing::ElementsAreArray;

View File

@ -60,15 +60,15 @@ enum : int { // The first valid value is 1.
kVideoTimingExtensionId,
};
const int kPayload = 100;
const int kRtxPayload = 98;
const uint32_t kTimestamp = 10;
const uint16_t kSeqNum = 33;
const uint32_t kSsrc = 725242;
const uint32_t kRtxSsrc = 12345;
const uint32_t kFlexFecSsrc = 45678;
const uint64_t kStartTime = 123456789;
const uint8_t kPayloadData[] = {47, 11, 32, 93, 89};
constexpr int kPayload = 100;
constexpr int kRtxPayload = 98;
constexpr uint32_t kTimestamp = 10;
constexpr uint16_t kSeqNum = 33;
constexpr uint32_t kSsrc = 725242;
constexpr uint32_t kRtxSsrc = 12345;
constexpr uint32_t kFlexFecSsrc = 45678;
constexpr uint64_t kStartTime = 123456789;
constexpr uint8_t kPayloadData[] = {47, 11, 32, 93, 89};
constexpr TimeDelta kDefaultExpectedRetransmissionTime = TimeDelta::Millis(125);
constexpr Frequency kRtpClockRate = Frequency::Hertz(90'000);
constexpr absl::string_view kMid = "mid";

View File

@ -54,8 +54,8 @@ using ::testing::NotNull;
using ::testing::Return;
using ::testing::SaveArg;
const int kFirstSeqNum = 1;
const int kLastSeqNum = 2;
constexpr int kFirstSeqNum = 1;
constexpr int kLastSeqNum = 2;
std::unique_ptr<RtpFrameObject> CreateRtpFrameObject(
const RTPVideoHeader& video_header,

View File

@ -20,8 +20,8 @@ namespace webrtc {
namespace {
const int kMaxPayloadSize = 1024;
const int kNumCores = 1;
constexpr int kMaxPayloadSize = 1024;
constexpr int kNumCores = 1;
const VideoEncoder::Capabilities kCapabilities(false);
const VideoEncoder::Settings kSettings(kCapabilities,

View File

@ -25,7 +25,7 @@ namespace test {
using Config = VideoCodecTestFixture::Config;
namespace {
const size_t kNumTemporalLayers = 2;
constexpr size_t kNumTemporalLayers = 2;
} // namespace
TEST(Config, NumberOfCoresWithUseSingleCore) {

View File

@ -23,7 +23,7 @@ using FrameStatistics = VideoCodecTestStatsImpl::FrameStatistics;
namespace {
const size_t kTimestamp = 12345;
constexpr size_t kTimestamp = 12345;
using ::testing::AllOf;
using ::testing::Contains;

View File

@ -41,8 +41,8 @@ namespace test {
namespace {
const int kWidth = 352;
const int kHeight = 288;
constexpr int kWidth = 352;
constexpr int kHeight = 288;
} // namespace

View File

@ -39,21 +39,21 @@ using ::testing::NiceMock;
namespace webrtc {
namespace {
// 5 frames per second at 90 kHz.
const uint32_t kTimestampDelta5Fps = 90000 / 5;
const int kDefaultQp = 54;
const int kDefaultTl0BitrateKbps = 200;
const int kDefaultTl1BitrateKbps = 2000;
const int kFrameRate = 5;
const int kSyncPeriodSeconds = 2;
const int kMaxSyncPeriodSeconds = 4;
constexpr uint32_t kTimestampDelta5Fps = 90000 / 5;
constexpr int kDefaultQp = 54;
constexpr int kDefaultTl0BitrateKbps = 200;
constexpr int kDefaultTl1BitrateKbps = 2000;
constexpr int kFrameRate = 5;
constexpr int kSyncPeriodSeconds = 2;
constexpr int kMaxSyncPeriodSeconds = 4;
// Expected flags for corresponding temporal layers.
const int kTl0Flags = VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF |
VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF;
const int kTl1Flags =
constexpr int kTl0Flags = VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF |
VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF;
constexpr int kTl1Flags =
VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST;
const int kTl1SyncFlags = VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_REF_GF |
VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST;
constexpr int kTl1SyncFlags = VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_REF_GF |
VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST;
const std::vector<uint32_t> kDefault2TlBitratesBps = {
kDefaultTl0BitrateKbps * 1000,
(kDefaultTl1BitrateKbps - kDefaultTl0BitrateKbps) * 1000};

View File

@ -50,7 +50,7 @@ using H264::NaluType::kStapA;
constexpr int kBufferSize = 2048;
// Example sprop string from https://tools.ietf.org/html/rfc3984.
const char kExampleSpropString[] = "Z0IACpZTBYmI,aMljiA==";
constexpr char kExampleSpropString[] = "Z0IACpZTBYmI,aMljiA==";
const std::vector<uint8_t> kExampleSpropRawSps{0x67, 0x42, 0x00, 0x0A, 0x96,
0x53, 0x05, 0x89, 0x88};
const std::vector<uint8_t> kExampleSpropRawPps{0x68, 0xC9, 0x63, 0x88};

View File

@ -18,11 +18,11 @@ namespace webrtc {
namespace {
const float kTargetBitRateKbps = 300;
const float kIncomingFrameRate = 30;
const size_t kFrameSizeBytes = 1250;
constexpr float kTargetBitRateKbps = 300;
constexpr float kIncomingFrameRate = 30;
constexpr size_t kFrameSizeBytes = 1250;
const size_t kLargeFrameSizeBytes = 25000;
constexpr size_t kLargeFrameSizeBytes = 25000;
const bool kIncludeKeyFrame = true;
const bool kDoNotIncludeKeyFrame = false;

View File

@ -26,8 +26,8 @@
namespace webrtc {
namespace {
const int kHeaderSize = 32;
const int kFrameHeaderSize = 12;
constexpr int kHeaderSize = 32;
constexpr int kFrameHeaderSize = 12;
uint8_t dummy_payload[4] = {0, 1, 2, 3};
// As the default parameter when the width and height of encodedImage are 0,
// the values are copied from ivf_file_writer.cc

View File

@ -24,14 +24,14 @@ namespace webrtc {
namespace {
// ffmpeg -s 16x16 -f rawvideo -pix_fmt rgb24 -r 30 -i /dev/zero -c:v libvpx
// -qmin 20 -qmax 20 -crf 20 -frames:v 1 -y out.ivf
const uint8_t kCodedFrameVp8Qp25[] = {
constexpr uint8_t kCodedFrameVp8Qp25[] = {
0x10, 0x02, 0x00, 0x9d, 0x01, 0x2a, 0x10, 0x00, 0x10, 0x00,
0x02, 0x47, 0x08, 0x85, 0x85, 0x88, 0x85, 0x84, 0x88, 0x0c,
0x82, 0x00, 0x0c, 0x0d, 0x60, 0x00, 0xfe, 0xfc, 0x5c, 0xd0};
// ffmpeg -s 16x16 -f rawvideo -pix_fmt rgb24 -r 30 -i /dev/zero -c:v libvpx-vp9
// -qmin 24 -qmax 24 -crf 24 -frames:v 1 -y out.ivf
const uint8_t kCodedFrameVp9Qp96[] = {
constexpr uint8_t kCodedFrameVp9Qp96[] = {
0xa2, 0x49, 0x83, 0x42, 0xe0, 0x00, 0xf0, 0x00, 0xf6, 0x00,
0x38, 0x24, 0x1c, 0x18, 0xc0, 0x00, 0x00, 0x30, 0x70, 0x00,
0x00, 0x4a, 0xa7, 0xff, 0xfc, 0xb9, 0x01, 0xbf, 0xff, 0xff,
@ -39,22 +39,22 @@ const uint8_t kCodedFrameVp9Qp96[] = {
// ffmpeg -s 16x16 -f rawvideo -pix_fmt yuv420p -r 30 -i /dev/zero -c:v libx264
// -qmin 38 -qmax 38 -crf 38 -profile:v baseline -frames:v 2 -y out.264
const uint8_t kCodedFrameH264SpsPpsIdrQp38[] = {
constexpr uint8_t kCodedFrameH264SpsPpsIdrQp38[] = {
0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0xc0, 0x0a, 0xd9, 0x1e, 0x84,
0x00, 0x00, 0x03, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0xf0, 0x3c,
0x48, 0x99, 0x20, 0x00, 0x00, 0x00, 0x01, 0x68, 0xcb, 0x80, 0xc4,
0xb2, 0x00, 0x00, 0x01, 0x65, 0x88, 0x84, 0xf1, 0x18, 0xa0, 0x00,
0x20, 0x5b, 0x1c, 0x00, 0x04, 0x07, 0xe3, 0x80, 0x00, 0x80, 0xfe};
const uint8_t kCodedFrameH264SpsPpsIdrQp49[] = {
constexpr uint8_t kCodedFrameH264SpsPpsIdrQp49[] = {
0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0xc0, 0x0a, 0xd9, 0x1e, 0x84,
0x00, 0x00, 0x03, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0xf0, 0x3c,
0x48, 0x99, 0x20, 0x00, 0x00, 0x00, 0x01, 0x68, 0xcb, 0x80, 0x5d,
0x2c, 0x80, 0x00, 0x00, 0x01, 0x65, 0x88, 0x84, 0xf1, 0x18, 0xa0,
0x00, 0x5e, 0x38, 0x00, 0x08, 0x03, 0xc7, 0x00, 0x01, 0x00, 0x7c};
const uint8_t kCodedFrameH264InterSliceQpDelta0[] = {0x00, 0x00, 0x00, 0x01,
0x41, 0x9a, 0x39, 0xea};
constexpr uint8_t kCodedFrameH264InterSliceQpDelta0[] = {
0x00, 0x00, 0x00, 0x01, 0x41, 0x9a, 0x39, 0xea};
} // namespace

View File

@ -24,10 +24,10 @@
namespace webrtc {
namespace {
const int kFramerate = 30;
const int kLowQp = 15;
const int kHighQp = 40;
const int kMinFramesNeededToScale = 60; // From quality_scaler.cc.
constexpr int kFramerate = 30;
constexpr int kLowQp = 15;
constexpr int kHighQp = 40;
constexpr int kMinFramesNeededToScale = 60; // From quality_scaler.cc.
constexpr TimeDelta kDefaultTimeout = TimeDelta::Millis(150);
} // namespace

View File

@ -46,7 +46,7 @@ constexpr uint32_t kSimulcastScreenshareMinBitrateKbps = 600;
constexpr uint32_t kSimulcastScreenshareMaxBitrateKbps = 1250;
// Default video hysteresis factor: allocatable bitrate for next layer must
// exceed 20% of min setting in order to be initially turned on.
const double kDefaultHysteresis = 1.2;
constexpr double kDefaultHysteresis = 1.2;
class MockTemporalLayers : public Vp8FrameBufferController {
public:

View File

@ -40,21 +40,21 @@
namespace webrtc {
namespace {
const int kDefaultWidth = 1280;
const int kDefaultHeight = 720;
const int kDefaultFrameRate = 30;
const uint32_t kDefaultMinBitrateBps = 60000;
const uint32_t kDefaultTargetBitrateBps = 2000000;
const uint32_t kDefaultMaxBitrateBps = 2000000;
const uint32_t kDefaultMinTransmitBitrateBps = 400000;
const int kDefaultMaxQp = 48;
const uint32_t kScreenshareTl0BitrateBps = 120000;
const uint32_t kScreenshareConferenceTl0BitrateBps = 200000;
const uint32_t kScreenshareCodecTargetBitrateBps = 200000;
const uint32_t kScreenshareDefaultFramerate = 5;
constexpr int kDefaultWidth = 1280;
constexpr int kDefaultHeight = 720;
constexpr int kDefaultFrameRate = 30;
constexpr uint32_t kDefaultMinBitrateBps = 60000;
constexpr uint32_t kDefaultTargetBitrateBps = 2000000;
constexpr uint32_t kDefaultMaxBitrateBps = 2000000;
constexpr uint32_t kDefaultMinTransmitBitrateBps = 400000;
constexpr int kDefaultMaxQp = 48;
constexpr uint32_t kScreenshareTl0BitrateBps = 120000;
constexpr uint32_t kScreenshareConferenceTl0BitrateBps = 200000;
constexpr uint32_t kScreenshareCodecTargetBitrateBps = 200000;
constexpr uint32_t kScreenshareDefaultFramerate = 5;
// Bitrates for the temporal layers of the higher screenshare simulcast stream.
const uint32_t kHighScreenshareTl0Bps = 800000;
const uint32_t kHighScreenshareTl1Bps = 1200000;
constexpr uint32_t kHighScreenshareTl0Bps = 800000;
constexpr uint32_t kHighScreenshareTl1Bps = 1200000;
} // namespace
// TODO(sprang): Extend coverage to handle the rest of the codec initializer.

View File

@ -129,14 +129,14 @@ using ::webrtc::SocketAddress;
// Default timeout for tests in this file.
// Should be large enough for slow buildbots to run the tests reliably.
const int kDefaultTimeout = 10000;
const int kMediumTimeout = 3000;
const int kShortTimeout = 1000;
constexpr int kDefaultTimeout = 10000;
constexpr int kMediumTimeout = 3000;
constexpr int kShortTimeout = 1000;
const int kOnlyLocalPorts = webrtc::PORTALLOCATOR_DISABLE_STUN |
webrtc::PORTALLOCATOR_DISABLE_RELAY |
webrtc::PORTALLOCATOR_DISABLE_TCP;
const int LOW_RTT = 20;
constexpr int kOnlyLocalPorts = webrtc::PORTALLOCATOR_DISABLE_STUN |
webrtc::PORTALLOCATOR_DISABLE_RELAY |
webrtc::PORTALLOCATOR_DISABLE_TCP;
constexpr int LOW_RTT = 20;
// Addresses on the public internet.
const SocketAddress kPublicAddrs[2] = {SocketAddress("11.11.11.11", 0),
SocketAddress("22.22.22.22", 0)};

View File

@ -30,13 +30,19 @@
using ::webrtc::CreateEnvironment;
using ::webrtc::IceCandidateType;
static const char kContentName[] = "test content";
namespace {
constexpr char kContentName[] = "test content";
// Based on ICE_UFRAG_LENGTH
static const char kIceUfrag[] = "UF00";
constexpr char kIceUfrag[] = "UF00";
// Based on ICE_PWD_LENGTH
static const char kIcePwd[] = "TESTICEPWD00000000000000";
static const char kTurnUsername[] = "test";
static const char kTurnPassword[] = "test";
constexpr char kIcePwd[] = "TESTICEPWD00000000000000";
constexpr char kTurnUsername[] = "test";
constexpr char kTurnPassword[] = "test";
// Constants for testing candidates
constexpr char kIpv4Address[] = "12.34.56.78";
constexpr char kIpv4AddressWithPort[] = "12.34.56.78:443";
} // namespace
class PortAllocatorTest : public ::testing::Test, public sigslot::has_slots<> {
public:
@ -288,10 +294,6 @@ TEST_F(PortAllocatorTest, RestrictIceCredentialsChange) {
allocator_->DiscardCandidatePool();
}
// Constants for testing candidates
const char kIpv4Address[] = "12.34.56.78";
const char kIpv4AddressWithPort[] = "12.34.56.78:443";
TEST_F(PortAllocatorTest, SanitizeEmptyCandidateDefaultConfig) {
webrtc::Candidate input;
webrtc::Candidate output = allocator_->SanitizeCandidate(input);

View File

@ -34,17 +34,17 @@
namespace {
const int kOnlyLocalPorts = webrtc::PORTALLOCATOR_DISABLE_STUN |
webrtc::PORTALLOCATOR_DISABLE_RELAY |
webrtc::PORTALLOCATOR_DISABLE_TCP;
constexpr int kOnlyLocalPorts = webrtc::PORTALLOCATOR_DISABLE_STUN |
webrtc::PORTALLOCATOR_DISABLE_RELAY |
webrtc::PORTALLOCATOR_DISABLE_TCP;
// The address of the public STUN server.
const webrtc::SocketAddress kStunAddr("99.99.99.1", webrtc::STUN_SERVER_PORT);
// The addresses for the public TURN server.
const webrtc::SocketAddress kTurnUdpIntAddr("99.99.99.3",
webrtc::STUN_SERVER_PORT);
const webrtc::RelayCredentials kRelayCredentials("test", "test");
const char kIceUfrag[] = "UF00";
const char kIcePwd[] = "TESTICEPWD00000000000000";
constexpr char kIceUfrag[] = "UF00";
constexpr char kIcePwd[] = "TESTICEPWD00000000000000";
} // namespace

View File

@ -95,13 +95,14 @@ const SocketAddress kValidHostnameAddr("valid-hostname", 5000);
const SocketAddress kBadHostnameAddr("not-a-real-hostname", 5000);
// STUN timeout (with all retries) is webrtc::STUN_TOTAL_TIMEOUT.
// Add some margin of error for slow bots.
const int kTimeoutMs = webrtc::STUN_TOTAL_TIMEOUT;
constexpr int kTimeoutMs = webrtc::STUN_TOTAL_TIMEOUT;
// stun prio = 100 (srflx) << 24 | 30 (IPv4) << 8 | 256 - 1 (component)
const uint32_t kStunCandidatePriority = (100 << 24) | (30 << 8) | (256 - 1);
constexpr uint32_t kStunCandidatePriority = (100 << 24) | (30 << 8) | (256 - 1);
// stun prio = 100 (srflx) << 24 | 40 (IPv6) << 8 | 256 - 1 (component)
const uint32_t kIPv6StunCandidatePriority = (100 << 24) | (40 << 8) | (256 - 1);
const int kInfiniteLifetime = -1;
const int kHighCostPortKeepaliveLifetimeMs = 2 * 60 * 1000;
constexpr uint32_t kIPv6StunCandidatePriority =
(100 << 24) | (40 << 8) | (256 - 1);
constexpr int kInfiniteLifetime = -1;
constexpr int kHighCostPortKeepaliveLifetimeMs = 2 * 60 * 1000;
constexpr uint64_t kTiebreakerDefault = 44444;

View File

@ -112,13 +112,13 @@ const SocketAddress kTurnUdpIPv6IntAddr("2400:4030:1:2c00:be30:abcd:efab:cdef",
const SocketAddress kTurnInvalidAddr("www.google.invalid.", 3478);
const SocketAddress kTurnValidAddr("www.google.valid.", 3478);
const char kCandidateFoundation[] = "foundation";
const char kIceUfrag1[] = "TESTICEUFRAG0001";
const char kIceUfrag2[] = "TESTICEUFRAG0002";
const char kIcePwd1[] = "TESTICEPWD00000000000001";
const char kIcePwd2[] = "TESTICEPWD00000000000002";
const char kTurnUsername[] = "test";
const char kTurnPassword[] = "test";
constexpr char kCandidateFoundation[] = "foundation";
constexpr char kIceUfrag1[] = "TESTICEUFRAG0001";
constexpr char kIceUfrag2[] = "TESTICEUFRAG0002";
constexpr char kIcePwd1[] = "TESTICEPWD00000000000001";
constexpr char kIcePwd2[] = "TESTICEPWD00000000000002";
constexpr char kTurnUsername[] = "test";
constexpr char kTurnPassword[] = "test";
// This test configures the virtual socket server to simulate delay so that we
// can verify operations take no more than the expected number of round trips.
constexpr unsigned int kSimulatedRtt = 50;

View File

@ -67,7 +67,7 @@ static const size_t kPacketHeaderLen = 12;
static const int kFakePacketId = 0x1234;
static const int kTimeout = 10000;
const uint8_t kRtpLeadByte = 0x80;
constexpr uint8_t kRtpLeadByte = 0x80;
static bool IsRtpLeadByte(uint8_t b) {
return b == kRtpLeadByte;

View File

@ -88,14 +88,14 @@ const webrtc::Codec kIsacCodec =
webrtc::CreateAudioCodec(103, "ISAC", 40000, 1);
const webrtc::Codec kH264Codec = webrtc::CreateVideoCodec(97, "H264");
const webrtc::Codec kH264SvcCodec = webrtc::CreateVideoCodec(99, "H264-SVC");
const uint32_t kSsrc1 = 0x1111;
const uint32_t kSsrc2 = 0x2222;
const uint32_t kSsrc3 = 0x3333;
const uint32_t kSsrc4 = 0x4444;
const int kAudioPts[] = {0, 8};
const int kVideoPts[] = {97, 99};
const char kAudioMid[] = "0";
const char kVideoMid[] = "1";
constexpr uint32_t kSsrc1 = 0x1111;
constexpr uint32_t kSsrc2 = 0x2222;
constexpr uint32_t kSsrc3 = 0x3333;
constexpr uint32_t kSsrc4 = 0x4444;
constexpr int kAudioPts[] = {0, 8};
constexpr int kVideoPts[] = {97, 99};
constexpr char kAudioMid[] = "0";
constexpr char kVideoMid[] = "1";
enum class NetworkIsWorker { Yes, No };
template <class ChannelT,

View File

@ -46,7 +46,7 @@ using ::webrtc::FieldTrials;
using ::webrtc::RtpTransport;
using ::webrtc::SrtpTransport;
const int kRtpAuthTagLen = 10;
constexpr int kRtpAuthTagLen = 10;
class DtlsSrtpTransportTest : public ::testing::Test,
public sigslot::has_slots<> {

View File

@ -39,17 +39,17 @@ using ::testing::NotNull;
using ::testing::Values;
namespace {
const char kAudioMid[] = "audio";
const char kVideoMid[] = "video";
const char kCandidateUfrag[] = "ufrag";
const char kCandidatePwd[] = "pwd";
const char kCandidateUfragVoice[] = "ufrag_voice";
const char kCandidatePwdVoice[] = "pwd_voice";
const char kCandidateUfragVideo[] = "ufrag_video";
const char kCandidatePwdVideo[] = "pwd_video";
const char kCandidateFoundation[] = "a0+B/1";
const uint32_t kCandidatePriority = 2130706432U; // pref = 1.0
const uint32_t kCandidateGeneration = 2;
constexpr char kAudioMid[] = "audio";
constexpr char kVideoMid[] = "video";
constexpr char kCandidateUfrag[] = "ufrag";
constexpr char kCandidatePwd[] = "pwd";
constexpr char kCandidateUfragVoice[] = "ufrag_voice";
constexpr char kCandidatePwdVoice[] = "pwd_voice";
constexpr char kCandidateUfragVideo[] = "ufrag_video";
constexpr char kCandidatePwdVideo[] = "pwd_video";
constexpr char kCandidateFoundation[] = "a0+B/1";
constexpr uint32_t kCandidatePriority = 2130706432U; // pref = 1.0
constexpr uint32_t kCandidateGeneration = 2;
// This creates a session description with both audio and video media contents.
// In SDP this is described by two m lines, one audio and one video.

View File

@ -61,11 +61,11 @@
namespace webrtc {
namespace {
const char kIceUfrag1[] = "U001";
const char kIcePwd1[] = "TESTICEPWD00000000000001";
const char kIceUfrag2[] = "U002";
const char kIcePwd2[] = "TESTIEPWD00000000000002";
const char kTransportName[] = "Test Transport";
constexpr char kIceUfrag1[] = "U001";
constexpr char kIcePwd1[] = "TESTICEPWD00000000000001";
constexpr char kIceUfrag2[] = "U002";
constexpr char kIcePwd2[] = "TESTIEPWD00000000000002";
constexpr char kTransportName[] = "Test Transport";
struct NegotiateRoleParams {
ConnectionRole local_role;

View File

@ -61,30 +61,21 @@
#include "test/gmock.h"
#include "test/gtest.h"
namespace webrtc {
using ::testing::_;
using ::testing::AtMost;
using ::testing::Eq;
using ::testing::Return;
using ::testing::UnorderedElementsAre;
using ::webrtc::ConnectionInfo;
using ::webrtc::SsrcReceiverInfo;
using ::webrtc::TransportChannelStats;
using ::webrtc::VideoMediaInfo;
using ::webrtc::VideoReceiverInfo;
using ::webrtc::VideoSenderInfo;
using ::webrtc::VoiceMediaInfo;
using ::webrtc::VoiceReceiverInfo;
using ::webrtc::VoiceSenderInfo;
namespace webrtc {
// Error return values
const char kNotFound[] = "NOT FOUND";
constexpr char kNotFound[] = "NOT FOUND";
// Constant names for track identification.
const char kLocalTrackId[] = "local_track_id";
const char kRemoteTrackId[] = "remote_track_id";
const uint32_t kSsrcOfTrack = 1234;
constexpr char kLocalTrackId[] = "local_track_id";
constexpr char kRemoteTrackId[] = "remote_track_id";
constexpr uint32_t kSsrcOfTrack = 1234;
class FakeAudioProcessor : public AudioProcessorInterface {
public:

View File

@ -87,9 +87,9 @@ using ::webrtc::UniqueRandomIdGenerator;
using Candidates = std::vector<Candidate>;
const char kAudioMid[] = "0";
const char kVideoMid[] = "1";
const char kDataMid[] = "2";
constexpr char kAudioMid[] = "0";
constexpr char kVideoMid[] = "1";
constexpr char kDataMid[] = "2";
class CodecLookupHelperForTesting : public CodecLookupHelper {
public:
@ -144,11 +144,11 @@ const Codec kVideoCodecsAnswer[] = {CreateVideoCodec(97, "H264")};
// H.265 level-id, according to H.265 spec, is calculated this way:
// For any given H.265 level a.b, level-id = (a * 10 + b) * 3. For level 6.0,
// level-id = (6 * 10 + 0) * 3 = 180. Similar for all other H.265 levels.
const char kVideoCodecsH265Level6LevelId[] = "180";
const char kVideoCodecsH265Level52LevelId[] = "156";
const char kVideoCodecsH265Level5LevelId[] = "150";
const char kVideoCodecsH265Level4LevelId[] = "120";
const char kVideoCodecsH265Level31LevelId[] = "93";
constexpr char kVideoCodecsH265Level6LevelId[] = "180";
constexpr char kVideoCodecsH265Level52LevelId[] = "156";
constexpr char kVideoCodecsH265Level5LevelId[] = "150";
constexpr char kVideoCodecsH265Level4LevelId[] = "120";
constexpr char kVideoCodecsH265Level31LevelId[] = "93";
const SdpVideoFormat kH265MainProfileLevel31Sdp(
"H265",
@ -357,19 +357,19 @@ const RtpExtension kRtpExtensionGenericFrameDescriptorUri00[] = {
3),
};
const uint32_t kSimulcastParamsSsrc[] = {10, 11, 20, 21, 30, 31};
const uint32_t kSimSsrc[] = {10, 20, 30};
const uint32_t kFec1Ssrc[] = {10, 11};
const uint32_t kFec2Ssrc[] = {20, 21};
const uint32_t kFec3Ssrc[] = {30, 31};
constexpr uint32_t kSimulcastParamsSsrc[] = {10, 11, 20, 21, 30, 31};
constexpr uint32_t kSimSsrc[] = {10, 20, 30};
constexpr uint32_t kFec1Ssrc[] = {10, 11};
constexpr uint32_t kFec2Ssrc[] = {20, 21};
constexpr uint32_t kFec3Ssrc[] = {30, 31};
const char kMediaStream1[] = "stream_1";
const char kMediaStream2[] = "stream_2";
const char kVideoTrack1[] = "video_1";
const char kVideoTrack2[] = "video_2";
const char kAudioTrack1[] = "audio_1";
const char kAudioTrack2[] = "audio_2";
const char kAudioTrack3[] = "audio_3";
constexpr char kMediaStream1[] = "stream_1";
constexpr char kMediaStream2[] = "stream_2";
constexpr char kVideoTrack1[] = "video_1";
constexpr char kVideoTrack2[] = "video_2";
constexpr char kAudioTrack1[] = "audio_1";
constexpr char kAudioTrack2[] = "audio_2";
constexpr char kAudioTrack3[] = "audio_3";
const char* kMediaProtocols[] = {"RTP/AVP", "RTP/SAVP", "RTP/AVPF",
"RTP/SAVPF"};
@ -4882,18 +4882,18 @@ const Codec kOfferAnswerCodecs[] = {CreateAudioCodec(40, "codec0", 16000, 1),
* 6 | x x x | x x x | x x x x x
*/
// Codecs used by offerer in the AudioCodecsAnswerTest
const int kOfferSendCodecs[] = {0, 1, 3, 5, 6};
const int kOfferRecvCodecs[] = {1, 2, 3, 4, 6};
constexpr int kOfferSendCodecs[] = {0, 1, 3, 5, 6};
constexpr int kOfferRecvCodecs[] = {1, 2, 3, 4, 6};
// Codecs used in the answerer in the AudioCodecsAnswerTest. The order is
// jumbled to catch the answer not following the order in the offer.
const int kAnswerSendCodecs[] = {6, 5, 2, 3, 4};
const int kAnswerRecvCodecs[] = {6, 5, 4, 1, 0};
constexpr int kAnswerSendCodecs[] = {6, 5, 2, 3, 4};
constexpr int kAnswerRecvCodecs[] = {6, 5, 4, 1, 0};
// The resulting sets of codecs in the answer in the AudioCodecsAnswerTest
const int kResultSend_RecvCodecs[] = {0, 1, 5, 6};
const int kResultRecv_SendCodecs[] = {2, 3, 4, 6};
const int kResultSendrecv_SendCodecs[] = {3, 6};
const int kResultSendrecv_RecvCodecs[] = {1, 6};
const int kResultSendrecv_SendrecvCodecs[] = {6};
constexpr int kResultSend_RecvCodecs[] = {0, 1, 5, 6};
constexpr int kResultRecv_SendCodecs[] = {2, 3, 4, 6};
constexpr int kResultSendrecv_SendCodecs[] = {3, 6};
constexpr int kResultSendrecv_RecvCodecs[] = {1, 6};
constexpr int kResultSendrecv_SendrecvCodecs[] = {6};
template <typename T, int IDXS>
std::vector<T> VectorFromIndices(const T* array, const int (&indices)[IDXS]) {

View File

@ -73,7 +73,7 @@ using ::webrtc::SdpSemantics;
namespace {
const int kMaxWait = 25000;
constexpr int kMaxWait = 25000;
} // namespace

View File

@ -87,23 +87,25 @@ using ::testing::NotNull;
using ::testing::Return;
using ::testing::UnorderedElementsAre;
const char kStunIceServer[] = "stun:stun.l.google.com:19302";
const char kTurnIceServer[] = "turn:test.com:1234";
const char kTurnIceServerWithTransport[] = "turn:hello.com?transport=tcp";
const char kSecureTurnIceServer[] = "turns:hello.com?transport=tcp";
const char kSecureTurnIceServerWithoutTransportParam[] = "turns:hello.com:443";
const char kSecureTurnIceServerWithoutTransportAndPortParam[] =
constexpr char kStunIceServer[] = "stun:stun.l.google.com:19302";
constexpr char kTurnIceServer[] = "turn:test.com:1234";
constexpr char kTurnIceServerWithTransport[] = "turn:hello.com?transport=tcp";
constexpr char kSecureTurnIceServer[] = "turns:hello.com?transport=tcp";
constexpr char kSecureTurnIceServerWithoutTransportParam[] =
"turns:hello.com:443";
constexpr char kSecureTurnIceServerWithoutTransportAndPortParam[] =
"turns:hello.com";
const char kTurnIceServerWithNoUsernameInUri[] = "turn:test.com:1234";
const char kTurnPassword[] = "turnpassword";
const int kDefaultStunPort = 3478;
const int kDefaultStunTlsPort = 5349;
const char kTurnUsername[] = "test";
const char kStunIceServerWithIPv4Address[] = "stun:1.2.3.4:1234";
const char kStunIceServerWithIPv4AddressWithoutPort[] = "stun:1.2.3.4";
const char kStunIceServerWithIPv6Address[] = "stun:[2401:fa00:4::]:1234";
const char kStunIceServerWithIPv6AddressWithoutPort[] = "stun:[2401:fa00:4::]";
const char kTurnIceServerWithIPv6Address[] = "turn:[2401:fa00:4::]:1234";
constexpr char kTurnIceServerWithNoUsernameInUri[] = "turn:test.com:1234";
constexpr char kTurnPassword[] = "turnpassword";
constexpr int kDefaultStunPort = 3478;
constexpr int kDefaultStunTlsPort = 5349;
constexpr char kTurnUsername[] = "test";
constexpr char kStunIceServerWithIPv4Address[] = "stun:1.2.3.4:1234";
constexpr char kStunIceServerWithIPv4AddressWithoutPort[] = "stun:1.2.3.4";
constexpr char kStunIceServerWithIPv6Address[] = "stun:[2401:fa00:4::]:1234";
constexpr char kStunIceServerWithIPv6AddressWithoutPort[] =
"stun:[2401:fa00:4::]";
constexpr char kTurnIceServerWithIPv6Address[] = "turn:[2401:fa00:4::]:1234";
class NullPeerConnectionObserver : public PeerConnectionObserver {
public:

View File

@ -48,9 +48,15 @@
#include "test/wait_until.h"
namespace webrtc {
namespace {
using ::testing::NiceMock;
using RTCConfiguration = PeerConnectionInterface::RTCConfiguration;
using RTCOfferAnswerOptions = PeerConnectionInterface::RTCOfferAnswerOptions;
class PeerConnectionWrapperForUsageHistogramTest;
typedef PeerConnectionWrapperForUsageHistogramTest* RawWrapperPtr;
constexpr const char kBasicRemoteDescription[] = R"(v=0
o=- 0 0 IN IP4 127.0.0.1
s=-
@ -68,11 +74,7 @@ a=rtcp-mux
a=rtpmap:101 fake_audio_codec/8000
)";
using RTCConfiguration = PeerConnectionInterface::RTCConfiguration;
using RTCOfferAnswerOptions = PeerConnectionInterface::RTCOfferAnswerOptions;
using ::testing::NiceMock;
const char kUsagePatternMetric[] = "WebRTC.PeerConnection.UsagePattern";
constexpr char kUsagePatternMetric[] = "WebRTC.PeerConnection.UsagePattern";
constexpr TimeDelta kDefaultTimeout = TimeDelta::Millis(10000);
const SocketAddress kLocalAddrs[2] = {SocketAddress("1.1.1.1", 0),
SocketAddress("2.2.2.2", 0)};
@ -87,10 +89,6 @@ int MakeUsageFingerprint(std::set<UsageEvent> events) {
return signature;
}
class PeerConnectionWrapperForUsageHistogramTest;
typedef PeerConnectionWrapperForUsageHistogramTest* RawWrapperPtr;
class ObserverForUsageHistogramTest : public MockPeerConnectionObserver {
public:
void OnIceCandidate(const IceCandidate* candidate) override;
@ -812,5 +810,4 @@ TEST_F(PeerConnectionUsageHistogramTest,
#endif
} // namespace
} // namespace webrtc

View File

@ -107,30 +107,30 @@ using ::testing::Values;
using RTCConfiguration = PeerConnectionInterface::RTCConfiguration;
using RTCOfferAnswerOptions = PeerConnectionInterface::RTCOfferAnswerOptions;
const char kStreamId1[] = "local_stream_1";
const char kStreamId2[] = "local_stream_2";
const char kStreamId3[] = "local_stream_3";
const int kDefaultStunPort = 3478;
const char kStunAddressOnly[] = "stun:address";
const char kStunInvalidPort[] = "stun:address:-1";
const char kStunAddressPortAndMore1[] = "stun:address:port:more";
const char kStunAddressPortAndMore2[] = "stun:address:port more";
const char kTurnIceServerUri[] = "turn:turn.example.org";
const char kTurnUsername[] = "user";
const char kTurnPassword[] = "password";
const char kTurnHostname[] = "turn.example.org";
const uint32_t kTimeout = 10000U;
constexpr char kStreamId1[] = "local_stream_1";
constexpr char kStreamId2[] = "local_stream_2";
constexpr char kStreamId3[] = "local_stream_3";
constexpr int kDefaultStunPort = 3478;
constexpr char kStunAddressOnly[] = "stun:address";
constexpr char kStunInvalidPort[] = "stun:address:-1";
constexpr char kStunAddressPortAndMore1[] = "stun:address:port:more";
constexpr char kStunAddressPortAndMore2[] = "stun:address:port more";
constexpr char kTurnIceServerUri[] = "turn:turn.example.org";
constexpr char kTurnUsername[] = "user";
constexpr char kTurnPassword[] = "password";
constexpr char kTurnHostname[] = "turn.example.org";
constexpr uint32_t kTimeout = 10000U;
const char kStreams[][8] = {"stream1", "stream2"};
const char kAudioTracks[][32] = {"audiotrack0", "audiotrack1"};
const char kVideoTracks[][32] = {"videotrack0", "videotrack1"};
constexpr char kStreams[][8] = {"stream1", "stream2"};
constexpr char kAudioTracks[][32] = {"audiotrack0", "audiotrack1"};
constexpr char kVideoTracks[][32] = {"videotrack0", "videotrack1"};
const char kRecvonly[] = "recvonly";
const char kSendrecv[] = "sendrecv";
constexpr char kRecvonly[] = "recvonly";
constexpr char kSendrecv[] = "sendrecv";
// Reference SDP with a MediaStream with label "stream1" and audio track with
// id "audio_1" and a video track with id "video_1;
const char kSdpStringWithStream1PlanB[] =
constexpr char kSdpStringWithStream1PlanB[] =
"v=0\r\n"
"o=- 0 0 IN IP4 127.0.0.1\r\n"
"s=-\r\n"
@ -160,7 +160,7 @@ const char kSdpStringWithStream1PlanB[] =
// Same string as above but with the MID changed to the Unified Plan default and
// a=msid added. This is needed so that this SDP can be used as an answer for a
// Unified Plan offer.
const char kSdpStringWithStream1UnifiedPlan[] =
constexpr char kSdpStringWithStream1UnifiedPlan[] =
"v=0\r\n"
"o=- 0 0 IN IP4 127.0.0.1\r\n"
"s=-\r\n"
@ -190,7 +190,7 @@ const char kSdpStringWithStream1UnifiedPlan[] =
// Reference SDP with a MediaStream with label "stream1" and audio track with
// id "audio_1";
const char kSdpStringWithStream1AudioTrackOnly[] =
constexpr char kSdpStringWithStream1AudioTrackOnly[] =
"v=0\r\n"
"o=- 0 0 IN IP4 127.0.0.1\r\n"
"s=-\r\n"
@ -210,7 +210,7 @@ const char kSdpStringWithStream1AudioTrackOnly[] =
// Reference SDP with two MediaStreams with label "stream1" and "stream2. Each
// MediaStreams have one audio track and one video track.
// This uses MSID.
const char kSdpStringWithStream1And2PlanB[] =
constexpr char kSdpStringWithStream1And2PlanB[] =
"v=0\r\n"
"o=- 0 0 IN IP4 127.0.0.1\r\n"
"s=-\r\n"
@ -242,7 +242,7 @@ const char kSdpStringWithStream1And2PlanB[] =
"a=ssrc:2 msid:stream1 videotrack0\r\n"
"a=ssrc:4 cname:stream2\r\n"
"a=ssrc:4 msid:stream2 videotrack1\r\n";
const char kSdpStringWithStream1And2UnifiedPlan[] =
constexpr char kSdpStringWithStream1And2UnifiedPlan[] =
"v=0\r\n"
"o=- 0 0 IN IP4 127.0.0.1\r\n"
"s=-\r\n"
@ -294,7 +294,7 @@ const char kSdpStringWithStream1And2UnifiedPlan[] =
"a=ssrc:4 msid:stream2 videotrack1\r\n";
// Reference SDP without MediaStreams. Msid is not supported.
const char kSdpStringWithoutStreams[] =
constexpr char kSdpStringWithoutStreams[] =
"v=0\r\n"
"o=- 0 0 IN IP4 127.0.0.1\r\n"
"s=-\r\n"
@ -319,7 +319,7 @@ const char kSdpStringWithoutStreams[] =
"a=rtpmap:120 VP8/90000\r\n";
// Reference SDP without MediaStreams. Msid is supported.
const char kSdpStringWithMsidWithoutStreams[] =
constexpr char kSdpStringWithMsidWithoutStreams[] =
"v=0\r\n"
"o=- 0 0 IN IP4 127.0.0.1\r\n"
"s=-\r\n"
@ -345,7 +345,7 @@ const char kSdpStringWithMsidWithoutStreams[] =
"a=rtpmap:120 VP8/90000\r\n";
// Reference SDP without MediaStreams and audio only.
const char kSdpStringWithoutStreamsAudioOnly[] =
constexpr char kSdpStringWithoutStreamsAudioOnly[] =
"v=0\r\n"
"o=- 0 0 IN IP4 127.0.0.1\r\n"
"s=-\r\n"
@ -361,7 +361,7 @@ const char kSdpStringWithoutStreamsAudioOnly[] =
"a=rtpmap:111 OPUS/48000/2\r\n";
// Reference SENDONLY SDP without MediaStreams. Msid is not supported.
const char kSdpStringSendOnlyWithoutStreams[] =
constexpr char kSdpStringSendOnlyWithoutStreams[] =
"v=0\r\n"
"o=- 0 0 IN IP4 127.0.0.1\r\n"
"s=-\r\n"
@ -387,14 +387,14 @@ const char kSdpStringSendOnlyWithoutStreams[] =
"a=rtcp-mux\r\n"
"a=rtpmap:120 VP8/90000\r\n";
const char kSdpStringInit[] =
constexpr char kSdpStringInit[] =
"v=0\r\n"
"o=- 0 0 IN IP4 127.0.0.1\r\n"
"s=-\r\n"
"t=0 0\r\n"
"a=msid-semantic: WMS\r\n";
const char kSdpStringAudio[] =
constexpr char kSdpStringAudio[] =
"m=audio 1 RTP/AVPF 111\r\n"
"a=ice-ufrag:e5785931\r\n"
"a=ice-pwd:36fb7878390db89481c1d46daa4278d8\r\n"
@ -405,7 +405,7 @@ const char kSdpStringAudio[] =
"a=rtcp-mux\r\n"
"a=rtpmap:111 OPUS/48000/2\r\n";
const char kSdpStringVideo[] =
constexpr char kSdpStringVideo[] =
"m=video 1 RTP/AVPF 120\r\n"
"a=ice-ufrag:e5785931\r\n"
"a=ice-pwd:36fb7878390db89481c1d46daa4278d8\r\n"
@ -416,19 +416,19 @@ const char kSdpStringVideo[] =
"a=rtcp-mux\r\n"
"a=rtpmap:120 VP8/90000\r\n";
const char kSdpStringMs1Audio0[] =
constexpr char kSdpStringMs1Audio0[] =
"a=ssrc:1 cname:stream1\r\n"
"a=ssrc:1 msid:stream1 audiotrack0\r\n";
const char kSdpStringMs1Video0[] =
constexpr char kSdpStringMs1Video0[] =
"a=ssrc:2 cname:stream1\r\n"
"a=ssrc:2 msid:stream1 videotrack0\r\n";
const char kSdpStringMs1Audio1[] =
constexpr char kSdpStringMs1Audio1[] =
"a=ssrc:3 cname:stream1\r\n"
"a=ssrc:3 msid:stream1 audiotrack1\r\n";
const char kSdpStringMs1Video1[] =
constexpr char kSdpStringMs1Video1[] =
"a=ssrc:4 cname:stream1\r\n"
"a=ssrc:4 msid:stream1 videotrack1\r\n";

View File

@ -82,7 +82,7 @@ using ::testing::StartsWith;
using ::testing::Values;
namespace {
const int64_t kWaitTimeout = 10000;
constexpr int64_t kWaitTimeout = 10000;
} // namespace
class PeerConnectionWrapperForSignalingTest : public PeerConnectionWrapper {

View File

@ -105,7 +105,7 @@ namespace webrtc {
namespace {
const int64_t kGetStatsReportTimeoutMs = 1000;
constexpr int64_t kGetStatsReportTimeoutMs = 1000;
// Fake data used by `SetupExampleStatsVoiceGraph()` to fill in remote outbound
// stats.

Some files were not shown because too many files have changed in this diff Show More