1cb89c6f91491e683e47e5505536c154c905d5194bjornv@webrtc.org/* 2cb89c6f91491e683e47e5505536c154c905d5194bjornv@webrtc.org * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3cb89c6f91491e683e47e5505536c154c905d5194bjornv@webrtc.org * 4cb89c6f91491e683e47e5505536c154c905d5194bjornv@webrtc.org * Use of this source code is governed by a BSD-style license 5cb89c6f91491e683e47e5505536c154c905d5194bjornv@webrtc.org * that can be found in the LICENSE file in the root of the source 6cb89c6f91491e683e47e5505536c154c905d5194bjornv@webrtc.org * tree. An additional intellectual property rights grant can be found 7cb89c6f91491e683e47e5505536c154c905d5194bjornv@webrtc.org * in the file PATENTS. All contributing project authors may 8cb89c6f91491e683e47e5505536c154c905d5194bjornv@webrtc.org * be found in the AUTHORS file in the root of the source tree. 9cb89c6f91491e683e47e5505536c154c905d5194bjornv@webrtc.org */ 109f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org#ifndef WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_OVERUSE_DETECTOR_H_ 119f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org#define WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_OVERUSE_DETECTOR_H_ 12cb89c6f91491e683e47e5505536c154c905d5194bjornv@webrtc.org 13cb89c6f91491e683e47e5505536c154c905d5194bjornv@webrtc.org#include <list> 14cb89c6f91491e683e47e5505536c154c905d5194bjornv@webrtc.org 159f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org#include "webrtc/base/constructormagic.h" 16ff761fba8274d93bd73e76c8b8a1f2d0776dd840Henrik Kjellander#include "webrtc/modules/include/module_common_types.h" 1747ce120efb74f3adc0a796f2399912d14bb4e4e6pbos@webrtc.org#include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h" 1847ce120efb74f3adc0a796f2399912d14bb4e4e6pbos@webrtc.org#include "webrtc/typedefs.h" 19cb89c6f91491e683e47e5505536c154c905d5194bjornv@webrtc.org 20cb89c6f91491e683e47e5505536c154c905d5194bjornv@webrtc.orgnamespace webrtc { 21cb89c6f91491e683e47e5505536c154c905d5194bjornv@webrtc.orgenum RateControlRegion; 22cb89c6f91491e683e47e5505536c154c905d5194bjornv@webrtc.org 23c62642c7a662a2a88293b82192e2240049f0cbb9stefanbool AdaptiveThresholdExperimentIsEnabled(); 24c62642c7a662a2a88293b82192e2240049f0cbb9stefan 25976a7e61c17047fdc27401a015a1be55749cc914stefan@webrtc.orgclass OveruseDetector { 26cb89c6f91491e683e47e5505536c154c905d5194bjornv@webrtc.org public: 2764c0a0a1110a69d722b6f7610e4096fe3288fe67stefan explicit OveruseDetector(const OverUseDetectorOptions& options); 28c62642c7a662a2a88293b82192e2240049f0cbb9stefan virtual ~OveruseDetector(); 29cb89c6f91491e683e47e5505536c154c905d5194bjornv@webrtc.org 309f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org // Update the detection state based on the estimated inter-arrival time delta 319f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org // offset. |timestamp_delta| is the delta between the last timestamp which the 329f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org // estimated offset is based on and the last timestamp on which the last 339f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org // offset was based on, representing the time between detector updates. 349f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org // |num_of_deltas| is the number of deltas the offset estimate is based on. 359f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org // Returns the state after the detection update. 36dcbd3acbef881b0e6a5d459c6f6b7c7080eb1a20Stefan Holmer BandwidthUsage Detect(double offset, 37dcbd3acbef881b0e6a5d459c6f6b7c7080eb1a20Stefan Holmer double timestamp_delta, 38dcbd3acbef881b0e6a5d459c6f6b7c7080eb1a20Stefan Holmer int num_of_deltas, 39dcbd3acbef881b0e6a5d459c6f6b7c7080eb1a20Stefan Holmer int64_t now_ms); 406dcef360f8564b2d291e08c4d727e7a595747da6stefan@webrtc.org 419f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org // Returns the current detector state. 429f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org BandwidthUsage State() const; 43976a7e61c17047fdc27401a015a1be55749cc914stefan@webrtc.org 449f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org private: 45c62642c7a662a2a88293b82192e2240049f0cbb9stefan void UpdateThreshold(double modified_offset, int64_t now_ms); 46c62642c7a662a2a88293b82192e2240049f0cbb9stefan void InitializeExperiment(); 47c62642c7a662a2a88293b82192e2240049f0cbb9stefan 48c62642c7a662a2a88293b82192e2240049f0cbb9stefan const bool in_experiment_; 49c62642c7a662a2a88293b82192e2240049f0cbb9stefan double k_up_; 50c62642c7a662a2a88293b82192e2240049f0cbb9stefan double k_down_; 51c62642c7a662a2a88293b82192e2240049f0cbb9stefan double overusing_time_threshold_; 529f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org // Must be first member variable. Cannot be const because we need to be 539f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org // copyable. 5464c0a0a1110a69d722b6f7610e4096fe3288fe67stefan webrtc::OverUseDetectorOptions options_; 55cb89c6f91491e683e47e5505536c154c905d5194bjornv@webrtc.org double threshold_; 56c62642c7a662a2a88293b82192e2240049f0cbb9stefan int64_t last_update_ms_; 57bd7aeba8fb4c87084b77068840f224b12b9d110castor@webrtc.org double prev_offset_; 58bd7aeba8fb4c87084b77068840f224b12b9d110castor@webrtc.org double time_over_using_; 599f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org int overuse_counter_; 60cb89c6f91491e683e47e5505536c154c905d5194bjornv@webrtc.org BandwidthUsage hypothesis_; 619f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org 623c089d751ede283e21e186885eaf705c3257ccd2henrikg RTC_DISALLOW_COPY_AND_ASSIGN(OveruseDetector); 63cb89c6f91491e683e47e5505536c154c905d5194bjornv@webrtc.org}; 64cb89c6f91491e683e47e5505536c154c905d5194bjornv@webrtc.org} // namespace webrtc 65cb89c6f91491e683e47e5505536c154c905d5194bjornv@webrtc.org 669f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org#endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_OVERUSE_DETECTOR_H_ 67