Line data Source code
1 : /*
2 : * Copyright (c) 2014 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_COMMON_AUDIO_VAD_INCLUDE_VAD_H_
12 : #define WEBRTC_COMMON_AUDIO_VAD_INCLUDE_VAD_H_
13 :
14 : #include <memory>
15 :
16 : #include "webrtc/base/checks.h"
17 : #include "webrtc/common_audio/vad/include/webrtc_vad.h"
18 : #include "webrtc/typedefs.h"
19 :
20 : namespace webrtc {
21 :
22 0 : class Vad {
23 : public:
24 : enum Aggressiveness {
25 : kVadNormal = 0,
26 : kVadLowBitrate = 1,
27 : kVadAggressive = 2,
28 : kVadVeryAggressive = 3
29 : };
30 :
31 : enum Activity { kPassive = 0, kActive = 1, kError = -1 };
32 :
33 0 : virtual ~Vad() = default;
34 :
35 : // Calculates a VAD decision for the given audio frame. Valid sample rates
36 : // are 8000, 16000, and 32000 Hz; the number of samples must be such that the
37 : // frame is 10, 20, or 30 ms long.
38 : virtual Activity VoiceActivity(const int16_t* audio,
39 : size_t num_samples,
40 : int sample_rate_hz) = 0;
41 :
42 : // Resets VAD state.
43 : virtual void Reset() = 0;
44 : };
45 :
46 : // Returns a Vad instance that's implemented on top of WebRtcVad.
47 : std::unique_ptr<Vad> CreateVad(Vad::Aggressiveness aggressiveness);
48 :
49 : } // namespace webrtc
50 :
51 : #endif // WEBRTC_COMMON_AUDIO_VAD_INCLUDE_VAD_H_
|