diff --git a/PRESUBMIT.py b/PRESUBMIT.py index a6d41c6515..80e461ab98 100755 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -30,7 +30,6 @@ CPPLINT_BLACKLIST = [ 'modules/utility', 'modules/video_capture', 'p2p', - 'pc', 'rtc_base', 'sdk/android/src/jni', 'sdk/objc', diff --git a/pc/channel_unittest.cc b/pc/channel_unittest.cc index c040854b93..07333b4070 100644 --- a/pc/channel_unittest.cc +++ b/pc/channel_unittest.cc @@ -525,7 +525,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { class ScopedCallThread { public: template - ScopedCallThread(const FunctorT& functor) + explicit ScopedCallThread(const FunctorT& functor) : thread_(rtc::Thread::Create()), task_(new rtc::FunctorMessageHandler(functor)) { thread_->Start(); diff --git a/pc/channelmanager.cc b/pc/channelmanager.cc index 23abdefb59..e597032dc1 100644 --- a/pc/channelmanager.cc +++ b/pc/channelmanager.cc @@ -11,6 +11,7 @@ #include "pc/channelmanager.h" #include +#include #include "media/base/device.h" #include "media/base/rtpdataengine.h" diff --git a/pc/currentspeakermonitor_unittest.cc b/pc/currentspeakermonitor_unittest.cc index 88b18211ab..fa3f0cb7d9 100644 --- a/pc/currentspeakermonitor_unittest.cc +++ b/pc/currentspeakermonitor_unittest.cc @@ -8,6 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include + #include "pc/currentspeakermonitor.h" #include "pc/audiomonitor.h" #include "rtc_base/gunit.h" diff --git a/pc/datachannel.cc b/pc/datachannel.cc index c342908580..9bc16df9cb 100644 --- a/pc/datachannel.cc +++ b/pc/datachannel.cc @@ -180,7 +180,7 @@ bool DataChannel::Init(const InternalDataChannelInit& config) { case webrtc::InternalDataChannelInit::kAcker: handshake_state_ = kHandshakeShouldSendAck; break; - }; + } // Try to connect to the transport in case the transport channel already // exists. diff --git a/pc/datachannel_unittest.cc b/pc/datachannel_unittest.cc index 7acfa8e0f7..f8e98808d5 100644 --- a/pc/datachannel_unittest.cc +++ b/pc/datachannel_unittest.cc @@ -9,6 +9,7 @@ */ #include +#include #include "pc/datachannel.h" #include "pc/sctputils.h" diff --git a/pc/externalhmac.cc b/pc/externalhmac.cc index 6c6d000a05..91f7412945 100644 --- a/pc/externalhmac.cc +++ b/pc/externalhmac.cc @@ -80,7 +80,7 @@ srtp_err_status_t external_hmac_alloc(srtp_auth_t** a, return srtp_err_status_alloc_fail; // Set pointers - *a = (srtp_auth_t *)pointer; + *a = reinterpret_cast(pointer); // |external_hmac| is const and libsrtp expects |type| to be non-const. // const conversion is required. |external_hmac| is constant because we don't // want to increase global count in Chrome. @@ -95,7 +95,8 @@ srtp_err_status_t external_hmac_alloc(srtp_auth_t** a, srtp_err_status_t external_hmac_dealloc(srtp_auth_t* a) { // Zeroize entire state - memset((uint8_t *)a, 0, sizeof(ExternalHmacContext) + sizeof(srtp_auth_t)); + memset(reinterpret_cast(a), 0, + sizeof(ExternalHmacContext) + sizeof(srtp_auth_t)); // Free memory delete[] a; diff --git a/pc/mediasession.cc b/pc/mediasession.cc index 835f76d1cf..3ca1074d79 100644 --- a/pc/mediasession.cc +++ b/pc/mediasession.cc @@ -2430,9 +2430,9 @@ const DataContentDescription* GetFirstDataContentDescription( // Non-const versions of the above functions. // -ContentInfo* GetFirstMediaContent(ContentInfos& contents, +ContentInfo* GetFirstMediaContent(ContentInfos* contents, MediaType media_type) { - for (ContentInfo& content : contents) { + for (ContentInfo& content : *contents) { if (IsMediaContentOfType(&content, media_type)) { return &content; } @@ -2440,15 +2440,15 @@ ContentInfo* GetFirstMediaContent(ContentInfos& contents, return nullptr; } -ContentInfo* GetFirstAudioContent(ContentInfos& contents) { +ContentInfo* GetFirstAudioContent(ContentInfos* contents) { return GetFirstMediaContent(contents, MEDIA_TYPE_AUDIO); } -ContentInfo* GetFirstVideoContent(ContentInfos& contents) { +ContentInfo* GetFirstVideoContent(ContentInfos* contents) { return GetFirstMediaContent(contents, MEDIA_TYPE_VIDEO); } -ContentInfo* GetFirstDataContent(ContentInfos& contents) { +ContentInfo* GetFirstDataContent(ContentInfos* contents) { return GetFirstMediaContent(contents, MEDIA_TYPE_DATA); } @@ -2458,7 +2458,7 @@ static ContentInfo* GetFirstMediaContent(SessionDescription* sdesc, return nullptr; } - return GetFirstMediaContent(sdesc->contents(), media_type); + return GetFirstMediaContent(&sdesc->contents(), media_type); } ContentInfo* GetFirstAudioContent(SessionDescription* sdesc) { diff --git a/pc/mediasession.h b/pc/mediasession.h index 6de9de9e30..513f645b4b 100644 --- a/pc/mediasession.h +++ b/pc/mediasession.h @@ -618,10 +618,10 @@ const DataContentDescription* GetFirstDataContentDescription( const SessionDescription* sdesc); // Non-const versions of the above functions. // Useful when modifying an existing description. -ContentInfo* GetFirstMediaContent(ContentInfos& contents, MediaType media_type); -ContentInfo* GetFirstAudioContent(ContentInfos& contents); -ContentInfo* GetFirstVideoContent(ContentInfos& contents); -ContentInfo* GetFirstDataContent(ContentInfos& contents); +ContentInfo* GetFirstMediaContent(ContentInfos* contents, MediaType media_type); +ContentInfo* GetFirstAudioContent(ContentInfos* contents); +ContentInfo* GetFirstVideoContent(ContentInfos* contents); +ContentInfo* GetFirstDataContent(ContentInfos* contents); ContentInfo* GetFirstAudioContent(SessionDescription* sdesc); ContentInfo* GetFirstVideoContent(SessionDescription* sdesc); ContentInfo* GetFirstDataContent(SessionDescription* sdesc); diff --git a/pc/mediasession_unittest.cc b/pc/mediasession_unittest.cc index 867640cf20..583362dd42 100644 --- a/pc/mediasession_unittest.cc +++ b/pc/mediasession_unittest.cc @@ -256,7 +256,16 @@ std::vector::iterator FindFirstMediaDescriptionByMid( return std::find_if( opts->media_description_options.begin(), opts->media_description_options.end(), - [mid](const MediaDescriptionOptions& t) { return t.mid == mid; }); + [&mid](const MediaDescriptionOptions& t) { return t.mid == mid; }); +} + +std::vector::const_iterator +FindFirstMediaDescriptionByMid(const std::string& mid, + const MediaSessionOptions& opts) { + return std::find_if( + opts.media_description_options.begin(), + opts.media_description_options.end(), + [&mid](const MediaDescriptionOptions& t) { return t.mid == mid; }); } // Add a media section to the |session_options|. @@ -402,7 +411,7 @@ class MediaSessionDescriptionFactoryTest : public testing::Test { } void TestTransportInfo(bool offer, - MediaSessionOptions& options, + const MediaSessionOptions& options, bool has_current_desc) { const std::string current_audio_ufrag = "current_audio_ufrag"; const std::string current_audio_pwd = "current_audio_pwd"; @@ -448,7 +457,7 @@ class MediaSessionDescriptionFactoryTest : public testing::Test { ti_audio->description.ice_pwd.size()); } auto media_desc_options_it = - FindFirstMediaDescriptionByMid("audio", &options); + FindFirstMediaDescriptionByMid("audio", options); EXPECT_EQ( media_desc_options_it->transport_options.enable_ice_renomination, GetIceRenomination(ti_audio)); @@ -476,7 +485,7 @@ class MediaSessionDescriptionFactoryTest : public testing::Test { } } auto media_desc_options_it = - FindFirstMediaDescriptionByMid("video", &options); + FindFirstMediaDescriptionByMid("video", options); EXPECT_EQ( media_desc_options_it->transport_options.enable_ice_renomination, GetIceRenomination(ti_video)); @@ -503,7 +512,7 @@ class MediaSessionDescriptionFactoryTest : public testing::Test { } } auto media_desc_options_it = - FindFirstMediaDescriptionByMid("data", &options); + FindFirstMediaDescriptionByMid("data", options); EXPECT_EQ( media_desc_options_it->transport_options.enable_ice_renomination, GetIceRenomination(ti_data)); diff --git a/pc/mediastream.cc b/pc/mediastream.cc index 0d6fcdab1e..eb78a8bf85 100644 --- a/pc/mediastream.cc +++ b/pc/mediastream.cc @@ -25,7 +25,7 @@ static typename V::iterator FindTrack(V* vector, } } return it; -}; +} rtc::scoped_refptr MediaStream::Create( const std::string& label) { diff --git a/pc/peerconnection.cc b/pc/peerconnection.cc index 0420b602f6..03d34d0246 100644 --- a/pc/peerconnection.cc +++ b/pc/peerconnection.cc @@ -206,8 +206,8 @@ template void SetChannelOnSendersAndReceivers(CHANNEL* channel, - SENDERS& senders, - RECEIVERS& receivers, + const SENDERS& senders, + const RECEIVERS& receivers, cricket::MediaType media_type) { for (auto& sender : senders) { if (sender->media_type() == media_type) { diff --git a/pc/peerconnectionendtoend_unittest.cc b/pc/peerconnectionendtoend_unittest.cc index bc80e1e6e2..dce69dabcc 100644 --- a/pc/peerconnectionendtoend_unittest.cc +++ b/pc/peerconnectionendtoend_unittest.cc @@ -184,7 +184,7 @@ std::unique_ptr CreateForwardingMockDecoder( std::unique_ptr real_decoder) { class ForwardingMockDecoder : public StrictMock { public: - ForwardingMockDecoder(std::unique_ptr decoder) + explicit ForwardingMockDecoder(std::unique_ptr decoder) : decoder_(std::move(decoder)) {} private: diff --git a/pc/peerconnectionfactory.cc b/pc/peerconnectionfactory.cc index dc84d76d01..2dcc4e5cda 100644 --- a/pc/peerconnectionfactory.cc +++ b/pc/peerconnectionfactory.cc @@ -106,7 +106,7 @@ PeerConnectionFactory::PeerConnectionFactory( } } - // TODO: Currently there is no way creating an external adm in + // TODO(deadbeef): Currently there is no way to create an external adm in // libjingle source tree. So we can 't currently assert if this is NULL. // RTC_DCHECK(default_adm != NULL); } diff --git a/pc/peerconnectionfactory.h b/pc/peerconnectionfactory.h index f5faeccc2c..398221ffde 100644 --- a/pc/peerconnectionfactory.h +++ b/pc/peerconnectionfactory.h @@ -49,7 +49,7 @@ class PeerConnectionFactory : public PeerConnectionFactoryInterface { std::unique_ptr cert_generator, PeerConnectionObserver* observer) override; - virtual rtc::scoped_refptr CreatePeerConnection( + rtc::scoped_refptr CreatePeerConnection( const PeerConnectionInterface::RTCConfiguration& configuration, std::unique_ptr allocator, std::unique_ptr cert_generator, @@ -60,13 +60,13 @@ class PeerConnectionFactory : public PeerConnectionFactoryInterface { rtc::scoped_refptr CreateLocalMediaStream(const std::string& label) override; - virtual rtc::scoped_refptr CreateAudioSource( + rtc::scoped_refptr CreateAudioSource( const cricket::AudioOptions& options) override; // Deprecated, use version without constraints. rtc::scoped_refptr CreateAudioSource( const MediaConstraintsInterface* constraints) override; - virtual rtc::scoped_refptr CreateVideoSource( + rtc::scoped_refptr CreateVideoSource( std::unique_ptr capturer) override; // This version supports filtering on width, height and frame rate. // For the "constraints=null" case, use the version without constraints. diff --git a/pc/peerconnectionfactory_unittest.cc b/pc/peerconnectionfactory_unittest.cc index 6fba8fa6dd..a1bdbf5af5 100644 --- a/pc/peerconnectionfactory_unittest.cc +++ b/pc/peerconnectionfactory_unittest.cc @@ -11,6 +11,7 @@ #include #include #include +#include #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" diff --git a/pc/peerconnectionwrapper.cc b/pc/peerconnectionwrapper.cc index 070deb9ddb..ddfa5a6907 100644 --- a/pc/peerconnectionwrapper.cc +++ b/pc/peerconnectionwrapper.cc @@ -13,6 +13,7 @@ #include #include #include +#include #include "api/jsepsessiondescription.h" #include "media/base/fakevideocapturer.h" diff --git a/pc/peerconnectionwrapper.h b/pc/peerconnectionwrapper.h index 88d2f07f57..2554f1f499 100644 --- a/pc/peerconnectionwrapper.h +++ b/pc/peerconnectionwrapper.h @@ -14,6 +14,7 @@ #include #include #include +#include #include "api/peerconnectioninterface.h" #include "pc/test/mockpeerconnectionobservers.h" diff --git a/pc/rtcstats_integrationtest.cc b/pc/rtcstats_integrationtest.cc index e0fb577a15..3da108300e 100644 --- a/pc/rtcstats_integrationtest.cc +++ b/pc/rtcstats_integrationtest.cc @@ -56,15 +56,16 @@ class RTCStatsReportTraceListener { } private: - static void AddTraceEventHandler(char phase, - const unsigned char* category_enabled, - const char* name, - unsigned long long id, - int num_args, - const char** arg_names, - const unsigned char* arg_types, - const unsigned long long* arg_values, - unsigned char flags) { + static void AddTraceEventHandler( + char phase, + const unsigned char* category_enabled, + const char* name, + unsigned long long id, // NOLINT(runtime/int) + int num_args, + const char** arg_names, + const unsigned char* arg_types, + const unsigned long long* arg_values, // NOLINT(runtime/int) + unsigned char flags) { RTC_DCHECK(traced_report_); EXPECT_STREQ("webrtc_stats", reinterpret_cast(category_enabled)); diff --git a/pc/rtcstatscollector.cc b/pc/rtcstatscollector.cc index d20f2ed2fc..12a6f5a780 100644 --- a/pc/rtcstatscollector.cc +++ b/pc/rtcstatscollector.cc @@ -12,6 +12,7 @@ #include #include +#include #include #include diff --git a/pc/rtcstatscollector.h b/pc/rtcstatscollector.h index a3a9c1e466..6effe73384 100644 --- a/pc/rtcstatscollector.h +++ b/pc/rtcstatscollector.h @@ -14,6 +14,7 @@ #include #include #include +#include #include #include "api/optional.h" diff --git a/pc/rtcstatscollector_unittest.cc b/pc/rtcstatscollector_unittest.cc index a5c2ee12cf..71b37976cc 100644 --- a/pc/rtcstatscollector_unittest.cc +++ b/pc/rtcstatscollector_unittest.cc @@ -14,6 +14,7 @@ #include #include #include +#include #include #include "api/jsepsessiondescription.h" @@ -181,9 +182,8 @@ class FakeAudioTrackForStats return audio_track_stats; } - FakeAudioTrackForStats(const std::string& id) - : MediaStreamTrack(id) { - } + explicit FakeAudioTrackForStats(const std::string& id) + : MediaStreamTrack(id) {} std::string kind() const override { return MediaStreamTrackInterface::kAudioKind; @@ -209,9 +209,8 @@ class FakeVideoTrackForStats return video_track; } - FakeVideoTrackForStats(const std::string& id) - : MediaStreamTrack(id) { - } + explicit FakeVideoTrackForStats(const std::string& id) + : MediaStreamTrack(id) {} std::string kind() const override { return MediaStreamTrackInterface::kVideoKind; diff --git a/pc/rtpreceiver.cc b/pc/rtpreceiver.cc index 4f88f1c0be..4dc9167723 100644 --- a/pc/rtpreceiver.cc +++ b/pc/rtpreceiver.cc @@ -10,6 +10,8 @@ #include "pc/rtpreceiver.h" +#include + #include "api/mediastreamtrackproxy.h" #include "api/videosourceproxy.h" #include "pc/audiotrack.h" diff --git a/pc/rtpreceiver.h b/pc/rtpreceiver.h index 6b9ca99bac..d3f0f2679e 100644 --- a/pc/rtpreceiver.h +++ b/pc/rtpreceiver.h @@ -18,6 +18,7 @@ #include #include +#include #include "api/mediastreaminterface.h" #include "api/rtpreceiverinterface.h" diff --git a/pc/rtpsender.cc b/pc/rtpsender.cc index 3d5594c13c..ac3a03cfba 100644 --- a/pc/rtpsender.cc +++ b/pc/rtpsender.cc @@ -10,6 +10,8 @@ #include "pc/rtpsender.h" +#include + #include "api/mediastreaminterface.h" #include "pc/localaudiosource.h" #include "rtc_base/checks.h" diff --git a/pc/rtpsender.h b/pc/rtpsender.h index 672637f385..ce8c657199 100644 --- a/pc/rtpsender.h +++ b/pc/rtpsender.h @@ -17,6 +17,7 @@ #include #include +#include #include "api/mediastreaminterface.h" #include "api/rtpsenderinterface.h" diff --git a/pc/sdputils.cc b/pc/sdputils.cc index 8932bea033..9bcbc439cd 100644 --- a/pc/sdputils.cc +++ b/pc/sdputils.cc @@ -10,6 +10,7 @@ #include "pc/sdputils.h" +#include #include #include "api/jsepsessiondescription.h" diff --git a/pc/sdputils.h b/pc/sdputils.h index 3a53a41756..7444aa72cd 100644 --- a/pc/sdputils.h +++ b/pc/sdputils.h @@ -13,6 +13,7 @@ #include #include +#include #include "api/jsep.h" #include "p2p/base/sessiondescription.h" diff --git a/pc/srtpfilter_unittest.cc b/pc/srtpfilter_unittest.cc index a71762c54e..52f3afaac4 100644 --- a/pc/srtpfilter_unittest.cc +++ b/pc/srtpfilter_unittest.cc @@ -21,21 +21,21 @@ using cricket::CS_REMOTE; namespace rtc { -static const std::string kTestKeyParams1 = +static const char kTestKeyParams1[] = "inline:WVNfX19zZW1jdGwgKCkgewkyMjA7fQp9CnVubGVz"; -static const std::string kTestKeyParams2 = +static const char kTestKeyParams2[] = "inline:PS1uQCVeeCFCanVmcjkpPywjNWhcYD0mXXtxaVBR"; -static const std::string kTestKeyParams3 = +static const char kTestKeyParams3[] = "inline:1234X19zZW1jdGwgKCkgewkyMjA7fQp9CnVubGVz"; -static const std::string kTestKeyParams4 = +static const char kTestKeyParams4[] = "inline:4567QCVeeCFCanVmcjkpPywjNWhcYD0mXXtxaVBR"; -static const std::string kTestKeyParamsGcm1 = +static const char kTestKeyParamsGcm1[] = "inline:e166KFlKzJsGW0d5apX+rrI05vxbrvMJEzFI14aTDCa63IRTlLK4iH66uOI="; -static const std::string kTestKeyParamsGcm2 = +static const char kTestKeyParamsGcm2[] = "inline:6X0oCd55zfz4VgtOwsuqcFq61275PDYN5uwuu3p7ZUHbfUY2FMpdP4m2PEo="; -static const std::string kTestKeyParamsGcm3 = +static const char kTestKeyParamsGcm3[] = "inline:YKlABGZWMgX32xuMotrG0v0T7G83veegaVzubQ=="; -static const std::string kTestKeyParamsGcm4 = +static const char kTestKeyParamsGcm4[] = "inline:gJ6tWoUym2v+/F6xjr7xaxiS3QbJJozl3ZD/0A=="; static const cricket::CryptoParams kTestCryptoParams1( 1, "AES_CM_128_HMAC_SHA1_80", kTestKeyParams1, ""); diff --git a/pc/srtptransport.cc b/pc/srtptransport.cc index aa76aa2f5e..0270da27fa 100644 --- a/pc/srtptransport.cc +++ b/pc/srtptransport.cc @@ -11,6 +11,7 @@ #include "pc/srtptransport.h" #include +#include #include "media/base/rtputils.h" #include "pc/rtptransport.h" diff --git a/pc/srtptransport.h b/pc/srtptransport.h index 9f20e1d8f6..03c353c530 100644 --- a/pc/srtptransport.h +++ b/pc/srtptransport.h @@ -14,6 +14,7 @@ #include #include #include +#include #include "pc/rtptransportinternal.h" #include "pc/srtpfilter.h" diff --git a/pc/srtptransport_unittest.cc b/pc/srtptransport_unittest.cc index d3bc259a05..d551c83b94 100644 --- a/pc/srtptransport_unittest.cc +++ b/pc/srtptransport_unittest.cc @@ -8,6 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include + #include "pc/srtptransport.h" #include "media/base/fakertp.h" @@ -141,14 +143,14 @@ class SrtpTransportTest : public testing::Test, public sigslot::has_slots<> { TestRtpAuthParams(srtp_transport1_.get(), cipher_suite_name); } else { ASSERT_TRUE(last_recv_packet2_.data()); - EXPECT_TRUE( - memcmp(last_recv_packet2_.data(), original_rtp_data, rtp_len) == 0); + EXPECT_EQ(0, + memcmp(last_recv_packet2_.data(), original_rtp_data, rtp_len)); // Get the encrypted packet from underneath packet transport and verify // the data is actually encrypted. auto fake_rtp_packet_transport = static_cast( srtp_transport1_->rtp_packet_transport()); - EXPECT_FALSE(memcmp(fake_rtp_packet_transport->last_sent_packet()->data(), - original_rtp_data, rtp_len) == 0); + EXPECT_NE(0, memcmp(fake_rtp_packet_transport->last_sent_packet()->data(), + original_rtp_data, rtp_len)); } // Do the same thing in the opposite direction; @@ -158,12 +160,12 @@ class SrtpTransportTest : public testing::Test, public sigslot::has_slots<> { TestRtpAuthParams(srtp_transport2_.get(), cipher_suite_name); } else { ASSERT_TRUE(last_recv_packet1_.data()); - EXPECT_TRUE( - memcmp(last_recv_packet1_.data(), original_rtp_data, rtp_len) == 0); + EXPECT_EQ(0, + memcmp(last_recv_packet1_.data(), original_rtp_data, rtp_len)); auto fake_rtp_packet_transport = static_cast( srtp_transport2_->rtp_packet_transport()); - EXPECT_FALSE(memcmp(fake_rtp_packet_transport->last_sent_packet()->data(), - original_rtp_data, rtp_len) == 0); + EXPECT_NE(0, memcmp(fake_rtp_packet_transport->last_sent_packet()->data(), + original_rtp_data, rtp_len)); } } @@ -186,25 +188,23 @@ class SrtpTransportTest : public testing::Test, public sigslot::has_slots<> { ASSERT_TRUE(srtp_transport1_->SendRtcpPacket(&rtcp_packet1to2, options, cricket::PF_SRTP_BYPASS)); ASSERT_TRUE(last_recv_packet2_.data()); - EXPECT_TRUE(memcmp(last_recv_packet2_.data(), rtcp_packet_data, rtcp_len) == - 0); + EXPECT_EQ(0, memcmp(last_recv_packet2_.data(), rtcp_packet_data, rtcp_len)); // Get the encrypted packet from underneath packet transport and verify the // data is actually encrypted. auto fake_rtp_packet_transport = static_cast( srtp_transport1_->rtp_packet_transport()); - EXPECT_FALSE(memcmp(fake_rtp_packet_transport->last_sent_packet()->data(), - rtcp_packet_data, rtcp_len) == 0); + EXPECT_NE(0, memcmp(fake_rtp_packet_transport->last_sent_packet()->data(), + rtcp_packet_data, rtcp_len)); // Do the same thing in the opposite direction; ASSERT_TRUE(srtp_transport2_->SendRtcpPacket(&rtcp_packet2to1, options, cricket::PF_SRTP_BYPASS)); ASSERT_TRUE(last_recv_packet1_.data()); - EXPECT_TRUE(memcmp(last_recv_packet1_.data(), rtcp_packet_data, rtcp_len) == - 0); + EXPECT_EQ(0, memcmp(last_recv_packet1_.data(), rtcp_packet_data, rtcp_len)); fake_rtp_packet_transport = static_cast( srtp_transport2_->rtp_packet_transport()); - EXPECT_FALSE(memcmp(fake_rtp_packet_transport->last_sent_packet()->data(), - rtcp_packet_data, rtcp_len) == 0); + EXPECT_NE(0, memcmp(fake_rtp_packet_transport->last_sent_packet()->data(), + rtcp_packet_data, rtcp_len)); } void TestSendRecvPacket(bool enable_external_auth, @@ -267,14 +267,13 @@ class SrtpTransportTest : public testing::Test, public sigslot::has_slots<> { ASSERT_TRUE(srtp_transport1_->SendRtpPacket(&rtp_packet1to2, options, cricket::PF_SRTP_BYPASS)); ASSERT_TRUE(last_recv_packet2_.data()); - EXPECT_TRUE(memcmp(last_recv_packet2_.data(), original_rtp_data, rtp_len) == - 0); + EXPECT_EQ(0, memcmp(last_recv_packet2_.data(), original_rtp_data, rtp_len)); // Get the encrypted packet from underneath packet transport and verify the // data and header extension are actually encrypted. auto fake_rtp_packet_transport = static_cast( srtp_transport1_->rtp_packet_transport()); - EXPECT_FALSE(memcmp(fake_rtp_packet_transport->last_sent_packet()->data(), - original_rtp_data, rtp_len) == 0); + EXPECT_NE(0, memcmp(fake_rtp_packet_transport->last_sent_packet()->data(), + original_rtp_data, rtp_len)); CompareHeaderExtensions( reinterpret_cast( fake_rtp_packet_transport->last_sent_packet()->data()), @@ -285,12 +284,11 @@ class SrtpTransportTest : public testing::Test, public sigslot::has_slots<> { ASSERT_TRUE(srtp_transport2_->SendRtpPacket(&rtp_packet2to1, options, cricket::PF_SRTP_BYPASS)); ASSERT_TRUE(last_recv_packet1_.data()); - EXPECT_TRUE(memcmp(last_recv_packet1_.data(), original_rtp_data, rtp_len) == - 0); + EXPECT_EQ(0, memcmp(last_recv_packet1_.data(), original_rtp_data, rtp_len)); fake_rtp_packet_transport = static_cast( srtp_transport2_->rtp_packet_transport()); - EXPECT_FALSE(memcmp(fake_rtp_packet_transport->last_sent_packet()->data(), - original_rtp_data, rtp_len) == 0); + EXPECT_NE(0, memcmp(fake_rtp_packet_transport->last_sent_packet()->data(), + original_rtp_data, rtp_len)); CompareHeaderExtensions( reinterpret_cast( fake_rtp_packet_transport->last_sent_packet()->data()), diff --git a/pc/statscollector.cc b/pc/statscollector.cc index 919ea464f3..15fe173082 100644 --- a/pc/statscollector.cc +++ b/pc/statscollector.cc @@ -74,13 +74,14 @@ StatsReport* AddTrackReport(StatsCollection* reports, } template -void CreateTrackReports(const TrackVector& tracks, StatsCollection* reports, - TrackIdMap& track_ids) { +void CreateTrackReports(const TrackVector& tracks, + StatsCollection* reports, + TrackIdMap* track_ids) { for (const auto& track : tracks) { const std::string& track_id = track->id(); StatsReport* report = AddTrackReport(reports, track_id); RTC_DCHECK(report != nullptr); - track_ids[track_id] = report; + (*track_ids)[track_id] = report; } } @@ -463,10 +464,10 @@ void StatsCollector::AddStream(MediaStreamInterface* stream) { RTC_DCHECK(pc_->signaling_thread()->IsCurrent()); RTC_DCHECK(stream != NULL); - CreateTrackReports(stream->GetAudioTracks(), - &reports_, track_ids_); - CreateTrackReports(stream->GetVideoTracks(), - &reports_, track_ids_); + CreateTrackReports(stream->GetAudioTracks(), &reports_, + &track_ids_); + CreateTrackReports(stream->GetVideoTracks(), &reports_, + &track_ids_); } void StatsCollector::AddLocalAudioTrack(AudioTrackInterface* audio_track, diff --git a/pc/statscollector.h b/pc/statscollector.h index 5c9006646a..bdfe64b958 100644 --- a/pc/statscollector.h +++ b/pc/statscollector.h @@ -16,6 +16,7 @@ #include #include +#include #include #include "api/mediastreaminterface.h" diff --git a/pc/statscollector_unittest.cc b/pc/statscollector_unittest.cc index 5e34f7f4e3..48e89595b1 100644 --- a/pc/statscollector_unittest.cc +++ b/pc/statscollector_unittest.cc @@ -12,6 +12,7 @@ #include #include +#include #include "pc/statscollector.h" diff --git a/pc/test/fakeaudiocapturemodule.h b/pc/test/fakeaudiocapturemodule.h index 25edea7dee..aa10efc0e1 100644 --- a/pc/test/fakeaudiocapturemodule.h +++ b/pc/test/fakeaudiocapturemodule.h @@ -164,7 +164,7 @@ class FakeAudioCaptureModule // exposed in which case the burden of proper instantiation would be put on // the creator of a FakeAudioCaptureModule instance. To create an instance of // this class use the Create(..) API. - explicit FakeAudioCaptureModule(); + FakeAudioCaptureModule(); // The destructor is protected because it is reference counted and should not // be deleted directly. virtual ~FakeAudioCaptureModule(); @@ -201,11 +201,11 @@ class FakeAudioCaptureModule // Callback for playout and recording. webrtc::AudioTransport* audio_callback_; - bool recording_; // True when audio is being pushed from the instance. - bool playing_; // True when audio is being pulled by the instance. + bool recording_; // True when audio is being pushed from the instance. + bool playing_; // True when audio is being pulled by the instance. - bool play_is_initialized_; // True when the instance is ready to pull audio. - bool rec_is_initialized_; // True when the instance is ready to push audio. + bool play_is_initialized_; // True when the instance is ready to pull audio. + bool rec_is_initialized_; // True when the instance is ready to push audio. // Input to and output from RecordedDataIsAvailable(..) makes it possible to // modify the current mic level. The implementation does not care about the diff --git a/pc/test/fakedatachannelprovider.h b/pc/test/fakedatachannelprovider.h index bafcb17bc1..2ac4f94309 100644 --- a/pc/test/fakedatachannelprovider.h +++ b/pc/test/fakedatachannelprovider.h @@ -11,6 +11,8 @@ #ifndef PC_TEST_FAKEDATACHANNELPROVIDER_H_ #define PC_TEST_FAKEDATACHANNELPROVIDER_H_ +#include + #include "pc/datachannel.h" #include "rtc_base/checks.h" diff --git a/pc/test/fakevideotrackrenderer.h b/pc/test/fakevideotrackrenderer.h index caec548ec2..617261ae92 100644 --- a/pc/test/fakevideotrackrenderer.h +++ b/pc/test/fakevideotrackrenderer.h @@ -18,7 +18,7 @@ namespace webrtc { class FakeVideoTrackRenderer : public cricket::FakeVideoRenderer { public: - FakeVideoTrackRenderer(VideoTrackInterface* video_track) + explicit FakeVideoTrackRenderer(VideoTrackInterface* video_track) : video_track_(video_track) { video_track_->AddOrUpdateSink(this, rtc::VideoSinkWants()); } diff --git a/pc/test/mock_datachannel.h b/pc/test/mock_datachannel.h index 4a77a6bf60..20a4da664a 100644 --- a/pc/test/mock_datachannel.h +++ b/pc/test/mock_datachannel.h @@ -11,6 +11,8 @@ #ifndef PC_TEST_MOCK_DATACHANNEL_H_ #define PC_TEST_MOCK_DATACHANNEL_H_ +#include + #include "pc/datachannel.h" #include "test/gmock.h" diff --git a/pc/test/mock_peerconnection.h b/pc/test/mock_peerconnection.h index 7944a4d966..d57ada8216 100644 --- a/pc/test/mock_peerconnection.h +++ b/pc/test/mock_peerconnection.h @@ -11,6 +11,7 @@ #ifndef PC_TEST_MOCK_PEERCONNECTION_H_ #define PC_TEST_MOCK_PEERCONNECTION_H_ +#include #include #include "call/call.h" diff --git a/pc/test/mock_webrtcsession.h b/pc/test/mock_webrtcsession.h index afd147381d..e027d0b8e9 100644 --- a/pc/test/mock_webrtcsession.h +++ b/pc/test/mock_webrtcsession.h @@ -28,10 +28,11 @@ class MockWebRtcSession : public webrtc::WebRtcSession { // http://crbug.com/428099. explicit MockWebRtcSession(cricket::ChannelManager* channel_manager, const cricket::MediaConfig& media_config) - : WebRtcSession(nullptr /* Call */, + : WebRtcSession( + nullptr, // call channel_manager, media_config, - nullptr, // event_log + nullptr, // event_log rtc::Thread::Current(), rtc::Thread::Current(), rtc::Thread::Current(), diff --git a/pc/test/mockpeerconnectionobservers.h b/pc/test/mockpeerconnectionobservers.h index 845dbc7ce7..9128b8c378 100644 --- a/pc/test/mockpeerconnectionobservers.h +++ b/pc/test/mockpeerconnectionobservers.h @@ -16,6 +16,8 @@ #include #include +#include +#include #include "api/datachannelinterface.h" #include "api/jsepicecandidate.h" diff --git a/pc/test/peerconnectiontestwrapper.cc b/pc/test/peerconnectiontestwrapper.cc index cc912171a2..6d28ef8111 100644 --- a/pc/test/peerconnectiontestwrapper.cc +++ b/pc/test/peerconnectiontestwrapper.cc @@ -8,6 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include #include #include "p2p/base/fakeportallocator.h" diff --git a/pc/test/peerconnectiontestwrapper.h b/pc/test/peerconnectiontestwrapper.h index d9488b45bb..aadaa8e3e4 100644 --- a/pc/test/peerconnectiontestwrapper.h +++ b/pc/test/peerconnectiontestwrapper.h @@ -12,6 +12,7 @@ #define PC_TEST_PEERCONNECTIONTESTWRAPPER_H_ #include +#include #include "api/peerconnectioninterface.h" #include "api/test/fakeconstraints.h" @@ -52,7 +53,7 @@ class PeerConnectionTestWrapper void OnRemoveStream( rtc::scoped_refptr stream) override {} void OnDataChannel( - rtc::scoped_refptr data_channel) override ; + rtc::scoped_refptr data_channel) override; void OnRenegotiationNeeded() override {} void OnIceConnectionChange( webrtc::PeerConnectionInterface::IceConnectionState new_state) override {} diff --git a/pc/test/testsdpstrings.h b/pc/test/testsdpstrings.h index 2c9912eeec..fc884a1de3 100644 --- a/pc/test/testsdpstrings.h +++ b/pc/test/testsdpstrings.h @@ -76,7 +76,7 @@ static const char kFireFoxSdpOffer[] = "a=candidate:5 2 UDP 1694302206 74.95.2.170 45468 typ srflx raddr" " 10.0.254.2 rport 61232\r\n" #endif - ; + ; // NOLINT(whitespace/semicolon) // Audio SDP with a limited set of audio codecs. static const char kAudioSdp[] = diff --git a/pc/videocapturertracksource.cc b/pc/videocapturertracksource.cc index 97c0994fba..2426cea5b3 100644 --- a/pc/videocapturertracksource.cc +++ b/pc/videocapturertracksource.cc @@ -12,6 +12,7 @@ #include #include +#include #include #include "api/mediaconstraintsinterface.h" diff --git a/pc/videocapturertracksource_unittest.cc b/pc/videocapturertracksource_unittest.cc index c64c83e959..a49264363c 100644 --- a/pc/videocapturertracksource_unittest.cc +++ b/pc/videocapturertracksource_unittest.cc @@ -10,6 +10,7 @@ #include #include +#include #include #include "api/test/fakeconstraints.h" diff --git a/pc/videotrack.cc b/pc/videotrack.cc index 718c0d6fee..bd6d9c26dd 100644 --- a/pc/videotrack.cc +++ b/pc/videotrack.cc @@ -8,11 +8,11 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include + #include "pc/videotrack.h" #include "rtc_base/refcountedobject.h" -#include - namespace webrtc { VideoTrack::VideoTrack(const std::string& label, diff --git a/pc/webrtcsdp.cc b/pc/webrtcsdp.cc index 47e429863e..f053bf5089 100644 --- a/pc/webrtcsdp.cc +++ b/pc/webrtcsdp.cc @@ -15,7 +15,9 @@ #include #include +#include #include +#include #include #include #include @@ -174,7 +176,7 @@ static const char kNewLine = '\n'; static const char kReturn = '\r'; static const char kLineBreak[] = "\r\n"; -// TODO: Generate the Session and Time description +// TODO(deadbeef): Generate the Session and Time description // instead of hardcoding. static const char kSessionVersion[] = "v=0"; // RFC 4566 @@ -675,7 +677,7 @@ static int GetCandidatePreferenceFromType(const std::string& type) { // likely to work, typically IPv4 relay. // RFC 5245 // The value of |component_id| currently supported are 1 (RTP) and 2 (RTCP). -// TODO: Decide the default destination in webrtcsession and +// TODO(deadbeef): Decide the default destination in webrtcsession and // pass it down via SessionDescription. static void GetDefaultDestination( const std::vector& candidates, @@ -1179,7 +1181,8 @@ bool ParseExtmap(const std::string& line, bool encrypted = false; if (uri == RtpExtension::kEncryptHeaderExtensionsUri) { // RFC 6904 - // a=extmap:] urn:ietf:params:rtp-hdrext:encrypt + // a=extmap:] urn:ietf:params:rtp-hdrext:encrypt + // const size_t expected_min_fields_encrypted = expected_min_fields + 1; if (fields.size() < expected_min_fields_encrypted) { return ParseFailedExpectMinFieldNum(line, expected_min_fields_encrypted, @@ -1207,7 +1210,7 @@ void BuildMediaDescription(const ContentInfo* content_info, if (content_info == NULL || message == NULL) { return; } - // TODO: Rethink if we should use sprintfn instead of stringstream. + // TODO(deadbeef): Rethink if we should use sprintfn instead of stringstream. // According to the style guide, streams should only be used for logging. // http://google-styleguide.googlecode.com/svn/ // trunk/cppguide.xml?showone=Streams#Streams @@ -2768,7 +2771,7 @@ bool ParseContent(const std::string& message, } if (!IsLineType(line, kLineTypeAttributes)) { - // TODO: Handle other lines if needed. + // TODO(deadbeef): Handle other lines if needed. LOG(LS_INFO) << "Ignored line: " << line; continue; } @@ -2892,7 +2895,7 @@ bool ParseContent(const std::string& message, } else if (HasAttribute(line, kAttributeXGoogleFlag)) { // Experimental attribute. Conference mode activates more aggressive // AEC and NS settings. - // TODO: expose API to set these directly. + // TODO(deadbeef): expose API to set these directly. std::string flag_value; if (!GetValue(line, kAttributeXGoogleFlag, &flag_value, error)) { return false; diff --git a/pc/webrtcsdp_unittest.cc b/pc/webrtcsdp_unittest.cc index 75dac2505b..e532324102 100644 --- a/pc/webrtcsdp_unittest.cc +++ b/pc/webrtcsdp_unittest.cc @@ -2598,7 +2598,7 @@ TEST_F(WebRtcSdpTest, DeserializeSdpWithCorruptedSctpDataChannels) { // No crash is a pass. } -void MutateJsepSctpPort(JsepSessionDescription& jdesc, +void MutateJsepSctpPort(JsepSessionDescription* jdesc, const SessionDescription& desc) { // take our pre-built session description and change the SCTP port. cricket::SessionDescription* mutant = desc.Copy(); @@ -2611,7 +2611,7 @@ void MutateJsepSctpPort(JsepSessionDescription& jdesc, dcdesc->set_codecs(codecs); // note: mutant's owned by jdesc now. - ASSERT_TRUE(jdesc.Initialize(mutant, kSessionId, kSessionVersion)); + ASSERT_TRUE(jdesc->Initialize(mutant, kSessionId, kSessionVersion)); mutant = NULL; } @@ -2621,7 +2621,7 @@ TEST_F(WebRtcSdpTest, DeserializeSdpWithSctpDataChannelAndUnusualPort) { // First setup the expected JsepSessionDescription. JsepSessionDescription jdesc(kDummyString); - MutateJsepSctpPort(jdesc, desc_); + MutateJsepSctpPort(&jdesc, desc_); // Then get the deserialized JsepSessionDescription. std::string sdp_with_data = kSdpString; @@ -2641,7 +2641,7 @@ TEST_F(WebRtcSdpTest, AddSctpDataChannel(use_sctpmap); JsepSessionDescription jdesc(kDummyString); - MutateJsepSctpPort(jdesc, desc_); + MutateJsepSctpPort(&jdesc, desc_); // We need to test the deserialized JsepSessionDescription from // kSdpSctpDataChannelStringWithSctpPort for diff --git a/pc/webrtcsession.cc b/pc/webrtcsession.cc index ebdcf4ebfe..477b1ff574 100644 --- a/pc/webrtcsession.cc +++ b/pc/webrtcsession.cc @@ -1872,7 +1872,7 @@ bool WebRtcSession::CreateDataChannel(const cricket::ContentInfo* content, RTC_FROM_HERE, rtc::Bind(&WebRtcSession::CreateSctpTransport_n, this, content->name, transport_name))) { return false; - }; + } } else { bool require_rtcp_mux = rtcp_mux_policy_ == PeerConnectionInterface::kRtcpMuxPolicyRequire; diff --git a/pc/webrtcsession.h b/pc/webrtcsession.h index 07202eec80..09e5a3e4c4 100644 --- a/pc/webrtcsession.h +++ b/pc/webrtcsession.h @@ -11,6 +11,7 @@ #ifndef PC_WEBRTCSESSION_H_ #define PC_WEBRTCSESSION_H_ +#include #include #include #include diff --git a/pc/webrtcsessiondescriptionfactory.cc b/pc/webrtcsessiondescriptionfactory.cc index bbab6462bc..69c629e9df 100644 --- a/pc/webrtcsessiondescriptionfactory.cc +++ b/pc/webrtcsessiondescriptionfactory.cc @@ -10,7 +10,10 @@ #include "pc/webrtcsessiondescriptionfactory.h" +#include +#include #include +#include #include "api/jsep.h" #include "api/jsepsessiondescription.h" diff --git a/pc/webrtcsessiondescriptionfactory.h b/pc/webrtcsessiondescriptionfactory.h index 5c3e18ed8a..7ad418fbac 100644 --- a/pc/webrtcsessiondescriptionfactory.h +++ b/pc/webrtcsessiondescriptionfactory.h @@ -12,6 +12,8 @@ #define PC_WEBRTCSESSIONDESCRIPTIONFACTORY_H_ #include +#include +#include #include "api/peerconnectioninterface.h" #include "p2p/base/transportdescriptionfactory.h"