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

Side by Side Diff: webrtc/modules/audio_mixer/source/new_audio_conference_mixer_impl.h

Issue 2111293003: Removed callback between old AudioConferenceMixer and OutputMixer. The audio frame with mixed audio… (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@new_mixer_format
Patch Set: Removed asserts, decreased lock holding time & minor changes. Created 4 years, 5 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
(Empty)
1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #ifndef WEBRTC_MODULES_AUDIO_MIXER_SOURCE_NEW_AUDIO_CONFERENCE_MIXER_IMPL_H_
12 #define WEBRTC_MODULES_AUDIO_MIXER_SOURCE_NEW_AUDIO_CONFERENCE_MIXER_IMPL_H_
13
14 #include <list>
15 #include <map>
16 #include <memory>
17
18 #include "webrtc/engine_configurations.h"
19 #include "webrtc/modules/audio_mixer/include/new_audio_conference_mixer.h"
20 #include "webrtc/modules/audio_conference_mixer/source/memory_pool.h"
21 #include "webrtc/modules/audio_conference_mixer/source/time_scheduler.h"
22 #include "webrtc/modules/include/module_common_types.h"
23
24 namespace webrtc {
25 class AudioProcessing;
26 class CriticalSectionWrapper;
27
28 struct FrameAndMuteInfo {
29 FrameAndMuteInfo(AudioFrame* f, bool m) : frame(f), muted(m) {}
30 AudioFrame* frame;
31 bool muted;
32 };
33
34 typedef std::list<FrameAndMuteInfo> AudioFrameList;
35 typedef std::list<MixerAudioSource*> MixerAudioSourceList;
36
37 // Cheshire cat implementation of MixerAudioSource's non virtual functions.
38 class NewMixHistory {
39 public:
40 NewMixHistory();
41 ~NewMixHistory();
42
43 // Returns true if the participant is being mixed.
44 bool IsMixed() const;
45
46 // Returns true if the participant was mixed previous mix
47 // iteration.
48 bool WasMixed() const;
49
50 // Updates the mixed status.
51 int32_t SetIsMixed(bool mixed);
52
53 void ResetMixedStatus();
54
55 private:
56 bool _isMixed;
57 };
58
59 class NewAudioConferenceMixerImpl : public NewAudioConferenceMixer {
60 public:
61 // AudioProcessing only accepts 10 ms frames.
62 enum { kProcessPeriodicityInMs = 10 };
63
64 explicit NewAudioConferenceMixerImpl(int id);
65 ~NewAudioConferenceMixerImpl();
66
67 // Must be called after ctor.
68 bool Init();
69
70 // Module functions
71 int64_t TimeUntilNextProcess() override;
72 void Process() override;
73
74 // NewAudioConferenceMixer functions
75 void Mix(AudioFrame* audio_frame_for_mixing) override;
76 int32_t SetMixabilityStatus(MixerAudioSource* participant,
77 bool mixable) override;
78 bool MixabilityStatus(const MixerAudioSource& participant) const override;
79 int32_t SetMinimumMixingFrequency(Frequency freq) override;
80 int32_t SetAnonymousMixabilityStatus(MixerAudioSource* participant,
81 bool mixable) override;
82 bool AnonymousMixabilityStatus(
83 const MixerAudioSource& participant) const override;
84
85 private:
86 enum { DEFAULT_AUDIO_FRAME_POOLSIZE = 50 };
87
88 // Set/get mix frequency
89 int32_t SetOutputFrequency(const Frequency& frequency);
90 Frequency OutputFrequency() const;
91
92 // Fills mixList with the AudioFrames pointers that should be used when
93 // mixing.
94 // maxAudioFrameCounter both input and output specifies how many more
95 // AudioFrames that are allowed to be mixed.
96 // rampOutList contain AudioFrames corresponding to an audio stream that
97 // used to be mixed but shouldn't be mixed any longer. These AudioFrames
98 // should be ramped out over this AudioFrame to avoid audio discontinuities.
99 void UpdateToMix(AudioFrameList* mixList,
100 AudioFrameList* rampOutList,
101 std::map<int, MixerAudioSource*>* mixParticipantList,
102 size_t* maxAudioFrameCounter) const;
103
104 // Return the lowest mixing frequency that can be used without having to
105 // downsample any audio.
106 int32_t GetLowestMixingFrequency() const;
107 int32_t GetLowestMixingFrequencyFromList(
108 const MixerAudioSourceList& mixList) const;
109
110 // Return the AudioFrames that should be mixed anonymously.
111 void GetAdditionalAudio(AudioFrameList* additionalFramesList) const;
112
113 // Update the NewMixHistory of all MixerAudioSources. mixedParticipantsList
114 // should contain a map of MixerAudioSources that have been mixed.
115 void UpdateMixedStatus(
116 const std::map<int, MixerAudioSource*>& mixedParticipantsList) const;
117
118 // Clears audioFrameList and reclaims all memory associated with it.
119 void ClearAudioFrameList(AudioFrameList* audioFrameList) const;
120
121 // This function returns true if it finds the MixerAudioSource in the
122 // specified list of MixerAudioSources.
123 bool IsParticipantInList(const MixerAudioSource& participant,
124 const MixerAudioSourceList& participantList) const;
125
126 // Add/remove the MixerAudioSource to the specified
127 // MixerAudioSource list.
128 bool AddParticipantToList(MixerAudioSource* participant,
129 MixerAudioSourceList* participantList) const;
130 bool RemoveParticipantFromList(MixerAudioSource* removeParticipant,
131 MixerAudioSourceList* participantList) const;
132
133 // Mix the AudioFrames stored in audioFrameList into mixedAudio.
134 static int32_t MixFromList(AudioFrame* mixedAudio,
135 const AudioFrameList& audioFrameList,
136 int32_t id,
137 bool use_limiter);
138
139 // Mix the AudioFrames stored in audioFrameList into mixedAudio. No
140 // record will be kept of this mix (e.g. the corresponding MixerAudioSources
141 // will not be marked as IsMixed()
142 int32_t MixAnonomouslyFromList(AudioFrame* mixedAudio,
143 const AudioFrameList& audioFrameList) const;
144
145 bool LimitMixedAudio(AudioFrame* mixedAudio) const;
146
147 std::unique_ptr<CriticalSectionWrapper> _crit;
148 std::unique_ptr<CriticalSectionWrapper> _cbCrit;
149
150 int32_t _id;
151
152 Frequency _minimumMixingFreq;
153
154 // The current sample frequency and sample size when mixing.
155 Frequency _outputFrequency;
156 size_t _sampleSize;
157
158 // Memory pool to avoid allocating/deallocating AudioFrames
159 MemoryPool<AudioFrame>* _audioFramePool;
160
161 // List of all participants. Note all lists are disjunct
162 MixerAudioSourceList _participantList; // May be mixed.
163 // Always mixed, anonomously.
164 MixerAudioSourceList _additionalParticipantList;
165
166 size_t _numMixedParticipants;
167 // Determines if we will use a limiter for clipping protection during
168 // mixing.
169 bool use_limiter_;
170
171 uint32_t _timeStamp;
172
173 // Metronome class.
174 TimeScheduler _timeScheduler;
175
176 // Counter keeping track of concurrent calls to process.
177 // Note: should never be higher than 1 or lower than 0.
178 int16_t _processCalls;
179
180 // Used for inhibiting saturation in mixing.
181 std::unique_ptr<AudioProcessing> _limiter;
182 };
183 } // namespace webrtc
184
185 #endif // WEBRTC_MODULES_AUDIO_MIXER_SOURCE_NEW_AUDIO_CONFERENCE_MIXER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698