1/*
2 *  Copyright (c) 2012 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 WEBRTC_MODULES_AUDIO_CODING_NETEQ_BUFFER_LEVEL_FILTER_H_
12#define WEBRTC_MODULES_AUDIO_CODING_NETEQ_BUFFER_LEVEL_FILTER_H_
13
14#include "webrtc/base/constructormagic.h"
15
16namespace webrtc {
17
18class BufferLevelFilter {
19 public:
20  BufferLevelFilter();
21  virtual ~BufferLevelFilter() {}
22  virtual void Reset();
23
24  // Updates the filter. Current buffer size is |buffer_size_packets| (Q0).
25  // If |time_stretched_samples| is non-zero, the value is converted to the
26  // corresponding number of packets, and is subtracted from the filtered
27  // value (thus bypassing the filter operation). |packet_len_samples| is the
28  // number of audio samples carried in each incoming packet.
29  virtual void Update(int buffer_size_packets, int time_stretched_samples,
30                      int packet_len_samples);
31
32  // Set the current target buffer level (obtained from
33  // DelayManager::base_target_level()). Used to select the appropriate
34  // filter coefficient.
35  virtual void SetTargetBufferLevel(int target_buffer_level);
36
37  virtual int filtered_current_level() const { return filtered_current_level_; }
38
39 private:
40  int level_factor_;  // Filter factor for the buffer level filter in Q8.
41  int filtered_current_level_;  // Filtered current buffer level in Q8.
42
43  DISALLOW_COPY_AND_ASSIGN(BufferLevelFilter);
44};
45
46}  // namespace webrtc
47#endif  // WEBRTC_MODULES_AUDIO_CODING_NETEQ_BUFFER_LEVEL_FILTER_H_
48