RTCIceCandidateStats.transportId added and collected.

BUG=webrtc:6756, chromium:632723, chromium:627816

Review-Url: https://codereview.webrtc.org/2597963002
Cr-Commit-Position: refs/heads/master@{#15875}
This commit is contained in:
hbos 2017-01-02 09:59:31 -08:00 committed by Commit bot
parent d25f79eb83
commit b4e426e8db
5 changed files with 27 additions and 9 deletions

View File

@ -390,6 +390,8 @@ class RTCStatsReportVerifier {
bool VerifyRTCIceCandidateStats(
const RTCIceCandidateStats& candidate) {
RTCStatsVerifier verifier(report_, &candidate);
verifier.TestMemberIsIDReference(
candidate.transport_id, RTCTransportStats::kType);
verifier.TestMemberIsDefined(candidate.is_remote);
verifier.TestMemberIsDefined(candidate.ip);
verifier.TestMemberIsNonNegative<int32_t>(candidate.port);

View File

@ -277,7 +277,7 @@ void ProduceCertificateStatsFromSSLCertificateStats(
const std::string& ProduceIceCandidateStats(
int64_t timestamp_us, const cricket::Candidate& candidate, bool is_local,
RTCStatsReport* report) {
const std::string& transport_id, RTCStatsReport* report) {
const std::string& id = "RTCIceCandidate_" + candidate.id();
const RTCStats* stats = report->Get(id);
if (!stats) {
@ -286,6 +286,7 @@ const std::string& ProduceIceCandidateStats(
candidate_stats.reset(new RTCLocalIceCandidateStats(id, timestamp_us));
else
candidate_stats.reset(new RTCRemoteIceCandidateStats(id, timestamp_us));
candidate_stats->transport_id = transport_id;
candidate_stats->ip = candidate.address().ipaddr().ToString();
candidate_stats->port = static_cast<int32_t>(candidate.address().port());
candidate_stats->protocol = candidate.protocol();
@ -664,9 +665,9 @@ void RTCStatsCollector::ProduceIceCandidateAndPairStats_n(
// Port objects, and prflx candidates (both local and remote) are only
// stored in candidate pairs. crbug.com/632723
candidate_pair_stats->local_candidate_id = ProduceIceCandidateStats(
timestamp_us, info.local_candidate, true, report);
timestamp_us, info.local_candidate, true, transport_id, report);
candidate_pair_stats->remote_candidate_id = ProduceIceCandidateStats(
timestamp_us, info.remote_candidate, false, report);
timestamp_us, info.remote_candidate, false, transport_id, report);
candidate_pair_stats->state =
IceCandidatePairStateToRTCStatsIceCandidatePairState(info.state);
candidate_pair_stats->priority = info.priority;

View File

@ -904,6 +904,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) {
0);
RTCLocalIceCandidateStats expected_a_local_host(
"RTCIceCandidate_" + a_local_host->id(), 0);
expected_a_local_host.transport_id = "RTCTransport_a_0";
expected_a_local_host.ip = "1.2.3.4";
expected_a_local_host.port = 5;
expected_a_local_host.protocol = "a_local_host's protocol";
@ -918,6 +919,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) {
1);
RTCRemoteIceCandidateStats expected_a_remote_srflx(
"RTCIceCandidate_" + a_remote_srflx->id(), 0);
expected_a_remote_srflx.transport_id = "RTCTransport_a_0";
expected_a_remote_srflx.ip = "6.7.8.9";
expected_a_remote_srflx.port = 10;
expected_a_remote_srflx.protocol = "remote_srflx's protocol";
@ -933,6 +935,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) {
2);
RTCLocalIceCandidateStats expected_a_local_prflx(
"RTCIceCandidate_" + a_local_prflx->id(), 0);
expected_a_local_prflx.transport_id = "RTCTransport_a_0";
expected_a_local_prflx.ip = "11.12.13.14";
expected_a_local_prflx.port = 15;
expected_a_local_prflx.protocol = "a_local_prflx's protocol";
@ -948,6 +951,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) {
3);
RTCRemoteIceCandidateStats expected_a_remote_relay(
"RTCIceCandidate_" + a_remote_relay->id(), 0);
expected_a_remote_relay.transport_id = "RTCTransport_a_0";
expected_a_remote_relay.ip = "16.17.18.19";
expected_a_remote_relay.port = 20;
expected_a_remote_relay.protocol = "a_remote_relay's protocol";
@ -964,6 +968,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) {
42);
RTCLocalIceCandidateStats expected_b_local(
"RTCIceCandidate_" + b_local->id(), 0);
expected_b_local.transport_id = "RTCTransport_b_0";
expected_b_local.ip = "42.42.42.42";
expected_b_local.port = 42;
expected_b_local.protocol = "b_local's protocol";
@ -979,6 +984,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) {
42);
RTCRemoteIceCandidateStats expected_b_remote(
"RTCIceCandidate_" + b_remote->id(), 0);
expected_b_remote.transport_id = "RTCTransport_b_0";
expected_b_remote.ip = "42.42.42.42";
expected_b_remote.port = 42;
expected_b_remote.protocol = "b_remote's protocol";
@ -1025,30 +1031,32 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) {
rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport();
EXPECT_TRUE(report->Get(expected_a_local_host.id()));
ASSERT_TRUE(report->Get(expected_a_local_host.id()));
EXPECT_EQ(expected_a_local_host,
report->Get(expected_a_local_host.id())->cast_to<
RTCLocalIceCandidateStats>());
EXPECT_TRUE(report->Get(expected_a_remote_srflx.id()));
ASSERT_TRUE(report->Get(expected_a_remote_srflx.id()));
EXPECT_EQ(expected_a_remote_srflx,
report->Get(expected_a_remote_srflx.id())->cast_to<
RTCRemoteIceCandidateStats>());
EXPECT_TRUE(report->Get(expected_a_local_prflx.id()));
ASSERT_TRUE(report->Get(expected_a_local_prflx.id()));
EXPECT_EQ(expected_a_local_prflx,
report->Get(expected_a_local_prflx.id())->cast_to<
RTCLocalIceCandidateStats>());
EXPECT_TRUE(report->Get(expected_a_remote_relay.id()));
ASSERT_TRUE(report->Get(expected_a_remote_relay.id()));
EXPECT_EQ(expected_a_remote_relay,
report->Get(expected_a_remote_relay.id())->cast_to<
RTCRemoteIceCandidateStats>());
EXPECT_TRUE(report->Get(expected_b_local.id()));
ASSERT_TRUE(report->Get(expected_b_local.id()));
EXPECT_EQ(expected_b_local,
report->Get(expected_b_local.id())->cast_to<
RTCLocalIceCandidateStats>());
EXPECT_TRUE(report->Get(expected_b_remote.id()));
ASSERT_TRUE(report->Get(expected_b_remote.id()));
EXPECT_EQ(expected_b_remote,
report->Get(expected_b_remote.id())->cast_to<
RTCRemoteIceCandidateStats>());
EXPECT_TRUE(report->Get("RTCTransport_a_0"));
EXPECT_TRUE(report->Get("RTCTransport_b_0"));
}
TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidatePairStats) {
@ -1115,9 +1123,11 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidatePairStats) {
EXPECT_EQ(
expected_pair,
report->Get(expected_pair.id())->cast_to<RTCIceCandidatePairStats>());
EXPECT_TRUE(report->Get(*expected_pair.transport_id));
RTCLocalIceCandidateStats expected_local_candidate(
*expected_pair.local_candidate_id, report->timestamp_us());
expected_local_candidate.transport_id = *expected_pair.transport_id;
expected_local_candidate.ip = "42.42.42.42";
expected_local_candidate.port = 42;
expected_local_candidate.protocol = "protocol";
@ -1132,6 +1142,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidatePairStats) {
RTCRemoteIceCandidateStats expected_remote_candidate(
*expected_pair.remote_candidate_id, report->timestamp_us());
expected_remote_candidate.transport_id = *expected_pair.transport_id;
expected_remote_candidate.ip = "42.42.42.42";
expected_remote_candidate.port = 42;
expected_remote_candidate.protocol = "protocol";

View File

@ -167,6 +167,7 @@ class RTCIceCandidateStats : public RTCStats {
RTCIceCandidateStats(const RTCIceCandidateStats& other);
~RTCIceCandidateStats() override;
RTCStatsMember<std::string> transport_id;
RTCStatsMember<bool> is_remote;
RTCStatsMember<std::string> ip;
RTCStatsMember<int32_t> port;

View File

@ -236,6 +236,7 @@ RTCIceCandidatePairStats::~RTCIceCandidatePairStats() {
}
WEBRTC_RTCSTATS_IMPL(RTCIceCandidateStats, RTCStats, "ice-candidate",
&transport_id,
&is_remote,
&ip,
&port,
@ -253,6 +254,7 @@ RTCIceCandidateStats::RTCIceCandidateStats(
RTCIceCandidateStats::RTCIceCandidateStats(
std::string&& id, int64_t timestamp_us, bool is_remote)
: RTCStats(std::move(id), timestamp_us),
transport_id("transportId"),
is_remote("isRemote", is_remote),
ip("ip"),
port("port"),
@ -265,6 +267,7 @@ RTCIceCandidateStats::RTCIceCandidateStats(
RTCIceCandidateStats::RTCIceCandidateStats(const RTCIceCandidateStats& other)
: RTCStats(other.id(), other.timestamp_us()),
transport_id(other.transport_id),
is_remote(other.is_remote),
ip(other.ip),
port(other.port),