post_decode_vad.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. #ifndef MODULES_AUDIO_CODING_NETEQ_POST_DECODE_VAD_H_
  11. #define MODULES_AUDIO_CODING_NETEQ_POST_DECODE_VAD_H_
  12. #include <stddef.h>
  13. #include <stdint.h>
  14. #include "api/audio_codecs/audio_decoder.h"
  15. #include "common_audio/vad/include/webrtc_vad.h"
  16. #include "rtc_base/constructor_magic.h"
  17. namespace webrtc {
  18. class PostDecodeVad {
  19. public:
  20. PostDecodeVad()
  21. : enabled_(false),
  22. running_(false),
  23. active_speech_(true),
  24. sid_interval_counter_(0),
  25. vad_instance_(NULL) {}
  26. virtual ~PostDecodeVad();
  27. // Enables post-decode VAD.
  28. void Enable();
  29. // Disables post-decode VAD.
  30. void Disable();
  31. // Initializes post-decode VAD.
  32. void Init();
  33. // Updates post-decode VAD with the audio data in |signal| having |length|
  34. // samples. The data is of type |speech_type|, at the sample rate |fs_hz|.
  35. void Update(int16_t* signal,
  36. size_t length,
  37. AudioDecoder::SpeechType speech_type,
  38. bool sid_frame,
  39. int fs_hz);
  40. // Accessors.
  41. bool enabled() const { return enabled_; }
  42. bool running() const { return running_; }
  43. bool active_speech() const { return active_speech_; }
  44. private:
  45. static const int kVadMode = 0; // Sets aggressiveness to "Normal".
  46. // Number of Update() calls without CNG/SID before re-enabling VAD.
  47. static const int kVadAutoEnable = 3000;
  48. bool enabled_;
  49. bool running_;
  50. bool active_speech_;
  51. int sid_interval_counter_;
  52. ::VadInst* vad_instance_;
  53. RTC_DISALLOW_COPY_AND_ASSIGN(PostDecodeVad);
  54. };
  55. } // namespace webrtc
  56. #endif // MODULES_AUDIO_CODING_NETEQ_POST_DECODE_VAD_H_