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