diff --git a/webrtc/api/rtcstats_integrationtest.cc b/webrtc/api/rtcstats_integrationtest.cc index d78ba3529f..84ea3aba97 100644 --- a/webrtc/api/rtcstats_integrationtest.cc +++ b/webrtc/api/rtcstats_integrationtest.cc @@ -354,6 +354,7 @@ class RTCStatsReportVerifier { bool VerifyRTCIceCandidateStats( const RTCIceCandidateStats& candidate) { RTCStatsVerifier verifier(report_, &candidate); + verifier.TestMemberIsDefined(candidate.is_remote); verifier.TestMemberIsDefined(candidate.ip); verifier.TestMemberIsDefined(candidate.port); verifier.TestMemberIsDefined(candidate.protocol); diff --git a/webrtc/api/rtcstatscollector_unittest.cc b/webrtc/api/rtcstatscollector_unittest.cc index 749b3d51e3..ee090543d9 100644 --- a/webrtc/api/rtcstatscollector_unittest.cc +++ b/webrtc/api/rtcstatscollector_unittest.cc @@ -909,6 +909,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) { expected_a_local_host.protocol = "a_local_host's protocol"; expected_a_local_host.candidate_type = "host"; expected_a_local_host.priority = 0; + EXPECT_FALSE(*expected_a_local_host.is_remote); std::unique_ptr a_remote_srflx = CreateFakeCandidate( "6.7.8.9", 10, @@ -922,6 +923,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) { expected_a_remote_srflx.protocol = "remote_srflx's protocol"; expected_a_remote_srflx.candidate_type = "srflx"; expected_a_remote_srflx.priority = 1; + EXPECT_TRUE(*expected_a_remote_srflx.is_remote); std::unique_ptr a_local_prflx = CreateFakeCandidate( "11.12.13.14", 15, @@ -935,6 +937,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) { expected_a_local_prflx.protocol = "a_local_prflx's protocol"; expected_a_local_prflx.candidate_type = "prflx"; expected_a_local_prflx.priority = 2; + EXPECT_FALSE(*expected_a_local_prflx.is_remote); std::unique_ptr a_remote_relay = CreateFakeCandidate( "16.17.18.19", 20, @@ -948,6 +951,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) { expected_a_remote_relay.protocol = "a_remote_relay's protocol"; expected_a_remote_relay.candidate_type = "relay"; expected_a_remote_relay.priority = 3; + EXPECT_TRUE(*expected_a_remote_relay.is_remote); // Candidates in the second transport stats. std::unique_ptr b_local = CreateFakeCandidate( @@ -962,6 +966,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) { expected_b_local.protocol = "b_local's protocol"; expected_b_local.candidate_type = "host"; expected_b_local.priority = 42; + EXPECT_FALSE(*expected_b_local.is_remote); std::unique_ptr b_remote = CreateFakeCandidate( "42.42.42.42", 42, @@ -975,6 +980,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) { expected_b_remote.protocol = "b_remote's protocol"; expected_b_remote.candidate_type = "host"; expected_b_remote.priority = 42; + EXPECT_TRUE(*expected_b_remote.is_remote); SessionStats session_stats; @@ -1108,6 +1114,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidatePairStats) { expected_local_candidate.protocol = "protocol"; expected_local_candidate.candidate_type = "host"; expected_local_candidate.priority = 42; + EXPECT_FALSE(*expected_local_candidate.is_remote); ASSERT_TRUE(report->Get(expected_local_candidate.id())); EXPECT_EQ(expected_local_candidate, report->Get(expected_local_candidate.id())->cast_to< @@ -1120,6 +1127,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidatePairStats) { expected_remote_candidate.protocol = "protocol"; expected_remote_candidate.candidate_type = "host"; expected_remote_candidate.priority = 42; + EXPECT_TRUE(*expected_remote_candidate.is_remote); ASSERT_TRUE(report->Get(expected_remote_candidate.id())); EXPECT_EQ(expected_remote_candidate, report->Get(expected_remote_candidate.id())->cast_to< diff --git a/webrtc/api/stats/rtcstats_objects.h b/webrtc/api/stats/rtcstats_objects.h index 429f93b755..d18b248ad7 100644 --- a/webrtc/api/stats/rtcstats_objects.h +++ b/webrtc/api/stats/rtcstats_objects.h @@ -170,6 +170,7 @@ class RTCIceCandidateStats : public RTCStats { RTCIceCandidateStats(const RTCIceCandidateStats& other); ~RTCIceCandidateStats() override; + RTCStatsMember is_remote; RTCStatsMember ip; RTCStatsMember port; RTCStatsMember protocol; @@ -180,8 +181,9 @@ class RTCIceCandidateStats : public RTCStats { RTCStatsMember url; protected: - RTCIceCandidateStats(const std::string& id, int64_t timestamp_us); - RTCIceCandidateStats(std::string&& id, int64_t timestamp_us); + RTCIceCandidateStats( + const std::string& id, int64_t timestamp_us, bool is_remote); + RTCIceCandidateStats(std::string&& id, int64_t timestamp_us, bool is_remote); }; // In the spec both local and remote varieties are of type RTCIceCandidateStats. diff --git a/webrtc/stats/rtcstats_objects.cc b/webrtc/stats/rtcstats_objects.cc index 73d070e740..d4fea49519 100644 --- a/webrtc/stats/rtcstats_objects.cc +++ b/webrtc/stats/rtcstats_objects.cc @@ -237,6 +237,7 @@ RTCIceCandidatePairStats::~RTCIceCandidatePairStats() { } WEBRTC_RTCSTATS_IMPL(RTCIceCandidateStats, RTCStats, "ice-candidate", + &is_remote, &ip, &port, &protocol, @@ -245,13 +246,14 @@ WEBRTC_RTCSTATS_IMPL(RTCIceCandidateStats, RTCStats, "ice-candidate", &url); RTCIceCandidateStats::RTCIceCandidateStats( - const std::string& id, int64_t timestamp_us) - : RTCIceCandidateStats(std::string(id), timestamp_us) { + const std::string& id, int64_t timestamp_us, bool is_remote) + : RTCIceCandidateStats(std::string(id), timestamp_us, is_remote) { } RTCIceCandidateStats::RTCIceCandidateStats( - std::string&& id, int64_t timestamp_us) + std::string&& id, int64_t timestamp_us, bool is_remote) : RTCStats(std::move(id), timestamp_us), + is_remote("isRemote", is_remote), ip("ip"), port("port"), protocol("protocol"), @@ -262,6 +264,7 @@ RTCIceCandidateStats::RTCIceCandidateStats( RTCIceCandidateStats::RTCIceCandidateStats(const RTCIceCandidateStats& other) : RTCStats(other.id(), other.timestamp_us()), + is_remote(other.is_remote), ip(other.ip), port(other.port), protocol(other.protocol), @@ -277,12 +280,12 @@ const char RTCLocalIceCandidateStats::kType[] = "local-candidate"; RTCLocalIceCandidateStats::RTCLocalIceCandidateStats( const std::string& id, int64_t timestamp_us) - : RTCIceCandidateStats(id, timestamp_us) { + : RTCIceCandidateStats(id, timestamp_us, false) { } RTCLocalIceCandidateStats::RTCLocalIceCandidateStats( std::string&& id, int64_t timestamp_us) - : RTCIceCandidateStats(std::move(id), timestamp_us) { + : RTCIceCandidateStats(std::move(id), timestamp_us, false) { } const char* RTCLocalIceCandidateStats::type() const { @@ -293,12 +296,12 @@ const char RTCRemoteIceCandidateStats::kType[] = "remote-candidate"; RTCRemoteIceCandidateStats::RTCRemoteIceCandidateStats( const std::string& id, int64_t timestamp_us) - : RTCIceCandidateStats(id, timestamp_us) { + : RTCIceCandidateStats(id, timestamp_us, true) { } RTCRemoteIceCandidateStats::RTCRemoteIceCandidateStats( std::string&& id, int64_t timestamp_us) - : RTCIceCandidateStats(std::move(id), timestamp_us) { + : RTCIceCandidateStats(std::move(id), timestamp_us, true) { } const char* RTCRemoteIceCandidateStats::type() const {