blob: 86d60b6813fbe71b193828ec83dc04f163017361 [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"
Niels Möller6f72f562017-10-19 13:15:17 +020019#include "rtc_base/refcount.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020020#include "rtc_base/thread_checker.h"
21#include "voice_engine/include/voe_base.h"
solenberg566ef242015-11-06 15:34:49 -080022
23namespace webrtc {
24namespace internal {
25
solenbergfc3a2e32017-09-26 09:35:01 -070026class AudioState final : public webrtc::AudioState {
solenberg566ef242015-11-06 15:34:49 -080027 public:
28 explicit AudioState(const AudioState::Config& config);
29 ~AudioState() override;
30
peaha9cc40b2017-06-29 08:32:09 -070031 AudioProcessing* audio_processing() override {
peahe67bedb2017-07-07 04:25:11 -070032 RTC_DCHECK(config_.audio_processing);
33 return config_.audio_processing.get();
peaha9cc40b2017-06-29 08:32:09 -070034 }
aleloidd310712016-11-17 06:28:59 -080035
peaha9cc40b2017-06-29 08:32:09 -070036 VoiceEngine* voice_engine();
aleloidd310712016-11-17 06:28:59 -080037 rtc::scoped_refptr<AudioMixer> mixer();
solenberg566ef242015-11-06 15:34:49 -080038 bool typing_noise_detected() const;
39
40 private:
41 // rtc::RefCountInterface implementation.
Niels Möller6f72f562017-10-19 13:15:17 +020042 void AddRef() const override;
43 rtc::RefCountReleaseStatus Release() const override;
solenberg566ef242015-11-06 15:34:49 -080044
solenberg566ef242015-11-06 15:34:49 -080045 rtc::ThreadChecker thread_checker_;
46 rtc::ThreadChecker process_thread_checker_;
47 const webrtc::AudioState::Config config_;
48
49 // We hold one interface pointer to the VoE to make sure it is kept alive.
50 ScopedVoEInterface<VoEBase> voe_base_;
51
solenberg566ef242015-11-06 15:34:49 -080052 // Reference count; implementation copied from rtc::RefCountedObject.
Niels Möller9155e492017-10-23 11:22:30 +020053 // TODO(nisse): Use RefCountedObject or RefCountedBase instead.
solenberg566ef242015-11-06 15:34:49 -080054 mutable volatile int ref_count_ = 0;
55
aleloidd310712016-11-17 06:28:59 -080056 // Transports mixed audio from the mixer to the audio device and
57 // recorded audio to the VoE AudioTransport.
58 AudioTransportProxy audio_transport_proxy_;
59
solenberg566ef242015-11-06 15:34:49 -080060 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(AudioState);
61};
62} // namespace internal
63} // namespace webrtc
64
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020065#endif // AUDIO_AUDIO_STATE_H_