From 325c1b219594ea644afaa4ba4d1b5da8ae645bcf Mon Sep 17 00:00:00 2001 From: Artem Titov Date: Mon, 22 Aug 2022 11:37:27 +0200 Subject: [PATCH] [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 Reviewed-by: Rasmus Brandt Auto-Submit: Artem Titov Cr-Commit-Position: refs/heads/main@{#37860} --- .../analyzer/video/default_video_quality_analyzer.cc | 3 ++- test/pc/e2e/analyzer/video/names_collection.h | 3 +++ test/pc/e2e/analyzer/video/names_collection_test.cc | 11 +++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/test/pc/e2e/analyzer/video/default_video_quality_analyzer.cc b/test/pc/e2e/analyzer/video/default_video_quality_analyzer.cc index e31843c8eb..64b5f05816 100644 --- a/test/pc/e2e/analyzer/video/default_video_quality_analyzer.cc +++ b/test/pc/e2e/analyzer/video/default_video_quality_analyzer.cc @@ -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; diff --git a/test/pc/e2e/analyzer/video/names_collection.h b/test/pc/e2e/analyzer/video/names_collection.h index e29bad1ad4..f9a13a2a11 100644 --- a/test/pc/e2e/analyzer/video/names_collection.h +++ b/test/pc/e2e/analyzer/video/names_collection.h @@ -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); } diff --git a/test/pc/e2e/analyzer/video/names_collection_test.cc b/test/pc/e2e/analyzer/video/names_collection_test.cc index 65932ea26e..6c52f96975 100644 --- a/test/pc/e2e/analyzer/video/names_collection_test.cc +++ b/test/pc/e2e/analyzer/video/names_collection_test.cc @@ -137,5 +137,16 @@ TEST(NamesCollectionTest, AddRemoveAddPreserveTheIndex) { EXPECT_THAT(collection.size(), Eq(static_cast(1))); } +TEST(NamesCollectionTest, GetKnownSizeReturnsForRemovedNames) { + NamesCollection collection(std::vector{}); + + size_t alice_index = collection.AddIfAbsent("alice"); + EXPECT_THAT(collection.GetKnownSize(), Eq(static_cast(1))); + + EXPECT_THAT(collection.RemoveIfPresent("alice"), + Eq(absl::optional(alice_index))); + EXPECT_THAT(collection.GetKnownSize(), Eq(static_cast(1))); +} + } // namespace } // namespace webrtc