Files
platform-external-webrtc/test/scenario/quality_stats_unittest.cc
Sebastian Jansson 9a4f38ec5c Adds optional video quality metrics to scenario tests.
Bug: webrtc:9510
Change-Id: I448e7156cc8f56930f58c4d25bd167df83a2ba85
Reviewed-on: https://webrtc-review.googlesource.com/c/114885
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26065}
2018-12-20 08:50:12 +00:00

63 lines
2.3 KiB
C++

/*
* Copyright 2018 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "test/gtest.h"
#include "test/scenario/scenario.h"
namespace webrtc {
namespace test {
namespace {
VideoStreamConfig AnalyzerVideoConfig(VideoQualityStats* stats) {
VideoStreamConfig config;
config.encoder.codec = VideoStreamConfig::Encoder::Codec::kVideoCodecVP8;
config.encoder.implementation =
VideoStreamConfig::Encoder::Implementation::kSoftware;
config.analyzer.frame_quality_handler = [stats](VideoFrameQualityInfo info) {
stats->HandleFrameInfo(info);
};
return config;
}
} // namespace
TEST(ScenarioAnalyzerTest, PsnrIsHighWhenNetworkIsGood) {
VideoQualityStats stats;
{
Scenario s;
NetworkNodeConfig good_network;
good_network.simulation.bandwidth = DataRate::kbps(1000);
auto route = s.CreateRoutes(s.CreateClient("caller", CallClientConfig()),
{s.CreateSimulationNode(good_network)},
s.CreateClient("callee", CallClientConfig()),
{s.CreateSimulationNode(NetworkNodeConfig())});
s.CreateVideoStream(route->forward(), AnalyzerVideoConfig(&stats));
s.RunFor(TimeDelta::seconds(1));
}
EXPECT_GT(stats.psnr.Mean(), 46);
}
TEST(ScenarioAnalyzerTest, PsnrIsLowWhenNetworkIsBad) {
VideoQualityStats stats;
{
Scenario s;
NetworkNodeConfig bad_network;
bad_network.simulation.bandwidth = DataRate::kbps(100);
bad_network.simulation.loss_rate = 0.02;
auto route = s.CreateRoutes(s.CreateClient("caller", CallClientConfig()),
{s.CreateSimulationNode(bad_network)},
s.CreateClient("callee", CallClientConfig()),
{s.CreateSimulationNode(NetworkNodeConfig())});
s.CreateVideoStream(route->forward(), AnalyzerVideoConfig(&stats));
s.RunFor(TimeDelta::seconds(2));
}
EXPECT_LT(stats.psnr.Mean(), 40);
}
} // namespace test
} // namespace webrtc