Battery Status API: add UMA logging for Linux.
[chromium-blink-merge.git] / remoting / host / audio_silence_detector.h
blob83beec36a9864354a1c4b5bb5755506aae8c0bf7
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef REMOTING_HOST_AUDIO_SILENCE_DETECTOR_H_
6 #define REMOTING_HOST_AUDIO_SILENCE_DETECTOR_H_
8 #include "base/basictypes.h"
9 #include "base/logging.h"
11 namespace remoting {
13 // Helper used in audio capturers to detect and drop silent audio packets.
14 class AudioSilenceDetector {
15 public:
16 // |threshold| is used to specify maximum absolute sample value that should
17 // still be considered as silence.
18 AudioSilenceDetector(int threshold);
19 ~AudioSilenceDetector();
21 void Reset(int sampling_rate, int channels);
23 // Must be called for each new chunk of data. Return true the given packet
24 // is silence should be dropped.
25 bool IsSilence(const int16* samples, size_t samples_count);
27 private:
28 // Maximum absolute sample value that should still be considered as silence.
29 int threshold_;
31 // Silence period threshold in samples. Silence intervals shorter than this
32 // value are still encoded and sent to the client, so that we don't disrupt
33 // playback by dropping them.
34 int silence_length_max_;
36 // Lengths of the current silence period in samples.
37 int silence_length_;
40 } // namespace remoting
42 #endif // REMOTING_HOST_AUDIO_SILENCE_DETECTOR_H_