Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(341)

Side by Side Diff: webrtc/modules/audio_mixer/audio_mixer_impl.h

Issue 2298163002: Simplifications of the mixing algorithm. (Closed)
Patch Set: Initial PS Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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> 14 #include <list>
15 #include <map> 15 #include <map>
16 #include <memory> 16 #include <memory>
17 #include <vector> 17 #include <vector>
18 18
19 #include "webrtc/base/thread_checker.h" 19 #include "webrtc/base/thread_checker.h"
20 #include "webrtc/engine_configurations.h" 20 #include "webrtc/engine_configurations.h"
21 #include "webrtc/modules/audio_mixer/audio_mixer.h" 21 #include "webrtc/modules/audio_mixer/audio_mixer.h"
22 #include "webrtc/modules/include/module_common_types.h" 22 #include "webrtc/modules/include/module_common_types.h"
23 #include "webrtc/voice_engine/level_indicator.h" 23 #include "webrtc/voice_engine/level_indicator.h"
24 24
25 namespace webrtc { 25 namespace webrtc {
26 class AudioProcessing; 26 class AudioProcessing;
27 class CriticalSectionWrapper; 27 class CriticalSectionWrapper;
28 28
29 struct FrameAndMuteInfo { 29 typedef std::list<AudioFrame*> AudioFrameList;
ivoc 2016/08/31 15:01:06 I think list is in many cases less efficient than
aleloi 2016/08/31 15:25:34 Will watch! I think the right way is to make a pe
aleloi 2016/09/01 13:20:43 Got convinced by watching. Changed to vector.
30 FrameAndMuteInfo(AudioFrame* f, bool m) : frame(f), muted(m) {}
31 AudioFrame* frame;
32 bool muted;
33 };
34
35 typedef std::list<FrameAndMuteInfo> AudioFrameList;
aleloi 2016/08/31 11:34:29 Mixing structure is a little simplified. Mute info
36 typedef std::list<MixerAudioSource*> MixerAudioSourceList; 30 typedef std::list<MixerAudioSource*> MixerAudioSourceList;
37 31
38 // Cheshire cat implementation of MixerAudioSource's non virtual functions. 32 // Cheshire cat implementation of MixerAudioSource's non virtual functions.
39 class NewMixHistory { 33 class NewMixHistory {
40 public: 34 public:
41 NewMixHistory(); 35 NewMixHistory();
42 ~NewMixHistory(); 36 ~NewMixHistory();
43 37
44 // Returns true if the audio source is being mixed. 38 // Returns true if the audio source is being mixed.
45 bool IsMixed() const; 39 bool IsMixed() const;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 size_t number_of_channels, 73 size_t number_of_channels,
80 AudioFrame* audio_frame_for_mixing) override; 74 AudioFrame* audio_frame_for_mixing) override;
81 bool AnonymousMixabilityStatus( 75 bool AnonymousMixabilityStatus(
82 const MixerAudioSource& audio_source) const override; 76 const MixerAudioSource& audio_source) const override;
83 77
84 private: 78 private:
85 // Set/get mix frequency 79 // Set/get mix frequency
86 int32_t SetOutputFrequency(const Frequency& frequency); 80 int32_t SetOutputFrequency(const Frequency& frequency);
87 Frequency OutputFrequency() const; 81 Frequency OutputFrequency() const;
88 82
89 // Compute what audio sources to mix from audio_source_list_. Ramp in 83 // Compute what audio sources to mix from audio_source_list_. Ramp
90 // and out. Update mixed status. maxAudioFrameCounter specifies how 84 // in and out. Update mixed status. Mixes up to
91 // many participants are allowed to be mixed. 85 // kMaximumAmountOfMixedAudioSources audio sources.
92 AudioFrameList UpdateToMix(size_t maxAudioFrameCounter) const 86 AudioFrameList GetNonAnonymousAudio() const EXCLUSIVE_LOCKS_REQUIRED(crit_);
93 EXCLUSIVE_LOCKS_REQUIRED(crit_);
94 87
95 // Return the lowest mixing frequency that can be used without having to 88 // Return the lowest mixing frequency that can be used without having to
96 // downsample any audio. 89 // downsample any audio.
97 int32_t GetLowestMixingFrequency() const; 90 int32_t GetLowestMixingFrequency() const;
98 int32_t GetLowestMixingFrequencyFromList( 91 int32_t GetLowestMixingFrequencyFromList(
99 const MixerAudioSourceList& mixList) const; 92 const MixerAudioSourceList& mixList) const;
100 93
101 // Return the AudioFrames that should be mixed anonymously. 94 // Return the AudioFrames that should be mixed anonymously. Ramp in
102 void GetAdditionalAudio(AudioFrameList* additionalFramesList) const 95 // and out. Update mixed status.
103 EXCLUSIVE_LOCKS_REQUIRED(crit_); 96 AudioFrameList GetAnonymousAudio() const EXCLUSIVE_LOCKS_REQUIRED(crit_);
aleloi 2016/08/31 11:34:29 Made naming and signature more consistent between
104 97
105 // This function returns true if it finds the MixerAudioSource in the 98 // This function returns true if it finds the MixerAudioSource in the
106 // specified list of MixerAudioSources. 99 // specified list of MixerAudioSources.
107 bool IsAudioSourceInList(const MixerAudioSource& audio_source, 100 bool IsAudioSourceInList(const MixerAudioSource& audio_source,
108 const MixerAudioSourceList& audioSourceList) const; 101 const MixerAudioSourceList& audioSourceList) const;
109 102
110 // Add/remove the MixerAudioSource to the specified 103 // Add/remove the MixerAudioSource to the specified
111 // MixerAudioSource list. 104 // MixerAudioSource list.
112 bool AddAudioSourceToList(MixerAudioSource* audio_source, 105 bool AddAudioSourceToList(MixerAudioSource* audio_source,
113 MixerAudioSourceList* audioSourceList) const; 106 MixerAudioSourceList* audioSourceList) const;
114 bool RemoveAudioSourceFromList(MixerAudioSource* removeAudioSource, 107 bool RemoveAudioSourceFromList(MixerAudioSource* removeAudioSource,
115 MixerAudioSourceList* audioSourceList) const; 108 MixerAudioSourceList* audioSourceList) const;
116 109
117 // Mix the AudioFrames stored in audioFrameList into mixedAudio. 110 // Mix the AudioFrames stored in audioFrameList into mixedAudio.
118 static int32_t MixFromList(AudioFrame* mixedAudio, 111 static int32_t MixFromList(AudioFrame* mixedAudio,
119 const AudioFrameList& audioFrameList, 112 const AudioFrameList& audioFrameList,
120 int32_t id, 113 int32_t id,
121 bool use_limiter); 114 bool use_limiter);
122 115
123 // Mix the AudioFrames stored in audioFrameList into mixedAudio. No
124 // record will be kept of this mix (e.g. the corresponding MixerAudioSources
125 // will not be marked as IsMixed()
126 int32_t MixAnonomouslyFromList(AudioFrame* mixedAudio,
127 const AudioFrameList& audioFrameList) const;
128
aleloi 2016/08/31 11:34:29 Merged with MixFromList
129 bool LimitMixedAudio(AudioFrame* mixedAudio) const; 116 bool LimitMixedAudio(AudioFrame* mixedAudio) const;
130 117
131 // Output level functions for VoEVolumeControl. 118 // Output level functions for VoEVolumeControl.
132 int GetOutputAudioLevel() override; 119 int GetOutputAudioLevel() override;
133 120
134 int GetOutputAudioLevelFullRange() override; 121 int GetOutputAudioLevelFullRange() override;
135 122
136 std::unique_ptr<CriticalSectionWrapper> crit_; 123 std::unique_ptr<CriticalSectionWrapper> crit_;
137 124
138 int32_t id_; 125 int32_t id_;
(...skipping 20 matching lines...) Expand all
159 146
160 // Used for inhibiting saturation in mixing. 147 // Used for inhibiting saturation in mixing.
161 std::unique_ptr<AudioProcessing> limiter_; 148 std::unique_ptr<AudioProcessing> limiter_;
162 149
163 // Measures audio level for the combined signal. 150 // Measures audio level for the combined signal.
164 voe::AudioLevel audio_level_; 151 voe::AudioLevel audio_level_;
165 }; 152 };
166 } // namespace webrtc 153 } // namespace webrtc
167 154
168 #endif // WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_IMPL_H_ 155 #endif // WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/audio_mixer/audio_mixer_impl.cc » ('j') | webrtc/modules/audio_mixer/audio_mixer_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698