blob: 1dfdf20ae92d74fd089ce475877116d935ed98b6 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
bjornv@webrtc.org0c6f9312012-01-30 09:39:08 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
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
bjornv@webrtc.org0c6f9312012-01-30 09:39:08 +000011#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_VOICE_DETECTION_IMPL_H_
12#define WEBRTC_MODULES_AUDIO_PROCESSING_VOICE_DETECTION_IMPL_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
pbos@webrtc.org7fad4b82013-05-28 08:11:59 +000014#include "webrtc/modules/audio_processing/include/audio_processing.h"
15#include "webrtc/modules/audio_processing/processing_component.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000016
17namespace webrtc {
andrew@webrtc.org56e4a052014-02-27 22:23:17 +000018
niklase@google.com470e71d2011-07-07 08:21:25 +000019class AudioBuffer;
andrew@webrtc.org56e4a052014-02-27 22:23:17 +000020class CriticalSectionWrapper;
niklase@google.com470e71d2011-07-07 08:21:25 +000021
22class VoiceDetectionImpl : public VoiceDetection,
23 public ProcessingComponent {
24 public:
andrew@webrtc.org56e4a052014-02-27 22:23:17 +000025 VoiceDetectionImpl(const AudioProcessing* apm, CriticalSectionWrapper* crit);
niklase@google.com470e71d2011-07-07 08:21:25 +000026 virtual ~VoiceDetectionImpl();
27
28 int ProcessCaptureAudio(AudioBuffer* audio);
29
30 // VoiceDetection implementation.
pbos@webrtc.org91620802013-08-02 11:44:11 +000031 virtual bool is_enabled() const OVERRIDE;
niklase@google.com470e71d2011-07-07 08:21:25 +000032
33 // ProcessingComponent implementation.
pbos@webrtc.org91620802013-08-02 11:44:11 +000034 virtual int Initialize() OVERRIDE;
niklase@google.com470e71d2011-07-07 08:21:25 +000035
36 private:
37 // VoiceDetection implementation.
pbos@webrtc.org91620802013-08-02 11:44:11 +000038 virtual int Enable(bool enable) OVERRIDE;
39 virtual int set_stream_has_voice(bool has_voice) OVERRIDE;
40 virtual bool stream_has_voice() const OVERRIDE;
41 virtual int set_likelihood(Likelihood likelihood) OVERRIDE;
42 virtual Likelihood likelihood() const OVERRIDE;
43 virtual int set_frame_size_ms(int size) OVERRIDE;
44 virtual int frame_size_ms() const OVERRIDE;
niklase@google.com470e71d2011-07-07 08:21:25 +000045
46 // ProcessingComponent implementation.
pbos@webrtc.org91620802013-08-02 11:44:11 +000047 virtual void* CreateHandle() const OVERRIDE;
48 virtual int InitializeHandle(void* handle) const OVERRIDE;
49 virtual int ConfigureHandle(void* handle) const OVERRIDE;
bjornv@webrtc.org5964fe02014-04-22 06:52:28 +000050 virtual void DestroyHandle(void* handle) const OVERRIDE;
pbos@webrtc.org91620802013-08-02 11:44:11 +000051 virtual int num_handles_required() const OVERRIDE;
52 virtual int GetHandleError(void* handle) const OVERRIDE;
niklase@google.com470e71d2011-07-07 08:21:25 +000053
andrew@webrtc.org56e4a052014-02-27 22:23:17 +000054 const AudioProcessing* apm_;
55 CriticalSectionWrapper* crit_;
niklase@google.com470e71d2011-07-07 08:21:25 +000056 bool stream_has_voice_;
57 bool using_external_vad_;
58 Likelihood likelihood_;
59 int frame_size_ms_;
60 int frame_size_samples_;
61};
62} // namespace webrtc
63
bjornv@webrtc.org0c6f9312012-01-30 09:39:08 +000064#endif // WEBRTC_MODULES_AUDIO_PROCESSING_VOICE_DETECTION_IMPL_H_