Keep RTCTransportStats on P2PTransportChannel.

This cl/ changes so that the RTCTransportStats bytes/packets
sent/recevied is computed in P2PTransportChannel. Previously
they were computed by aggregating over the Connections, but that
does not work when Connections are created and destroyed.

Bug: webrtc:13769
Change-Id: Ia97dfae70b5aced897d4813ec007ba61bc032f87
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253100
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Jonas Oreland <jonaso@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36103}
This commit is contained in:
Jonas Oreland
2022-03-01 13:55:37 +01:00
committed by WebRTC LUCI CQ
parent 4d278e2caf
commit 42da5a9a10
6 changed files with 123 additions and 18 deletions

View File

@ -2042,21 +2042,20 @@ void RTCStatsCollector::ProduceTransportStats_n(
new RTCTransportStats(RTCTransportStatsIDFromTransportChannel(
transport_name, channel_stats.component),
timestamp_us));
transport_stats->bytes_sent = 0;
transport_stats->packets_sent = 0;
transport_stats->bytes_received = 0;
transport_stats->packets_received = 0;
transport_stats->packets_sent =
channel_stats.ice_transport_stats.packets_sent;
transport_stats->packets_received =
channel_stats.ice_transport_stats.packets_received;
transport_stats->bytes_sent =
channel_stats.ice_transport_stats.bytes_sent;
transport_stats->bytes_received =
channel_stats.ice_transport_stats.bytes_received;
transport_stats->dtls_state =
DtlsTransportStateToRTCDtlsTransportState(channel_stats.dtls_state);
transport_stats->selected_candidate_pair_changes =
channel_stats.ice_transport_stats.selected_candidate_pair_changes;
for (const cricket::ConnectionInfo& info :
channel_stats.ice_transport_stats.connection_infos) {
*transport_stats->bytes_sent += info.sent_total_bytes;
*transport_stats->packets_sent +=
info.sent_total_packets - info.sent_discarded_packets;
*transport_stats->bytes_received += info.recv_total_bytes;
*transport_stats->packets_received += info.packets_received;
if (info.best_connection) {
transport_stats->selected_candidate_pair_id =
RTCIceCandidatePairStatsIDFromConnectionInfo(info);