henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2013 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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef MODULES_AUDIO_CODING_NETEQ_POST_DECODE_VAD_H_ |
| 12 | #define MODULES_AUDIO_CODING_NETEQ_POST_DECODE_VAD_H_ |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 13 | |
Yves Gerey | 988cc08 | 2018-10-23 12:03:01 +0200 | [diff] [blame^] | 14 | #include <stddef.h> |
| 15 | #include <stdint.h> |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 16 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 17 | #include "api/audio_codecs/audio_decoder.h" |
| 18 | #include "common_audio/vad/include/webrtc_vad.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 19 | #include "rtc_base/constructormagic.h" |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 20 | |
| 21 | namespace webrtc { |
| 22 | |
| 23 | class PostDecodeVad { |
| 24 | public: |
| 25 | PostDecodeVad() |
| 26 | : enabled_(false), |
| 27 | running_(false), |
| 28 | active_speech_(true), |
| 29 | sid_interval_counter_(0), |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 30 | vad_instance_(NULL) {} |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 31 | |
pbos@webrtc.org | 2d1a55c | 2013-07-31 15:54:00 +0000 | [diff] [blame] | 32 | virtual ~PostDecodeVad(); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 33 | |
| 34 | // Enables post-decode VAD. |
| 35 | void Enable(); |
| 36 | |
| 37 | // Disables post-decode VAD. |
| 38 | void Disable(); |
| 39 | |
| 40 | // Initializes post-decode VAD. |
| 41 | void Init(); |
| 42 | |
| 43 | // Updates post-decode VAD with the audio data in |signal| having |length| |
| 44 | // samples. The data is of type |speech_type|, at the sample rate |fs_hz|. |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 45 | void Update(int16_t* signal, |
| 46 | size_t length, |
| 47 | AudioDecoder::SpeechType speech_type, |
| 48 | bool sid_frame, |
| 49 | int fs_hz); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 50 | |
| 51 | // Accessors. |
| 52 | bool enabled() const { return enabled_; } |
| 53 | bool running() const { return running_; } |
| 54 | bool active_speech() const { return active_speech_; } |
| 55 | |
| 56 | private: |
| 57 | static const int kVadMode = 0; // Sets aggressiveness to "Normal". |
| 58 | // Number of Update() calls without CNG/SID before re-enabling VAD. |
| 59 | static const int kVadAutoEnable = 3000; |
| 60 | |
| 61 | bool enabled_; |
| 62 | bool running_; |
| 63 | bool active_speech_; |
| 64 | int sid_interval_counter_; |
| 65 | ::VadInst* vad_instance_; |
| 66 | |
henrikg | 3c089d7 | 2015-09-16 05:37:44 -0700 | [diff] [blame] | 67 | RTC_DISALLOW_COPY_AND_ASSIGN(PostDecodeVad); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 68 | }; |
| 69 | |
| 70 | } // namespace webrtc |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 71 | #endif // MODULES_AUDIO_CODING_NETEQ_POST_DECODE_VAD_H_ |