19f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org/* 29f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 39f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org * 49f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org * Use of this source code is governed by a BSD-style license 59f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org * that can be found in the LICENSE file in the root of the source 69f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org * tree. An additional intellectual property rights grant can be found 79f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org * in the file PATENTS. All contributing project authors may 89f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org * be found in the AUTHORS file in the root of the source tree. 99f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org */ 109f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org#ifndef WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_OVERUSE_ESTIMATOR_H_ 119f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org#define WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_OVERUSE_ESTIMATOR_H_ 129f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org 139f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org#include <list> 149f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org 159f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org#include "webrtc/base/constructormagic.h" 169f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org#include "webrtc/common_types.h" 179f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org#include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h" 189f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org 199f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.orgnamespace webrtc { 209f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org 219f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.orgclass OveruseEstimator { 229f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org public: 239f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org explicit OveruseEstimator(const OverUseDetectorOptions& options); 249f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org ~OveruseEstimator(); 259f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org 269f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org // Update the estimator with a new sample. The deltas should represent deltas 279f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org // between timestamp groups as defined by the InterArrival class. 289f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org // |current_hypothesis| should be the hypothesis of the over-use detector at 299f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org // this time. 309f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org void Update(int64_t t_delta, double ts_delta, int size_delta, 319f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org BandwidthUsage current_hypothesis); 329f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org 339f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org // Returns the estimated noise/jitter variance in ms^2. 349f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org double var_noise() const { 359f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org return var_noise_; 369f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org } 379f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org 389f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org // Returns the estimated inter-arrival time delta offset in ms. 399f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org double offset() const { 409f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org return offset_; 419f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org } 429f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org 439f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org // Returns the number of deltas which the current over-use estimator state is 449f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org // based on. 459f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org unsigned int num_of_deltas() const { 469f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org return num_of_deltas_; 479f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org } 489f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org 499f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org private: 509f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org double UpdateMinFramePeriod(double ts_delta); 519f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org void UpdateNoiseEstimate(double residual, double ts_delta, bool stable_state); 529f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org 539f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org // Must be first member variable. Cannot be const because we need to be 549f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org // copyable. 559f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org OverUseDetectorOptions options_; 569f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org uint16_t num_of_deltas_; 579f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org double slope_; 589f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org double offset_; 599f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org double prev_offset_; 609f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org double E_[2][2]; 619f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org double process_noise_[2]; 629f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org double avg_noise_; 639f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org double var_noise_; 649f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org std::list<double> ts_delta_hist_; 659f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org 663c089d751ede283e21e186885eaf705c3257ccd2henrikg RTC_DISALLOW_COPY_AND_ASSIGN(OveruseEstimator); 679f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org}; 689f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org} // namespace webrtc 699f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org 709f79fe684a5d8c2dfb0db43a3715f32c5eebd94fpbos@webrtc.org#endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_OVERUSE_ESTIMATOR_H_ 71