19a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org/* 29a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 39a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org * 49a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org * Use of this source code is governed by a BSD-style license 59a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org * that can be found in the LICENSE file in the root of the source 69a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org * tree. An additional intellectual property rights grant can be found 79a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org * in the file PATENTS. All contributing project authors may 89a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org * be found in the AUTHORS file in the root of the source tree. 99a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org */ 109a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org 11e5abc854f3dc47de16067c2a41476c39b7626722henrik.lundin@webrtc.org#ifndef WEBRTC_MODULES_AUDIO_CODING_NETEQ_POST_DECODE_VAD_H_ 12e5abc854f3dc47de16067c2a41476c39b7626722henrik.lundin@webrtc.org#define WEBRTC_MODULES_AUDIO_CODING_NETEQ_POST_DECODE_VAD_H_ 139a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org 149a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#include <string> // size_t 159a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org 16774b3d38a4a0f1a8ec08972a3c543cb5d607ce13henrike@webrtc.org#include "webrtc/base/constructormagic.h" 179a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#include "webrtc/common_audio/vad/include/webrtc_vad.h" 189a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#include "webrtc/common_types.h" // NULL 19e5abc854f3dc47de16067c2a41476c39b7626722henrik.lundin@webrtc.org#include "webrtc/modules/audio_coding/neteq/defines.h" 20e5abc854f3dc47de16067c2a41476c39b7626722henrik.lundin@webrtc.org#include "webrtc/modules/audio_coding/neteq/interface/audio_decoder.h" 21e5abc854f3dc47de16067c2a41476c39b7626722henrik.lundin@webrtc.org#include "webrtc/modules/audio_coding/neteq/packet.h" 229a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#include "webrtc/typedefs.h" 239a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org 249a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.orgnamespace webrtc { 259a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org 269a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.orgclass PostDecodeVad { 279a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org public: 289a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org PostDecodeVad() 299a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org : enabled_(false), 309a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org running_(false), 319a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org active_speech_(true), 329a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org sid_interval_counter_(0), 339a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org vad_instance_(NULL) { 349a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org } 359a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org 36dd1b19d950158fbb1d7e1792c4db95460d5f8c49pbos@webrtc.org virtual ~PostDecodeVad(); 379a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org 389a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org // Enables post-decode VAD. 399a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org void Enable(); 409a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org 419a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org // Disables post-decode VAD. 429a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org void Disable(); 439a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org 449a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org // Initializes post-decode VAD. 459a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org void Init(); 469a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org 479a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org // Updates post-decode VAD with the audio data in |signal| having |length| 489a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org // samples. The data is of type |speech_type|, at the sample rate |fs_hz|. 49045e45efeca8776975254550137ec65268aadb54turaj@webrtc.org void Update(int16_t* signal, int length, 509a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org AudioDecoder::SpeechType speech_type, bool sid_frame, int fs_hz); 519a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org 529a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org // Accessors. 539a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org bool enabled() const { return enabled_; } 549a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org bool running() const { return running_; } 559a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org bool active_speech() const { return active_speech_; } 569a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org 579a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org private: 589a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org static const int kVadMode = 0; // Sets aggressiveness to "Normal". 599a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org // Number of Update() calls without CNG/SID before re-enabling VAD. 609a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org static const int kVadAutoEnable = 3000; 619a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org 629a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org bool enabled_; 639a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org bool running_; 649a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org bool active_speech_; 659a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org int sid_interval_counter_; 669a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org ::VadInst* vad_instance_; 679a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org 689a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org DISALLOW_COPY_AND_ASSIGN(PostDecodeVad); 699a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org}; 709a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org 719a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org} // namespace webrtc 72e5abc854f3dc47de16067c2a41476c39b7626722henrik.lundin@webrtc.org#endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_POST_DECODE_VAD_H_ 73