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 11 #ifndef MODULES_AUDIO_CODING_NETEQ_POST_DECODE_VAD_H_ 12 #define MODULES_AUDIO_CODING_NETEQ_POST_DECODE_VAD_H_ 13 14 #include <stddef.h> 15 #include <stdint.h> 16 17 #include "api/audio_codecs/audio_decoder.h" 18 #include "common_audio/vad/include/webrtc_vad.h" 19 20 namespace webrtc { 21 22 class PostDecodeVad { 23 public: PostDecodeVad()24 PostDecodeVad() 25 : enabled_(false), 26 running_(false), 27 active_speech_(true), 28 sid_interval_counter_(0), 29 vad_instance_(NULL) {} 30 31 virtual ~PostDecodeVad(); 32 33 PostDecodeVad(const PostDecodeVad&) = delete; 34 PostDecodeVad& operator=(const PostDecodeVad&) = delete; 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`. 47 void Update(int16_t* signal, 48 size_t length, 49 AudioDecoder::SpeechType speech_type, 50 bool sid_frame, 51 int fs_hz); 52 53 // Accessors. enabled()54 bool enabled() const { return enabled_; } running()55 bool running() const { return running_; } active_speech()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 }; 69 70 } // namespace webrtc 71 #endif // MODULES_AUDIO_CODING_NETEQ_POST_DECODE_VAD_H_ 72