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"
13 // Helper used in audio capturers to detect and drop silent audio packets.
14 class AudioSilenceDetector
{
16 // |threshold| is used to specify maximum absolute sample value that should
17 // still be considered as silence.
18 explicit 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
);
28 // Maximum absolute sample value that should still be considered as silence.
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.
40 } // namespace remoting
42 #endif // REMOTING_HOST_AUDIO_SILENCE_DETECTOR_H_