OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 VOICE_ENGINE_TRANSMIT_MIXER_H_ | 11 #ifndef VOICE_ENGINE_TRANSMIT_MIXER_H_ |
12 #define VOICE_ENGINE_TRANSMIT_MIXER_H_ | 12 #define VOICE_ENGINE_TRANSMIT_MIXER_H_ |
13 | 13 |
14 #include <memory> | 14 #include <memory> |
15 | 15 |
16 #include "common_audio/resampler/include/push_resampler.h" | 16 #include "common_audio/resampler/include/push_resampler.h" |
17 #include "common_types.h" // NOLINT(build/include) | 17 #include "common_types.h" // NOLINT(build/include) |
18 #include "modules/audio_processing/typing_detection.h" | 18 #include "modules/audio_processing/typing_detection.h" |
19 #include "modules/include/module_common_types.h" | 19 #include "modules/include/module_common_types.h" |
20 #include "rtc_base/criticalsection.h" | 20 #include "rtc_base/criticalsection.h" |
21 #include "voice_engine/audio_level.h" | 21 #include "voice_engine/audio_level.h" |
22 #include "voice_engine/include/voe_base.h" | 22 #include "voice_engine/include/voe_base.h" |
23 #include "voice_engine/monitor_module.h" | |
24 #include "voice_engine/voice_engine_defines.h" | 23 #include "voice_engine/voice_engine_defines.h" |
25 | 24 |
26 #if !defined(WEBRTC_ANDROID) && !defined(WEBRTC_IOS) | 25 #if !defined(WEBRTC_ANDROID) && !defined(WEBRTC_IOS) |
27 #define WEBRTC_VOICE_ENGINE_TYPING_DETECTION 1 | 26 #define WEBRTC_VOICE_ENGINE_TYPING_DETECTION 1 |
28 #else | 27 #else |
29 #define WEBRTC_VOICE_ENGINE_TYPING_DETECTION 0 | 28 #define WEBRTC_VOICE_ENGINE_TYPING_DETECTION 0 |
30 #endif | 29 #endif |
31 | 30 |
32 namespace webrtc { | 31 namespace webrtc { |
33 class AudioProcessing; | 32 class AudioProcessing; |
34 class ProcessThread; | 33 class ProcessThread; |
35 | 34 |
36 namespace voe { | 35 namespace voe { |
37 | 36 |
38 class ChannelManager; | 37 class ChannelManager; |
39 class MixedAudio; | 38 class MixedAudio; |
40 class Statistics; | 39 class Statistics; |
41 | 40 |
42 class TransmitMixer { | 41 class TransmitMixer { |
43 public: | 42 public: |
44 static int32_t Create(TransmitMixer*& mixer, uint32_t instanceId); | 43 static int32_t Create(TransmitMixer*& mixer, uint32_t instanceId); |
45 | 44 |
46 static void Destroy(TransmitMixer*& mixer); | 45 static void Destroy(TransmitMixer*& mixer); |
47 | 46 |
48 int32_t SetEngineInformation(ProcessThread& processThread, | 47 void SetEngineInformation(ChannelManager* channelManager); |
49 Statistics& engineStatistics, | |
50 ChannelManager& channelManager); | |
51 | 48 |
52 int32_t SetAudioProcessingModule( | 49 int32_t SetAudioProcessingModule(AudioProcessing* audioProcessingModule); |
53 AudioProcessing* audioProcessingModule); | |
54 | 50 |
55 int32_t PrepareDemux(const void* audioSamples, | 51 int32_t PrepareDemux(const void* audioSamples, |
56 size_t nSamples, | 52 size_t nSamples, |
57 size_t nChannels, | 53 size_t nChannels, |
58 uint32_t samplesPerSec, | 54 uint32_t samplesPerSec, |
59 uint16_t totalDelayMS, | 55 uint16_t totalDelayMS, |
60 int32_t clockDrift, | 56 int32_t clockDrift, |
61 uint16_t currentMicLevel, | 57 uint16_t currentMicLevel, |
62 bool keyPressed); | 58 bool keyPressed); |
63 | 59 |
(...skipping 11 matching lines...) Expand all Loading... |
75 virtual int16_t AudioLevelFullRange() const; | 71 virtual int16_t AudioLevelFullRange() const; |
76 | 72 |
77 // See description of "totalAudioEnergy" in the WebRTC stats spec: | 73 // See description of "totalAudioEnergy" in the WebRTC stats spec: |
78 // https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats-totalaud
ioenergy | 74 // https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats-totalaud
ioenergy |
79 // 'virtual' to allow mocking. | 75 // 'virtual' to allow mocking. |
80 virtual double GetTotalInputEnergy() const; | 76 virtual double GetTotalInputEnergy() const; |
81 | 77 |
82 // 'virtual' to allow mocking. | 78 // 'virtual' to allow mocking. |
83 virtual double GetTotalInputDuration() const; | 79 virtual double GetTotalInputDuration() const; |
84 | 80 |
85 int32_t RegisterVoiceEngineObserver(VoiceEngineObserver& observer); | |
86 | |
87 virtual ~TransmitMixer(); | 81 virtual ~TransmitMixer(); |
88 | 82 |
89 #if WEBRTC_VOICE_ENGINE_TYPING_DETECTION | |
90 // Periodic callback from the MonitorModule. | |
91 void OnPeriodicProcess(); | |
92 #endif | |
93 | |
94 // Virtual to allow mocking. | 83 // Virtual to allow mocking. |
95 virtual void EnableStereoChannelSwapping(bool enable); | 84 virtual void EnableStereoChannelSwapping(bool enable); |
96 bool IsStereoChannelSwappingEnabled(); | 85 bool IsStereoChannelSwappingEnabled(); |
97 | 86 |
| 87 // Virtual to allow mocking. |
| 88 virtual bool typing_noise_detected() const; |
| 89 |
98 protected: | 90 protected: |
99 #if WEBRTC_VOICE_ENGINE_TYPING_DETECTION | |
100 TransmitMixer() : _monitorModule(this) {} | |
101 #else | |
102 TransmitMixer() = default; | 91 TransmitMixer() = default; |
103 #endif | |
104 | 92 |
105 private: | 93 private: |
106 TransmitMixer(uint32_t instanceId); | 94 TransmitMixer(uint32_t instanceId); |
107 | 95 |
108 // Gets the maximum sample rate and number of channels over all currently | 96 // Gets the maximum sample rate and number of channels over all currently |
109 // sending codecs. | 97 // sending codecs. |
110 void GetSendCodecInfo(int* max_sample_rate, size_t* max_channels); | 98 void GetSendCodecInfo(int* max_sample_rate, size_t* max_channels); |
111 | 99 |
112 void GenerateAudioFrame(const int16_t audioSamples[], | 100 void GenerateAudioFrame(const int16_t audioSamples[], |
113 size_t nSamples, | 101 size_t nSamples, |
114 size_t nChannels, | 102 size_t nChannels, |
115 int samplesPerSec); | 103 int samplesPerSec); |
116 | 104 |
117 void ProcessAudio(int delay_ms, int clock_drift, int current_mic_level, | 105 void ProcessAudio(int delay_ms, int clock_drift, int current_mic_level, |
118 bool key_pressed); | 106 bool key_pressed); |
119 | 107 |
120 #if WEBRTC_VOICE_ENGINE_TYPING_DETECTION | 108 #if WEBRTC_VOICE_ENGINE_TYPING_DETECTION |
121 void TypingDetection(bool keyPressed); | 109 void TypingDetection(bool key_pressed); |
122 #endif | 110 #endif |
123 | 111 |
124 // uses | 112 // uses |
125 Statistics* _engineStatisticsPtr = nullptr; | |
126 ChannelManager* _channelManagerPtr = nullptr; | 113 ChannelManager* _channelManagerPtr = nullptr; |
127 AudioProcessing* audioproc_ = nullptr; | 114 AudioProcessing* audioproc_ = nullptr; |
128 VoiceEngineObserver* _voiceEngineObserverPtr = nullptr; | |
129 ProcessThread* _processThreadPtr = nullptr; | |
130 | 115 |
131 // owns | 116 // owns |
132 AudioFrame _audioFrame; | 117 AudioFrame _audioFrame; |
133 PushResampler<int16_t> resampler_; // ADM sample rate -> mixing rate | 118 PushResampler<int16_t> resampler_; // ADM sample rate -> mixing rate |
134 voe::AudioLevel _audioLevel; | 119 voe::AudioLevel _audioLevel; |
135 // protect file instances and their variables in MixedParticipants() | |
136 rtc::CriticalSection _critSect; | |
137 rtc::CriticalSection _callbackCritSect; | |
138 | 120 |
139 #if WEBRTC_VOICE_ENGINE_TYPING_DETECTION | 121 #if WEBRTC_VOICE_ENGINE_TYPING_DETECTION |
140 MonitorModule<TransmitMixer> _monitorModule; | 122 webrtc::TypingDetection typing_detection_; |
141 webrtc::TypingDetection _typingDetection; | |
142 bool _typingNoiseWarningPending = false; | |
143 bool _typingNoiseDetected = false; | |
144 #endif | 123 #endif |
145 | 124 |
| 125 rtc::CriticalSection lock_; |
| 126 bool typing_noise_detected_ RTC_GUARDED_BY(lock_) = false; |
| 127 |
146 int _instanceId = 0; | 128 int _instanceId = 0; |
147 uint32_t _captureLevel = 0; | 129 uint32_t _captureLevel = 0; |
148 bool stereo_codec_ = false; | 130 bool stereo_codec_ = false; |
149 bool swap_stereo_channels_ = false; | 131 bool swap_stereo_channels_ = false; |
150 }; | 132 }; |
151 } // namespace voe | 133 } // namespace voe |
152 } // namespace webrtc | 134 } // namespace webrtc |
153 | 135 |
154 #endif // VOICE_ENGINE_TRANSMIT_MIXER_H_ | 136 #endif // VOICE_ENGINE_TRANSMIT_MIXER_H_ |
OLD | NEW |