OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_COMMON_AUDIO_VAD_INCLUDE_VAD_H_ | 11 #ifndef WEBRTC_COMMON_AUDIO_VAD_INCLUDE_VAD_H_ |
12 #define WEBRTC_COMMON_AUDIO_VAD_INCLUDE_VAD_H_ | 12 #define WEBRTC_COMMON_AUDIO_VAD_INCLUDE_VAD_H_ |
13 | 13 |
14 #include "webrtc/base/checks.h" | 14 #include "webrtc/base/checks.h" |
| 15 #include "webrtc/base/scoped_ptr.h" |
15 #include "webrtc/common_audio/vad/include/webrtc_vad.h" | 16 #include "webrtc/common_audio/vad/include/webrtc_vad.h" |
16 #include "webrtc/typedefs.h" | 17 #include "webrtc/typedefs.h" |
17 | 18 |
18 namespace webrtc { | 19 namespace webrtc { |
19 | 20 |
20 // This is a C++ wrapper class for WebRtcVad. | |
21 class Vad { | 21 class Vad { |
22 public: | 22 public: |
23 enum Aggressiveness { | 23 enum Aggressiveness { |
24 kVadNormal = 0, | 24 kVadNormal = 0, |
25 kVadLowBitrate = 1, | 25 kVadLowBitrate = 1, |
26 kVadAggressive = 2, | 26 kVadAggressive = 2, |
27 kVadVeryAggressive = 3 | 27 kVadVeryAggressive = 3 |
28 }; | 28 }; |
29 | 29 |
30 enum Activity { kPassive = 0, kActive = 1, kError = -1 }; | 30 enum Activity { kPassive = 0, kActive = 1, kError = -1 }; |
31 | 31 |
32 explicit Vad(enum Aggressiveness mode); | 32 virtual ~Vad() = default; |
33 | 33 |
34 virtual ~Vad(); | 34 // Calculates a VAD decision for the given audio frame. Valid sample rates |
35 | 35 // are 8000, 16000, and 32000 Hz; the number of samples must be such that the |
| 36 // frame is 10, 20, or 30 ms long. |
36 virtual Activity VoiceActivity(const int16_t* audio, | 37 virtual Activity VoiceActivity(const int16_t* audio, |
37 size_t num_samples, | 38 size_t num_samples, |
38 int sample_rate_hz); | 39 int sample_rate_hz) = 0; |
39 | 40 |
40 // Reset VAD state. | 41 // Resets VAD state. |
41 virtual void Reset(); | 42 virtual void Reset() = 0; |
42 | |
43 private: | |
44 VadInst* handle_; | |
45 Aggressiveness aggressiveness_; | |
46 }; | 43 }; |
47 | 44 |
| 45 // Returns a Vad instance that's implemented on top of WebRtcVad. |
| 46 rtc::scoped_ptr<Vad> CreateVad(Vad::Aggressiveness aggressiveness); |
| 47 |
48 } // namespace webrtc | 48 } // namespace webrtc |
| 49 |
49 #endif // WEBRTC_COMMON_AUDIO_VAD_INCLUDE_VAD_H_ | 50 #endif // WEBRTC_COMMON_AUDIO_VAD_INCLUDE_VAD_H_ |
OLD | NEW |