Skip to content

Commit

Permalink
Reformat the WebRTC code base
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cr-Commit-Position: refs/heads/master@{#23660}
  • Loading branch information
Yves Gerey committed Jun 19, 2018
1 parent b602123 commit 665174f
Show file tree
Hide file tree
Showing 1,569 changed files with 30,937 additions and 30,751 deletions.
2 changes: 1 addition & 1 deletion api/array_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#ifndef API_ARRAY_VIEW_H_
#define API_ARRAY_VIEW_H_

#include <array>
#include <algorithm>
#include <array>
#include <type_traits>

#include "rtc_base/checks.h"
Expand Down
7 changes: 5 additions & 2 deletions api/audio/audio_frame.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ void AudioFrame::UpdateFrame(uint32_t timestamp,
}

void AudioFrame::CopyFrom(const AudioFrame& src) {
if (this == &src) return;
if (this == &src)
return;

timestamp_ = src.timestamp_;
elapsed_time_ms_ = src.elapsed_time_ms_;
Expand Down Expand Up @@ -116,7 +117,9 @@ void AudioFrame::Mute() {
muted_ = true;
}

bool AudioFrame::muted() const { return muted_; }
bool AudioFrame::muted() const {
return muted_;
}

// static
const int16_t* AudioFrame::empty_data() {
Expand Down
15 changes: 7 additions & 8 deletions api/audio/audio_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,7 @@ class AudioFrame {
kMaxDataSizeBytes = kMaxDataSizeSamples * sizeof(int16_t),
};

enum VADActivity {
kVadActive = 0,
kVadPassive = 1,
kVadUnknown = 2
};
enum VADActivity { kVadActive = 0, kVadPassive = 1, kVadUnknown = 2 };
enum SpeechType {
kNormalSpeech = 0,
kPLC = 1,
Expand All @@ -66,9 +62,12 @@ class AudioFrame {
// ResetWithoutMuting() to skip this wasteful zeroing.
void ResetWithoutMuting();

void UpdateFrame(uint32_t timestamp, const int16_t* data,
size_t samples_per_channel, int sample_rate_hz,
SpeechType speech_type, VADActivity vad_activity,
void UpdateFrame(uint32_t timestamp,
const int16_t* data,
size_t samples_per_channel,
int sample_rate_hz,
SpeechType speech_type,
VADActivity vad_activity,
size_t num_channels = 1);

void CopyFrom(const AudioFrame& src);
Expand Down
5 changes: 2 additions & 3 deletions api/audio/test/audio_frame_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,8 @@ TEST(AudioFrameTest, CopyFrom) {
AudioFrame frame2;

int16_t samples[kNumChannels * kSamplesPerChannel] = {17};
frame2.UpdateFrame(kTimestamp, samples, kSamplesPerChannel,
kSampleRateHz, AudioFrame::kPLC, AudioFrame::kVadActive,
kNumChannels);
frame2.UpdateFrame(kTimestamp, samples, kSamplesPerChannel, kSampleRateHz,
AudioFrame::kPLC, AudioFrame::kVadActive, kNumChannels);
frame1.CopyFrom(frame2);

EXPECT_EQ(frame2.timestamp_, frame1.timestamp_);
Expand Down
5 changes: 2 additions & 3 deletions api/audio_codecs/audio_encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,8 @@ class AudioEncoder {

// Provides target audio bitrate and corresponding probing interval of
// the bandwidth estimator to this encoder to allow it to adapt.
virtual void OnReceivedUplinkBandwidth(
int target_audio_bitrate_bps,
rtc::Optional<int64_t> bwe_period_ms);
virtual void OnReceivedUplinkBandwidth(int target_audio_bitrate_bps,
rtc::Optional<int64_t> bwe_period_ms);

// Provides RTT to this encoder to allow it to adapt.
virtual void OnReceivedRtt(int rtt_ms);
Expand Down
2 changes: 1 addition & 1 deletion api/audio_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ struct AudioOptions {
ost << ToStringIfSet("residual_echo_detector", residual_echo_detector);
ost << ToStringIfSet("tx_agc_target_dbov", tx_agc_target_dbov);
ost << ToStringIfSet("tx_agc_digital_compression_gain",
tx_agc_digital_compression_gain);
tx_agc_digital_compression_gain);
ost << ToStringIfSet("tx_agc_limiter", tx_agc_limiter);
ost << ToStringIfSet("combined_audio_video_bwe", combined_audio_video_bwe);
ost << ToStringIfSet("audio_network_adaptor", audio_network_adaptor);
Expand Down
53 changes: 20 additions & 33 deletions api/candidate.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,23 @@ class Candidate {
Candidate(const Candidate&);
~Candidate();

const std::string & id() const { return id_; }
void set_id(const std::string & id) { id_ = id; }
const std::string& id() const { return id_; }
void set_id(const std::string& id) { id_ = id; }

int component() const { return component_; }
void set_component(int component) { component_ = component; }

const std::string & protocol() const { return protocol_; }
void set_protocol(const std::string & protocol) { protocol_ = protocol; }
const std::string& protocol() const { return protocol_; }
void set_protocol(const std::string& protocol) { protocol_ = protocol; }

// The protocol used to talk to relay.
const std::string& relay_protocol() const { return relay_protocol_; }
void set_relay_protocol(const std::string& protocol) {
relay_protocol_ = protocol;
}

const rtc::SocketAddress & address() const { return address_; }
void set_address(const rtc::SocketAddress & address) {
address_ = address;
}
const rtc::SocketAddress& address() const { return address_; }
void set_address(const rtc::SocketAddress& address) { address_ = address; }

uint32_t priority() const { return priority_; }
void set_priority(const uint32_t priority) { priority_ = priority; }
Expand All @@ -91,17 +89,17 @@ class Candidate {
}

// TODO(honghaiz): Change to usernameFragment or ufrag.
const std::string & username() const { return username_; }
void set_username(const std::string & username) { username_ = username; }
const std::string& username() const { return username_; }
void set_username(const std::string& username) { username_ = username; }

const std::string & password() const { return password_; }
void set_password(const std::string & password) { password_ = password; }
const std::string& password() const { return password_; }
void set_password(const std::string& password) { password_ = password; }

const std::string & type() const { return type_; }
void set_type(const std::string & type) { type_ = type; }
const std::string& type() const { return type_; }
void set_type(const std::string& type) { type_ = type; }

const std::string & network_name() const { return network_name_; }
void set_network_name(const std::string & network_name) {
const std::string& network_name() const { return network_name_; }
void set_network_name(const std::string& network_name) {
network_name_ = network_name;
}

Expand All @@ -127,24 +125,17 @@ class Candidate {
uint16_t network_id() const { return network_id_; }
void set_network_id(uint16_t network_id) { network_id_ = network_id; }

const std::string& foundation() const {
return foundation_;
}
const std::string& foundation() const { return foundation_; }
void set_foundation(const std::string& foundation) {
foundation_ = foundation;
}

const rtc::SocketAddress & related_address() const {
return related_address_;
}
void set_related_address(
const rtc::SocketAddress & related_address) {
const rtc::SocketAddress& related_address() const { return related_address_; }
void set_related_address(const rtc::SocketAddress& related_address) {
related_address_ = related_address;
}
const std::string& tcptype() const { return tcptype_; }
void set_tcptype(const std::string& tcptype) {
tcptype_ = tcptype;
}
void set_tcptype(const std::string& tcptype) { tcptype_ = tcptype; }

// The name of the transport channel of this candidate.
// TODO(phoglund): remove.
Expand All @@ -164,13 +155,9 @@ class Candidate {
// given one when looking for a matching candidate to remove.
bool MatchesForRemoval(const Candidate& c) const;

std::string ToString() const {
return ToStringInternal(false);
}
std::string ToString() const { return ToStringInternal(false); }

std::string ToSensitiveString() const {
return ToStringInternal(true);
}
std::string ToSensitiveString() const { return ToStringInternal(true); }

uint32_t GetPriority(uint32_t type_preference,
int network_adapter_preference,
Expand Down
8 changes: 2 additions & 6 deletions api/datachannelinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,10 @@ struct DataChannelInit {
// as binary or text.
struct DataBuffer {
DataBuffer(const rtc::CopyOnWriteBuffer& data, bool binary)
: data(data),
binary(binary) {
}
: data(data), binary(binary) {}
// For convenience for unit tests.
explicit DataBuffer(const std::string& text)
: data(text.data(), text.length()),
binary(false) {
}
: data(text.data(), text.length()), binary(false) {}
size_t size() const { return data.size(); }

rtc::CopyOnWriteBuffer data;
Expand Down
3 changes: 2 additions & 1 deletion api/dtmfsenderinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ class DtmfSenderInterface : public rtc::RefCountInterface {
// If InsertDtmf is called on the same object while an existing task for this
// object to generate DTMF is still running, the previous task is canceled.
// Returns true on success and false on failure.
virtual bool InsertDtmf(const std::string& tones, int duration,
virtual bool InsertDtmf(const std::string& tones,
int duration,
int inter_tone_gap) = 0;

// Returns the track given as argument to the constructor. Only exists for
Expand Down
2 changes: 1 addition & 1 deletion api/fakemetricsobserver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void FakeMetricsObserver::IncrementEnumCounter(
}

void FakeMetricsObserver::AddHistogramSample(PeerConnectionMetricsName type,
int value) {
int value) {
RTC_DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK_EQ(histogram_samples_[type], 0);
histogram_samples_[type] = value;
Expand Down
3 changes: 1 addition & 2 deletions api/fakemetricsobserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ class FakeMetricsObserver : public MetricsObserverInterface {
void IncrementEnumCounter(PeerConnectionEnumCounterType,
int counter,
int counter_max) override;
void AddHistogramSample(PeerConnectionMetricsName type,
int value) override;
void AddHistogramSample(PeerConnectionMetricsName type, int value) override;

// Accessors to be used by the tests.
int GetEnumCounter(PeerConnectionEnumCounterType type, int counter) const;
Expand Down
4 changes: 1 addition & 3 deletions api/jsep.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,7 @@ class CreateSessionDescriptionObserver : public rtc::RefCountInterface {
// is deprecated; in order to let clients remove the old version, it has a
// default implementation. If both versions are unimplemented, the
// result will be a runtime error (stack overflow). This is intentional.
virtual void OnFailure(RTCError error) {
OnFailure(error.message());
}
virtual void OnFailure(RTCError error) { OnFailure(error.message()); }
virtual void OnFailure(const std::string& error) {
OnFailure(RTCError(RTCErrorType::INTERNAL_ERROR, std::string(error)));
}
Expand Down
11 changes: 4 additions & 7 deletions api/jsepicecandidate.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ namespace webrtc {
class JsepIceCandidate : public IceCandidateInterface {
public:
JsepIceCandidate(const std::string& sdp_mid, int sdp_mline_index);
JsepIceCandidate(const std::string& sdp_mid, int sdp_mline_index,
JsepIceCandidate(const std::string& sdp_mid,
int sdp_mline_index,
const cricket::Candidate& candidate);
~JsepIceCandidate();
// |err| may be null.
Expand All @@ -39,9 +40,7 @@ class JsepIceCandidate : public IceCandidateInterface {

virtual std::string sdp_mid() const { return sdp_mid_; }
virtual int sdp_mline_index() const { return sdp_mline_index_; }
virtual const cricket::Candidate& candidate() const {
return candidate_;
}
virtual const cricket::Candidate& candidate() const { return candidate_; }

virtual std::string server_url() const { return candidate_.url(); }

Expand All @@ -64,9 +63,7 @@ class JsepCandidateCollection : public IceCandidateCollection {
JsepCandidateCollection(JsepCandidateCollection&& o)
: candidates_(std::move(o.candidates_)) {}
~JsepCandidateCollection();
virtual size_t count() const {
return candidates_.size();
}
virtual size_t count() const { return candidates_.size(); }
virtual bool HasCandidate(const IceCandidateInterface* candidate) const;
// Adds and takes ownership of the JsepIceCandidate.
// TODO(deadbeef): Make this use an std::unique_ptr<>, so ownership logic is
Expand Down
12 changes: 4 additions & 8 deletions api/jsepsessiondescription.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,17 @@ class JsepSessionDescription : public SessionDescriptionInterface {
// TODO(deadbeef): Make this use an std::unique_ptr<>, so ownership logic is
// more clear.
bool Initialize(cricket::SessionDescription* description,
const std::string& session_id,
const std::string& session_version);
const std::string& session_id,
const std::string& session_version);

virtual cricket::SessionDescription* description() {
return description_.get();
}
virtual const cricket::SessionDescription* description() const {
return description_.get();
}
virtual std::string session_id() const {
return session_id_;
}
virtual std::string session_version() const {
return session_version_;
}
virtual std::string session_id() const { return session_id_; }
virtual std::string session_version() const { return session_version_; }
virtual SdpType GetType() const { return type_; }
virtual std::string type() const { return SdpTypeToString(type_); }
// Allows changing the type. Used for testing.
Expand Down
25 changes: 11 additions & 14 deletions api/mediaconstraintsinterface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ const char MediaConstraintsInterface::kMaxFrameRate[] = "maxFrameRate";
const char MediaConstraintsInterface::kMinFrameRate[] = "minFrameRate";

// Audio constraints.
const char MediaConstraintsInterface::kEchoCancellation[] =
"echoCancellation";
const char MediaConstraintsInterface::kEchoCancellation[] = "echoCancellation";
const char MediaConstraintsInterface::kGoogEchoCancellation[] =
"googEchoCancellation";
const char MediaConstraintsInterface::kExtendedFilterEchoCancellation[] =
Expand All @@ -107,8 +106,7 @@ const char MediaConstraintsInterface::kExperimentalNoiseSuppression[] =
"googNoiseSuppression2";
const char MediaConstraintsInterface::kIntelligibilityEnhancer[] =
"intelligibilityEnhancer";
const char MediaConstraintsInterface::kHighpassFilter[] =
"googHighpassFilter";
const char MediaConstraintsInterface::kHighpassFilter[] = "googHighpassFilter";
const char MediaConstraintsInterface::kTypingNoiseDetection[] =
"googTypingNoiseDetection";
const char MediaConstraintsInterface::kAudioMirroring[] = "googAudioMirroring";
Expand All @@ -125,11 +123,9 @@ const char MediaConstraintsInterface::kOfferToReceiveVideo[] =
"OfferToReceiveVideo";
const char MediaConstraintsInterface::kVoiceActivityDetection[] =
"VoiceActivityDetection";
const char MediaConstraintsInterface::kIceRestart[] =
"IceRestart";
const char MediaConstraintsInterface::kIceRestart[] = "IceRestart";
// Google specific constraint for BUNDLE enable/disable.
const char MediaConstraintsInterface::kUseRtpMux[] =
"googUseRtpMUX";
const char MediaConstraintsInterface::kUseRtpMux[] = "googUseRtpMUX";

// Below constraints should be used during PeerConnection construction.
const char MediaConstraintsInterface::kEnableDtlsSrtp[] =
Expand All @@ -150,11 +146,11 @@ const char MediaConstraintsInterface::kCpuOveruseDetection[] =
"googCpuOveruseDetection";
const char MediaConstraintsInterface::kPayloadPadding[] = "googPayloadPadding";


// Set |value| to the value associated with the first appearance of |key|, or
// return false if |key| is not found.
bool MediaConstraintsInterface::Constraints::FindFirst(
const std::string& key, std::string* value) const {
const std::string& key,
std::string* value) const {
for (Constraints::const_iterator iter = begin(); iter != end(); ++iter) {
if (iter->key == key) {
*value = iter->value;
Expand All @@ -165,7 +161,8 @@ bool MediaConstraintsInterface::Constraints::FindFirst(
}

bool FindConstraint(const MediaConstraintsInterface* constraints,
const std::string& key, bool* value,
const std::string& key,
bool* value,
size_t* mandatory_constraints) {
return ::FindConstraint<bool>(constraints, key, value, mandatory_constraints);
}
Expand All @@ -192,9 +189,9 @@ void CopyConstraintsIntoRtcConfiguration(
}
FindConstraint(constraints, MediaConstraintsInterface::kEnableDscp,
&configuration->media_config.enable_dscp, nullptr);
FindConstraint(
constraints, MediaConstraintsInterface::kCpuOveruseDetection,
&configuration->media_config.video.enable_cpu_adaptation, nullptr);
FindConstraint(constraints, MediaConstraintsInterface::kCpuOveruseDetection,
&configuration->media_config.video.enable_cpu_adaptation,
nullptr);
FindConstraint(constraints, MediaConstraintsInterface::kEnableRtpDataChannels,
&configuration->enable_rtp_data_channel, nullptr);
// Find Suspend Below Min Bitrate constraint.
Expand Down
Loading

0 comments on commit 665174f

Please sign in to comment.