Use ordered data structure for supported frame lengths in ANA.
The ANA frame length controller requires the provided frame lengths supported by the encoder to be ordered. A data structural guarantee of such was in an earlier version but was accidentally removed since https://codereview.webrtc.org/2429503002. This CL uses std::set to ensure that again.
Change-Id: Ia197dbf6a34f02506e81c9f49d6cd60e4cdacef4
BUG: webrtc:6303
Reviewed-on: https://webrtc-review.googlesource.com/c/115946
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Commit-Queue: Minyue Li <minyue@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26119}
diff --git a/modules/audio_coding/audio_network_adaptor/controller_manager.cc b/modules/audio_coding/audio_network_adaptor/controller_manager.cc
index 32f9fcb..6c99561 100644
--- a/modules/audio_coding/audio_network_adaptor/controller_manager.cc
+++ b/modules/audio_coding/audio_network_adaptor/controller_manager.cc
@@ -147,13 +147,13 @@
}
FrameLengthController::Config ctor_config(
- std::vector<int>(), initial_frame_length_ms, min_encoder_bitrate_bps,
+ std::set<int>(), initial_frame_length_ms, min_encoder_bitrate_bps,
config.fl_increasing_packet_loss_fraction(),
config.fl_decreasing_packet_loss_fraction(), fl_increase_overhead_offset,
fl_decrease_overhead_offset, std::move(fl_changing_bandwidths_bps));
for (auto frame_length : encoder_frame_lengths_ms)
- ctor_config.encoder_frame_lengths_ms.push_back(frame_length);
+ ctor_config.encoder_frame_lengths_ms.insert(frame_length);
return std::unique_ptr<FrameLengthController>(
new FrameLengthController(ctor_config));
diff --git a/modules/audio_coding/audio_network_adaptor/frame_length_controller.cc b/modules/audio_coding/audio_network_adaptor/frame_length_controller.cc
index b123c7c..3cb91fd 100644
--- a/modules/audio_coding/audio_network_adaptor/frame_length_controller.cc
+++ b/modules/audio_coding/audio_network_adaptor/frame_length_controller.cc
@@ -28,7 +28,7 @@
} // namespace
FrameLengthController::Config::Config(
- const std::vector<int>& encoder_frame_lengths_ms,
+ const std::set<int>& encoder_frame_lengths_ms,
int initial_frame_length_ms,
int min_encoder_bitrate_bps,
float fl_increasing_packet_loss_fraction,
diff --git a/modules/audio_coding/audio_network_adaptor/frame_length_controller.h b/modules/audio_coding/audio_network_adaptor/frame_length_controller.h
index f0a5aab..c852704 100644
--- a/modules/audio_coding/audio_network_adaptor/frame_length_controller.h
+++ b/modules/audio_coding/audio_network_adaptor/frame_length_controller.h
@@ -13,7 +13,7 @@
#include <stddef.h>
#include <map>
-#include <vector>
+#include <set>
#include "absl/types/optional.h"
#include "modules/audio_coding/audio_network_adaptor/controller.h"
@@ -33,7 +33,7 @@
int from_frame_length_ms;
int to_frame_length_ms;
};
- Config(const std::vector<int>& encoder_frame_lengths_ms,
+ Config(const std::set<int>& encoder_frame_lengths_ms,
int initial_frame_length_ms,
int min_encoder_bitrate_bps,
float fl_increasing_packet_loss_fraction,
@@ -43,7 +43,7 @@
std::map<FrameLengthChange, int> fl_changing_bandwidths_bps);
Config(const Config& other);
~Config();
- std::vector<int> encoder_frame_lengths_ms;
+ std::set<int> encoder_frame_lengths_ms;
int initial_frame_length_ms;
int min_encoder_bitrate_bps;
// Uplink packet loss fraction below which frame length can increase.
@@ -74,7 +74,7 @@
const Config config_;
- std::vector<int>::const_iterator frame_length_ms_;
+ std::set<int>::const_iterator frame_length_ms_;
absl::optional<int> uplink_bandwidth_bps_;
diff --git a/modules/audio_coding/audio_network_adaptor/frame_length_controller_unittest.cc b/modules/audio_coding/audio_network_adaptor/frame_length_controller_unittest.cc
index f97ad4f..8d6d815 100644
--- a/modules/audio_coding/audio_network_adaptor/frame_length_controller_unittest.cc
+++ b/modules/audio_coding/audio_network_adaptor/frame_length_controller_unittest.cc
@@ -42,7 +42,7 @@
std::unique_ptr<FrameLengthController> CreateController(
const std::map<FrameLengthController::Config::FrameLengthChange, int>&
frame_length_change_criteria,
- const std::vector<int>& encoder_frame_lengths_ms,
+ const std::set<int>& encoder_frame_lengths_ms,
int initial_frame_length_ms) {
std::unique_ptr<FrameLengthController> controller(
new FrameLengthController(FrameLengthController::Config(