tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

reorder_optimizer.h (1381B)


      1 /*
      2 *  Copyright (c) 2021 The WebRTC project authors. All Rights Reserved.
      3 *
      4 *  Use of this source code is governed by a BSD-style license
      5 *  that can be found in the LICENSE file in the root of the source
      6 *  tree. An additional intellectual property rights grant can be found
      7 *  in the file PATENTS.  All contributing project authors may
      8 *  be found in the AUTHORS file in the root of the source tree.
      9 */
     10 
     11 #ifndef MODULES_AUDIO_CODING_NETEQ_REORDER_OPTIMIZER_H_
     12 #define MODULES_AUDIO_CODING_NETEQ_REORDER_OPTIMIZER_H_
     13 
     14 #include <optional>
     15 
     16 #include "modules/audio_coding/neteq/histogram.h"
     17 
     18 namespace webrtc {
     19 
     20 // Calculates an optimal delay to reduce the chance of missing reordered
     21 // packets. The delay/loss trade-off can be tune using the `ms_per_loss_percent`
     22 // parameter.
     23 class ReorderOptimizer {
     24 public:
     25  ReorderOptimizer(int forget_factor,
     26                   int ms_per_loss_percent,
     27                   std::optional<int> start_forget_weight);
     28 
     29  void Update(int relative_delay_ms, bool reordered, int base_delay_ms);
     30 
     31  std::optional<int> GetOptimalDelayMs() const { return optimal_delay_ms_; }
     32 
     33  void Reset();
     34 
     35 private:
     36  int MinimizeCostFunction(int base_delay_ms) const;
     37 
     38  Histogram histogram_;
     39  const int ms_per_loss_percent_;
     40  std::optional<int> optimal_delay_ms_;
     41 };
     42 
     43 }  // namespace webrtc
     44 #endif  // MODULES_AUDIO_CODING_NETEQ_REORDER_OPTIMIZER_H_