OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef AUDIO_AUDIO_STATE_H_ | 11 #ifndef AUDIO_AUDIO_STATE_H_ |
12 #define AUDIO_AUDIO_STATE_H_ | 12 #define AUDIO_AUDIO_STATE_H_ |
13 | 13 |
14 #include "audio/audio_transport_proxy.h" | 14 #include "audio/audio_transport_proxy.h" |
15 #include "audio/scoped_voe_interface.h" | 15 #include "audio/scoped_voe_interface.h" |
16 #include "call/audio_state.h" | 16 #include "call/audio_state.h" |
17 #include "rtc_base/constructormagic.h" | 17 #include "rtc_base/constructormagic.h" |
18 #include "rtc_base/criticalsection.h" | 18 #include "rtc_base/criticalsection.h" |
19 #include "rtc_base/thread_checker.h" | 19 #include "rtc_base/thread_checker.h" |
20 #include "voice_engine/include/voe_base.h" | 20 #include "voice_engine/include/voe_base.h" |
21 | 21 |
22 namespace webrtc { | 22 namespace webrtc { |
23 namespace internal { | 23 namespace internal { |
24 | 24 |
25 class AudioState final : public webrtc::AudioState, | 25 class AudioState final : public webrtc::AudioState { |
26 public webrtc::VoiceEngineObserver { | |
27 public: | 26 public: |
28 explicit AudioState(const AudioState::Config& config); | 27 explicit AudioState(const AudioState::Config& config); |
29 ~AudioState() override; | 28 ~AudioState() override; |
30 | 29 |
31 AudioProcessing* audio_processing() override { | 30 AudioProcessing* audio_processing() override { |
32 RTC_DCHECK(config_.audio_processing); | 31 RTC_DCHECK(config_.audio_processing); |
33 return config_.audio_processing.get(); | 32 return config_.audio_processing.get(); |
34 } | 33 } |
35 | 34 |
36 VoiceEngine* voice_engine(); | 35 VoiceEngine* voice_engine(); |
37 rtc::scoped_refptr<AudioMixer> mixer(); | 36 rtc::scoped_refptr<AudioMixer> mixer(); |
38 bool typing_noise_detected() const; | 37 bool typing_noise_detected() const; |
39 | 38 |
40 private: | 39 private: |
41 // rtc::RefCountInterface implementation. | 40 // rtc::RefCountInterface implementation. |
42 int AddRef() const override; | 41 int AddRef() const override; |
43 int Release() const override; | 42 int Release() const override; |
44 | 43 |
45 // webrtc::VoiceEngineObserver implementation. | |
46 void CallbackOnError(int channel_id, int err_code) override; | |
47 | |
48 rtc::ThreadChecker thread_checker_; | 44 rtc::ThreadChecker thread_checker_; |
49 rtc::ThreadChecker process_thread_checker_; | 45 rtc::ThreadChecker process_thread_checker_; |
50 const webrtc::AudioState::Config config_; | 46 const webrtc::AudioState::Config config_; |
51 | 47 |
52 // We hold one interface pointer to the VoE to make sure it is kept alive. | 48 // We hold one interface pointer to the VoE to make sure it is kept alive. |
53 ScopedVoEInterface<VoEBase> voe_base_; | 49 ScopedVoEInterface<VoEBase> voe_base_; |
54 | 50 |
55 // The critical section isn't strictly needed in this case, but xSAN bots may | |
56 // trigger on unprotected cross-thread access. | |
57 rtc::CriticalSection crit_sect_; | |
58 bool typing_noise_detected_ RTC_GUARDED_BY(crit_sect_) = false; | |
59 | |
60 // Reference count; implementation copied from rtc::RefCountedObject. | 51 // Reference count; implementation copied from rtc::RefCountedObject. |
61 mutable volatile int ref_count_ = 0; | 52 mutable volatile int ref_count_ = 0; |
62 | 53 |
63 // Transports mixed audio from the mixer to the audio device and | 54 // Transports mixed audio from the mixer to the audio device and |
64 // recorded audio to the VoE AudioTransport. | 55 // recorded audio to the VoE AudioTransport. |
65 AudioTransportProxy audio_transport_proxy_; | 56 AudioTransportProxy audio_transport_proxy_; |
66 | 57 |
67 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(AudioState); | 58 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(AudioState); |
68 }; | 59 }; |
69 } // namespace internal | 60 } // namespace internal |
70 } // namespace webrtc | 61 } // namespace webrtc |
71 | 62 |
72 #endif // AUDIO_AUDIO_STATE_H_ | 63 #endif // AUDIO_AUDIO_STATE_H_ |
OLD | NEW |