[clang-tidy] Apply performance-for-range-copy fixes.

This CL applies clang-tidy's performance-for-range-copy [1] on the
WebRTC codebase.

All changes in this CL are automatically generated by both clang-tidy
and 'git cl format'.

[1] - https://clang.llvm.org/extra/clang-tidy/checks/performance-for-range-copy.html

Bug: webrtc:10215
Change-Id: I7c83290b8866d76129bbec4e24e6701f5014102e
Reviewed-on: https://webrtc-review.googlesource.com/c/120043
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26420}
This commit is contained in:
Mirko Bonadei 2019-01-27 17:29:42 +01:00 committed by Commit Bot
parent 2d65fff16f
commit 739baf097b
35 changed files with 100 additions and 100 deletions

View File

@ -441,7 +441,7 @@ void RampUpDownUpTester::PollStats() {
bool suspended = false;
if (num_video_streams_ > 0) {
webrtc::VideoSendStream::Stats stats = send_stream_->GetStats();
for (auto it : stats.substreams) {
for (const auto& it : stats.substreams) {
transmit_bitrate_bps += it.second.total_bitrate_bps;
}
suspended = stats.suspended;

View File

@ -1295,7 +1295,7 @@ void RtcEventLogEncoderNewFormat::EncodeRtpPacketIncoming(
const std::map<uint32_t, std::vector<const RtcEventRtpPacketIncoming*>>&
batch,
rtclog2::EventStream* event_stream) {
for (auto it : batch) {
for (const auto& it : batch) {
RTC_DCHECK(!it.second.empty());
EncodeRtpPacket(it.second, event_stream->add_incoming_rtp_packets());
}
@ -1305,7 +1305,7 @@ void RtcEventLogEncoderNewFormat::EncodeRtpPacketOutgoing(
const std::map<uint32_t, std::vector<const RtcEventRtpPacketOutgoing*>>&
batch,
rtclog2::EventStream* event_stream) {
for (auto it : batch) {
for (const auto& it : batch) {
RTC_DCHECK(!it.second.empty());
EncodeRtpPacket(it.second, event_stream->add_outgoing_rtp_packets());
}

View File

@ -801,7 +801,7 @@ TEST_F(WebRtcVoiceEngineTestFake, CreateRecvStream) {
TEST_F(WebRtcVoiceEngineTestFake, OpusSupportsTransportCc) {
const std::vector<cricket::AudioCodec>& codecs = engine_->send_codecs();
bool opus_found = false;
for (cricket::AudioCodec codec : codecs) {
for (const cricket::AudioCodec& codec : codecs) {
if (codec.name == "opus") {
EXPECT_TRUE(HasTransportCc(codec));
opus_found = true;

View File

@ -422,7 +422,7 @@ TEST(FecControllerPlrBasedTest, SingleThresholdCurveForEnablingAndDisabling) {
// Test that FEC is turned on whenever we're on the curve or above it,
// independent of the starting FEC state.
for (std::vector<NetworkState> states_list : {on, above}) {
for (const std::vector<NetworkState>& states_list : {on, above}) {
for (NetworkState net_state : states_list) {
for (bool initial_fec_enabled : {false, true}) {
auto states =

View File

@ -462,7 +462,7 @@ TEST(FecControllerRplrBasedTest, SingleThresholdCurveForEnablingAndDisabling) {
// Test that FEC is turned on whenever we're on the curve or above it,
// independent of the starting FEC state.
for (std::vector<NetworkState> states_list : {on, above}) {
for (const std::vector<NetworkState>& states_list : {on, above}) {
for (NetworkState net_state : states_list) {
for (bool initial_fec_enabled : {false, true}) {
FecControllerRplrBased controller(

View File

@ -122,7 +122,7 @@ int main(int argc, char* argv[]) {
const std::vector<std::string> input_files = parse_input_files();
std::vector<webrtc::test::FilePlayingSource> sources;
const int num_channels = FLAG_stereo ? 2 : 1;
for (auto input_file : input_files) {
for (const auto& input_file : input_files) {
sources.emplace_back(input_file);
}

View File

@ -124,7 +124,7 @@ void LossBasedBandwidthEstimation::UpdateLossStatistics(
return;
}
int loss_count = 0;
for (auto pkt : packet_results) {
for (const auto& pkt : packet_results) {
loss_count += pkt.receive_time.IsInfinite() ? 1 : 0;
}
last_loss_ratio_ = static_cast<double>(loss_count) / packet_results.size();

View File

@ -440,7 +440,7 @@ void RTCPReceiver::HandleSenderReport(const CommonHeader& rtcp_block,
packet_information->packet_type_flags |= kRtcpRr;
}
for (const rtcp::ReportBlock report_block : sender_report.report_blocks())
for (const rtcp::ReportBlock& report_block : sender_report.report_blocks())
HandleReportBlock(report_block, packet_information, remote_ssrc);
}

View File

@ -353,7 +353,7 @@ bool MdnsMessage::Write(rtc::ByteBufferWriter* buf) const {
header_.Write(buf);
auto write_rr = [&buf](const std::vector<MdnsResourceRecord>& section) {
for (auto rr : section) {
for (const auto& rr : section) {
if (!rr.Write(buf)) {
return false;
}
@ -361,7 +361,7 @@ bool MdnsMessage::Write(rtc::ByteBufferWriter* buf) const {
return true;
};
for (auto question : question_section_) {
for (const auto& question : question_section_) {
if (!question.Write(buf)) {
return false;
}

View File

@ -957,7 +957,7 @@ void Port::UpdateNetworkCost() {
// Network cost change will affect the connection selection criteria.
// Signal the connection state change on each connection to force a
// re-sort in P2PTransportChannel.
for (auto kv : connections_) {
for (const auto& kv : connections_) {
Connection* conn = kv.second;
conn->SignalStateChange(conn);
}

View File

@ -69,7 +69,7 @@ void StunRequestManager::SendDelayed(StunRequest* request, int delay) {
}
void StunRequestManager::Flush(int msg_type) {
for (const auto kv : requests_) {
for (const auto& kv : requests_) {
StunRequest* request = kv.second;
if (msg_type == kAllRequests || msg_type == request->type()) {
thread_->Clear(request, MSG_STUN_SEND);
@ -79,7 +79,7 @@ void StunRequestManager::Flush(int msg_type) {
}
bool StunRequestManager::HasRequest(int msg_type) {
for (const auto kv : requests_) {
for (const auto& kv : requests_) {
StunRequest* request = kv.second;
if (msg_type == kAllRequests || msg_type == request->type()) {
return true;

View File

@ -401,7 +401,7 @@ class TurnPortTest : public testing::Test,
if (connections.empty()) {
return false;
}
for (auto kv : connections) {
for (const auto& kv : connections) {
if (!CheckConnectionFailedAndPruned(kv.second)) {
return false;
}

View File

@ -764,7 +764,7 @@ TEST_F(BasicPortAllocatorTest, TestIgnoreOnlyLoopbackNetworkByDefault) {
EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_,
kDefaultAllocationTimeout, fake_clock);
EXPECT_EQ(4U, candidates_.size());
for (Candidate candidate : candidates_) {
for (const Candidate& candidate : candidates_) {
EXPECT_LT(candidate.address().ip(), 0x12345604U);
}
}

View File

@ -672,7 +672,7 @@ RTCError JsepTransportController::ValidateAndMaybeUpdateBundleGroup(
// The BUNDLE group containing a MID that no m= section has is invalid.
if (new_bundle_group) {
for (auto content_name : new_bundle_group->content_names()) {
for (const auto& content_name : new_bundle_group->content_names()) {
if (!description->GetContentByName(content_name)) {
return RTCError(RTCErrorType::INVALID_PARAMETER,
"The BUNDLE group contains MID:" + content_name +
@ -688,7 +688,7 @@ RTCError JsepTransportController::ValidateAndMaybeUpdateBundleGroup(
if (new_bundle_group) {
// The BUNDLE group in answer should be a subset of offered group.
for (auto content_name : new_bundle_group->content_names()) {
for (const auto& content_name : new_bundle_group->content_names()) {
if (!offered_bundle_group ||
!offered_bundle_group->HasContentName(content_name)) {
return RTCError(RTCErrorType::INVALID_PARAMETER,
@ -699,7 +699,7 @@ RTCError JsepTransportController::ValidateAndMaybeUpdateBundleGroup(
}
if (bundle_group_) {
for (auto content_name : bundle_group_->content_names()) {
for (const auto& content_name : bundle_group_->content_names()) {
// An answer that removes m= sections from pre-negotiated BUNDLE group
// without rejecting it, is invalid.
if (!new_bundle_group ||
@ -740,7 +740,7 @@ RTCError JsepTransportController::ValidateAndMaybeUpdateBundleGroup(
// If the |bundled_content| is rejected, other contents in the bundle group
// should be rejected.
if (bundled_content->rejected) {
for (auto content_name : bundle_group_->content_names()) {
for (const auto& content_name : bundle_group_->content_names()) {
auto other_content = description->GetContentByName(content_name);
if (!other_content->rejected) {
return RTCError(
@ -775,7 +775,7 @@ void JsepTransportController::HandleRejectedContent(
// then destroy the cricket::JsepTransport.
RemoveTransportForMid(content_info.name);
if (content_info.name == bundled_mid()) {
for (auto content_name : bundle_group_->content_names()) {
for (const auto& content_name : bundle_group_->content_names()) {
RemoveTransportForMid(content_name);
}
bundle_group_.reset();
@ -881,7 +881,7 @@ std::vector<int> JsepTransportController::GetEncryptedHeaderExtensionIds(
}
std::vector<int> encrypted_header_extension_ids;
for (auto extension : content_desc->rtp_header_extensions()) {
for (const auto& extension : content_desc->rtp_header_extensions()) {
if (!extension.encrypt) {
continue;
}

View File

@ -838,7 +838,7 @@ PeerConnection::~PeerConnection() {
// Need to stop transceivers before destroying the stats collector because
// AudioRtpSender has a reference to the StatsCollector it will update when
// stopping.
for (auto transceiver : transceivers_) {
for (const auto& transceiver : transceivers_) {
transceiver->Stop();
}
@ -874,12 +874,12 @@ PeerConnection::~PeerConnection() {
void PeerConnection::DestroyAllChannels() {
// Destroy video channels first since they may have a pointer to a voice
// channel.
for (auto transceiver : transceivers_) {
for (const auto& transceiver : transceivers_) {
if (transceiver->media_type() == cricket::MEDIA_TYPE_VIDEO) {
DestroyTransceiverChannel(transceiver);
}
}
for (auto transceiver : transceivers_) {
for (const auto& transceiver : transceivers_) {
if (transceiver->media_type() == cricket::MEDIA_TYPE_AUDIO) {
DestroyTransceiverChannel(transceiver);
}
@ -1624,7 +1624,7 @@ rtc::scoped_refptr<RtpSenderInterface> PeerConnection::CreateSender(
std::vector<rtc::scoped_refptr<RtpSenderInterface>> PeerConnection::GetSenders()
const {
std::vector<rtc::scoped_refptr<RtpSenderInterface>> ret;
for (auto sender : GetSendersInternal()) {
for (const auto& sender : GetSendersInternal()) {
ret.push_back(sender);
}
return ret;
@ -1634,7 +1634,7 @@ std::vector<rtc::scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>>>
PeerConnection::GetSendersInternal() const {
std::vector<rtc::scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>>>
all_senders;
for (auto transceiver : transceivers_) {
for (const auto& transceiver : transceivers_) {
auto senders = transceiver->internal()->senders();
all_senders.insert(all_senders.end(), senders.begin(), senders.end());
}
@ -1656,7 +1656,7 @@ PeerConnection::GetReceiversInternal() const {
std::vector<
rtc::scoped_refptr<RtpReceiverProxyWithInternal<RtpReceiverInternal>>>
all_receivers;
for (auto transceiver : transceivers_) {
for (const auto& transceiver : transceivers_) {
auto receivers = transceiver->internal()->receivers();
all_receivers.insert(all_receivers.end(), receivers.begin(),
receivers.end());
@ -1669,7 +1669,7 @@ PeerConnection::GetTransceivers() const {
RTC_CHECK(IsUnifiedPlan())
<< "GetTransceivers is only supported with Unified Plan SdpSemantics.";
std::vector<rtc::scoped_refptr<RtpTransceiverInterface>> all_transceivers;
for (auto transceiver : transceivers_) {
for (const auto& transceiver : transceivers_) {
all_transceivers.push_back(transceiver);
}
return all_transceivers;
@ -1880,7 +1880,7 @@ RTCError PeerConnection::HandleLegacyOfferOptions(
void PeerConnection::RemoveRecvDirectionFromReceivingTransceiversOfType(
cricket::MediaType media_type) {
for (auto transceiver : GetReceivingTransceiversOfType(media_type)) {
for (const auto& transceiver : GetReceivingTransceiversOfType(media_type)) {
RtpTransceiverDirection new_direction =
RtpTransceiverDirectionWithRecvSet(transceiver->direction(), false);
if (new_direction != transceiver->direction()) {
@ -1914,7 +1914,7 @@ PeerConnection::GetReceivingTransceiversOfType(cricket::MediaType media_type) {
std::vector<
rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>>
receiving_transceivers;
for (auto transceiver : transceivers_) {
for (const auto& transceiver : transceivers_) {
if (!transceiver->stopped() && transceiver->media_type() == media_type &&
RtpTransceiverDirectionHasRecv(transceiver->direction())) {
receiving_transceivers.push_back(transceiver);
@ -2107,7 +2107,7 @@ RTCError PeerConnection::ApplyLocalDescription(
}
std::vector<rtc::scoped_refptr<RtpTransceiverInterface>> remove_list;
std::vector<rtc::scoped_refptr<MediaStreamInterface>> removed_streams;
for (auto transceiver : transceivers_) {
for (const auto& transceiver : transceivers_) {
// 2.2.7.1.1.(6-9): Set sender and receiver's transport slots.
// Note that code paths that don't set MID won't be able to use
// information about DTLS transports.
@ -2147,10 +2147,10 @@ RTCError PeerConnection::ApplyLocalDescription(
}
}
auto observer = Observer();
for (auto transceiver : remove_list) {
for (const auto& transceiver : remove_list) {
observer->OnRemoveTrack(transceiver->receiver());
}
for (auto stream : removed_streams) {
for (const auto& stream : removed_streams) {
observer->OnRemoveStream(stream);
}
} else {
@ -2192,7 +2192,7 @@ RTCError PeerConnection::ApplyLocalDescription(
}
if (IsUnifiedPlan()) {
for (auto transceiver : transceivers_) {
for (const auto& transceiver : transceivers_) {
const ContentInfo* content =
FindMediaSectionForTransceiver(transceiver, local_description());
if (!content) {
@ -2526,7 +2526,7 @@ RTCError PeerConnection::ApplyRemoteDescription(
std::vector<rtc::scoped_refptr<RtpTransceiverInterface>> remove_list;
std::vector<rtc::scoped_refptr<MediaStreamInterface>> added_streams;
std::vector<rtc::scoped_refptr<MediaStreamInterface>> removed_streams;
for (auto transceiver : transceivers_) {
for (const auto& transceiver : transceivers_) {
const ContentInfo* content =
FindMediaSectionForTransceiver(transceiver, remote_description());
if (!content) {
@ -2610,19 +2610,19 @@ RTCError PeerConnection::ApplyRemoteDescription(
}
// Once all processing has finished, fire off callbacks.
auto observer = Observer();
for (auto transceiver : now_receiving_transceivers) {
for (const auto& transceiver : now_receiving_transceivers) {
stats_->AddTrack(transceiver->receiver()->track());
observer->OnTrack(transceiver);
observer->OnAddTrack(transceiver->receiver(),
transceiver->receiver()->streams());
}
for (auto stream : added_streams) {
for (const auto& stream : added_streams) {
observer->OnAddStream(stream);
}
for (auto transceiver : remove_list) {
for (const auto& transceiver : remove_list) {
observer->OnRemoveTrack(transceiver->receiver());
}
for (auto stream : removed_streams) {
for (const auto& stream : removed_streams) {
observer->OnRemoveStream(stream);
}
}
@ -2774,7 +2774,7 @@ void PeerConnection::RemoveRemoteStreamsIfEmpty(
// TODO(https://crbug.com/webrtc/9480): When we use stream IDs instead of
// streams, see if the stream was removed by checking if this was the last
// receiver with that stream ID.
for (auto remote_stream : remote_streams) {
for (const auto& remote_stream : remote_streams) {
if (remote_stream->GetAudioTracks().empty() &&
remote_stream->GetVideoTracks().empty()) {
remote_streams_->RemoveStream(remote_stream);
@ -3510,7 +3510,7 @@ void PeerConnection::Close() {
ChangeSignalingState(PeerConnectionInterface::kClosed);
NoteUsageEvent(UsageEvent::CLOSE_CALLED);
for (auto transceiver : transceivers_) {
for (const auto& transceiver : transceivers_) {
transceiver->Stop();
}
@ -4151,7 +4151,7 @@ void PeerConnection::GetOptionsForUnifiedPlanOffer(
// and not associated). Reuse media sections marked as recyclable first,
// otherwise append to the end of the offer. New media sections should be
// added in the order they were added to the PeerConnection.
for (auto transceiver : transceivers_) {
for (const auto& transceiver : transceivers_) {
if (transceiver->mid() || transceiver->stopped()) {
continue;
}
@ -4921,7 +4921,7 @@ bool PeerConnection::HasRtpSender(cricket::MediaType type) const {
rtc::scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>>
PeerConnection::FindSenderForTrack(MediaStreamTrackInterface* track) const {
for (auto transceiver : transceivers_) {
for (const auto& transceiver : transceivers_) {
for (auto sender : transceiver->internal()->senders()) {
if (sender->track() == track) {
return sender;
@ -4933,7 +4933,7 @@ PeerConnection::FindSenderForTrack(MediaStreamTrackInterface* track) const {
rtc::scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>>
PeerConnection::FindSenderById(const std::string& sender_id) const {
for (auto transceiver : transceivers_) {
for (const auto& transceiver : transceivers_) {
for (auto sender : transceiver->internal()->senders()) {
if (sender->id() == sender_id) {
return sender;
@ -4945,7 +4945,7 @@ PeerConnection::FindSenderById(const std::string& sender_id) const {
rtc::scoped_refptr<RtpReceiverProxyWithInternal<RtpReceiverInternal>>
PeerConnection::FindReceiverById(const std::string& receiver_id) const {
for (auto transceiver : transceivers_) {
for (const auto& transceiver : transceivers_) {
for (auto receiver : transceiver->internal()->receivers()) {
if (receiver->id() == receiver_id) {
return receiver;
@ -5105,7 +5105,7 @@ void PeerConnection::StopRtcEventLog_w() {
cricket::ChannelInterface* PeerConnection::GetChannel(
const std::string& content_name) {
for (auto transceiver : transceivers_) {
for (const auto& transceiver : transceivers_) {
cricket::ChannelInterface* channel = transceiver->internal()->channel();
if (channel && channel->content_name() == content_name) {
return channel;
@ -5220,7 +5220,7 @@ RTCError PeerConnection::PushdownMediaDescription(
RTC_DCHECK(sdesc);
// Push down the new SDP media section for each audio/video transceiver.
for (auto transceiver : transceivers_) {
for (const auto& transceiver : transceivers_) {
const ContentInfo* content_info =
FindMediaSectionForTransceiver(transceiver, sdesc);
cricket::ChannelInterface* channel = transceiver->internal()->channel();
@ -5571,7 +5571,7 @@ cricket::CandidateStatsList PeerConnection::GetPooledCandidateStats() const {
std::map<std::string, std::string> PeerConnection::GetTransportNamesByMid()
const {
std::map<std::string, std::string> transport_names_by_mid;
for (auto transceiver : transceivers_) {
for (const auto& transceiver : transceivers_) {
cricket::ChannelInterface* channel = transceiver->internal()->channel();
if (channel) {
transport_names_by_mid[channel->content_name()] =
@ -5748,7 +5748,7 @@ void PeerConnection::OnTransportControllerDtlsHandshakeError(
}
void PeerConnection::EnableSending() {
for (auto transceiver : transceivers_) {
for (const auto& transceiver : transceivers_) {
cricket::ChannelInterface* channel = transceiver->internal()->channel();
if (channel && !channel->enabled()) {
channel->Enable(true);
@ -6508,7 +6508,7 @@ void PeerConnection::OnTransportControllerGatheringState(
void PeerConnection::ReportTransportStats() {
std::map<std::string, std::set<cricket::MediaType>>
media_types_by_transport_name;
for (auto transceiver : transceivers_) {
for (const auto& transceiver : transceivers_) {
if (transceiver->internal()->channel()) {
const std::string& transport_name =
transceiver->internal()->channel()->transport_name();

View File

@ -95,7 +95,7 @@ class PeerConnectionWrapperForBundleTest : public PeerConnectionWrapper {
cricket::VoiceChannel* voice_channel() {
auto transceivers = GetInternalPeerConnection()->GetTransceiversInternal();
for (auto transceiver : transceivers) {
for (const auto& transceiver : transceivers) {
if (transceiver->media_type() == cricket::MEDIA_TYPE_AUDIO) {
return static_cast<cricket::VoiceChannel*>(
transceiver->internal()->channel());
@ -116,7 +116,7 @@ class PeerConnectionWrapperForBundleTest : public PeerConnectionWrapper {
cricket::VideoChannel* video_channel() {
auto transceivers = GetInternalPeerConnection()->GetTransceiversInternal();
for (auto transceiver : transceivers) {
for (const auto& transceiver : transceivers) {
if (transceiver->media_type() == cricket::MEDIA_TYPE_VIDEO) {
return static_cast<cricket::VideoChannel*>(
transceiver->internal()->channel());

View File

@ -211,7 +211,7 @@ class PeerConnectionIceBaseTest : public ::testing::Test {
static_cast<PeerConnectionProxyWithInternal<PeerConnectionInterface>*>(
pc_wrapper_ptr->pc());
PeerConnection* pc = static_cast<PeerConnection*>(pc_proxy->internal());
for (auto transceiver : pc->GetTransceiversInternal()) {
for (const auto& transceiver : pc->GetTransceiversInternal()) {
if (transceiver->media_type() == cricket::MEDIA_TYPE_AUDIO) {
// TODO(amithi): This test seems to be using a method that should not
// be public |rtp_packet_transport|. Because the test is not mocking

View File

@ -347,7 +347,7 @@ class PeerConnectionWrapper : public webrtc::PeerConnectionObserver,
std::vector<rtc::scoped_refptr<RtpReceiverInterface>> GetReceiversOfType(
cricket::MediaType media_type) {
std::vector<rtc::scoped_refptr<RtpReceiverInterface>> receivers;
for (auto receiver : pc()->GetReceivers()) {
for (const auto& receiver : pc()->GetReceivers()) {
if (receiver->media_type() == media_type) {
receivers.push_back(receiver);
}
@ -2237,7 +2237,7 @@ TEST_P(PeerConnectionIntegrationTest, AnswererRejectsAudioAndVideoSections) {
} else {
callee()->SetRemoteOfferHandler([this] {
// Stopping all transceivers will cause all media sections to be rejected.
for (auto transceiver : callee()->pc()->GetTransceivers()) {
for (const auto& transceiver : callee()->pc()->GetTransceivers()) {
transceiver->Stop();
}
});
@ -2551,7 +2551,7 @@ TEST_P(PeerConnectionIntegrationTest, GetBytesReceivedStatsWithOldStatsApi) {
// Get a handle to the remote tracks created, so they can be used as GetStats
// filters.
for (auto receiver : callee()->pc()->GetReceivers()) {
for (const auto& receiver : callee()->pc()->GetReceivers()) {
// We received frames, so we definitely should have nonzero "received bytes"
// stats at this point.
EXPECT_GT(callee()->OldGetStatsForTrack(receiver->track())->BytesReceived(),

View File

@ -2664,7 +2664,7 @@ TEST_P(PeerConnectionInterfaceTest, CloseAndTestStreamsAndStates) {
} else {
// Verify that the RtpTransceivers are still present but all stopped.
EXPECT_EQ(2u, pc_->GetTransceivers().size());
for (auto transceiver : pc_->GetTransceivers()) {
for (const auto& transceiver : pc_->GetTransceivers()) {
EXPECT_TRUE(transceiver->stopped());
}
}

View File

@ -536,7 +536,7 @@ void ProduceSenderMediaTrackStats(
// TODO(hbos): Return stats of detached tracks. We have to perform stats
// gathering at the time of detachment to get accurate stats and timestamps.
// https://crbug.com/659137
for (auto sender : senders) {
for (const auto& sender : senders) {
if (sender->media_type() == cricket::MEDIA_TYPE_AUDIO) {
AudioTrackInterface* track =
static_cast<AudioTrackInterface*>(sender->track().get());
@ -604,7 +604,7 @@ void ProduceReceiverMediaTrackStats(
std::vector<rtc::scoped_refptr<RtpReceiverInternal>> receivers,
RTCStatsReport* report) {
// This function iterates over the receivers to find the remote tracks.
for (auto receiver : receivers) {
for (const auto& receiver : receivers) {
if (receiver->media_type() == cricket::MEDIA_TYPE_AUDIO) {
AudioTrackInterface* track =
static_cast<AudioTrackInterface*>(receiver->track().get());
@ -1118,7 +1118,7 @@ void RTCStatsCollector::ProduceMediaStreamStats_s(
std::map<std::string, std::vector<std::string>> track_ids;
for (const auto& stats : transceiver_stats_infos_) {
for (auto sender : stats.transceiver->senders()) {
for (const auto& sender : stats.transceiver->senders()) {
std::string track_id =
RTCMediaStreamTrackStatsIDFromDirectionAndAttachment(
kSender, sender->internal()->AttachmentId());
@ -1126,7 +1126,7 @@ void RTCStatsCollector::ProduceMediaStreamStats_s(
track_ids[stream_id].push_back(track_id);
}
}
for (auto receiver : stats.transceiver->receivers()) {
for (const auto& receiver : stats.transceiver->receivers()) {
std::string track_id =
RTCMediaStreamTrackStatsIDFromDirectionAndAttachment(
kReceiver, receiver->internal()->AttachmentId());
@ -1152,14 +1152,14 @@ void RTCStatsCollector::ProduceMediaStreamTrackStats_s(
RTC_DCHECK(signaling_thread_->IsCurrent());
for (const RtpTransceiverStatsInfo& stats : transceiver_stats_infos_) {
std::vector<rtc::scoped_refptr<RtpSenderInternal>> senders;
for (auto sender : stats.transceiver->senders()) {
for (const auto& sender : stats.transceiver->senders()) {
senders.push_back(sender->internal());
}
ProduceSenderMediaTrackStats(timestamp_us, *stats.track_media_info_map,
senders, report);
std::vector<rtc::scoped_refptr<RtpReceiverInternal>> receivers;
for (auto receiver : stats.transceiver->receivers()) {
for (const auto& receiver : stats.transceiver->receivers()) {
receivers.push_back(receiver->internal());
}
ProduceReceiverMediaTrackStats(timestamp_us, *stats.track_media_info_map,
@ -1422,7 +1422,7 @@ RTCStatsCollector::PrepareTransceiverStatsInfos_s() const {
std::unique_ptr<cricket::VideoMediaInfo>>
video_stats;
for (auto transceiver : pc_->GetTransceiversInternal()) {
for (const auto& transceiver : pc_->GetTransceiversInternal()) {
cricket::MediaType media_type = transceiver->media_type();
// Prepare stats entry. The TrackMediaInfoMap will be filled in after the
@ -1495,11 +1495,11 @@ RTCStatsCollector::PrepareTransceiverStatsInfos_s() const {
}
}
std::vector<rtc::scoped_refptr<RtpSenderInternal>> senders;
for (auto sender : transceiver->senders()) {
for (const auto& sender : transceiver->senders()) {
senders.push_back(sender->internal());
}
std::vector<rtc::scoped_refptr<RtpReceiverInternal>> receivers;
for (auto receiver : transceiver->receivers()) {
for (const auto& receiver : transceiver->receivers()) {
receivers.push_back(receiver->internal());
}
stats.track_media_info_map = absl::make_unique<TrackMediaInfoMap>(

View File

@ -211,9 +211,9 @@ void AudioRtpReceiver::set_stream_ids(std::vector<std::string> stream_ids) {
void AudioRtpReceiver::SetStreams(
const std::vector<rtc::scoped_refptr<MediaStreamInterface>>& streams) {
// Remove remote track from any streams that are going away.
for (auto existing_stream : streams_) {
for (const auto& existing_stream : streams_) {
bool removed = true;
for (auto stream : streams) {
for (const auto& stream : streams) {
if (existing_stream->id() == stream->id()) {
RTC_DCHECK_EQ(existing_stream.get(), stream.get());
removed = false;
@ -225,9 +225,9 @@ void AudioRtpReceiver::SetStreams(
}
}
// Add remote track to any streams that are new.
for (auto stream : streams) {
for (const auto& stream : streams) {
bool added = true;
for (auto existing_stream : streams_) {
for (const auto& existing_stream : streams_) {
if (stream->id() == existing_stream->id()) {
RTC_DCHECK_EQ(stream.get(), existing_stream.get());
added = false;
@ -410,9 +410,9 @@ void VideoRtpReceiver::set_stream_ids(std::vector<std::string> stream_ids) {
void VideoRtpReceiver::SetStreams(
const std::vector<rtc::scoped_refptr<MediaStreamInterface>>& streams) {
// Remove remote track from any streams that are going away.
for (auto existing_stream : streams_) {
for (const auto& existing_stream : streams_) {
bool removed = true;
for (auto stream : streams) {
for (const auto& stream : streams) {
if (existing_stream->id() == stream->id()) {
RTC_DCHECK_EQ(existing_stream.get(), stream.get());
removed = false;
@ -424,9 +424,9 @@ void VideoRtpReceiver::SetStreams(
}
}
// Add remote track to any streams that are new.
for (auto stream : streams) {
for (const auto& stream : streams) {
bool added = true;
for (auto existing_stream : streams_) {
for (const auto& existing_stream : streams_) {
if (stream->id() == existing_stream->id()) {
RTC_DCHECK_EQ(stream.get(), existing_stream.get());
added = false;

View File

@ -62,12 +62,12 @@ void RtpTransceiver::SetChannel(cricket::ChannelInterface* channel) {
this, &RtpTransceiver::OnFirstPacketReceived);
}
for (auto sender : senders_) {
for (const auto& sender : senders_) {
sender->internal()->SetMediaChannel(channel_ ? channel_->media_channel()
: nullptr);
}
for (auto receiver : receivers_) {
for (const auto& receiver : receivers_) {
if (!channel_) {
receiver->internal()->Stop();
}
@ -150,7 +150,7 @@ absl::optional<std::string> RtpTransceiver::mid() const {
}
void RtpTransceiver::OnFirstPacketReceived(cricket::ChannelInterface*) {
for (auto receiver : receivers_) {
for (const auto& receiver : receivers_) {
receiver->internal()->NotifyFirstPacketReceived();
}
}
@ -215,10 +215,10 @@ absl::optional<RtpTransceiverDirection> RtpTransceiver::fired_direction()
}
void RtpTransceiver::Stop() {
for (auto sender : senders_) {
for (const auto& sender : senders_) {
sender->internal()->Stop();
}
for (auto receiver : receivers_) {
for (const auto& receiver : receivers_) {
receiver->internal()->Stop();
}
stopped_ = true;

View File

@ -81,7 +81,7 @@ rtc::StringBuilder& operator<<(
rtc::StringBuilder& operator<<(rtc::StringBuilder& builder,
const SimulcastLayerList& simulcast_layers) {
bool first = true;
for (auto alternatives : simulcast_layers) {
for (const auto& alternatives : simulcast_layers) {
if (!first) {
builder << kDelimiterSemicolon;
}

View File

@ -875,7 +875,7 @@ void StatsCollector::ExtractBweInfo() {
// Fill in target encoder bitrate, actual encoder bitrate, rtx bitrate, etc.
// TODO(holmer): Also fill this in for audio.
for (auto transceiver : pc_->GetTransceiversInternal()) {
for (const auto& transceiver : pc_->GetTransceiversInternal()) {
if (transceiver->media_type() != cricket::MEDIA_TYPE_VIDEO) {
continue;
}
@ -916,7 +916,7 @@ void StatsCollector::ExtractMediaInfo() {
{
rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls;
for (auto transceiver : pc_->GetTransceiversInternal()) {
for (const auto& transceiver : pc_->GetTransceiversInternal()) {
if (!transceiver->internal()->channel()) {
continue;
}

View File

@ -281,10 +281,10 @@ void PeerConnectionTestWrapper::GetAndAddUserMedia(
const webrtc::FakeConstraints& video_constraints) {
rtc::scoped_refptr<webrtc::MediaStreamInterface> stream =
GetUserMedia(audio, audio_options, video, video_constraints);
for (auto audio_track : stream->GetAudioTracks()) {
for (const auto& audio_track : stream->GetAudioTracks()) {
EXPECT_TRUE(peer_connection_->AddTrack(audio_track, {stream->id()}).ok());
}
for (auto video_track : stream->GetVideoTracks()) {
for (const auto& video_track : stream->GetVideoTracks()) {
EXPECT_TRUE(peer_connection_->AddTrack(video_track, {stream->id()}).ok());
}
}

View File

@ -47,7 +47,7 @@ void GetAudioAndVideoTrackBySsrc(
// means one thread jump if on signaling thread and two thread jumps if on any
// other threads). Is there a way to avoid thread jump(s) on a per
// sender/receiver, per method basis?
for (auto rtp_sender : rtp_senders) {
for (const auto& rtp_sender : rtp_senders) {
cricket::MediaType media_type = rtp_sender->media_type();
MediaStreamTrackInterface* track = rtp_sender->track();
if (!track) {
@ -72,7 +72,7 @@ void GetAudioAndVideoTrackBySsrc(
}
}
}
for (auto rtp_receiver : rtp_receivers) {
for (const auto& rtp_receiver : rtp_receivers) {
cricket::MediaType media_type = rtp_receiver->media_type();
MediaStreamTrackInterface* track = rtp_receiver->track();
RTC_DCHECK(track);
@ -126,10 +126,10 @@ TrackMediaInfoMap::TrackMediaInfoMap(
&remote_video_track_by_ssrc, &unsignaled_audio_track,
&unsignaled_video_track);
for (auto sender : rtp_senders) {
for (const auto& sender : rtp_senders) {
attachment_id_by_track_[sender->track()] = sender->AttachmentId();
}
for (auto receiver : rtp_receivers) {
for (const auto& receiver : rtp_receivers) {
attachment_id_by_track_[receiver->track()] = receiver->AttachmentId();
}

View File

@ -22,7 +22,7 @@ OpenSSLSessionCache::OpenSSLSessionCache(SSLMode ssl_mode, SSL_CTX* ssl_ctx)
}
OpenSSLSessionCache::~OpenSSLSessionCache() {
for (auto it : sessions_) {
for (const auto& it : sessions_) {
SSL_SESSION_free(it.second);
}
SSL_CTX_free(ssl_ctx_);

View File

@ -90,7 +90,7 @@ TYPED_TEST(UniqueIdGeneratorTest, AddedElementsAreNotGenerated) {
rtc::InitRandom(0);
Generator generator2;
for (typename Generator::value_type value : known_values) {
for (const typename Generator::value_type& value : known_values) {
generator2.AddKnownId(value);
}

View File

@ -579,7 +579,7 @@ void PeerConnectionDelegateAdapter::OnRemoveTrack(
std::vector<rtc::scoped_refptr<webrtc::RtpTransceiverInterface>> nativeTransceivers(
_peerConnection->GetTransceivers());
NSMutableArray *transceivers = [[NSMutableArray alloc] init];
for (auto nativeTransceiver : nativeTransceivers) {
for (const auto &nativeTransceiver : nativeTransceivers) {
RTCRtpTransceiver *transceiver = [[RTCRtpTransceiver alloc] initWithFactory:self.factory
nativeRtpTransceiver:nativeTransceiver];
[transceivers addObject:transceiver];

View File

@ -22,7 +22,7 @@ VideoReceiveStream::Config ParseVideoReceiveStreamJsonConfig(
webrtc::Transport* transport,
const Json::Value& json) {
auto receive_config = VideoReceiveStream::Config(transport);
for (const auto decoder_json : json["decoders"]) {
for (const auto& decoder_json : json["decoders"]) {
VideoReceiveStream::Decoder decoder;
decoder.video_format =
SdpVideoFormat(decoder_json["payload_name"].asString());

View File

@ -326,7 +326,7 @@ void SimulatedTimeClient::CongestionProcess(Timestamp at_time) {
void SimulatedTimeClient::PacerProcess(Timestamp at_time) {
ProcessFrames(at_time);
for (auto to_send : sender_.PaceAndPullSendPackets(at_time)) {
for (const auto& to_send : sender_.PaceAndPullSendPackets(at_time)) {
sender_.send_node_->OnPacketReceived(EmulatedIpPacket(
rtc::SocketAddress() /*from*/, rtc::SocketAddress() /*to*/,
sender_.send_receiver_id_, to_send.data, at_time));

View File

@ -308,7 +308,7 @@ ColumnPrinter SendVideoStream::StatsPrinter() {
VideoSendStream::Stats video_stats = send_stream_->GetStats();
int width = 0;
int height = 0;
for (auto stream_stat : video_stats.substreams) {
for (const auto& stream_stat : video_stats.substreams) {
width = std::max(width, stream_stat.second.width);
height = std::max(height, stream_stat.second.height);
}

View File

@ -275,7 +275,7 @@ void ReceiveStatisticsProxy::UpdateHistograms() {
// Aggregate content_specific_stats_ by removing experiment or simulcast
// information;
std::map<VideoContentType, ContentSpecificStats> aggregated_stats;
for (auto it : content_specific_stats_) {
for (const auto& it : content_specific_stats_) {
// Calculate simulcast specific metrics (".S0" ... ".S2" suffixes).
VideoContentType content_type = it.first;
if (videocontenttypehelpers::GetSimulcastId(content_type) > 0) {
@ -297,7 +297,7 @@ void ReceiveStatisticsProxy::UpdateHistograms() {
aggregated_stats[content_type].Add(it.second);
}
for (auto it : aggregated_stats) {
for (const auto& it : aggregated_stats) {
// For the metric Foo we report the following slices:
// WebRTC.Video.Foo,
// WebRTC.Video.Screenshare.Foo,

View File

@ -458,7 +458,7 @@ void VideoAnalyzer::PollStats() {
if (send_stats.media_bitrate_bps > 0)
media_bitrate_bps_.AddSample(send_stats.media_bitrate_bps);
size_t fec_bytes = 0;
for (auto kv : send_stats.substreams) {
for (const auto& kv : send_stats.substreams) {
fec_bytes += kv.second.rtp_stats.fec.payload_bytes +
kv.second.rtp_stats.fec.padding_bytes;
}

View File

@ -477,7 +477,7 @@ void VideoQualityTest::FillScalabilitySettings(
// lists. To use a default value for an element, use -1 or leave empty.
// Validity checks performed in CheckParamsAndInjectionComponents.
RTC_CHECK(params->ss[video_idx].streams.empty());
for (auto descriptor : stream_descriptors) {
for (const auto& descriptor : stream_descriptors) {
if (descriptor.empty())
continue;
VideoStream stream =
@ -513,7 +513,7 @@ void VideoQualityTest::FillScalabilitySettings(
params->ss[video_idx].selected_sl = selected_sl;
params->ss[video_idx].inter_layer_pred = inter_layer_pred;
RTC_CHECK(params->ss[video_idx].spatial_layers.empty());
for (auto descriptor : sl_descriptors) {
for (const auto& descriptor : sl_descriptors) {
if (descriptor.empty())
continue;
std::vector<int> v = VideoQualityTest::ParseCSV(descriptor);