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

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

Issue 2238803002: Changed folder structure in new mixer and fixed simple lint errors. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Small changes in response to comments. Created 4 years, 4 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) 2012 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 #include <vector>
18
19 #include "webrtc/base/thread_checker.h"
20 #include "webrtc/engine_configurations.h"
21 #include "webrtc/modules/audio_mixer/include/new_audio_conference_mixer.h"
22 #include "webrtc/modules/audio_conference_mixer/source/memory_pool.h"
23 #include "webrtc/modules/include/module_common_types.h"
24
25 namespace webrtc {
26 class AudioProcessing;
27 class CriticalSectionWrapper;
28
29 struct FrameAndMuteInfo {
30 FrameAndMuteInfo(AudioFrame* f, bool m) : frame(f), muted(m) {}
31 AudioFrame* frame;
32 bool muted;
33 };
34
35 typedef std::list<FrameAndMuteInfo> AudioFrameList;
36 typedef std::list<MixerAudioSource*> MixerAudioSourceList;
37
38 // Cheshire cat implementation of MixerAudioSource's non virtual functions.
39 class NewMixHistory {
40 public:
41 NewMixHistory();
42 ~NewMixHistory();
43
44 // Returns true if the audio source is being mixed.
45 bool IsMixed() const;
46
47 // Returns true if the audio source was mixed previous mix
48 // iteration.
49 bool WasMixed() const;
50
51 // Updates the mixed status.
52 int32_t SetIsMixed(bool mixed);
53
54 void ResetMixedStatus();
55
56 private:
57 bool is_mixed_;
58 };
59
60 class NewAudioConferenceMixerImpl : public NewAudioConferenceMixer {
61 public:
62 // AudioProcessing only accepts 10 ms frames.
63 enum { kProcessPeriodicityInMs = 10 };
64
65 explicit NewAudioConferenceMixerImpl(int id);
66
67 // Must be called after ctor.
68 bool Init();
69
70 // NewAudioConferenceMixer functions
71 int32_t SetMixabilityStatus(MixerAudioSource* audio_source,
72 bool mixable) override;
73 bool MixabilityStatus(const MixerAudioSource& audio_source) const override;
74 int32_t SetAnonymousMixabilityStatus(MixerAudioSource* audio_source,
75 bool mixable) override;
76 void Mix(int sample_rate,
77 size_t number_of_channels,
78 AudioFrame* audio_frame_for_mixing) override;
79 bool AnonymousMixabilityStatus(
80 const MixerAudioSource& audio_source) const override;
81
82 private:
83 // Set/get mix frequency
84 int32_t SetOutputFrequency(const Frequency& frequency);
85 Frequency OutputFrequency() const;
86
87 // Compute what audio sources to mix from audio_source_list_. Ramp in
88 // and out. Update mixed status. maxAudioFrameCounter specifies how
89 // many participants are allowed to be mixed.
90 AudioFrameList UpdateToMix(size_t maxAudioFrameCounter) const;
91
92 // Return the lowest mixing frequency that can be used without having to
93 // downsample any audio.
94 int32_t GetLowestMixingFrequency() const;
95 int32_t GetLowestMixingFrequencyFromList(
96 const MixerAudioSourceList& mixList) const;
97
98 // Return the AudioFrames that should be mixed anonymously.
99 void GetAdditionalAudio(AudioFrameList* additionalFramesList) const;
100
101 // This function returns true if it finds the MixerAudioSource in the
102 // specified list of MixerAudioSources.
103 bool IsAudioSourceInList(const MixerAudioSource& audio_source,
104 const MixerAudioSourceList& audioSourceList) const;
105
106 // Add/remove the MixerAudioSource to the specified
107 // MixerAudioSource list.
108 bool AddAudioSourceToList(MixerAudioSource* audio_source,
109 MixerAudioSourceList* audioSourceList) const;
110 bool RemoveAudioSourceFromList(MixerAudioSource* removeAudioSource,
111 MixerAudioSourceList* audioSourceList) const;
112
113 // Mix the AudioFrames stored in audioFrameList into mixedAudio.
114 static int32_t MixFromList(AudioFrame* mixedAudio,
115 const AudioFrameList& audioFrameList,
116 int32_t id,
117 bool use_limiter);
118
119 // Mix the AudioFrames stored in audioFrameList into mixedAudio. No
120 // record will be kept of this mix (e.g. the corresponding MixerAudioSources
121 // will not be marked as IsMixed()
122 int32_t MixAnonomouslyFromList(AudioFrame* mixedAudio,
123 const AudioFrameList& audioFrameList) const;
124
125 bool LimitMixedAudio(AudioFrame* mixedAudio) const;
126
127 std::unique_ptr<CriticalSectionWrapper> crit_;
128 std::unique_ptr<CriticalSectionWrapper> cb_crit_;
129
130 int32_t id_;
131
132 // The current sample frequency and sample size when mixing.
133 Frequency output_frequency_;
134 size_t sample_size_;
135
136 // List of all audio sources. Note all lists are disjunct
137 MixerAudioSourceList audio_source_list_; // May be mixed.
138
139 // Always mixed, anonomously.
140 MixerAudioSourceList additional_audio_source_list_;
141
142 size_t num_mixed_audio_sources_;
143 // Determines if we will use a limiter for clipping protection during
144 // mixing.
145 bool use_limiter_;
146
147 uint32_t time_stamp_;
148
149 // Ensures that Mix is called from the same thread.
150 rtc::ThreadChecker thread_checker_;
151
152 // Used for inhibiting saturation in mixing.
153 std::unique_ptr<AudioProcessing> limiter_;
154 };
155 } // namespace webrtc
156
157 #endif // WEBRTC_MODULES_AUDIO_MIXER_SOURCE_NEW_AUDIO_CONFERENCE_MIXER_IMPL_H_
OLDNEW
« no previous file with comments | « webrtc/modules/audio_mixer/source/OWNERS ('k') | webrtc/modules/audio_mixer/source/new_audio_conference_mixer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698