Use default value if field trial switch is set to an invalid number
Bug: webrtc:9851
Change-Id: I195e2e9b30905bd65f703098db9a1e7e44eac073
Reviewed-on: https://webrtc-review.googlesource.com/c/107620
Reviewed-by: Erik Språng <sprang@webrtc.org>
Commit-Queue: Johannes Kron <kron@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25354}diff --git a/video/rtp_video_stream_receiver.cc b/video/rtp_video_stream_receiver.cc
index 6f1724f..c6b297d 100644
--- a/video/rtp_video_stream_receiver.cc
+++ b/video/rtp_video_stream_receiver.cc
@@ -154,15 +154,16 @@
process_thread_->RegisterModule(nack_module_.get(), RTC_FROM_HERE);
}
- // The group here can be either a positive integer with an explicit size, in
- // which case that is used as size. All other values shall result in the
- // default value being used.
+ // The group here must be a positive power of 2, in which case that is used as
+ // size. All other values shall result in the default value being used.
const std::string group_name =
webrtc::field_trial::FindFullName("WebRTC-PacketBufferMaxSize");
int packet_buffer_max_size = kPacketBufferMaxSize;
if (!group_name.empty() &&
(sscanf(group_name.c_str(), "%d", &packet_buffer_max_size) != 1 ||
- packet_buffer_max_size <= 0)) {
+ packet_buffer_max_size <= 0 ||
+ // Verify that the number is a positive power of 2.
+ (packet_buffer_max_size & (packet_buffer_max_size - 1)) != 0)) {
RTC_LOG(LS_WARNING) << "Invalid packet buffer max size: " << group_name;
packet_buffer_max_size = kPacketBufferMaxSize;
}