stats: do not expose empty ice-ufrag on transport stats
following the guidelines from
https://w3c.github.io/webrtc-stats/#guidelines-for-implementing-stats-objects
This came up during https://github.com/w3c/webrtc-stats/issues/804
Bug: None
Change-Id: I1360fc66d67d30f77d897e58f3741e4fac420c96
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/399960
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Commit-Queue: Philipp Hancke <phancke@meta.com>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#45137}
diff --git a/pc/rtc_stats_collector.cc b/pc/rtc_stats_collector.cc
index 3be877c..4a364da 100644
--- a/pc/rtc_stats_collector.cc
+++ b/pc/rtc_stats_collector.cc
@@ -10,11 +10,9 @@
#include "pc/rtc_stats_collector.h"
-#include <stdint.h>
-#include <stdio.h>
-
#include <algorithm>
#include <cstdint>
+#include <cstdio>
#include <map>
#include <memory>
#include <optional>
@@ -86,8 +84,8 @@
namespace {
-const char kDirectionInbound = 'I';
-const char kDirectionOutbound = 'O';
+constexpr char kDirectionInbound = 'I';
+constexpr char kDirectionOutbound = 'O';
constexpr char kAudioPlayoutSingletonId[] = "AP";
@@ -1972,8 +1970,11 @@
channel_stats.ice_transport_stats.selected_candidate_pair_changes;
channel_transport_stats->ice_role =
IceRoleToRTCIceRole(channel_stats.ice_transport_stats.ice_role);
- channel_transport_stats->ice_local_username_fragment =
- channel_stats.ice_transport_stats.ice_local_username_fragment;
+ if (!channel_stats.ice_transport_stats.ice_local_username_fragment
+ .empty()) {
+ channel_transport_stats->ice_local_username_fragment =
+ channel_stats.ice_transport_stats.ice_local_username_fragment;
+ }
channel_transport_stats->ice_state =
IceTransportStateToRTCIceTransportState(
channel_stats.ice_transport_stats.ice_state);