stats: implement iceLocalUsernameFragment
https://www.w3.org/TR/webrtc-stats/#dom-rtctransportstats-icelocalusernamefragment BUG=webrtc:14022 Change-Id: If56ebe66d83f4e535c2245f2ca3848469914679f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/261243 Reviewed-by: Harald Alvestrand <hta@webrtc.org> Commit-Queue: Philipp Hancke <philipp.hancke@googlemail.com> Cr-Commit-Position: refs/heads/main@{#36772}
This commit is contained in:
committed by
WebRTC LUCI CQ
parent
d7fd0f9744
commit
95b1a3497c
@ -709,6 +709,7 @@ class RTC_EXPORT RTCTransportStats final : public RTCStats {
|
||||
RTCStatsMember<std::string> srtp_cipher;
|
||||
RTCStatsMember<uint32_t> selected_candidate_pair_changes;
|
||||
RTCStatsMember<std::string> ice_role;
|
||||
RTCStatsMember<std::string> ice_local_username_fragment;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@ -49,6 +49,7 @@ struct IceTransportStats {
|
||||
uint64_t packets_received = 0;
|
||||
|
||||
IceRole ice_role = ICEROLE_UNKNOWN;
|
||||
std::string ice_local_username_fragment;
|
||||
};
|
||||
|
||||
typedef std::vector<Candidate> Candidates;
|
||||
|
||||
@ -1665,6 +1665,7 @@ bool P2PTransportChannel::GetStats(IceTransportStats* ice_transport_stats) {
|
||||
ice_transport_stats->packets_received = packets_received_;
|
||||
|
||||
ice_transport_stats->ice_role = GetIceRole();
|
||||
ice_transport_stats->ice_local_username_fragment = ice_parameters_.ufrag;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2116,6 +2116,8 @@ void RTCStatsCollector::ProduceTransportStats_n(
|
||||
channel_stats.ice_transport_stats.selected_candidate_pair_changes;
|
||||
transport_stats->ice_role =
|
||||
IceRoleToRTCIceRole(channel_stats.ice_transport_stats.ice_role);
|
||||
transport_stats->ice_local_username_fragment =
|
||||
channel_stats.ice_transport_stats.ice_local_username_fragment;
|
||||
for (const cricket::ConnectionInfo& info :
|
||||
channel_stats.ice_transport_stats.connection_infos) {
|
||||
if (info.best_connection) {
|
||||
|
||||
@ -2449,6 +2449,8 @@ TEST_F(RTCStatsCollectorTest, CollectRTCTransportStats) {
|
||||
rtp_transport_channel_stats.ice_transport_stats.packets_received = 4;
|
||||
rtp_transport_channel_stats.ice_transport_stats
|
||||
.selected_candidate_pair_changes = 1;
|
||||
rtp_transport_channel_stats.ice_transport_stats.ice_local_username_fragment =
|
||||
"thelocalufrag";
|
||||
pc_->SetTransportStats(kTransportName, {rtp_transport_channel_stats});
|
||||
|
||||
// Get stats without RTCP, an active connection or certificates.
|
||||
@ -2466,6 +2468,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCTransportStats) {
|
||||
expected_rtp_transport.dtls_role = RTCDtlsRole::kUnknown;
|
||||
expected_rtp_transport.selected_candidate_pair_changes = 1;
|
||||
expected_rtp_transport.ice_role = RTCIceRole::kUnknown;
|
||||
expected_rtp_transport.ice_local_username_fragment = "thelocalufrag";
|
||||
|
||||
ASSERT_TRUE(report->Get(expected_rtp_transport.id()));
|
||||
EXPECT_EQ(
|
||||
@ -2491,6 +2494,8 @@ TEST_F(RTCStatsCollectorTest, CollectRTCTransportStats) {
|
||||
rtcp_transport_channel_stats.ice_transport_stats.packets_sent = 1;
|
||||
rtcp_transport_channel_stats.ice_transport_stats.bytes_received = 42;
|
||||
rtcp_transport_channel_stats.ice_transport_stats.packets_received = 4;
|
||||
rtcp_transport_channel_stats.ice_transport_stats.ice_local_username_fragment =
|
||||
"thelocalufrag";
|
||||
pc_->SetTransportStats(kTransportName, {rtp_transport_channel_stats,
|
||||
rtcp_transport_channel_stats});
|
||||
|
||||
@ -2509,6 +2514,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCTransportStats) {
|
||||
expected_rtcp_transport.dtls_role = RTCDtlsRole::kUnknown;
|
||||
expected_rtcp_transport.selected_candidate_pair_changes = 0;
|
||||
expected_rtcp_transport.ice_role = RTCIceRole::kUnknown;
|
||||
expected_rtcp_transport.ice_local_username_fragment = "thelocalufrag";
|
||||
|
||||
expected_rtp_transport.rtcp_transport_stats_id = expected_rtcp_transport.id();
|
||||
ASSERT_TRUE(report->Get(expected_rtp_transport.id()));
|
||||
@ -2610,6 +2616,8 @@ TEST_F(RTCStatsCollectorTest, CollectRTCTransportStatsWithCrypto) {
|
||||
rtp_transport_channel_stats.dtls_role = rtc::SSL_CLIENT;
|
||||
rtp_transport_channel_stats.ice_transport_stats.ice_role =
|
||||
cricket::ICEROLE_CONTROLLING;
|
||||
rtp_transport_channel_stats.ice_transport_stats.ice_local_username_fragment =
|
||||
"thelocalufrag";
|
||||
// 0x2F is TLS_RSA_WITH_AES_128_CBC_SHA according to IANA
|
||||
rtp_transport_channel_stats.ssl_cipher_suite = 0x2F;
|
||||
rtp_transport_channel_stats.srtp_crypto_suite = rtc::kSrtpAes128CmSha1_80;
|
||||
@ -2629,10 +2637,11 @@ TEST_F(RTCStatsCollectorTest, CollectRTCTransportStatsWithCrypto) {
|
||||
expected_rtp_transport.bytes_received = 0;
|
||||
expected_rtp_transport.packets_sent = 0;
|
||||
expected_rtp_transport.packets_received = 0;
|
||||
expected_rtp_transport.ice_role = RTCIceRole::kControlling;
|
||||
expected_rtp_transport.ice_local_username_fragment = "thelocalufrag";
|
||||
// Crypto parameters
|
||||
expected_rtp_transport.tls_version = "0203";
|
||||
expected_rtp_transport.dtls_role = RTCDtlsRole::kClient;
|
||||
expected_rtp_transport.ice_role = RTCIceRole::kControlling;
|
||||
expected_rtp_transport.dtls_cipher = "TLS_RSA_WITH_AES_128_CBC_SHA";
|
||||
expected_rtp_transport.srtp_cipher = "AES_CM_128_HMAC_SHA1_80";
|
||||
|
||||
|
||||
@ -1144,6 +1144,7 @@ class RTCStatsReportVerifier {
|
||||
verifier.TestMemberIsPositive<uint32_t>(
|
||||
transport.selected_candidate_pair_changes);
|
||||
verifier.TestMemberIsDefined(transport.ice_role);
|
||||
verifier.TestMemberIsDefined(transport.ice_local_username_fragment);
|
||||
return verifier.ExpectAllMembersSuccessfullyTested();
|
||||
}
|
||||
|
||||
|
||||
@ -1098,7 +1098,8 @@ WEBRTC_RTCSTATS_IMPL(RTCTransportStats, RTCStats, "transport",
|
||||
&dtls_role,
|
||||
&srtp_cipher,
|
||||
&selected_candidate_pair_changes,
|
||||
&ice_role)
|
||||
&ice_role,
|
||||
&ice_local_username_fragment)
|
||||
// clang-format on
|
||||
|
||||
RTCTransportStats::RTCTransportStats(const std::string& id,
|
||||
@ -1121,7 +1122,8 @@ RTCTransportStats::RTCTransportStats(std::string&& id, int64_t timestamp_us)
|
||||
dtls_role("dtlsRole"),
|
||||
srtp_cipher("srtpCipher"),
|
||||
selected_candidate_pair_changes("selectedCandidatePairChanges"),
|
||||
ice_role("iceRole") {}
|
||||
ice_role("iceRole"),
|
||||
ice_local_username_fragment("iceLocalUsernameFragment") {}
|
||||
|
||||
RTCTransportStats::RTCTransportStats(const RTCTransportStats& other)
|
||||
: RTCStats(other.id(), other.timestamp_us()),
|
||||
@ -1139,7 +1141,8 @@ RTCTransportStats::RTCTransportStats(const RTCTransportStats& other)
|
||||
dtls_role(other.dtls_role),
|
||||
srtp_cipher(other.srtp_cipher),
|
||||
selected_candidate_pair_changes(other.selected_candidate_pair_changes),
|
||||
ice_role(other.ice_role) {}
|
||||
ice_role(other.ice_role),
|
||||
ice_local_username_fragment(other.ice_local_username_fragment) {}
|
||||
|
||||
RTCTransportStats::~RTCTransportStats() {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user