blob: 649d20f7bea69e878e466562b3182c65cfb67231 [file] [log] [blame]
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +00001/*
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 Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_AUDIO_CODING_NETEQ_POST_DECODE_VAD_H_
12#define MODULES_AUDIO_CODING_NETEQ_POST_DECODE_VAD_H_
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +000013
14#include <string> // size_t
15
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020016#include "api/audio_codecs/audio_decoder.h"
17#include "common_audio/vad/include/webrtc_vad.h"
18#include "common_types.h" // NULL
19#include "modules/audio_coding/neteq/defines.h"
20#include "modules/audio_coding/neteq/packet.h"
21#include "rtc_base/constructormagic.h"
22#include "typedefs.h"
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +000023
24namespace webrtc {
25
26class PostDecodeVad {
27 public:
28 PostDecodeVad()
29 : enabled_(false),
30 running_(false),
31 active_speech_(true),
32 sid_interval_counter_(0),
33 vad_instance_(NULL) {
34 }
35
pbos@webrtc.org2d1a55c2013-07-31 15:54:00 +000036 virtual ~PostDecodeVad();
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +000037
38 // Enables post-decode VAD.
39 void Enable();
40
41 // Disables post-decode VAD.
42 void Disable();
43
44 // Initializes post-decode VAD.
45 void Init();
46
47 // Updates post-decode VAD with the audio data in |signal| having |length|
48 // samples. The data is of type |speech_type|, at the sample rate |fs_hz|.
Peter Kastingdce40cf2015-08-24 14:52:23 -070049 void Update(int16_t* signal, size_t length,
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +000050 AudioDecoder::SpeechType speech_type, bool sid_frame, int fs_hz);
51
52 // Accessors.
53 bool enabled() const { return enabled_; }
54 bool running() const { return running_; }
55 bool active_speech() const { return active_speech_; }
56
57 private:
58 static const int kVadMode = 0; // Sets aggressiveness to "Normal".
59 // Number of Update() calls without CNG/SID before re-enabling VAD.
60 static const int kVadAutoEnable = 3000;
61
62 bool enabled_;
63 bool running_;
64 bool active_speech_;
65 int sid_interval_counter_;
66 ::VadInst* vad_instance_;
67
henrikg3c089d72015-09-16 05:37:44 -070068 RTC_DISALLOW_COPY_AND_ASSIGN(PostDecodeVad);
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +000069};
70
71} // namespace webrtc
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020072#endif // MODULES_AUDIO_CODING_NETEQ_POST_DECODE_VAD_H_