Adopt absl::string_view in modules/congestion_controller/
Bug: webrtc:13579 Change-Id: I8d62487689293e425ee76c2dce5de243d7edc97a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/271284 Reviewed-by: Erik Språng <sprang@webrtc.org> Commit-Queue: Ali Tofigh <alito@webrtc.org> Reviewed-by: Björn Terelius <terelius@webrtc.org> Cr-Commit-Position: refs/heads/main@{#37807}
This commit is contained in:
parent
723f19d230
commit
15b464deaf
@ -300,7 +300,10 @@ if (rtc_include_tests) {
|
|||||||
"../../../test/logging:log_writer",
|
"../../../test/logging:log_writer",
|
||||||
"../../remote_bitrate_estimator",
|
"../../remote_bitrate_estimator",
|
||||||
]
|
]
|
||||||
absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
|
absl_deps = [
|
||||||
|
"//third_party/abseil-cpp/absl/strings",
|
||||||
|
"//third_party/abseil-cpp/absl/types:optional",
|
||||||
|
]
|
||||||
}
|
}
|
||||||
if (!build_with_chromium) {
|
if (!build_with_chromium) {
|
||||||
rtc_library("goog_cc_unittests") {
|
rtc_library("goog_cc_unittests") {
|
||||||
|
|||||||
@ -13,6 +13,7 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include "absl/strings/string_view.h"
|
||||||
#include "modules/congestion_controller/goog_cc/delay_based_bwe.h"
|
#include "modules/congestion_controller/goog_cc/delay_based_bwe.h"
|
||||||
#include "rtc_base/checks.h"
|
#include "rtc_base/checks.h"
|
||||||
|
|
||||||
@ -145,7 +146,7 @@ int64_t StreamGenerator::GenerateFrame(std::vector<PacketResult>* packets,
|
|||||||
|
|
||||||
DelayBasedBweTest::DelayBasedBweTest() : DelayBasedBweTest("") {}
|
DelayBasedBweTest::DelayBasedBweTest() : DelayBasedBweTest("") {}
|
||||||
|
|
||||||
DelayBasedBweTest::DelayBasedBweTest(const std::string& field_trial_string)
|
DelayBasedBweTest::DelayBasedBweTest(absl::string_view field_trial_string)
|
||||||
: field_trial(
|
: field_trial(
|
||||||
std::make_unique<test::ScopedFieldTrials>(field_trial_string)),
|
std::make_unique<test::ScopedFieldTrials>(field_trial_string)),
|
||||||
clock_(100000000),
|
clock_(100000000),
|
||||||
|
|||||||
@ -18,6 +18,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "absl/strings/string_view.h"
|
||||||
#include "api/transport/field_trial_based_config.h"
|
#include "api/transport/field_trial_based_config.h"
|
||||||
#include "api/transport/network_types.h"
|
#include "api/transport/network_types.h"
|
||||||
#include "modules/congestion_controller/goog_cc/acknowledged_bitrate_estimator.h"
|
#include "modules/congestion_controller/goog_cc/acknowledged_bitrate_estimator.h"
|
||||||
@ -117,7 +118,7 @@ class StreamGenerator {
|
|||||||
class DelayBasedBweTest : public ::testing::Test {
|
class DelayBasedBweTest : public ::testing::Test {
|
||||||
public:
|
public:
|
||||||
DelayBasedBweTest();
|
DelayBasedBweTest();
|
||||||
explicit DelayBasedBweTest(const std::string& field_trial_string);
|
explicit DelayBasedBweTest(absl::string_view field_trial_string);
|
||||||
~DelayBasedBweTest() override;
|
~DelayBasedBweTest() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include <queue>
|
#include <queue>
|
||||||
|
|
||||||
|
#include "absl/strings/string_view.h"
|
||||||
#include "api/test/network_emulation/create_cross_traffic.h"
|
#include "api/test/network_emulation/create_cross_traffic.h"
|
||||||
#include "api/test/network_emulation/cross_traffic.h"
|
#include "api/test/network_emulation/cross_traffic.h"
|
||||||
#include "api/transport/goog_cc_factory.h"
|
#include "api/transport/goog_cc_factory.h"
|
||||||
@ -138,10 +139,10 @@ absl::optional<DataRate> PacketTransmissionAndFeedbackBlock(
|
|||||||
|
|
||||||
// Scenarios:
|
// Scenarios:
|
||||||
|
|
||||||
void UpdatesTargetRateBasedOnLinkCapacity(std::string test_name = "") {
|
void UpdatesTargetRateBasedOnLinkCapacity(absl::string_view test_name = "") {
|
||||||
ScopedFieldTrials trial("WebRTC-SendSideBwe-WithOverhead/Enabled/");
|
ScopedFieldTrials trial("WebRTC-SendSideBwe-WithOverhead/Enabled/");
|
||||||
auto factory = CreateFeedbackOnlyFactory();
|
auto factory = CreateFeedbackOnlyFactory();
|
||||||
Scenario s("googcc_unit/target_capacity" + test_name, false);
|
Scenario s("googcc_unit/target_capacity" + std::string(test_name), false);
|
||||||
CallClientConfig config;
|
CallClientConfig config;
|
||||||
config.transport.cc_factory = &factory;
|
config.transport.cc_factory = &factory;
|
||||||
config.transport.rates.min_rate = DataRate::KilobitsPerSec(10);
|
config.transport.rates.min_rate = DataRate::KilobitsPerSec(10);
|
||||||
@ -188,7 +189,7 @@ void UpdatesTargetRateBasedOnLinkCapacity(std::string test_name = "") {
|
|||||||
EXPECT_NEAR(client->target_rate().kbps(), 90, 25);
|
EXPECT_NEAR(client->target_rate().kbps(), 90, 25);
|
||||||
}
|
}
|
||||||
|
|
||||||
DataRate RunRembDipScenario(std::string test_name) {
|
DataRate RunRembDipScenario(absl::string_view test_name) {
|
||||||
Scenario s(test_name);
|
Scenario s(test_name);
|
||||||
NetworkSimulationConfig net_conf;
|
NetworkSimulationConfig net_conf;
|
||||||
net_conf.bandwidth = DataRate::KilobitsPerSec(2000);
|
net_conf.bandwidth = DataRate::KilobitsPerSec(2000);
|
||||||
@ -619,7 +620,7 @@ TEST(GoogCcScenario, LossBasedControlDoesModestBackoffToHighLoss) {
|
|||||||
EXPECT_GT(client->target_rate().kbps(), 100);
|
EXPECT_GT(client->target_rate().kbps(), 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
DataRate AverageBitrateAfterCrossInducedLoss(std::string name) {
|
DataRate AverageBitrateAfterCrossInducedLoss(absl::string_view name) {
|
||||||
Scenario s(name, false);
|
Scenario s(name, false);
|
||||||
NetworkSimulationConfig net_conf;
|
NetworkSimulationConfig net_conf;
|
||||||
net_conf.bandwidth = DataRate::KilobitsPerSec(1000);
|
net_conf.bandwidth = DataRate::KilobitsPerSec(1000);
|
||||||
|
|||||||
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
#include "absl/strings/string_view.h"
|
||||||
#include "absl/types/optional.h"
|
#include "absl/types/optional.h"
|
||||||
#include "modules/congestion_controller/goog_cc/alr_detector.h"
|
#include "modules/congestion_controller/goog_cc/alr_detector.h"
|
||||||
#include "modules/congestion_controller/goog_cc/delay_based_bwe.h"
|
#include "modules/congestion_controller/goog_cc/delay_based_bwe.h"
|
||||||
@ -44,8 +45,8 @@ void WriteTypedValue(RtcEventLogOutput* out, absl::optional<Timestamp> value) {
|
|||||||
template <typename F>
|
template <typename F>
|
||||||
class TypedFieldLogger : public FieldLogger {
|
class TypedFieldLogger : public FieldLogger {
|
||||||
public:
|
public:
|
||||||
TypedFieldLogger(std::string name, F&& getter)
|
TypedFieldLogger(absl::string_view name, F&& getter)
|
||||||
: name_(std::move(name)), getter_(std::forward<F>(getter)) {}
|
: name_(name), getter_(std::forward<F>(getter)) {}
|
||||||
const std::string& name() const override { return name_; }
|
const std::string& name() const override { return name_; }
|
||||||
void WriteValue(RtcEventLogOutput* out) override {
|
void WriteValue(RtcEventLogOutput* out) override {
|
||||||
WriteTypedValue(out, getter_());
|
WriteTypedValue(out, getter_());
|
||||||
@ -57,8 +58,8 @@ class TypedFieldLogger : public FieldLogger {
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename F>
|
template <typename F>
|
||||||
FieldLogger* Log(std::string name, F&& getter) {
|
FieldLogger* Log(absl::string_view name, F&& getter) {
|
||||||
return new TypedFieldLogger<F>(std::move(name), std::forward<F>(getter));
|
return new TypedFieldLogger<F>(name, std::forward<F>(getter));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
#include "absl/flags/flag.h"
|
#include "absl/flags/flag.h"
|
||||||
#include "absl/flags/parse.h"
|
#include "absl/flags/parse.h"
|
||||||
|
#include "absl/strings/string_view.h"
|
||||||
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
|
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
|
||||||
#include "api/audio_codecs/builtin_audio_encoder_factory.h"
|
#include "api/audio_codecs/builtin_audio_encoder_factory.h"
|
||||||
#include "rtc_base/socket_address.h"
|
#include "rtc_base/socket_address.h"
|
||||||
@ -32,13 +33,13 @@ namespace test {
|
|||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
std::unique_ptr<FileLogWriterFactory> GetScenarioLogManager(
|
std::unique_ptr<FileLogWriterFactory> GetScenarioLogManager(
|
||||||
std::string file_name) {
|
absl::string_view file_name) {
|
||||||
if (absl::GetFlag(FLAGS_scenario_logs) && !file_name.empty()) {
|
if (absl::GetFlag(FLAGS_scenario_logs) && !file_name.empty()) {
|
||||||
std::string output_root = absl::GetFlag(FLAGS_scenario_logs_root);
|
std::string output_root = absl::GetFlag(FLAGS_scenario_logs_root);
|
||||||
if (output_root.empty())
|
if (output_root.empty())
|
||||||
output_root = OutputPath() + "output_data/";
|
output_root = OutputPath() + "output_data/";
|
||||||
|
|
||||||
auto base_filename = output_root + file_name + ".";
|
auto base_filename = output_root + std::string(file_name) + ".";
|
||||||
RTC_LOG(LS_INFO) << "Saving scenario logs to: " << base_filename;
|
RTC_LOG(LS_INFO) << "Saving scenario logs to: " << base_filename;
|
||||||
return std::make_unique<FileLogWriterFactory>(base_filename);
|
return std::make_unique<FileLogWriterFactory>(base_filename);
|
||||||
}
|
}
|
||||||
@ -54,10 +55,10 @@ Scenario::Scenario(const testing::TestInfo* test_info)
|
|||||||
: Scenario(std::string(test_info->test_suite_name()) + "/" +
|
: Scenario(std::string(test_info->test_suite_name()) + "/" +
|
||||||
test_info->name()) {}
|
test_info->name()) {}
|
||||||
|
|
||||||
Scenario::Scenario(std::string file_name)
|
Scenario::Scenario(absl::string_view file_name)
|
||||||
: Scenario(file_name, /*real_time=*/false) {}
|
: Scenario(file_name, /*real_time=*/false) {}
|
||||||
|
|
||||||
Scenario::Scenario(std::string file_name, bool real_time)
|
Scenario::Scenario(absl::string_view file_name, bool real_time)
|
||||||
: Scenario(GetScenarioLogManager(file_name), real_time) {}
|
: Scenario(GetScenarioLogManager(file_name), real_time) {}
|
||||||
|
|
||||||
Scenario::Scenario(
|
Scenario::Scenario(
|
||||||
@ -91,7 +92,7 @@ ColumnPrinter Scenario::TimePrinter() {
|
|||||||
32);
|
32);
|
||||||
}
|
}
|
||||||
|
|
||||||
StatesPrinter* Scenario::CreatePrinter(std::string name,
|
StatesPrinter* Scenario::CreatePrinter(absl::string_view name,
|
||||||
TimeDelta interval,
|
TimeDelta interval,
|
||||||
std::vector<ColumnPrinter> printers) {
|
std::vector<ColumnPrinter> printers) {
|
||||||
std::vector<ColumnPrinter> all_printers{TimePrinter()};
|
std::vector<ColumnPrinter> all_printers{TimePrinter()};
|
||||||
@ -105,7 +106,8 @@ StatesPrinter* Scenario::CreatePrinter(std::string name,
|
|||||||
return printer;
|
return printer;
|
||||||
}
|
}
|
||||||
|
|
||||||
CallClient* Scenario::CreateClient(std::string name, CallClientConfig config) {
|
CallClient* Scenario::CreateClient(absl::string_view name,
|
||||||
|
CallClientConfig config) {
|
||||||
CallClient* client = new CallClient(network_manager_.time_controller(),
|
CallClient* client = new CallClient(network_manager_.time_controller(),
|
||||||
GetLogWriterFactory(name), config);
|
GetLogWriterFactory(name), config);
|
||||||
if (config.transport.state_log_interval.IsFinite()) {
|
if (config.transport.state_log_interval.IsFinite()) {
|
||||||
@ -118,7 +120,7 @@ CallClient* Scenario::CreateClient(std::string name, CallClientConfig config) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CallClient* Scenario::CreateClient(
|
CallClient* Scenario::CreateClient(
|
||||||
std::string name,
|
absl::string_view name,
|
||||||
std::function<void(CallClientConfig*)> config_modifier) {
|
std::function<void(CallClientConfig*)> config_modifier) {
|
||||||
CallClientConfig config;
|
CallClientConfig config;
|
||||||
config_modifier(&config);
|
config_modifier(&config);
|
||||||
|
|||||||
@ -15,6 +15,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "absl/functional/any_invocable.h"
|
#include "absl/functional/any_invocable.h"
|
||||||
|
#include "absl/strings/string_view.h"
|
||||||
#include "api/task_queue/task_queue_base.h"
|
#include "api/task_queue/task_queue_base.h"
|
||||||
#include "api/test/time_controller.h"
|
#include "api/test/time_controller.h"
|
||||||
#include "rtc_base/fake_clock.h"
|
#include "rtc_base/fake_clock.h"
|
||||||
@ -43,8 +44,8 @@ class Scenario {
|
|||||||
public:
|
public:
|
||||||
Scenario();
|
Scenario();
|
||||||
explicit Scenario(const testing::TestInfo* test_info);
|
explicit Scenario(const testing::TestInfo* test_info);
|
||||||
explicit Scenario(std::string file_name);
|
explicit Scenario(absl::string_view file_name);
|
||||||
Scenario(std::string file_name, bool real_time);
|
Scenario(absl::string_view file_name, bool real_time);
|
||||||
Scenario(std::unique_ptr<LogWriterFactoryInterface> log_writer_manager,
|
Scenario(std::unique_ptr<LogWriterFactoryInterface> log_writer_manager,
|
||||||
bool real_time);
|
bool real_time);
|
||||||
|
|
||||||
@ -63,9 +64,9 @@ class Scenario {
|
|||||||
SimulationNode* CreateMutableSimulationNode(
|
SimulationNode* CreateMutableSimulationNode(
|
||||||
std::function<void(NetworkSimulationConfig*)> config_modifier);
|
std::function<void(NetworkSimulationConfig*)> config_modifier);
|
||||||
|
|
||||||
CallClient* CreateClient(std::string name, CallClientConfig config);
|
CallClient* CreateClient(absl::string_view name, CallClientConfig config);
|
||||||
CallClient* CreateClient(
|
CallClient* CreateClient(
|
||||||
std::string name,
|
absl::string_view name,
|
||||||
std::function<void(CallClientConfig*)> config_modifier);
|
std::function<void(CallClientConfig*)> config_modifier);
|
||||||
|
|
||||||
CallClientPair* CreateRoutes(CallClient* first,
|
CallClientPair* CreateRoutes(CallClient* first,
|
||||||
@ -139,7 +140,7 @@ class Scenario {
|
|||||||
size_t packet_size);
|
size_t packet_size);
|
||||||
|
|
||||||
ColumnPrinter TimePrinter();
|
ColumnPrinter TimePrinter();
|
||||||
StatesPrinter* CreatePrinter(std::string name,
|
StatesPrinter* CreatePrinter(absl::string_view name,
|
||||||
TimeDelta interval,
|
TimeDelta interval,
|
||||||
std::vector<ColumnPrinter> printers);
|
std::vector<ColumnPrinter> printers);
|
||||||
|
|
||||||
@ -148,13 +149,13 @@ class Scenario {
|
|||||||
// Return the duration of the current session so far.
|
// Return the duration of the current session so far.
|
||||||
TimeDelta TimeSinceStart();
|
TimeDelta TimeSinceStart();
|
||||||
|
|
||||||
std::unique_ptr<RtcEventLogOutput> GetLogWriter(std::string name) {
|
std::unique_ptr<RtcEventLogOutput> GetLogWriter(absl::string_view name) {
|
||||||
if (!log_writer_factory_ || name.empty())
|
if (!log_writer_factory_ || name.empty())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
return log_writer_factory_->Create(name);
|
return log_writer_factory_->Create(name);
|
||||||
}
|
}
|
||||||
std::unique_ptr<LogWriterFactoryInterface> GetLogWriterFactory(
|
std::unique_ptr<LogWriterFactoryInterface> GetLogWriterFactory(
|
||||||
std::string name) {
|
absl::string_view name) {
|
||||||
if (!log_writer_factory_ || name.empty())
|
if (!log_writer_factory_ || name.empty())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
return std::make_unique<LogWriterFactoryAddPrefix>(
|
return std::make_unique<LogWriterFactoryAddPrefix>(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user