[DVQA] Use all known peers count when determine metic's name

Bug: b/243115145
Change-Id: Ib375bc7373e3c70a05e8fe6ddd156bb524cc6f99
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/272548
Commit-Queue: Rasmus Brandt <brandtr@webrtc.org>
Reviewed-by: Rasmus Brandt <brandtr@webrtc.org>
Auto-Submit: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37860}
This commit is contained in:
Artem Titov
2022-08-22 11:37:27 +02:00
committed by WebRTC LUCI CQ
parent c6c346da61
commit 325c1b2195
3 changed files with 16 additions and 1 deletions

View File

@ -1010,7 +1010,8 @@ StatsKey DefaultVideoQualityAnalyzer::ToStatsKey(
std::string DefaultVideoQualityAnalyzer::ToMetricName(
const InternalStatsKey& key) const {
const std::string& stream_label = streams_.name(key.stream);
if (peers_->size() <= 2 && key.sender != key.receiver) {
if (peers_->GetKnownSize() <= 2 && key.sender != key.receiver) {
// TODO(titovartem): remove this special case.
return stream_label;
}
rtc::StringBuilder out;

View File

@ -44,6 +44,9 @@ class NamesCollection {
// Returns amount of currently presented names in the collection.
size_t size() const { return size_; }
// Returns amount of all names known to this collection.
size_t GetKnownSize() const { return names_.size(); }
// Returns index of the `name` which was known to the collection. Crashes
// if `name` was never registered in the collection.
size_t index(absl::string_view name) const { return index_.at(name); }

View File

@ -137,5 +137,16 @@ TEST(NamesCollectionTest, AddRemoveAddPreserveTheIndex) {
EXPECT_THAT(collection.size(), Eq(static_cast<size_t>(1)));
}
TEST(NamesCollectionTest, GetKnownSizeReturnsForRemovedNames) {
NamesCollection collection(std::vector<std::string>{});
size_t alice_index = collection.AddIfAbsent("alice");
EXPECT_THAT(collection.GetKnownSize(), Eq(static_cast<size_t>(1)));
EXPECT_THAT(collection.RemoveIfPresent("alice"),
Eq(absl::optional<size_t>(alice_index)));
EXPECT_THAT(collection.GetKnownSize(), Eq(static_cast<size_t>(1)));
}
} // namespace
} // namespace webrtc