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 #include "webrtc/audio/audio_state.h" | 11 #include "webrtc/audio/audio_state.h" |
12 | 12 |
13 #include "webrtc/base/atomicops.h" | 13 #include "webrtc/base/atomicops.h" |
14 #include "webrtc/base/checks.h" | 14 #include "webrtc/base/checks.h" |
15 #include "webrtc/base/logging.h" | 15 #include "webrtc/base/logging.h" |
| 16 #include "webrtc/modules/audio_device/include/audio_device.h" |
16 #include "webrtc/voice_engine/include/voe_errors.h" | 17 #include "webrtc/voice_engine/include/voe_errors.h" |
17 | 18 |
18 namespace webrtc { | 19 namespace webrtc { |
19 namespace internal { | 20 namespace internal { |
20 | 21 |
21 AudioState::AudioState(const AudioState::Config& config) | 22 AudioState::AudioState(const AudioState::Config& config) |
22 : config_(config), voe_base_(config.voice_engine) { | 23 : config_(config), voe_base_(config.voice_engine) { |
23 process_thread_checker_.DetachFromThread(); | 24 process_thread_checker_.DetachFromThread(); |
24 // Only one AudioState should be created per VoiceEngine. | 25 // Only one AudioState should be created per VoiceEngine. |
25 RTC_CHECK(voe_base_->RegisterVoiceEngineObserver(*this) != -1); | 26 RTC_CHECK(voe_base_->RegisterVoiceEngineObserver(*this) != -1); |
| 27 |
| 28 auto* const device = audio_device(); |
| 29 RTC_DCHECK(device); |
| 30 audio_transport_proxy_.reset(new AudioTransportProxy( |
| 31 voe_base_->audio_transport(), voe_base_->audio_processing(), mixer())); |
| 32 device->RegisterAudioCallback(nullptr); |
| 33 device->RegisterAudioCallback(audio_transport_proxy_.get()); |
26 } | 34 } |
27 | 35 |
28 AudioState::~AudioState() { | 36 AudioState::~AudioState() { |
29 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 37 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
30 voe_base_->DeRegisterVoiceEngineObserver(); | 38 voe_base_->DeRegisterVoiceEngineObserver(); |
31 } | 39 } |
32 | 40 |
33 VoiceEngine* AudioState::voice_engine() { | 41 VoiceEngine* AudioState::voice_engine() { |
34 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 42 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
35 return config_.voice_engine; | 43 return config_.voice_engine; |
36 } | 44 } |
37 | 45 |
| 46 AudioDeviceModule* AudioState::audio_device() { |
| 47 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 48 return voe_base_->audio_device_module(); |
| 49 } |
| 50 |
| 51 rtc::scoped_refptr<AudioMixer> AudioState::mixer() const { |
| 52 return config_.audio_mixer; |
| 53 } |
| 54 |
38 bool AudioState::typing_noise_detected() const { | 55 bool AudioState::typing_noise_detected() const { |
39 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 56 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
40 rtc::CritScope lock(&crit_sect_); | 57 rtc::CritScope lock(&crit_sect_); |
41 return typing_noise_detected_; | 58 return typing_noise_detected_; |
42 } | 59 } |
43 | 60 |
44 // Reference count; implementation copied from rtc::RefCountedObject. | 61 // Reference count; implementation copied from rtc::RefCountedObject. |
45 int AudioState::AddRef() const { | 62 int AudioState::AddRef() const { |
46 return rtc::AtomicOps::Increment(&ref_count_); | 63 return rtc::AtomicOps::Increment(&ref_count_); |
47 } | 64 } |
(...skipping 22 matching lines...) Expand all Loading... |
70 typing_noise_detected_ = false; | 87 typing_noise_detected_ = false; |
71 } | 88 } |
72 } | 89 } |
73 } // namespace internal | 90 } // namespace internal |
74 | 91 |
75 rtc::scoped_refptr<AudioState> AudioState::Create( | 92 rtc::scoped_refptr<AudioState> AudioState::Create( |
76 const AudioState::Config& config) { | 93 const AudioState::Config& config) { |
77 return rtc::scoped_refptr<AudioState>(new internal::AudioState(config)); | 94 return rtc::scoped_refptr<AudioState>(new internal::AudioState(config)); |
78 } | 95 } |
79 } // namespace webrtc | 96 } // namespace webrtc |
OLD | NEW |