Skip to content

Commit

Permalink
Fix clang style errors in rtp_rtcp and dependant targets
Browse files Browse the repository at this point in the history
Mark functions with override instead of virtual.
Add explicit non-trivial constructors/assign operators/destructors.
Define them in .cc files instead of inlining
use auto* instead of auto when deduced type is raw pointer

Bug: webrtc:163
Change-Id: I4d8a05d6a64fcc2ca16d02c5fcf9488fda832a6d
Reviewed-on: https://webrtc-review.googlesource.com/48781
Commit-Queue: Danil Chapovalov <[email protected]>
Reviewed-by: Karl Wiberg <[email protected]>
Cr-Commit-Position: refs/heads/master@{#21927}
  • Loading branch information
DanilChapovalov authored and Commit Bot committed Feb 7, 2018
1 parent 740f8e7 commit 2a5ce2b
Show file tree
Hide file tree
Showing 43 changed files with 189 additions and 65 deletions.
1 change: 1 addition & 0 deletions api/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ rtc_static_library("libjingle_peerconnection_api") {
"rtp_headers.h",
"rtpparameters.cc",
"rtpparameters.h",
"rtpreceiverinterface.cc",
"rtpreceiverinterface.h",
"rtpsenderinterface.h",
"rtptransceiverinterface.h",
Expand Down
13 changes: 13 additions & 0 deletions api/mediastreaminterface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,17 @@ AudioProcessorInterface::GetStats(bool /*has_remote_tracks*/) {
return new_stats;
}

VideoTrackInterface::ContentHint VideoTrackInterface::content_hint() const {
return ContentHint::kNone;
}

bool AudioTrackInterface::GetSignalLevel(int* level) {
return false;
}

rtc::scoped_refptr<AudioProcessorInterface>
AudioTrackInterface::GetAudioProcessor() {
return nullptr;
}

} // namespace webrtc
22 changes: 10 additions & 12 deletions api/mediastreaminterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class MediaSourceInterface : public rtc::RefCountInterface,
virtual bool remote() const = 0;

protected:
virtual ~MediaSourceInterface() {}
~MediaSourceInterface() override = default;
};

// C++ version of MediaStreamTrack.
Expand Down Expand Up @@ -106,7 +106,7 @@ class MediaStreamTrackInterface : public rtc::RefCountInterface,
virtual TrackState state() const = 0;

protected:
virtual ~MediaStreamTrackInterface() {}
~MediaStreamTrackInterface() override = default;
};

// VideoTrackSourceInterface is a reference counted source used for
Expand Down Expand Up @@ -147,7 +147,7 @@ class VideoTrackSourceInterface
virtual bool GetStats(Stats* stats) = 0;

protected:
virtual ~VideoTrackSourceInterface() {}
~VideoTrackSourceInterface() override = default;
};

// VideoTrackInterface is designed to be invoked on the signaling thread except
Expand All @@ -173,11 +173,11 @@ class VideoTrackInterface

virtual VideoTrackSourceInterface* GetSource() const = 0;

virtual ContentHint content_hint() const { return ContentHint::kNone; }
virtual ContentHint content_hint() const;
virtual void set_content_hint(ContentHint hint) {}

protected:
virtual ~VideoTrackInterface() {}
~VideoTrackInterface() override = default;
};

// Interface for receiving audio data from a AudioTrack.
Expand Down Expand Up @@ -269,7 +269,7 @@ class AudioProcessorInterface : public rtc::RefCountInterface {
virtual AudioProcessorStatistics GetStats(bool has_remote_tracks);

protected:
virtual ~AudioProcessorInterface() {}
~AudioProcessorInterface() override = default;
};

class AudioTrackInterface : public MediaStreamTrackInterface {
Expand All @@ -286,17 +286,15 @@ class AudioTrackInterface : public MediaStreamTrackInterface {
// Return true on success, otherwise false.
// TODO(deadbeef): Change the interface to int GetSignalLevel() and pure
// virtual after it's implemented in chromium.
virtual bool GetSignalLevel(int* level) { return false; }
virtual bool GetSignalLevel(int* level);

// Get the audio processor used by the audio track. Return null if the track
// does not have any processor.
// TODO(deadbeef): Make the interface pure virtual.
virtual rtc::scoped_refptr<AudioProcessorInterface> GetAudioProcessor() {
return nullptr;
}
virtual rtc::scoped_refptr<AudioProcessorInterface> GetAudioProcessor();

protected:
virtual ~AudioTrackInterface() {}
~AudioTrackInterface() override = default;
};

typedef std::vector<rtc::scoped_refptr<AudioTrackInterface> >
Expand Down Expand Up @@ -331,7 +329,7 @@ class MediaStreamInterface : public rtc::RefCountInterface,
virtual bool RemoveTrack(VideoTrackInterface* track) = 0;

protected:
virtual ~MediaStreamInterface() {}
~MediaStreamInterface() override = default;
};

} // namespace webrtc
Expand Down
48 changes: 48 additions & 0 deletions api/rtpreceiverinterface.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright 2018 The WebRTC Project Authors. All rights reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/

#include "api/rtpreceiverinterface.h"

namespace webrtc {

RtpSource::RtpSource(int64_t timestamp_ms,
uint32_t source_id,
RtpSourceType source_type)
: timestamp_ms_(timestamp_ms),
source_id_(source_id),
source_type_(source_type) {}

RtpSource::RtpSource(int64_t timestamp_ms,
uint32_t source_id,
RtpSourceType source_type,
uint8_t audio_level)
: timestamp_ms_(timestamp_ms),
source_id_(source_id),
source_type_(source_type),
audio_level_(audio_level) {}

RtpSource::RtpSource(const RtpSource&) = default;
RtpSource& RtpSource::operator=(const RtpSource&) = default;
RtpSource::~RtpSource() = default;

std::vector<rtc::scoped_refptr<MediaStreamInterface>>
RtpReceiverInterface::streams() const {
return {};
}

std::vector<RtpSource> RtpReceiverInterface::GetSources() const {
return {};
}

int RtpReceiverInterface::AttachmentId() const {
return 0;
}

} // namespace webrtc
31 changes: 12 additions & 19 deletions api/rtpreceiverinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,16 @@ enum class RtpSourceType {
class RtpSource {
public:
RtpSource() = delete;
RtpSource(int64_t timestamp_ms, uint32_t source_id, RtpSourceType source_type)
: timestamp_ms_(timestamp_ms),
source_id_(source_id),
source_type_(source_type) {}

RtpSource(int64_t timestamp_ms,
uint32_t source_id,
RtpSourceType source_type);
RtpSource(int64_t timestamp_ms,
uint32_t source_id,
RtpSourceType source_type,
uint8_t audio_level)
: timestamp_ms_(timestamp_ms),
source_id_(source_id),
source_type_(source_type),
audio_level_(audio_level) {}
uint8_t audio_level);
RtpSource(const RtpSource&);
RtpSource& operator=(const RtpSource&);
~RtpSource();

int64_t timestamp_ms() const { return timestamp_ms_; }
void update_timestamp_ms(int64_t timestamp_ms) {
Expand Down Expand Up @@ -98,10 +95,7 @@ class RtpReceiverInterface : public rtc::RefCountInterface {
// the [[AssociatedRemoteMediaStreams]] internal slot in the spec.
// https://w3c.github.io/webrtc-pc/#dfn-x%5B%5Bassociatedremotemediastreams%5D%5D
// TODO(hbos): Make pure virtual as soon as Chromium's mock implements this.
virtual std::vector<rtc::scoped_refptr<MediaStreamInterface>> streams()
const {
return std::vector<rtc::scoped_refptr<MediaStreamInterface>>();
}
virtual std::vector<rtc::scoped_refptr<MediaStreamInterface>> streams() const;

// Audio or video receiver?
virtual cricket::MediaType media_type() const = 0;
Expand All @@ -124,19 +118,18 @@ class RtpReceiverInterface : public rtc::RefCountInterface {
// TODO(zhihuang): Remove the default implementation once the subclasses
// implement this. Currently, the only relevant subclass is the
// content::FakeRtpReceiver in Chromium.
virtual std::vector<RtpSource> GetSources() const {
return std::vector<RtpSource>();
}
virtual std::vector<RtpSource> GetSources() const;

// TODO(hta): Remove default implementation or move function to
// an internal interface. content::FakeRtpReceiver in Chromium needs this.

// Returns an ID that changes if the attached track changes, but
// otherwise remains constant. Used to generate IDs for stats.
// The special value zero means that no track is attached.
virtual int AttachmentId() const { return 0; }
virtual int AttachmentId() const;

protected:
virtual ~RtpReceiverInterface() {}
~RtpReceiverInterface() override = default;
};

// Define proxy for RtpReceiverInterface.
Expand Down
2 changes: 2 additions & 0 deletions common_video/h264/sps_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ typedef rtc::Optional<webrtc::SpsParser::SpsState> OptionalSps;

namespace webrtc {

SpsParser::SpsState::SpsState() = default;

// General note: this is based off the 02/2014 version of the H.264 standard.
// You can find it on this page:
// http://www.itu.int/rec/T-REC-H.264
Expand Down
2 changes: 1 addition & 1 deletion common_video/h264/sps_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class SpsParser {
// The parsed state of the SPS. Only some select values are stored.
// Add more as they are actually needed.
struct SpsState {
SpsState() = default;
SpsState();

uint32_t width = 0;
uint32_t height = 0;
Expand Down
1 change: 1 addition & 0 deletions logging/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ rtc_source_set("rtc_event_log_api") {
sources = [
"rtc_event_log/encoder/rtc_event_log_encoder.h",
"rtc_event_log/events/rtc_event.h",
"rtc_event_log/rtc_event_log.cc",
"rtc_event_log/rtc_event_log.h",
"rtc_event_log/rtc_event_log_factory_interface.h",
]
Expand Down
21 changes: 21 additions & 0 deletions logging/rtc_event_log/rtc_event_log.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/

#include "logging/rtc_event_log/rtc_event_log.h"

namespace webrtc {

bool RtcEventLogNullImpl::StartLogging(
std::unique_ptr<RtcEventLogOutput> output,
int64_t output_period_ms) {
return false;
}

} // namespace webrtc
4 changes: 1 addition & 3 deletions logging/rtc_event_log/rtc_event_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ class RtcEventLog {
class RtcEventLogNullImpl : public RtcEventLog {
public:
bool StartLogging(std::unique_ptr<RtcEventLogOutput> output,
int64_t output_period_ms) override {
return false;
}
int64_t output_period_ms) override;
void StopLogging() override {}
void Log(std::unique_ptr<RtcEvent> event) override {}
};
Expand Down
5 changes: 5 additions & 0 deletions modules/remote_bitrate_estimator/test/bwe_test_logging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ static std::string ToString(uint32_t v) {
return ss.str();
}

Logging::ThreadState::ThreadState() = default;
Logging::ThreadState::~ThreadState() = default;

Logging::Context::Context(uint32_t name, int64_t timestamp_ms, bool enabled) {
Logging::GetInstance()->PushState(ToString(name), timestamp_ms, enabled);
}
Expand Down Expand Up @@ -205,6 +208,8 @@ Logging::Logging()
: thread_map_() {
}

Logging::~Logging() = default;

Logging::State::State() : tag(""), timestamp_ms(0), enabled(true) {}

Logging::State::State(const std::string& tag, int64_t timestamp_ms,
Expand Down
3 changes: 3 additions & 0 deletions modules/remote_bitrate_estimator/test/bwe_test_logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -331,12 +331,15 @@ class Logging {
bool enabled;
};
struct ThreadState {
ThreadState();
~ThreadState();
State global_state;
std::stack<State> stack;
};
typedef std::map<uint32_t, ThreadState> ThreadMap;

Logging();
~Logging();
void PushState(const std::string& append_to_tag, int64_t timestamp_ms,
bool enabled);
void PopState();
Expand Down
5 changes: 0 additions & 5 deletions modules/rtp_rtcp/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,6 @@ rtc_static_library("rtp_rtcp") {
defines = [ "BWE_TEST_LOGGING_COMPILE_TIME_ENABLE=0" ]
}

if (!build_with_chromium && is_clang) {
# Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
}

deps = [
":rtp_rtcp_format",
"..:module_api",
Expand Down
2 changes: 1 addition & 1 deletion modules/rtp_rtcp/source/flexfec_sender.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ bool FlexfecSender::FecAvailable() const {
std::vector<std::unique_ptr<RtpPacketToSend>> FlexfecSender::GetFecPackets() {
std::vector<std::unique_ptr<RtpPacketToSend>> fec_packets_to_send;
fec_packets_to_send.reserve(ulpfec_generator_.generated_fec_packets_.size());
for (const auto& fec_packet : ulpfec_generator_.generated_fec_packets_) {
for (const auto* fec_packet : ulpfec_generator_.generated_fec_packets_) {
std::unique_ptr<RtpPacketToSend> fec_packet_to_send(
new RtpPacketToSend(&rtp_header_extension_map_));

Expand Down
2 changes: 1 addition & 1 deletion modules/rtp_rtcp/source/forward_error_correction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ void ForwardErrorCorrection::AttemptRecovery(
continue;
}

auto recovered_packet_ptr = recovered_packet.get();
auto* recovered_packet_ptr = recovered_packet.get();
// Add recovered packet to the list of recovered packets and update any
// FEC packets covering this packet with a pointer to the data.
// TODO(holmer): Consider replacing this with a binary search for the
Expand Down
4 changes: 3 additions & 1 deletion modules/rtp_rtcp/source/packet_loss_stats.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ PacketLossStats::PacketLossStats()
multiple_loss_historic_packet_count_(0) {
}

PacketLossStats::~PacketLossStats() = default;

void PacketLossStats::AddLostPacket(uint16_t sequence_number) {
// Detect sequence number wrap around.
if (!lost_packets_buffer_.empty() &&
Expand Down Expand Up @@ -77,7 +79,7 @@ void PacketLossStats::ComputeLossCounts(
std::vector<const std::set<uint16_t>*> buffers;
buffers.push_back(&lost_packets_buffer_);
buffers.push_back(&lost_packets_wrapped_buffer_);
for (auto buffer : buffers) {
for (const auto* buffer : buffers) {
for (auto it = buffer->begin(); it != buffer->end(); ++it) {
uint16_t current_num = *it;
if (sequential_count > 0 && current_num != ((last_num + 1) & 0xFFFF)) {
Expand Down
2 changes: 1 addition & 1 deletion modules/rtp_rtcp/source/packet_loss_stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace webrtc {
class PacketLossStats {
public:
PacketLossStats();
~PacketLossStats() {}
~PacketLossStats();

// Adds a lost packet to the stats by sequence number.
void AddLostPacket(uint16_t sequence_number);
Expand Down
2 changes: 2 additions & 0 deletions modules/rtp_rtcp/source/receive_statistics_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ StreamStatisticianImpl::StreamStatisticianImpl(
rtcp_callback_(rtcp_callback),
rtp_callback_(rtp_callback) {}

StreamStatisticianImpl::~StreamStatisticianImpl() = default;

void StreamStatisticianImpl::IncomingPacket(const RTPHeader& header,
size_t packet_length,
bool retransmitted) {
Expand Down
4 changes: 2 additions & 2 deletions modules/rtp_rtcp/source/receive_statistics_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class StreamStatisticianImpl : public StreamStatistician {
Clock* clock,
RtcpStatisticsCallback* rtcp_callback,
StreamDataCountersCallback* rtp_callback);
virtual ~StreamStatisticianImpl() {}
~StreamStatisticianImpl() override;

// |reset| here and in next method restarts calculation of fraction_lost stat.
bool GetStatistics(RtcpStatistics* statistics, bool reset) override;
Expand Down Expand Up @@ -96,7 +96,7 @@ class ReceiveStatisticsImpl : public ReceiveStatistics,
public:
explicit ReceiveStatisticsImpl(Clock* clock);

~ReceiveStatisticsImpl();
~ReceiveStatisticsImpl() override;

// Implement ReceiveStatisticsProvider.
std::vector<rtcp::ReportBlock> RtcpReportBlocks(size_t max_blocks) override;
Expand Down
Loading

0 comments on commit 2a5ce2b

Please sign in to comment.