Add API to get raw stats value from DefaultAudioQualityAnalyzer

Bug: webrtc:10138
Change-Id: I60601a47c8dd8f669297d91825fe057f2b3da634
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/133565
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27685}
This commit is contained in:
Artem Titov 2019-04-18 13:18:43 +02:00 committed by Commit Bot
parent d3e761e822
commit 76723ae836
3 changed files with 17 additions and 4 deletions

View File

@ -385,6 +385,7 @@ rtc_source_set("default_audio_quality_analyzer") {
"../../../api:libjingle_peerconnection_api",
"../../../api:stats_observer_interface",
"../../../api:track_id_stream_label_map",
"../../../rtc_base:criticalsection",
"../../../rtc_base:logging",
"../../../rtc_base:rtc_numerics",
"//third_party/abseil-cpp/absl/strings",

View File

@ -10,8 +10,6 @@
#include "test/pc/e2e/analyzer/audio/default_audio_quality_analyzer.h"
#include <string.h>
#include "api/stats_types.h"
#include "rtc_base/logging.h"
#include "test/testsupport/perf_test.h"
@ -80,6 +78,8 @@ void DefaultAudioQualityAnalyzer::OnStatsReports(
const std::string& stream_label =
GetStreamLabelFromStatsReport(stats_report);
rtc::CritScope crit(&lock_);
AudioStreamStats& audio_stream_stats = streams_stats_[stream_label];
audio_stream_stats.expand_rate.AddSample(expand_rate->float_val());
audio_stream_stats.accelerate_rate.AddSample(accelerate_rate->float_val());
@ -106,6 +106,7 @@ std::string DefaultAudioQualityAnalyzer::GetTestCaseName(
}
void DefaultAudioQualityAnalyzer::Stop() {
rtc::CritScope crit(&lock_);
for (auto& item : streams_stats_) {
ReportResult("expand_rate", item.first, item.second.expand_rate,
"unitless");
@ -120,6 +121,12 @@ void DefaultAudioQualityAnalyzer::Stop() {
}
}
std::map<std::string, AudioStreamStats>
DefaultAudioQualityAnalyzer::GetAudioStreamsStats() const {
rtc::CritScope crit(&lock_);
return streams_stats_;
}
void DefaultAudioQualityAnalyzer::ReportResult(
const std::string& metric_name,
const std::string& stream_label,

View File

@ -18,13 +18,13 @@
#include "api/stats_types.h"
#include "api/test/audio_quality_analyzer_interface.h"
#include "api/test/track_id_stream_label_map.h"
#include "rtc_base/critical_section.h"
#include "rtc_base/numerics/samples_stats_counter.h"
namespace webrtc {
namespace webrtc_pc_e2e {
struct AudioStreamStats {
public:
SamplesStatsCounter expand_rate;
SamplesStatsCounter accelerate_rate;
SamplesStatsCounter preemptive_rate;
@ -42,6 +42,9 @@ class DefaultAudioQualityAnalyzer : public AudioQualityAnalyzerInterface {
const StatsReports& stats_reports) override;
void Stop() override;
// Returns audio quality stats per stream label.
std::map<std::string, AudioStreamStats> GetAudioStreamsStats() const;
private:
const std::string& GetStreamLabelFromStatsReport(
const StatsReport* stats_report) const;
@ -53,7 +56,9 @@ class DefaultAudioQualityAnalyzer : public AudioQualityAnalyzerInterface {
std::string test_case_name_;
TrackIdStreamLabelMap* analyzer_helper_;
std::map<std::string, AudioStreamStats> streams_stats_;
rtc::CriticalSection lock_;
std::map<std::string, AudioStreamStats> streams_stats_ RTC_GUARDED_BY(lock_);
};
} // namespace webrtc_pc_e2e