Enables configuration of transmission max bitrate multiplier and fec protection level.

Bug: webrtc:8963
Change-Id: I5e323f3947f84f87791a42024a4168f721ac6094
Reviewed-on: https://webrtc-review.googlesource.com/59142
Commit-Queue: Ying Wang <yinwa@webrtc.org>
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22273}
This commit is contained in:
Ying Wang 2018-03-02 17:04:11 +01:00 committed by Commit Bot
parent 13e743419d
commit a646d30820
3 changed files with 27 additions and 7 deletions

View File

@ -126,6 +126,7 @@ rtc_source_set("bitrate_allocator") {
"../rtc_base:rtc_base_approved", "../rtc_base:rtc_base_approved",
"../rtc_base:sequenced_task_checker", "../rtc_base:sequenced_task_checker",
"../system_wrappers", "../system_wrappers",
"../system_wrappers:field_trial_api",
"../system_wrappers:metrics_api", "../system_wrappers:metrics_api",
] ]
if (!build_with_chromium && is_clang) { if (!build_with_chromium && is_clang) {

View File

@ -20,16 +20,14 @@
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
#include "rtc_base/logging.h" #include "rtc_base/logging.h"
#include "system_wrappers/include/clock.h" #include "system_wrappers/include/clock.h"
#include "system_wrappers/include/field_trial.h"
#include "system_wrappers/include/metrics.h" #include "system_wrappers/include/metrics.h"
namespace webrtc { namespace webrtc {
// Allow packets to be transmitted in up to 2 times max video bitrate if the // Allow packets to be transmitted in up to 2 times max video bitrate if the
// bandwidth estimate allows it. // bandwidth estimate allows it.
// TODO(bugs.webrtc.org/8541): May be worth to refactor to keep this logic in const uint8_t kTransmissionMaxBitrateMultiplier = 2;
// video send stream. Similar logic is implemented in
// AudioPriorityBitrateAllocationStrategy.
const int kTransmissionMaxBitrateMultiplier = 2;
const int kDefaultBitrateBps = 300000; const int kDefaultBitrateBps = 300000;
// Require a bitrate increase of max(10%, 20kbps) to resume paused streams. // Require a bitrate increase of max(10%, 20kbps) to resume paused streams.
@ -61,7 +59,9 @@ BitrateAllocator::BitrateAllocator(LimitObserver* limit_observer)
last_bwe_log_time_(0), last_bwe_log_time_(0),
total_requested_padding_bitrate_(0), total_requested_padding_bitrate_(0),
total_requested_min_bitrate_(0), total_requested_min_bitrate_(0),
bitrate_allocation_strategy_(nullptr) { bitrate_allocation_strategy_(nullptr),
transmission_max_bitrate_multiplier_(
GetTransmissionMaxBitrateMultiplier()) {
sequenced_checker_.Detach(); sequenced_checker_.Detach();
} }
@ -70,6 +70,17 @@ BitrateAllocator::~BitrateAllocator() {
num_pause_events_); num_pause_events_);
} }
uint8_t BitrateAllocator::GetTransmissionMaxBitrateMultiplier() {
uint64_t multiplier = strtoul(webrtc::field_trial::FindFullName(
"WebRTC-TransmissionMaxBitrateMultiplier")
.c_str(),
nullptr, 10);
if (multiplier > 0 && multiplier <= kTransmissionMaxBitrateMultiplier) {
return static_cast<uint8_t>(multiplier);
}
return kTransmissionMaxBitrateMultiplier;
}
void BitrateAllocator::OnNetworkChanged(uint32_t target_bitrate_bps, void BitrateAllocator::OnNetworkChanged(uint32_t target_bitrate_bps,
uint8_t fraction_loss, uint8_t fraction_loss,
int64_t rtt, int64_t rtt,
@ -302,7 +313,7 @@ BitrateAllocator::ObserverAllocation BitrateAllocator::AllocateBitrates(
if (bitrate <= sum_max_bitrates) if (bitrate <= sum_max_bitrates)
return NormalRateAllocation(bitrate, sum_min_bitrates); return NormalRateAllocation(bitrate, sum_min_bitrates);
// All observers will get up to kTransmissionMaxBitrateMultiplier x max. // All observers will get up to transmission_max_bitrate_multiplier_ x max.
return MaxRateAllocation(bitrate, sum_max_bitrates); return MaxRateAllocation(bitrate, sum_max_bitrates);
} }
@ -406,7 +417,7 @@ BitrateAllocator::ObserverAllocation BitrateAllocator::MaxRateAllocation(
allocation[observer_config.observer] = observer_config.max_bitrate_bps; allocation[observer_config.observer] = observer_config.max_bitrate_bps;
bitrate -= observer_config.max_bitrate_bps; bitrate -= observer_config.max_bitrate_bps;
} }
DistributeBitrateEvenly(bitrate, true, kTransmissionMaxBitrateMultiplier, DistributeBitrateEvenly(bitrate, true, transmission_max_bitrate_multiplier_,
&allocation); &allocation);
return allocation; return allocation;
} }

View File

@ -188,6 +188,13 @@ class BitrateAllocator {
const ObserverAllocation& observers_capacities, const ObserverAllocation& observers_capacities,
ObserverAllocation* allocation); ObserverAllocation* allocation);
// Allow packets to be transmitted in up to 2 times max video bitrate if the
// bandwidth estimate allows it.
// TODO(bugs.webrtc.org/8541): May be worth to refactor to keep this logic in
// video send stream. Similar logic is implemented in
// AudioPriorityBitrateAllocationStrategy.
uint8_t GetTransmissionMaxBitrateMultiplier();
rtc::SequencedTaskChecker sequenced_checker_; rtc::SequencedTaskChecker sequenced_checker_;
LimitObserver* const limit_observer_ RTC_GUARDED_BY(&sequenced_checker_); LimitObserver* const limit_observer_ RTC_GUARDED_BY(&sequenced_checker_);
// Stored in a list to keep track of the insertion order. // Stored in a list to keep track of the insertion order.
@ -205,6 +212,7 @@ class BitrateAllocator {
uint32_t total_requested_min_bitrate_ RTC_GUARDED_BY(&sequenced_checker_); uint32_t total_requested_min_bitrate_ RTC_GUARDED_BY(&sequenced_checker_);
std::unique_ptr<rtc::BitrateAllocationStrategy> bitrate_allocation_strategy_ std::unique_ptr<rtc::BitrateAllocationStrategy> bitrate_allocation_strategy_
RTC_GUARDED_BY(&sequenced_checker_); RTC_GUARDED_BY(&sequenced_checker_);
uint8_t transmission_max_bitrate_multiplier_;
}; };
} // namespace webrtc } // namespace webrtc