Chromium Code Reviews| 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_CONFERENCE_MIXER_SOURCE_AUDIO_CONFERENCE_MIXER_IMPL _H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_CONFERENCE_MIXER_SOURCE_AUDIO_CONFERENCE_MIXER_IMPL _H_ |
| 12 #define WEBRTC_MODULES_AUDIO_CONFERENCE_MIXER_SOURCE_AUDIO_CONFERENCE_MIXER_IMPL _H_ | 12 #define WEBRTC_MODULES_AUDIO_CONFERENCE_MIXER_SOURCE_AUDIO_CONFERENCE_MIXER_IMPL _H_ |
| 13 | 13 |
| 14 #include <list> | 14 #include <list> |
| 15 #include <map> | 15 #include <map> |
| 16 | 16 |
| 17 #include "webrtc/base/scoped_ptr.h" | 17 #include "webrtc/base/scoped_ptr.h" |
| 18 #include "webrtc/engine_configurations.h" | 18 #include "webrtc/engine_configurations.h" |
| 19 #include "webrtc/modules/audio_conference_mixer/interface/audio_conference_mixer .h" | 19 #include "webrtc/modules/audio_conference_mixer/interface/audio_conference_mixer .h" |
| 20 #include "webrtc/modules/audio_conference_mixer/source/level_indicator.h" | |
| 21 #include "webrtc/modules/audio_conference_mixer/source/memory_pool.h" | 20 #include "webrtc/modules/audio_conference_mixer/source/memory_pool.h" |
| 22 #include "webrtc/modules/audio_conference_mixer/source/time_scheduler.h" | 21 #include "webrtc/modules/audio_conference_mixer/source/time_scheduler.h" |
| 23 #include "webrtc/modules/interface/module_common_types.h" | 22 #include "webrtc/modules/interface/module_common_types.h" |
| 24 | 23 |
| 25 namespace webrtc { | 24 namespace webrtc { |
| 26 class AudioProcessing; | 25 class AudioProcessing; |
| 27 class CriticalSectionWrapper; | 26 class CriticalSectionWrapper; |
| 28 | 27 |
| 29 typedef std::list<AudioFrame*> AudioFrameList; | 28 typedef std::list<AudioFrame*> AudioFrameList; |
| 30 typedef std::list<MixerParticipant*> MixerParticipantList; | 29 typedef std::list<MixerParticipant*> MixerParticipantList; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 64 bool Init(); | 63 bool Init(); |
| 65 | 64 |
| 66 // Module functions | 65 // Module functions |
| 67 int64_t TimeUntilNextProcess() override; | 66 int64_t TimeUntilNextProcess() override; |
| 68 int32_t Process() override; | 67 int32_t Process() override; |
| 69 | 68 |
| 70 // AudioConferenceMixer functions | 69 // AudioConferenceMixer functions |
| 71 int32_t RegisterMixedStreamCallback( | 70 int32_t RegisterMixedStreamCallback( |
| 72 AudioMixerOutputReceiver& mixReceiver) override; | 71 AudioMixerOutputReceiver& mixReceiver) override; |
| 73 int32_t UnRegisterMixedStreamCallback() override; | 72 int32_t UnRegisterMixedStreamCallback() override; |
| 74 int32_t RegisterMixerStatusCallback( | |
| 75 AudioMixerStatusReceiver& mixerStatusCallback, | |
| 76 const uint32_t amountOf10MsBetweenCallbacks) override; | |
| 77 int32_t UnRegisterMixerStatusCallback() override; | |
| 78 int32_t SetMixabilityStatus(MixerParticipant& participant, | 73 int32_t SetMixabilityStatus(MixerParticipant& participant, |
| 79 bool mixable) override; | 74 bool mixable) override; |
| 80 int32_t MixabilityStatus(MixerParticipant& participant, | 75 int32_t MixabilityStatus(MixerParticipant& participant, |
| 81 bool& mixable) override; | 76 bool& mixable) override; |
| 82 int32_t SetMinimumMixingFrequency(Frequency freq) override; | 77 int32_t SetMinimumMixingFrequency(Frequency freq) override; |
| 83 int32_t SetAnonymousMixabilityStatus(MixerParticipant& participant, | 78 int32_t SetAnonymousMixabilityStatus(MixerParticipant& participant, |
| 84 const bool mixable) override; | 79 const bool mixable) override; |
| 85 int32_t AnonymousMixabilityStatus(MixerParticipant& participant, | 80 int32_t AnonymousMixabilityStatus(MixerParticipant& participant, |
| 86 bool& mixable) override; | 81 bool& mixable) override; |
| 87 | 82 |
| 88 private: | 83 private: |
| 89 enum{DEFAULT_AUDIO_FRAME_POOLSIZE = 50}; | 84 enum{DEFAULT_AUDIO_FRAME_POOLSIZE = 50}; |
| 90 | 85 |
| 91 // Set/get mix frequency | 86 // Set/get mix frequency |
| 92 int32_t SetOutputFrequency(const Frequency frequency); | 87 int32_t SetOutputFrequency(const Frequency frequency); |
| 93 Frequency OutputFrequency() const; | 88 Frequency OutputFrequency() const; |
| 94 | 89 |
| 95 // Fills mixList with the AudioFrames pointers that should be used when | 90 // Fills mixList with the AudioFrames pointers that should be used when |
| 96 // mixing. Fills mixParticipantList with ParticipantStatistics for the | 91 // mixing. |
| 97 // participants who's AudioFrames are inside mixList. | |
|
ajm
2015/07/25 01:46:12
who's -> whose
minyue-webrtc
2015/07/27 13:10:13
This is a removed line
| |
| 98 // maxAudioFrameCounter both input and output specifies how many more | 92 // maxAudioFrameCounter both input and output specifies how many more |
| 99 // AudioFrames that are allowed to be mixed. | 93 // AudioFrames that are allowed to be mixed. |
| 100 // rampOutList contain AudioFrames corresponding to an audio stream that | 94 // rampOutList contain AudioFrames corresponding to an audio stream that |
| 101 // used to be mixed but shouldn't be mixed any longer. These AudioFrames | 95 // used to be mixed but shouldn't be mixed any longer. These AudioFrames |
| 102 // should be ramped out over this AudioFrame to avoid audio discontinuities. | 96 // should be ramped out over this AudioFrame to avoid audio discontinuities. |
| 103 void UpdateToMix( | 97 void UpdateToMix( |
| 104 AudioFrameList* mixList, | 98 AudioFrameList* mixList, |
| 105 AudioFrameList* rampOutList, | 99 AudioFrameList* rampOutList, |
| 106 std::map<int, MixerParticipant*>* mixParticipantList, | 100 std::map<int, MixerParticipant*>* mixParticipantList, |
| 107 size_t& maxAudioFrameCounter); | 101 size_t& maxAudioFrameCounter); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 AudioFrame& mixedAudio, | 141 AudioFrame& mixedAudio, |
| 148 const AudioFrameList* audioFrameList); | 142 const AudioFrameList* audioFrameList); |
| 149 // Mix the AudioFrames stored in audioFrameList into mixedAudio. No | 143 // Mix the AudioFrames stored in audioFrameList into mixedAudio. No |
| 150 // record will be kept of this mix (e.g. the corresponding MixerParticipants | 144 // record will be kept of this mix (e.g. the corresponding MixerParticipants |
| 151 // will not be marked as IsMixed() | 145 // will not be marked as IsMixed() |
| 152 int32_t MixAnonomouslyFromList(AudioFrame& mixedAudio, | 146 int32_t MixAnonomouslyFromList(AudioFrame& mixedAudio, |
| 153 const AudioFrameList* audioFrameList); | 147 const AudioFrameList* audioFrameList); |
| 154 | 148 |
| 155 bool LimitMixedAudio(AudioFrame& mixedAudio); | 149 bool LimitMixedAudio(AudioFrame& mixedAudio); |
| 156 | 150 |
| 157 // Scratch memory | |
| 158 // Note that the scratch memory may only be touched in the scope of | |
| 159 // Process(). | |
| 160 size_t _scratchParticipantsToMixAmount; | |
| 161 ParticipantStatistics _scratchMixedParticipants[ | |
| 162 kMaximumAmountOfMixedParticipants]; | |
| 163 uint32_t _scratchVadPositiveParticipantsAmount; | |
| 164 ParticipantStatistics _scratchVadPositiveParticipants[ | |
| 165 kMaximumAmountOfMixedParticipants]; | |
| 166 | |
| 167 rtc::scoped_ptr<CriticalSectionWrapper> _crit; | 151 rtc::scoped_ptr<CriticalSectionWrapper> _crit; |
| 168 rtc::scoped_ptr<CriticalSectionWrapper> _cbCrit; | 152 rtc::scoped_ptr<CriticalSectionWrapper> _cbCrit; |
| 169 | 153 |
| 170 int32_t _id; | 154 int32_t _id; |
| 171 | 155 |
| 172 Frequency _minimumMixingFreq; | 156 Frequency _minimumMixingFreq; |
| 173 | 157 |
| 174 // Mix result callback | 158 // Mix result callback |
| 175 AudioMixerOutputReceiver* _mixReceiver; | 159 AudioMixerOutputReceiver* _mixReceiver; |
| 176 | 160 |
| 177 AudioMixerStatusReceiver* _mixerStatusCallback; | |
| 178 uint32_t _amountOf10MsBetweenCallbacks; | |
| 179 uint32_t _amountOf10MsUntilNextCallback; | |
| 180 bool _mixerStatusCb; | |
| 181 | |
| 182 // The current sample frequency and sample size when mixing. | 161 // The current sample frequency and sample size when mixing. |
| 183 Frequency _outputFrequency; | 162 Frequency _outputFrequency; |
| 184 uint16_t _sampleSize; | 163 uint16_t _sampleSize; |
| 185 | 164 |
| 186 // Memory pool to avoid allocating/deallocating AudioFrames | 165 // Memory pool to avoid allocating/deallocating AudioFrames |
| 187 MemoryPool<AudioFrame>* _audioFramePool; | 166 MemoryPool<AudioFrame>* _audioFramePool; |
| 188 | 167 |
| 189 // List of all participants. Note all lists are disjunct | 168 // List of all participants. Note all lists are disjunct |
| 190 MixerParticipantList _participantList; // May be mixed. | 169 MixerParticipantList _participantList; // May be mixed. |
| 191 // Always mixed, anonomously. | 170 // Always mixed, anonomously. |
| 192 MixerParticipantList _additionalParticipantList; | 171 MixerParticipantList _additionalParticipantList; |
| 193 | 172 |
| 194 size_t _numMixedParticipants; | 173 size_t _numMixedParticipants; |
| 195 // Determines if we will use a limiter for clipping protection during | 174 // Determines if we will use a limiter for clipping protection during |
| 196 // mixing. | 175 // mixing. |
| 197 bool use_limiter_; | 176 bool use_limiter_; |
| 198 | 177 |
| 199 uint32_t _timeStamp; | 178 uint32_t _timeStamp; |
| 200 | 179 |
| 201 // Metronome class. | 180 // Metronome class. |
| 202 TimeScheduler _timeScheduler; | 181 TimeScheduler _timeScheduler; |
| 203 | 182 |
| 204 // Smooth level indicator. | |
| 205 LevelIndicator _mixedAudioLevel; | |
| 206 | |
| 207 // Counter keeping track of concurrent calls to process. | 183 // Counter keeping track of concurrent calls to process. |
| 208 // Note: should never be higher than 1 or lower than 0. | 184 // Note: should never be higher than 1 or lower than 0. |
| 209 int16_t _processCalls; | 185 int16_t _processCalls; |
| 210 | 186 |
| 211 // Used for inhibiting saturation in mixing. | 187 // Used for inhibiting saturation in mixing. |
| 212 rtc::scoped_ptr<AudioProcessing> _limiter; | 188 rtc::scoped_ptr<AudioProcessing> _limiter; |
| 213 }; | 189 }; |
| 214 } // namespace webrtc | 190 } // namespace webrtc |
| 215 | 191 |
| 216 #endif // WEBRTC_MODULES_AUDIO_CONFERENCE_MIXER_SOURCE_AUDIO_CONFERENCE_MIXER_IM PL_H_ | 192 #endif // WEBRTC_MODULES_AUDIO_CONFERENCE_MIXER_SOURCE_AUDIO_CONFERENCE_MIXER_IM PL_H_ |
| OLD | NEW |