| 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 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 typedef std::list<FrameAndMuteInfo> AudioFrameList; | 34 typedef std::list<FrameAndMuteInfo> AudioFrameList; |
| 35 typedef std::list<MixerAudioSource*> MixerAudioSourceList; | 35 typedef std::list<MixerAudioSource*> MixerAudioSourceList; |
| 36 | 36 |
| 37 // Cheshire cat implementation of MixerAudioSource's non virtual functions. | 37 // Cheshire cat implementation of MixerAudioSource's non virtual functions. |
| 38 class NewMixHistory { | 38 class NewMixHistory { |
| 39 public: | 39 public: |
| 40 NewMixHistory(); | 40 NewMixHistory(); |
| 41 ~NewMixHistory(); | 41 ~NewMixHistory(); |
| 42 | 42 |
| 43 // Returns true if the participant is being mixed. | 43 // Returns true if the audio source is being mixed. |
| 44 bool IsMixed() const; | 44 bool IsMixed() const; |
| 45 | 45 |
| 46 // Returns true if the participant was mixed previous mix | 46 // Returns true if the audio source was mixed previous mix |
| 47 // iteration. | 47 // iteration. |
| 48 bool WasMixed() const; | 48 bool WasMixed() const; |
| 49 | 49 |
| 50 // Updates the mixed status. | 50 // Updates the mixed status. |
| 51 int32_t SetIsMixed(bool mixed); | 51 int32_t SetIsMixed(bool mixed); |
| 52 | 52 |
| 53 void ResetMixedStatus(); | 53 void ResetMixedStatus(); |
| 54 | 54 |
| 55 private: | 55 private: |
| 56 bool _isMixed; | 56 bool _isMixed; |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 class NewAudioConferenceMixerImpl : public NewAudioConferenceMixer { | 59 class NewAudioConferenceMixerImpl : public NewAudioConferenceMixer { |
| 60 public: | 60 public: |
| 61 // AudioProcessing only accepts 10 ms frames. | 61 // AudioProcessing only accepts 10 ms frames. |
| 62 enum { kProcessPeriodicityInMs = 10 }; | 62 enum { kProcessPeriodicityInMs = 10 }; |
| 63 | 63 |
| 64 explicit NewAudioConferenceMixerImpl(int id); | 64 explicit NewAudioConferenceMixerImpl(int id); |
| 65 ~NewAudioConferenceMixerImpl(); | 65 ~NewAudioConferenceMixerImpl(); |
| 66 | 66 |
| 67 // Must be called after ctor. | 67 // Must be called after ctor. |
| 68 bool Init(); | 68 bool Init(); |
| 69 | 69 |
| 70 // Module functions | 70 // Module functions |
| 71 int64_t TimeUntilNextProcess() override; | 71 int64_t TimeUntilNextProcess() override; |
| 72 void Process() override; | 72 void Process() override; |
| 73 | 73 |
| 74 // NewAudioConferenceMixer functions | 74 // NewAudioConferenceMixer functions |
| 75 int32_t RegisterMixedStreamCallback( | 75 int32_t SetMixabilityStatus(MixerAudioSource* audio_source, |
| 76 OldAudioMixerOutputReceiver* mixReceiver) override; | |
| 77 int32_t UnRegisterMixedStreamCallback() override; | |
| 78 int32_t SetMixabilityStatus(MixerAudioSource* participant, | |
| 79 bool mixable) override; | 76 bool mixable) override; |
| 80 bool MixabilityStatus(const MixerAudioSource& participant) const override; | 77 bool MixabilityStatus(const MixerAudioSource& audio_source) const override; |
| 78 int32_t SetAnonymousMixabilityStatus(MixerAudioSource* audio_source, |
| 79 bool mixable) override; |
| 80 void Mix(AudioFrame* audio_frame_for_mixing) override; |
| 81 int32_t SetMinimumMixingFrequency(Frequency freq) override; | 81 int32_t SetMinimumMixingFrequency(Frequency freq) override; |
| 82 int32_t SetAnonymousMixabilityStatus(MixerAudioSource* participant, | |
| 83 bool mixable) override; | |
| 84 bool AnonymousMixabilityStatus( | 82 bool AnonymousMixabilityStatus( |
| 85 const MixerAudioSource& participant) const override; | 83 const MixerAudioSource& audio_source) const override; |
| 86 | 84 |
| 87 private: | 85 private: |
| 88 enum { DEFAULT_AUDIO_FRAME_POOLSIZE = 50 }; | 86 enum { DEFAULT_AUDIO_FRAME_POOLSIZE = 50 }; |
| 89 | 87 |
| 90 // Set/get mix frequency | 88 // Set/get mix frequency |
| 91 int32_t SetOutputFrequency(const Frequency& frequency); | 89 int32_t SetOutputFrequency(const Frequency& frequency); |
| 92 Frequency OutputFrequency() const; | 90 Frequency OutputFrequency() const; |
| 93 | 91 |
| 94 // Fills mixList with the AudioFrames pointers that should be used when | 92 // Fills mixList with the AudioFrames pointers that should be used when |
| 95 // mixing. | 93 // mixing. |
| 96 // maxAudioFrameCounter both input and output specifies how many more | 94 // maxAudioFrameCounter both input and output specifies how many more |
| 97 // AudioFrames that are allowed to be mixed. | 95 // AudioFrames that are allowed to be mixed. |
| 98 // rampOutList contain AudioFrames corresponding to an audio stream that | 96 // rampOutList contain AudioFrames corresponding to an audio stream that |
| 99 // used to be mixed but shouldn't be mixed any longer. These AudioFrames | 97 // used to be mixed but shouldn't be mixed any longer. These AudioFrames |
| 100 // should be ramped out over this AudioFrame to avoid audio discontinuities. | 98 // should be ramped out over this AudioFrame to avoid audio discontinuities. |
| 101 void UpdateToMix(AudioFrameList* mixList, | 99 void UpdateToMix(AudioFrameList* mixList, |
| 102 AudioFrameList* rampOutList, | 100 AudioFrameList* rampOutList, |
| 103 std::map<int, MixerAudioSource*>* mixParticipantList, | 101 std::map<int, MixerAudioSource*>* mixAudioSourceList, |
| 104 size_t* maxAudioFrameCounter) const; | 102 size_t* maxAudioFrameCounter) const; |
| 105 | 103 |
| 106 // Return the lowest mixing frequency that can be used without having to | 104 // Return the lowest mixing frequency that can be used without having to |
| 107 // downsample any audio. | 105 // downsample any audio. |
| 108 int32_t GetLowestMixingFrequency() const; | 106 int32_t GetLowestMixingFrequency() const; |
| 109 int32_t GetLowestMixingFrequencyFromList( | 107 int32_t GetLowestMixingFrequencyFromList( |
| 110 const MixerAudioSourceList& mixList) const; | 108 const MixerAudioSourceList& mixList) const; |
| 111 | 109 |
| 112 // Return the AudioFrames that should be mixed anonymously. | 110 // Return the AudioFrames that should be mixed anonymously. |
| 113 void GetAdditionalAudio(AudioFrameList* additionalFramesList) const; | 111 void GetAdditionalAudio(AudioFrameList* additionalFramesList) const; |
| 114 | 112 |
| 115 // Update the NewMixHistory of all MixerAudioSources. mixedParticipantsList | 113 // Update the NewMixHistory of all MixerAudioSources. mixedAudioSourcesList |
| 116 // should contain a map of MixerAudioSources that have been mixed. | 114 // should contain a map of MixerAudioSources that have been mixed. |
| 117 void UpdateMixedStatus( | 115 void UpdateMixedStatus( |
| 118 const std::map<int, MixerAudioSource*>& mixedParticipantsList) const; | 116 const std::map<int, MixerAudioSource*>& mixedAudioSourcesList) const; |
| 119 | 117 |
| 120 // Clears audioFrameList and reclaims all memory associated with it. | 118 // Clears audioFrameList and reclaims all memory associated with it. |
| 121 void ClearAudioFrameList(AudioFrameList* audioFrameList) const; | 119 void ClearAudioFrameList(AudioFrameList* audioFrameList) const; |
| 122 | 120 |
| 123 // This function returns true if it finds the MixerAudioSource in the | 121 // This function returns true if it finds the MixerAudioSource in the |
| 124 // specified list of MixerAudioSources. | 122 // specified list of MixerAudioSources. |
| 125 bool IsParticipantInList(const MixerAudioSource& participant, | 123 bool IsAudioSourceInList(const MixerAudioSource& audio_source, |
| 126 const MixerAudioSourceList& participantList) const; | 124 const MixerAudioSourceList& audioSourceList) const; |
| 127 | 125 |
| 128 // Add/remove the MixerAudioSource to the specified | 126 // Add/remove the MixerAudioSource to the specified |
| 129 // MixerAudioSource list. | 127 // MixerAudioSource list. |
| 130 bool AddParticipantToList(MixerAudioSource* participant, | 128 bool AddAudioSourceToList(MixerAudioSource* audio_source, |
| 131 MixerAudioSourceList* participantList) const; | 129 MixerAudioSourceList* audioSourceList) const; |
| 132 bool RemoveParticipantFromList(MixerAudioSource* removeParticipant, | 130 bool RemoveAudioSourceFromList(MixerAudioSource* removeAudioSource, |
| 133 MixerAudioSourceList* participantList) const; | 131 MixerAudioSourceList* audioSourceList) const; |
| 134 | 132 |
| 135 // Mix the AudioFrames stored in audioFrameList into mixedAudio. | 133 // Mix the AudioFrames stored in audioFrameList into mixedAudio. |
| 136 int32_t MixFromList(AudioFrame* mixedAudio, | 134 static int32_t MixFromList(AudioFrame* mixedAudio, |
| 137 const AudioFrameList& audioFrameList) const; | 135 const AudioFrameList& audioFrameList, |
| 136 int32_t id, |
| 137 bool use_limiter); |
| 138 | 138 |
| 139 // Mix the AudioFrames stored in audioFrameList into mixedAudio. No | 139 // Mix the AudioFrames stored in audioFrameList into mixedAudio. No |
| 140 // record will be kept of this mix (e.g. the corresponding MixerAudioSources | 140 // record will be kept of this mix (e.g. the corresponding MixerAudioSources |
| 141 // will not be marked as IsMixed() | 141 // will not be marked as IsMixed() |
| 142 int32_t MixAnonomouslyFromList(AudioFrame* mixedAudio, | 142 int32_t MixAnonomouslyFromList(AudioFrame* mixedAudio, |
| 143 const AudioFrameList& audioFrameList) const; | 143 const AudioFrameList& audioFrameList) const; |
| 144 | 144 |
| 145 bool LimitMixedAudio(AudioFrame* mixedAudio) const; | 145 bool LimitMixedAudio(AudioFrame* mixedAudio) const; |
| 146 | 146 |
| 147 std::unique_ptr<CriticalSectionWrapper> _crit; | 147 std::unique_ptr<CriticalSectionWrapper> _crit; |
| 148 std::unique_ptr<CriticalSectionWrapper> _cbCrit; | 148 std::unique_ptr<CriticalSectionWrapper> _cbCrit; |
| 149 | 149 |
| 150 int32_t _id; | 150 int32_t _id; |
| 151 | 151 |
| 152 Frequency _minimumMixingFreq; | 152 Frequency _minimumMixingFreq; |
| 153 | 153 |
| 154 // Mix result callback | |
| 155 OldAudioMixerOutputReceiver* _mixReceiver; | |
| 156 | |
| 157 // The current sample frequency and sample size when mixing. | 154 // The current sample frequency and sample size when mixing. |
| 158 Frequency _outputFrequency; | 155 Frequency _outputFrequency; |
| 159 size_t _sampleSize; | 156 size_t _sampleSize; |
| 160 | 157 |
| 161 // Memory pool to avoid allocating/deallocating AudioFrames | 158 // Memory pool to avoid allocating/deallocating AudioFrames |
| 162 MemoryPool<AudioFrame>* _audioFramePool; | 159 MemoryPool<AudioFrame>* _audioFramePool; |
| 163 | 160 |
| 164 // List of all participants. Note all lists are disjunct | 161 // List of all audio sources. Note all lists are disjunct |
| 165 MixerAudioSourceList _participantList; // May be mixed. | 162 MixerAudioSourceList audio_source_list_; // May be mixed. |
| 166 // Always mixed, anonomously. | 163 // Always mixed, anonomously. |
| 167 MixerAudioSourceList _additionalParticipantList; | 164 MixerAudioSourceList additional_audio_source_list_; |
| 168 | 165 |
| 169 size_t _numMixedParticipants; | 166 size_t num_mixed_audio_sources_; |
| 170 // Determines if we will use a limiter for clipping protection during | 167 // Determines if we will use a limiter for clipping protection during |
| 171 // mixing. | 168 // mixing. |
| 172 bool use_limiter_; | 169 bool use_limiter_; |
| 173 | 170 |
| 174 uint32_t _timeStamp; | 171 uint32_t _timeStamp; |
| 175 | 172 |
| 176 // Metronome class. | 173 // Metronome class. |
| 177 TimeScheduler _timeScheduler; | 174 TimeScheduler _timeScheduler; |
| 178 | 175 |
| 179 // Counter keeping track of concurrent calls to process. | 176 // Counter keeping track of concurrent calls to process. |
| 180 // Note: should never be higher than 1 or lower than 0. | 177 // Note: should never be higher than 1 or lower than 0. |
| 181 int16_t _processCalls; | 178 int16_t _processCalls; |
| 182 | 179 |
| 183 // Used for inhibiting saturation in mixing. | 180 // Used for inhibiting saturation in mixing. |
| 184 std::unique_ptr<AudioProcessing> _limiter; | 181 std::unique_ptr<AudioProcessing> _limiter; |
| 185 }; | 182 }; |
| 186 } // namespace webrtc | 183 } // namespace webrtc |
| 187 | 184 |
| 188 #endif // WEBRTC_MODULES_AUDIO_MIXER_SOURCE_NEW_AUDIO_CONFERENCE_MIXER_IMPL_H_ | 185 #endif // WEBRTC_MODULES_AUDIO_MIXER_SOURCE_NEW_AUDIO_CONFERENCE_MIXER_IMPL_H_ |
| OLD | NEW |