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}
This commit is contained in:
Yves Gerey
2018-06-19 15:03:05 +02:00
parent b602123a5a
commit 665174fdbb
1569 changed files with 30495 additions and 30309 deletions

View File

@ -61,17 +61,17 @@ const std::string& PlatformChecksum(const std::string& checksum_general,
const std::string& checksum_win_32,
const std::string& checksum_win_64) {
#if defined(WEBRTC_ANDROID)
#ifdef WEBRTC_ARCH_64_BITS
return checksum_android_64;
#else
return checksum_android_32;
#endif // WEBRTC_ARCH_64_BITS
#ifdef WEBRTC_ARCH_64_BITS
return checksum_android_64;
#else
return checksum_android_32;
#endif // WEBRTC_ARCH_64_BITS
#elif defined(WEBRTC_WIN)
#ifdef WEBRTC_ARCH_64_BITS
return checksum_win_64;
#else
return checksum_win_32;
#endif // WEBRTC_ARCH_64_BITS
#ifdef WEBRTC_ARCH_64_BITS
return checksum_win_64;
#else
return checksum_win_32;
#endif // WEBRTC_ARCH_64_BITS
#else
return checksum_general;
#endif // WEBRTC_WIN
@ -107,7 +107,8 @@ void Convert(const webrtc::RtcpStatistics& stats_raw,
stats->set_jitter(stats_raw.jitter);
}
void AddMessage(FILE* file, rtc::MessageDigest* digest,
void AddMessage(FILE* file,
rtc::MessageDigest* digest,
const std::string& message) {
int32_t size = message.length();
if (file)
@ -164,7 +165,8 @@ class ResultSink {
explicit ResultSink(const std::string& output_file);
~ResultSink();
template<typename T> void AddResult(const T* test_results, size_t length);
template <typename T>
void AddResult(const T* test_results, size_t length);
void AddResult(const NetEqNetworkStatistics& stats);
void AddResult(const RtcpStatistics& stats);
@ -190,7 +192,7 @@ ResultSink::~ResultSink() {
fclose(output_fp_);
}
template<typename T>
template <typename T>
void ResultSink::AddResult(const T* test_results, size_t length) {
if (output_fp_) {
ASSERT_EQ(length, fwrite(test_results, sizeof(T), length, output_fp_));
@ -247,7 +249,7 @@ class NetEqDecodingTest : public ::testing::Test {
virtual void SetUp();
virtual void TearDown();
void SelectDecoders(NetEqDecoder* used_codec);
void OpenInputFile(const std::string &rtp_file);
void OpenInputFile(const std::string& rtp_file);
void Process();
void DecodeAndCompare(const std::string& rtp_file,
@ -265,9 +267,11 @@ class NetEqDecodingTest : public ::testing::Test {
uint8_t* payload,
size_t* payload_len);
void WrapTest(uint16_t start_seq_no, uint32_t start_timestamp,
void WrapTest(uint16_t start_seq_no,
uint32_t start_timestamp,
const std::set<uint16_t>& drop_seq_numbers,
bool expect_seq_no_wrap, bool expect_timestamp_wrap);
bool expect_seq_no_wrap,
bool expect_timestamp_wrap);
void LongCngWithClockDrift(double drift_factor,
double network_freeze_ms,
@ -316,7 +320,7 @@ void NetEqDecodingTest::TearDown() {
delete neteq_;
}
void NetEqDecodingTest::OpenInputFile(const std::string &rtp_file) {
void NetEqDecodingTest::OpenInputFile(const std::string& rtp_file) {
rtp_source_.reset(test::RtpFileSource::Create(rtp_file));
}
@ -384,8 +388,8 @@ void NetEqDecodingTest::DecodeAndCompare(
ss << "Lap number " << i++ << " in DecodeAndCompare while loop";
SCOPED_TRACE(ss.str()); // Print out the parameter values on failure.
ASSERT_NO_FATAL_FAILURE(Process());
ASSERT_NO_FATAL_FAILURE(output.AddResult(
out_frame_.data(), out_frame_.samples_per_channel_));
ASSERT_NO_FATAL_FAILURE(
output.AddResult(out_frame_.data(), out_frame_.samples_per_channel_));
// Query the network statistics API once per second
if (sim_clock_ % 1000 == 0) {
@ -447,7 +451,7 @@ void NetEqDecodingTest::PopulateCng(int frame_index,
rtp_info->ssrc = 0x1234; // Just an arbitrary SSRC.
rtp_info->payloadType = 98; // WB CNG.
rtp_info->markerBit = 0;
payload[0] = 64; // Noise level -64 dBov, quite arbitrarily chosen.
payload[0] = 64; // Noise level -64 dBov, quite arbitrarily chosen.
*payload_len = 1; // Only noise level, no spectral parameters.
}
@ -462,36 +466,29 @@ TEST_F(NetEqDecodingTest, MAYBE_TestBitExactness) {
const std::string input_rtp_file =
webrtc::test::ResourcePath("audio_coding/neteq_universal_new", "rtp");
const std::string output_checksum = PlatformChecksum(
"0c6dc227f781c81a229970f8fceda1a012498cba",
"15c4a2202877a414515e218bdb7992f0ad53e5af",
"not used",
"0c6dc227f781c81a229970f8fceda1a012498cba",
"25fc4c863caa499aa447a5b8d059f5452cbcc500");
const std::string output_checksum =
PlatformChecksum("0c6dc227f781c81a229970f8fceda1a012498cba",
"15c4a2202877a414515e218bdb7992f0ad53e5af", "not used",
"0c6dc227f781c81a229970f8fceda1a012498cba",
"25fc4c863caa499aa447a5b8d059f5452cbcc500");
const std::string network_stats_checksum =
PlatformChecksum("4b2370f5c794741d2a46be5c7935c66ef3fb53e9",
"e339cb2adf5ab3dfc21cb7205d670a34751e8336",
"not used",
"e339cb2adf5ab3dfc21cb7205d670a34751e8336", "not used",
"4b2370f5c794741d2a46be5c7935c66ef3fb53e9",
"4b2370f5c794741d2a46be5c7935c66ef3fb53e9");
const std::string rtcp_stats_checksum = PlatformChecksum(
"b8880bf9fed2487efbddcb8d94b9937a29ae521d",
"f3f7b3d3e71d7e635240b5373b57df6a7e4ce9d4",
"not used",
"b8880bf9fed2487efbddcb8d94b9937a29ae521d",
"b8880bf9fed2487efbddcb8d94b9937a29ae521d");
const std::string rtcp_stats_checksum =
PlatformChecksum("b8880bf9fed2487efbddcb8d94b9937a29ae521d",
"f3f7b3d3e71d7e635240b5373b57df6a7e4ce9d4", "not used",
"b8880bf9fed2487efbddcb8d94b9937a29ae521d",
"b8880bf9fed2487efbddcb8d94b9937a29ae521d");
DecodeAndCompare(input_rtp_file,
output_checksum,
network_stats_checksum,
rtcp_stats_checksum,
FLAG_gen_ref);
DecodeAndCompare(input_rtp_file, output_checksum, network_stats_checksum,
rtcp_stats_checksum, FLAG_gen_ref);
}
#if !defined(WEBRTC_IOS) && \
defined(WEBRTC_NETEQ_UNITTEST_BITEXACT) && \
#if !defined(WEBRTC_IOS) && defined(WEBRTC_NETEQ_UNITTEST_BITEXACT) && \
defined(WEBRTC_CODEC_OPUS)
#define MAYBE_TestOpusBitExactness TestOpusBitExactness
#else
@ -501,12 +498,12 @@ TEST_F(NetEqDecodingTest, MAYBE_TestOpusBitExactness) {
const std::string input_rtp_file =
webrtc::test::ResourcePath("audio_coding/neteq_opus", "rtp");
const std::string output_checksum = PlatformChecksum(
"14a63b3c7b925c82296be4bafc71bec85f2915c2",
"b7b7ed802b0e18ee416973bf3b9ae98599b0181d",
"5876e52dda90d5ca433c3726555b907b97c86374",
"14a63b3c7b925c82296be4bafc71bec85f2915c2",
"14a63b3c7b925c82296be4bafc71bec85f2915c2");
const std::string output_checksum =
PlatformChecksum("14a63b3c7b925c82296be4bafc71bec85f2915c2",
"b7b7ed802b0e18ee416973bf3b9ae98599b0181d",
"5876e52dda90d5ca433c3726555b907b97c86374",
"14a63b3c7b925c82296be4bafc71bec85f2915c2",
"14a63b3c7b925c82296be4bafc71bec85f2915c2");
const std::string network_stats_checksum =
PlatformChecksum("adb3272498e436d1c019cbfd71610e9510c54497",
@ -515,22 +512,18 @@ TEST_F(NetEqDecodingTest, MAYBE_TestOpusBitExactness) {
"adb3272498e436d1c019cbfd71610e9510c54497",
"adb3272498e436d1c019cbfd71610e9510c54497");
const std::string rtcp_stats_checksum = PlatformChecksum(
"e37c797e3de6a64dda88c9ade7a013d022a2e1e0",
"e37c797e3de6a64dda88c9ade7a013d022a2e1e0",
"e37c797e3de6a64dda88c9ade7a013d022a2e1e0",
"e37c797e3de6a64dda88c9ade7a013d022a2e1e0",
"e37c797e3de6a64dda88c9ade7a013d022a2e1e0");
const std::string rtcp_stats_checksum =
PlatformChecksum("e37c797e3de6a64dda88c9ade7a013d022a2e1e0",
"e37c797e3de6a64dda88c9ade7a013d022a2e1e0",
"e37c797e3de6a64dda88c9ade7a013d022a2e1e0",
"e37c797e3de6a64dda88c9ade7a013d022a2e1e0",
"e37c797e3de6a64dda88c9ade7a013d022a2e1e0");
DecodeAndCompare(input_rtp_file,
output_checksum,
network_stats_checksum,
rtcp_stats_checksum,
FLAG_gen_ref);
DecodeAndCompare(input_rtp_file, output_checksum, network_stats_checksum,
rtcp_stats_checksum, FLAG_gen_ref);
}
#if !defined(WEBRTC_IOS) && \
defined(WEBRTC_NETEQ_UNITTEST_BITEXACT) && \
#if !defined(WEBRTC_IOS) && defined(WEBRTC_NETEQ_UNITTEST_BITEXACT) && \
defined(WEBRTC_CODEC_OPUS)
#define MAYBE_TestOpusDtxBitExactness TestOpusDtxBitExactness
#else
@ -805,10 +798,8 @@ TEST_F(NetEqDecodingTest, LongCngWithNegativeClockDrift) {
const bool kGetAudioDuringFreezeRecovery = false;
const int kDelayToleranceMs = 20;
const int kMaxTimeToSpeechMs = 100;
LongCngWithClockDrift(kDriftFactor,
kNetworkFreezeTimeMs,
kGetAudioDuringFreezeRecovery,
kDelayToleranceMs,
LongCngWithClockDrift(kDriftFactor, kNetworkFreezeTimeMs,
kGetAudioDuringFreezeRecovery, kDelayToleranceMs,
kMaxTimeToSpeechMs);
}
@ -819,10 +810,8 @@ TEST_F(NetEqDecodingTest, LongCngWithPositiveClockDrift) {
const bool kGetAudioDuringFreezeRecovery = false;
const int kDelayToleranceMs = 20;
const int kMaxTimeToSpeechMs = 100;
LongCngWithClockDrift(kDriftFactor,
kNetworkFreezeTimeMs,
kGetAudioDuringFreezeRecovery,
kDelayToleranceMs,
LongCngWithClockDrift(kDriftFactor, kNetworkFreezeTimeMs,
kGetAudioDuringFreezeRecovery, kDelayToleranceMs,
kMaxTimeToSpeechMs);
}
@ -833,10 +822,8 @@ TEST_F(NetEqDecodingTest, LongCngWithNegativeClockDriftNetworkFreeze) {
const bool kGetAudioDuringFreezeRecovery = false;
const int kDelayToleranceMs = 50;
const int kMaxTimeToSpeechMs = 200;
LongCngWithClockDrift(kDriftFactor,
kNetworkFreezeTimeMs,
kGetAudioDuringFreezeRecovery,
kDelayToleranceMs,
LongCngWithClockDrift(kDriftFactor, kNetworkFreezeTimeMs,
kGetAudioDuringFreezeRecovery, kDelayToleranceMs,
kMaxTimeToSpeechMs);
}
@ -847,10 +834,8 @@ TEST_F(NetEqDecodingTest, LongCngWithPositiveClockDriftNetworkFreeze) {
const bool kGetAudioDuringFreezeRecovery = false;
const int kDelayToleranceMs = 20;
const int kMaxTimeToSpeechMs = 100;
LongCngWithClockDrift(kDriftFactor,
kNetworkFreezeTimeMs,
kGetAudioDuringFreezeRecovery,
kDelayToleranceMs,
LongCngWithClockDrift(kDriftFactor, kNetworkFreezeTimeMs,
kGetAudioDuringFreezeRecovery, kDelayToleranceMs,
kMaxTimeToSpeechMs);
}
@ -861,10 +846,8 @@ TEST_F(NetEqDecodingTest, LongCngWithPositiveClockDriftNetworkFreezeExtraPull) {
const bool kGetAudioDuringFreezeRecovery = true;
const int kDelayToleranceMs = 20;
const int kMaxTimeToSpeechMs = 100;
LongCngWithClockDrift(kDriftFactor,
kNetworkFreezeTimeMs,
kGetAudioDuringFreezeRecovery,
kDelayToleranceMs,
LongCngWithClockDrift(kDriftFactor, kNetworkFreezeTimeMs,
kGetAudioDuringFreezeRecovery, kDelayToleranceMs,
kMaxTimeToSpeechMs);
}
@ -874,10 +857,8 @@ TEST_F(NetEqDecodingTest, LongCngWithoutClockDrift) {
const bool kGetAudioDuringFreezeRecovery = false;
const int kDelayToleranceMs = 10;
const int kMaxTimeToSpeechMs = 50;
LongCngWithClockDrift(kDriftFactor,
kNetworkFreezeTimeMs,
kGetAudioDuringFreezeRecovery,
kDelayToleranceMs,
LongCngWithClockDrift(kDriftFactor, kNetworkFreezeTimeMs,
kGetAudioDuringFreezeRecovery, kDelayToleranceMs,
kMaxTimeToSpeechMs);
}
@ -1002,11 +983,11 @@ class NetEqBgnTest : public NetEqDecodingTest {
ASSERT_EQ(AudioFrame::kNormalSpeech, output.speech_type_);
// Next packet.
rtp_info.timestamp += rtc::checked_cast<uint32_t>(
expected_samples_per_channel);
rtp_info.timestamp +=
rtc::checked_cast<uint32_t>(expected_samples_per_channel);
rtp_info.sequenceNumber++;
receive_timestamp += rtc::checked_cast<uint32_t>(
expected_samples_per_channel);
receive_timestamp +=
rtc::checked_cast<uint32_t>(expected_samples_per_channel);
}
output.Reset();
@ -1099,8 +1080,8 @@ void NetEqDecodingTest::WrapTest(uint16_t start_seq_no,
if (packets_inserted > 4) {
// Expect preferred and actual buffer size to be no more than 2 frames.
EXPECT_LE(network_stats.preferred_buffer_size_ms, kFrameSizeMs * 2);
EXPECT_LE(network_stats.current_buffer_size_ms, kFrameSizeMs * 2 +
algorithmic_delay_ms_);
EXPECT_LE(network_stats.current_buffer_size_ms,
kFrameSizeMs * 2 + algorithmic_delay_ms_);
}
last_seq_no = seq_no;
last_timestamp = timestamp;
@ -1166,8 +1147,8 @@ void NetEqDecodingTest::DuplicateCng() {
const int kSamples = kFrameSizeMs * kSampleRateKhz;
const size_t kPayloadBytes = kSamples * 2;
const int algorithmic_delay_samples = std::max(
algorithmic_delay_ms_ * kSampleRateKhz, 5 * kSampleRateKhz / 8);
const int algorithmic_delay_samples =
std::max(algorithmic_delay_ms_ * kSampleRateKhz, 5 * kSampleRateKhz / 8);
// Insert three speech packets. Three are needed to get the frame length
// correct.
uint8_t payload[kPayloadBytes] = {0};
@ -1239,7 +1220,9 @@ void NetEqDecodingTest::DuplicateCng() {
*playout_timestamp);
}
TEST_F(NetEqDecodingTest, DiscardDuplicateCng) { DuplicateCng(); }
TEST_F(NetEqDecodingTest, DiscardDuplicateCng) {
DuplicateCng();
}
TEST_F(NetEqDecodingTest, CngFirst) {
uint16_t seq_no = 0;
@ -1493,25 +1476,25 @@ namespace {
return ::testing::AssertionFailure() << "timestamp_ diff (" << a.timestamp_
<< " != " << b.timestamp_ << ")";
if (a.sample_rate_hz_ != b.sample_rate_hz_)
return ::testing::AssertionFailure() << "sample_rate_hz_ diff ("
<< a.sample_rate_hz_
<< " != " << b.sample_rate_hz_ << ")";
return ::testing::AssertionFailure()
<< "sample_rate_hz_ diff (" << a.sample_rate_hz_
<< " != " << b.sample_rate_hz_ << ")";
if (a.samples_per_channel_ != b.samples_per_channel_)
return ::testing::AssertionFailure()
<< "samples_per_channel_ diff (" << a.samples_per_channel_
<< " != " << b.samples_per_channel_ << ")";
if (a.num_channels_ != b.num_channels_)
return ::testing::AssertionFailure() << "num_channels_ diff ("
<< a.num_channels_
<< " != " << b.num_channels_ << ")";
return ::testing::AssertionFailure()
<< "num_channels_ diff (" << a.num_channels_
<< " != " << b.num_channels_ << ")";
if (a.speech_type_ != b.speech_type_)
return ::testing::AssertionFailure() << "speech_type_ diff ("
<< a.speech_type_
<< " != " << b.speech_type_ << ")";
return ::testing::AssertionFailure()
<< "speech_type_ diff (" << a.speech_type_
<< " != " << b.speech_type_ << ")";
if (a.vad_activity_ != b.vad_activity_)
return ::testing::AssertionFailure() << "vad_activity_ diff ("
<< a.vad_activity_
<< " != " << b.vad_activity_ << ")";
return ::testing::AssertionFailure()
<< "vad_activity_ diff (" << a.vad_activity_
<< " != " << b.vad_activity_ << ")";
return ::testing::AssertionSuccess();
}
@ -1520,9 +1503,9 @@ namespace {
::testing::AssertionResult res = AudioFramesEqualExceptData(a, b);
if (!res)
return res;
if (memcmp(
a.data(), b.data(),
a.samples_per_channel_ * a.num_channels_ * sizeof(*a.data())) != 0) {
if (memcmp(a.data(), b.data(),
a.samples_per_channel_ * a.num_channels_ * sizeof(*a.data())) !=
0) {
return ::testing::AssertionFailure() << "data_ diff";
}
return ::testing::AssertionSuccess();