diff --git a/api/candidate.cc b/api/candidate.cc index 8969b06583..0a1c359002 100644 --- a/api/candidate.cc +++ b/api/candidate.cc @@ -112,9 +112,10 @@ std::string Candidate::ToStringInternal(bool sensitive) const { std::string related_address = sensitive ? related_address_.ToSensitiveString() : related_address_.ToString(); ost << "Cand[" << transport_name_ << ":" << foundation_ << ":" << component_ - << ":" << protocol_ << ":" << priority_ << ":" << address << ":" << type_ - << ":" << related_address << ":" << username_ << ":" << password_ << ":" - << network_id_ << ":" << network_cost_ << ":" << generation_ << "]"; + << ":" << protocol_ << ":" << priority_ << ":" << address << ":" + << type_name() << ":" << related_address << ":" << username_ << ":" + << password_ << ":" << network_id_ << ":" << network_cost_ << ":" + << generation_ << "]"; return ost.Release(); } diff --git a/p2p/base/connection.cc b/p2p/base/connection.cc index 3809f12232..3f0c9c20b2 100644 --- a/p2p/base/connection.cc +++ b/p2p/base/connection.cc @@ -1330,11 +1330,11 @@ std::string Connection::ToString() const { const Candidate& local = local_candidate(); const Candidate& remote = remote_candidate(); ss << local.id() << ":" << local.component() << ":" << local.generation() - << ":" << local.type() << ":" << local.protocol() << ":" + << ":" << local.type_name() << ":" << local.protocol() << ":" << local.address().ToSensitiveString() << "->" << remote.id() << ":" - << remote.component() << ":" << remote.priority() << ":" << remote.type() - << ":" << remote.protocol() << ":" << remote.address().ToSensitiveString() - << "|"; + << remote.component() << ":" << remote.priority() << ":" + << remote.type_name() << ":" << remote.protocol() << ":" + << remote.address().ToSensitiveString() << "|"; ss << CONNECT_STATE_ABBREV[connected_] << RECEIVE_STATE_ABBREV[receiving_] << WRITE_STATE_ABBREV[write_state_] << ICESTATE[static_cast(state_)] diff --git a/p2p/base/p2p_transport_channel.cc b/p2p/base/p2p_transport_channel.cc index 2f18f1dbb9..eb3553b52a 100644 --- a/p2p/base/p2p_transport_channel.cc +++ b/p2p/base/p2p_transport_channel.cc @@ -1416,7 +1416,8 @@ bool P2PTransportChannel::CreateConnection(PortInterface* port, if ((port->Type() != remote_candidate.type()) && (port->Type() == RELAY_PORT_TYPE || remote_candidate.is_relay())) { RTC_LOG(LS_INFO) << ToString() << ": skip creating connection " - << port->Type() << " to " << remote_candidate.type(); + << port->Type() << " to " + << remote_candidate.type_name(); return false; } } diff --git a/p2p/base/p2p_transport_channel_unittest.cc b/p2p/base/p2p_transport_channel_unittest.cc index 79e984cfec..b180ab8d2b 100644 --- a/p2p/base/p2p_transport_channel_unittest.cc +++ b/p2p/base/p2p_transport_channel_unittest.cc @@ -589,9 +589,9 @@ class P2PTransportChannelTestBase : public ::testing::Test, // on the local and remote candidate of ep1_ch1, match. This can be // used in an EXPECT_TRUE_WAIT. bool CheckCandidate1(const Result& expected) { - const std::string& local_type = LocalCandidate(ep1_ch1())->type(); + auto local_type = LocalCandidate(ep1_ch1())->type(); const std::string& local_protocol = LocalCandidate(ep1_ch1())->protocol(); - const std::string& remote_type = RemoteCandidate(ep1_ch1())->type(); + auto remote_type = RemoteCandidate(ep1_ch1())->type(); const std::string& remote_protocol = RemoteCandidate(ep1_ch1())->protocol(); return (local_protocol == expected.controlling_protocol && remote_protocol == expected.controlled_protocol && @@ -608,9 +608,9 @@ class P2PTransportChannelTestBase : public ::testing::Test, return; } - const std::string& local_type = LocalCandidate(ep1_ch1())->type(); + auto local_type = LocalCandidate(ep1_ch1())->type(); const std::string& local_protocol = LocalCandidate(ep1_ch1())->protocol(); - const std::string& remote_type = RemoteCandidate(ep1_ch1())->type(); + auto remote_type = RemoteCandidate(ep1_ch1())->type(); const std::string& remote_protocol = RemoteCandidate(ep1_ch1())->protocol(); EXPECT_EQ(expected.controlling_type, local_type); EXPECT_EQ(expected.controlled_type, remote_type); @@ -622,9 +622,9 @@ class P2PTransportChannelTestBase : public ::testing::Test, // on the local and remote candidate of ep2_ch1, match. This can be // used in an EXPECT_TRUE_WAIT. bool CheckCandidate2(const Result& expected) { - const std::string& local_type = LocalCandidate(ep2_ch1())->type(); + auto local_type = LocalCandidate(ep2_ch1())->type(); const std::string& local_protocol = LocalCandidate(ep2_ch1())->protocol(); - const std::string& remote_type = RemoteCandidate(ep2_ch1())->type(); + auto remote_type = RemoteCandidate(ep2_ch1())->type(); const std::string& remote_protocol = RemoteCandidate(ep2_ch1())->protocol(); return (local_protocol == expected.controlled_protocol && remote_protocol == expected.controlling_protocol && @@ -641,9 +641,9 @@ class P2PTransportChannelTestBase : public ::testing::Test, return; } - const std::string& local_type = LocalCandidate(ep2_ch1())->type(); + auto local_type = LocalCandidate(ep2_ch1())->type(); const std::string& local_protocol = LocalCandidate(ep2_ch1())->protocol(); - const std::string& remote_type = RemoteCandidate(ep2_ch1())->type(); + auto remote_type = RemoteCandidate(ep2_ch1())->type(); const std::string& remote_protocol = RemoteCandidate(ep2_ch1())->protocol(); EXPECT_EQ(expected.controlled_type, local_type); EXPECT_EQ(expected.controlling_type, remote_type); diff --git a/pc/peer_connection_ice_unittest.cc b/pc/peer_connection_ice_unittest.cc index bd4848cf8b..267cca4959 100644 --- a/pc/peer_connection_ice_unittest.cc +++ b/pc/peer_connection_ice_unittest.cc @@ -361,7 +361,7 @@ class PeerConnectionIceTest << " != " << b.address().ToString(); } if (a.type() != b.type()) { - failure_info << "\ntype: " << a.type() << " != " << b.type(); + failure_info << "\ntype: " << a.type_name() << " != " << b.type_name(); } std::string failure_info_str = failure_info.str(); if (failure_info_str.empty()) { diff --git a/pc/rtc_stats_collector.cc b/pc/rtc_stats_collector.cc index b9492c904b..a49e8ef0b2 100644 --- a/pc/rtc_stats_collector.cc +++ b/pc/rtc_stats_collector.cc @@ -164,19 +164,6 @@ std::string RTCMediaSourceStatsIDFromKindAndAttachment( return sb.str(); } -const char* CandidateTypeToRTCIceCandidateType(const cricket::Candidate& c) { - if (c.is_local()) - return "host"; - if (c.is_stun()) - return "srflx"; - if (c.is_prflx()) - return "prflx"; - if (c.is_relay()) - return "relay"; - RTC_DCHECK_NOTREACHED(); - return nullptr; -} - const char* DataStateToRTCDataChannelState( DataChannelInterface::DataState state) { switch (state) { @@ -998,8 +985,7 @@ const std::string& ProduceIceCandidateStats(Timestamp timestamp, candidate_stats->address = candidate.address().ipaddr().ToString(); candidate_stats->port = static_cast(candidate.address().port()); candidate_stats->protocol = candidate.protocol(); - candidate_stats->candidate_type = - CandidateTypeToRTCIceCandidateType(candidate); + candidate_stats->candidate_type = candidate.type_name(); candidate_stats->priority = static_cast(candidate.priority()); candidate_stats->foundation = candidate.foundation(); auto related_address = candidate.related_address(); diff --git a/pc/webrtc_sdp.cc b/pc/webrtc_sdp.cc index 1069a18391..ea9c8580cd 100644 --- a/pc/webrtc_sdp.cc +++ b/pc/webrtc_sdp.cc @@ -1120,7 +1120,7 @@ bool ParseCandidate(absl::string_view message, return ParseFailed(first_line, "Unsupported transport type.", error); } - std::string candidate_type; + absl::string_view candidate_type; const absl::string_view type = fields[7]; if (type == kCandidateHost) { candidate_type = cricket::LOCAL_PORT_TYPE;