RTCTransportStats.dtlsState replaces .activeConnection

In accordance with recent spec change:
https://github.com/w3c/webrtc-stats/pull/122

BUG=chromium:653873, chromium:627816

Review-Url: https://codereview.webrtc.org/2625993002
Cr-Commit-Position: refs/heads/master@{#16098}
This commit is contained in:
hbos
2017-01-16 07:38:02 -08:00
committed by Commit bot
parent 3d200bd6ac
commit 7064d5929a
7 changed files with 49 additions and 11 deletions

View File

@ -572,7 +572,7 @@ class RTCStatsReportVerifier {
verifier.TestMemberIsNonNegative<uint64_t>(transport.bytes_received);
verifier.TestMemberIsOptionalIDReference(
transport.rtcp_transport_stats_id, RTCTransportStats::kType);
verifier.TestMemberIsDefined(transport.active_connection);
verifier.TestMemberIsDefined(transport.dtls_state);
verifier.TestMemberIsIDReference(
transport.selected_candidate_pair_id, RTCIceCandidatePairStats::kType);
verifier.TestMemberIsIDReference(

View File

@ -132,6 +132,25 @@ const char* IceCandidatePairStateToRTCStatsIceCandidatePairState(
}
}
const char* DtlsTransportStateToRTCDtlsTransportState(
cricket::DtlsTransportState state) {
switch (state) {
case cricket::DTLS_TRANSPORT_NEW:
return RTCDtlsTransportState::kNew;
case cricket::DTLS_TRANSPORT_CONNECTING:
return RTCDtlsTransportState::kConnecting;
case cricket::DTLS_TRANSPORT_CONNECTED:
return RTCDtlsTransportState::kConnected;
case cricket::DTLS_TRANSPORT_CLOSED:
return RTCDtlsTransportState::kClosed;
case cricket::DTLS_TRANSPORT_FAILED:
return RTCDtlsTransportState::kFailed;
default:
RTC_NOTREACHED();
return nullptr;
}
}
std::unique_ptr<RTCCodecStats> CodecStatsFromRtpCodecParameters(
uint64_t timestamp_us, bool inbound, bool audio,
const RtpCodecParameters& codec_params) {
@ -926,13 +945,13 @@ void RTCStatsCollector::ProduceTransportStats_n(
timestamp_us));
transport_stats->bytes_sent = 0;
transport_stats->bytes_received = 0;
transport_stats->active_connection = false;
transport_stats->dtls_state = DtlsTransportStateToRTCDtlsTransportState(
channel_stats.dtls_state);
for (const cricket::ConnectionInfo& info :
channel_stats.connection_infos) {
*transport_stats->bytes_sent += info.sent_total_bytes;
*transport_stats->bytes_received += info.recv_total_bytes;
if (info.best_connection) {
transport_stats->active_connection = true;
transport_stats->selected_candidate_pair_id =
RTCIceCandidatePairStatsIDFromConnectionInfo(info);
}

View File

@ -1989,6 +1989,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCTransportStats) {
cricket::TransportChannelStats rtp_transport_channel_stats;
rtp_transport_channel_stats.component = cricket::ICE_CANDIDATE_COMPONENT_RTP;
rtp_transport_channel_stats.connection_infos.push_back(rtp_connection_info);
rtp_transport_channel_stats.dtls_state = cricket::DTLS_TRANSPORT_NEW;
session_stats.transport_stats["transport"].channel_stats.push_back(
rtp_transport_channel_stats);
@ -2008,7 +2009,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCTransportStats) {
report->timestamp_us());
expected_rtp_transport.bytes_sent = 42;
expected_rtp_transport.bytes_received = 1337;
expected_rtp_transport.active_connection = false;
expected_rtp_transport.dtls_state = RTCDtlsTransportState::kNew;
ASSERT_TRUE(report->Get(expected_rtp_transport.id()));
EXPECT_EQ(
@ -2025,6 +2026,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCTransportStats) {
rtcp_transport_channel_stats.component =
cricket::ICE_CANDIDATE_COMPONENT_RTCP;
rtcp_transport_channel_stats.connection_infos.push_back(rtcp_connection_info);
rtcp_transport_channel_stats.dtls_state = cricket::DTLS_TRANSPORT_CONNECTING;
session_stats.transport_stats["transport"].channel_stats.push_back(
rtcp_transport_channel_stats);
@ -2038,7 +2040,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCTransportStats) {
report->timestamp_us());
expected_rtcp_transport.bytes_sent = 1337;
expected_rtcp_transport.bytes_received = 42;
expected_rtcp_transport.active_connection = false;
expected_rtcp_transport.dtls_state = RTCDtlsTransportState::kConnecting;
expected_rtp_transport.rtcp_transport_stats_id = expected_rtcp_transport.id();
@ -2051,7 +2053,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCTransportStats) {
expected_rtcp_transport,
report->Get(expected_rtcp_transport.id())->cast_to<RTCTransportStats>());
// Get stats with an active connection.
// Get stats with an active connection (selected candidate pair).
session_stats.transport_stats["transport"]
.channel_stats[1]
.connection_infos[0]
@ -2060,7 +2062,6 @@ TEST_F(RTCStatsCollectorTest, CollectRTCTransportStats) {
collector_->ClearCachedStatsReport();
report = GetStatsReport();
expected_rtcp_transport.active_connection = true;
expected_rtcp_transport.selected_candidate_pair_id =
"RTCIceCandidatePair_" + rtcp_local_candidate->id() + "_" +
rtcp_remote_candidate->id();

View File

@ -42,6 +42,15 @@ struct RTCIceCandidateType {
static const char* kRelay;
};
// https://w3c.github.io/webrtc-pc/#idl-def-rtcdtlstransportstate
struct RTCDtlsTransportState {
static const char* kNew;
static const char* kConnecting;
static const char* kConnected;
static const char* kClosed;
static const char* kFailed;
};
// https://w3c.github.io/webrtc-stats/#certificatestats-dict*
class RTCCertificateStats final : public RTCStats {
public:
@ -391,7 +400,8 @@ class RTCTransportStats final : public RTCStats {
RTCStatsMember<uint64_t> bytes_sent;
RTCStatsMember<uint64_t> bytes_received;
RTCStatsMember<std::string> rtcp_transport_stats_id;
RTCStatsMember<bool> active_connection;
// TODO(hbos): Support enum types? "RTCStatsMember<RTCDtlsTransportState>"?
RTCStatsMember<std::string> dtls_state;
RTCStatsMember<std::string> selected_candidate_pair_id;
RTCStatsMember<std::string> local_certificate_id;
RTCStatsMember<std::string> remote_certificate_id;

View File

@ -291,6 +291,7 @@ bool JsepTransport::GetStats(TransportStats* stats) {
substats.component = kv.first;
channel->GetSrtpCryptoSuite(&substats.srtp_crypto_suite);
channel->GetSslCipherSuite(&substats.ssl_cipher_suite);
substats.dtls_state = channel->dtls_state();
if (!channel->GetStats(&substats.connection_infos)) {
return false;
}

View File

@ -125,6 +125,7 @@ struct TransportChannelStats {
ConnectionInfos connection_infos;
int srtp_crypto_suite = rtc::SRTP_INVALID_CRYPTO_SUITE;
int ssl_cipher_suite = rtc::TLS_NULL_WITH_NULL_NULL;
DtlsTransportState dtls_state = DTLS_TRANSPORT_NEW;
};
// Information about all the channels of a transport.

View File

@ -29,6 +29,12 @@ const char* RTCIceCandidateType::kSrflx = "srflx";
const char* RTCIceCandidateType::kPrflx = "prflx";
const char* RTCIceCandidateType::kRelay = "relay";
const char* RTCDtlsTransportState::kNew = "new";
const char* RTCDtlsTransportState::kConnecting = "connecting";
const char* RTCDtlsTransportState::kConnected = "connected";
const char* RTCDtlsTransportState::kClosed = "closed";
const char* RTCDtlsTransportState::kFailed = "failed";
WEBRTC_RTCSTATS_IMPL(RTCCertificateStats, RTCStats, "certificate",
&fingerprint,
&fingerprint_algorithm,
@ -601,7 +607,7 @@ WEBRTC_RTCSTATS_IMPL(RTCTransportStats, RTCStats, "transport",
&bytes_sent,
&bytes_received,
&rtcp_transport_stats_id,
&active_connection,
&dtls_state,
&selected_candidate_pair_id,
&local_certificate_id,
&remote_certificate_id);
@ -617,7 +623,7 @@ RTCTransportStats::RTCTransportStats(
bytes_sent("bytesSent"),
bytes_received("bytesReceived"),
rtcp_transport_stats_id("rtcpTransportStatsId"),
active_connection("activeConnection"),
dtls_state("dtlsState"),
selected_candidate_pair_id("selectedCandidatePairId"),
local_certificate_id("localCertificateId"),
remote_certificate_id("remoteCertificateId") {
@ -629,7 +635,7 @@ RTCTransportStats::RTCTransportStats(
bytes_sent(other.bytes_sent),
bytes_received(other.bytes_received),
rtcp_transport_stats_id(other.rtcp_transport_stats_id),
active_connection(other.active_connection),
dtls_state(other.dtls_state),
selected_candidate_pair_id(other.selected_candidate_pair_id),
local_certificate_id(other.local_certificate_id),
remote_certificate_id(other.remote_certificate_id) {