blob: c9c2cc561e9e63b445a34d2ffcc8ad44ea010283 [file] [log] [blame]
solenberg566ef242015-11-06 15:34:49 -08001/*
2 * Copyright (c) 2015 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 AUDIO_AUDIO_STATE_H_
12#define AUDIO_AUDIO_STATE_H_
solenberg566ef242015-11-06 15:34:49 -080013
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020014#include "audio/audio_transport_proxy.h"
15#include "audio/scoped_voe_interface.h"
16#include "call/audio_state.h"
17#include "rtc_base/constructormagic.h"
18#include "rtc_base/criticalsection.h"
19#include "rtc_base/thread_checker.h"
20#include "voice_engine/include/voe_base.h"
solenberg566ef242015-11-06 15:34:49 -080021
22namespace webrtc {
23namespace internal {
24
solenbergfc3a2e32017-09-26 09:35:01 -070025class AudioState final : public webrtc::AudioState {
solenberg566ef242015-11-06 15:34:49 -080026 public:
27 explicit AudioState(const AudioState::Config& config);
28 ~AudioState() override;
29
peaha9cc40b2017-06-29 08:32:09 -070030 AudioProcessing* audio_processing() override {
peahe67bedb2017-07-07 04:25:11 -070031 RTC_DCHECK(config_.audio_processing);
32 return config_.audio_processing.get();
peaha9cc40b2017-06-29 08:32:09 -070033 }
aleloidd310712016-11-17 06:28:59 -080034
peaha9cc40b2017-06-29 08:32:09 -070035 VoiceEngine* voice_engine();
aleloidd310712016-11-17 06:28:59 -080036 rtc::scoped_refptr<AudioMixer> mixer();
solenberg566ef242015-11-06 15:34:49 -080037 bool typing_noise_detected() const;
38
39 private:
40 // rtc::RefCountInterface implementation.
41 int AddRef() const override;
42 int Release() const override;
43
solenberg566ef242015-11-06 15:34:49 -080044 rtc::ThreadChecker thread_checker_;
45 rtc::ThreadChecker process_thread_checker_;
46 const webrtc::AudioState::Config config_;
47
48 // We hold one interface pointer to the VoE to make sure it is kept alive.
49 ScopedVoEInterface<VoEBase> voe_base_;
50
solenberg566ef242015-11-06 15:34:49 -080051 // Reference count; implementation copied from rtc::RefCountedObject.
52 mutable volatile int ref_count_ = 0;
53
aleloidd310712016-11-17 06:28:59 -080054 // Transports mixed audio from the mixer to the audio device and
55 // recorded audio to the VoE AudioTransport.
56 AudioTransportProxy audio_transport_proxy_;
57
solenberg566ef242015-11-06 15:34:49 -080058 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(AudioState);
59};
60} // namespace internal
61} // namespace webrtc
62
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020063#endif // AUDIO_AUDIO_STATE_H_