Reland of BWE allocation strategy

TBR=stefan@webrtc.org,alexnarest@webrtc.org

Bug: webrtc:8243
Change-Id: Ie68e4f414b2ac32ba4e64877cb250fabcb089a07
Reviewed-on: https://webrtc-review.googlesource.com/13940
Commit-Queue: Alex Narest <alexnarest@webrtc.org>
Reviewed-by: Alex Narest <alexnarest@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20369}
This commit is contained in:
Alex Narest
2017-10-20 10:37:47 +02:00
committed by Commit Bot
parent b82de30080
commit 78609d5b6b
31 changed files with 543 additions and 24 deletions

View File

@ -14,10 +14,12 @@
#include <stdint.h>
#include <map>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "rtc_base/bitrateallocationstrategy.h"
#include "rtc_base/sequenced_task_checker.h"
namespace webrtc {
@ -94,32 +96,35 @@ class BitrateAllocator {
// the list of added observers, a best guess is returned.
int GetStartBitrate(BitrateAllocatorObserver* observer);
// Sets external allocation strategy. If strategy is not set default WebRTC
// allocation mechanism will be used. The strategy may be changed during call.
// Setting NULL value will restore default WEBRTC allocation strategy.
void SetBitrateAllocationStrategy(
std::unique_ptr<rtc::BitrateAllocationStrategy>
bitrate_allocation_strategy);
private:
// Note: All bitrates for member variables and methods are in bps.
struct ObserverConfig {
struct ObserverConfig : rtc::BitrateAllocationStrategy::TrackConfig {
ObserverConfig(BitrateAllocatorObserver* observer,
uint32_t min_bitrate_bps,
uint32_t max_bitrate_bps,
uint32_t pad_up_bitrate_bps,
bool enforce_min_bitrate,
std::string track_id)
: observer(observer),
min_bitrate_bps(min_bitrate_bps),
max_bitrate_bps(max_bitrate_bps),
: TrackConfig(min_bitrate_bps,
max_bitrate_bps,
enforce_min_bitrate,
track_id),
observer(observer),
pad_up_bitrate_bps(pad_up_bitrate_bps),
enforce_min_bitrate(enforce_min_bitrate),
allocated_bitrate_bps(-1),
media_ratio(1.0),
track_id(track_id) {}
media_ratio(1.0) {}
BitrateAllocatorObserver* observer;
uint32_t min_bitrate_bps;
uint32_t max_bitrate_bps;
uint32_t pad_up_bitrate_bps;
bool enforce_min_bitrate;
int64_t allocated_bitrate_bps;
double media_ratio; // Part of the total bitrate used for media [0.0, 1.0].
std::string track_id;
};
// Calculates the minimum requested send bitrate and max padding bitrate and
@ -172,6 +177,8 @@ class BitrateAllocator {
int64_t last_bwe_log_time_ RTC_GUARDED_BY(&sequenced_checker_);
uint32_t total_requested_padding_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_
RTC_GUARDED_BY(&sequenced_checker_);
};
} // namespace webrtc
#endif // CALL_BITRATE_ALLOCATOR_H_