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 WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_IMPL_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_IMPL_H_ |
12 #define WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_IMPL_H_ | 12 #define WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_IMPL_H_ |
13 | 13 |
14 #include <list> | |
15 #include <map> | 14 #include <map> |
16 #include <memory> | 15 #include <memory> |
17 #include <vector> | 16 #include <vector> |
18 | 17 |
19 #include "webrtc/base/thread_checker.h" | 18 #include "webrtc/base/thread_checker.h" |
20 #include "webrtc/engine_configurations.h" | 19 #include "webrtc/engine_configurations.h" |
21 #include "webrtc/modules/audio_mixer/audio_mixer.h" | 20 #include "webrtc/modules/audio_mixer/audio_mixer.h" |
22 #include "webrtc/modules/include/module_common_types.h" | 21 #include "webrtc/modules/include/module_common_types.h" |
23 #include "webrtc/voice_engine/level_indicator.h" | 22 #include "webrtc/voice_engine/level_indicator.h" |
24 | 23 |
25 namespace webrtc { | 24 namespace webrtc { |
26 class AudioProcessing; | 25 class AudioProcessing; |
27 class CriticalSectionWrapper; | 26 class CriticalSectionWrapper; |
28 | 27 |
29 struct FrameAndMuteInfo { | 28 typedef std::vector<AudioFrame*> AudioFrameList; |
30 FrameAndMuteInfo(AudioFrame* f, bool m) : frame(f), muted(m) {} | 29 typedef std::vector<MixerAudioSource*> MixerAudioSourceList; |
31 AudioFrame* frame; | |
32 bool muted; | |
33 }; | |
34 | |
35 typedef std::list<FrameAndMuteInfo> AudioFrameList; | |
36 typedef std::list<MixerAudioSource*> MixerAudioSourceList; | |
37 | 30 |
38 // Cheshire cat implementation of MixerAudioSource's non virtual functions. | 31 // Cheshire cat implementation of MixerAudioSource's non virtual functions. |
39 class NewMixHistory { | 32 class NewMixHistory { |
40 public: | 33 public: |
41 NewMixHistory(); | 34 NewMixHistory(); |
42 ~NewMixHistory(); | 35 ~NewMixHistory(); |
43 | 36 |
44 // Returns true if the audio source is being mixed. | 37 // Returns true if the audio source is being mixed. |
45 bool IsMixed() const; | 38 bool IsMixed() const; |
46 | 39 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 bool AnonymousMixabilityStatus( | 71 bool AnonymousMixabilityStatus( |
79 const MixerAudioSource& audio_source) const override; | 72 const MixerAudioSource& audio_source) const override; |
80 | 73 |
81 private: | 74 private: |
82 AudioMixerImpl(int id, std::unique_ptr<AudioProcessing> limiter); | 75 AudioMixerImpl(int id, std::unique_ptr<AudioProcessing> limiter); |
83 | 76 |
84 // Set/get mix frequency | 77 // Set/get mix frequency |
85 int32_t SetOutputFrequency(const Frequency& frequency); | 78 int32_t SetOutputFrequency(const Frequency& frequency); |
86 Frequency OutputFrequency() const; | 79 Frequency OutputFrequency() const; |
87 | 80 |
88 // Compute what audio sources to mix from audio_source_list_. Ramp in | 81 // Compute what audio sources to mix from audio_source_list_. Ramp |
89 // and out. Update mixed status. maxAudioFrameCounter specifies how | 82 // in and out. Update mixed status. Mixes up to |
90 // many participants are allowed to be mixed. | 83 // kMaximumAmountOfMixedAudioSources audio sources. |
91 AudioFrameList UpdateToMix(size_t maxAudioFrameCounter) const | 84 AudioFrameList GetNonAnonymousAudio() const EXCLUSIVE_LOCKS_REQUIRED(crit_); |
92 EXCLUSIVE_LOCKS_REQUIRED(crit_); | |
93 | 85 |
94 // Return the lowest mixing frequency that can be used without having to | 86 // Return the lowest mixing frequency that can be used without having to |
95 // downsample any audio. | 87 // downsample any audio. |
96 int32_t GetLowestMixingFrequency() const; | 88 int32_t GetLowestMixingFrequency() const; |
97 int32_t GetLowestMixingFrequencyFromList( | 89 int32_t GetLowestMixingFrequencyFromList( |
98 const MixerAudioSourceList& mixList) const; | 90 const MixerAudioSourceList& mixList) const; |
99 | 91 |
100 // Return the AudioFrames that should be mixed anonymously. | 92 // Return the AudioFrames that should be mixed anonymously. Ramp in |
101 void GetAdditionalAudio(AudioFrameList* additionalFramesList) const | 93 // and out. Update mixed status. |
102 EXCLUSIVE_LOCKS_REQUIRED(crit_); | 94 AudioFrameList GetAnonymousAudio() const EXCLUSIVE_LOCKS_REQUIRED(crit_); |
103 | 95 |
104 // This function returns true if it finds the MixerAudioSource in the | 96 // This function returns true if it finds the MixerAudioSource in the |
105 // specified list of MixerAudioSources. | 97 // specified list of MixerAudioSources. |
106 bool IsAudioSourceInList(const MixerAudioSource& audio_source, | 98 bool IsAudioSourceInList(const MixerAudioSource& audio_source, |
107 const MixerAudioSourceList& audioSourceList) const; | 99 const MixerAudioSourceList& audioSourceList) const; |
108 | 100 |
109 // Add/remove the MixerAudioSource to the specified | 101 // Add/remove the MixerAudioSource to the specified |
110 // MixerAudioSource list. | 102 // MixerAudioSource list. |
111 bool AddAudioSourceToList(MixerAudioSource* audio_source, | 103 bool AddAudioSourceToList(MixerAudioSource* audio_source, |
112 MixerAudioSourceList* audioSourceList) const; | 104 MixerAudioSourceList* audioSourceList) const; |
113 bool RemoveAudioSourceFromList(MixerAudioSource* removeAudioSource, | 105 bool RemoveAudioSourceFromList(MixerAudioSource* removeAudioSource, |
114 MixerAudioSourceList* audioSourceList) const; | 106 MixerAudioSourceList* audioSourceList) const; |
115 | 107 |
116 // Mix the AudioFrames stored in audioFrameList into mixedAudio. | 108 // Mix the AudioFrames stored in audioFrameList into mixedAudio. |
117 static int32_t MixFromList(AudioFrame* mixedAudio, | 109 static int32_t MixFromList(AudioFrame* mixedAudio, |
118 const AudioFrameList& audioFrameList, | 110 const AudioFrameList& audioFrameList, |
119 int32_t id, | 111 int32_t id, |
120 bool use_limiter); | 112 bool use_limiter); |
121 | 113 |
122 // Mix the AudioFrames stored in audioFrameList into mixedAudio. No | |
123 // record will be kept of this mix (e.g. the corresponding MixerAudioSources | |
124 // will not be marked as IsMixed() | |
125 int32_t MixAnonomouslyFromList(AudioFrame* mixedAudio, | |
126 const AudioFrameList& audioFrameList) const; | |
127 | |
128 bool LimitMixedAudio(AudioFrame* mixedAudio) const; | 114 bool LimitMixedAudio(AudioFrame* mixedAudio) const; |
129 | 115 |
130 // Output level functions for VoEVolumeControl. | 116 // Output level functions for VoEVolumeControl. |
131 int GetOutputAudioLevel() override; | 117 int GetOutputAudioLevel() override; |
132 | 118 |
133 int GetOutputAudioLevelFullRange() override; | 119 int GetOutputAudioLevelFullRange() override; |
134 | 120 |
135 rtc::CriticalSection crit_; | 121 rtc::CriticalSection crit_; |
136 | 122 |
137 const int32_t id_; | 123 const int32_t id_; |
(...skipping 20 matching lines...) Expand all Loading... |
158 | 144 |
159 // Used for inhibiting saturation in mixing. | 145 // Used for inhibiting saturation in mixing. |
160 std::unique_ptr<AudioProcessing> limiter_ ACCESS_ON(&thread_checker_); | 146 std::unique_ptr<AudioProcessing> limiter_ ACCESS_ON(&thread_checker_); |
161 | 147 |
162 // Measures audio level for the combined signal. | 148 // Measures audio level for the combined signal. |
163 voe::AudioLevel audio_level_ ACCESS_ON(&thread_checker_); | 149 voe::AudioLevel audio_level_ ACCESS_ON(&thread_checker_); |
164 }; | 150 }; |
165 } // namespace webrtc | 151 } // namespace webrtc |
166 | 152 |
167 #endif // WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_IMPL_H_ | 153 #endif // WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_IMPL_H_ |
OLD | NEW |