| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 // The dtor not needed, because this class does no longer manage | |
| 66 // memory. | |
| 67 | 65 |
| 68 // Must be called after ctor. | 66 // Must be called after ctor. |
| 69 bool Init(); | 67 bool Init(); |
| 70 | 68 |
| 71 // NewAudioConferenceMixer functions | 69 // NewAudioConferenceMixer functions |
| 72 int32_t SetMixabilityStatus(MixerAudioSource* audio_source, | 70 int32_t SetMixabilityStatus(MixerAudioSource* audio_source, |
| 73 bool mixable) override; | 71 bool mixable) override; |
| 74 bool MixabilityStatus(const MixerAudioSource& audio_source) const override; | 72 bool MixabilityStatus(const MixerAudioSource& audio_source) const override; |
| 75 int32_t SetAnonymousMixabilityStatus(MixerAudioSource* audio_source, | 73 int32_t SetAnonymousMixabilityStatus(MixerAudioSource* audio_source, |
| 76 bool mixable) override; | 74 bool mixable) override; |
| 77 void Mix(AudioFrame* audio_frame_for_mixing) override; | 75 void Mix(int sample_rate, |
| 78 int32_t SetMinimumMixingFrequency(Frequency freq) override; | 76 size_t number_of_channels, |
| 77 AudioFrame* audio_frame_for_mixing) override; |
| 79 bool AnonymousMixabilityStatus( | 78 bool AnonymousMixabilityStatus( |
| 80 const MixerAudioSource& audio_source) const override; | 79 const MixerAudioSource& audio_source) const override; |
| 81 | 80 |
| 82 private: | 81 private: |
| 83 // Set/get mix frequency | 82 // Set/get mix frequency |
| 84 int32_t SetOutputFrequency(const Frequency& frequency); | 83 int32_t SetOutputFrequency(const Frequency& frequency); |
| 85 Frequency OutputFrequency() const; | 84 Frequency OutputFrequency() const; |
| 86 | 85 |
| 87 // Compute what audio sources to mix from audio_source_list_. Ramp in | 86 // Compute what audio sources to mix from audio_source_list_. Ramp in |
| 88 // and out. Update mixed status. maxAudioFrameCounter specifies how | 87 // and out. Update mixed status. maxAudioFrameCounter specifies how |
| 89 // many participants are allowed to be mixed. | 88 // many participants are allowed to be mixed. |
| 90 AudioFrameList UpdateToMix(size_t maxAudioFrameCounter) const; | 89 AudioFrameList UpdateToMix(size_t maxAudioFrameCounter) const; |
| 91 | 90 |
| 92 // Return the lowest mixing frequency that can be used without having to | 91 // Return the lowest mixing frequency that can be used without having to |
| 93 // downsample any audio. | 92 // downsample any audio. |
| 94 int32_t GetLowestMixingFrequency() const; | 93 int32_t GetLowestMixingFrequency() const; |
| 95 int32_t GetLowestMixingFrequencyFromList( | 94 int32_t GetLowestMixingFrequencyFromList( |
| 96 const MixerAudioSourceList& mixList) const; | 95 const MixerAudioSourceList& mixList) const; |
| 97 | 96 |
| 98 // Return the AudioFrames that should be mixed anonymously. | 97 // Return the AudioFrames that should be mixed anonymously. |
| 99 void GetAdditionalAudio(AudioFrameList* additionalFramesList) const; | 98 void GetAdditionalAudio(AudioFrameList* additionalFramesList) const; |
| 100 | 99 |
| 101 // Clears audioFrameList and reclaims all memory associated with it. | |
| 102 void ClearAudioFrameList(AudioFrameList* audioFrameList) const; | |
| 103 | |
| 104 // This function returns true if it finds the MixerAudioSource in the | 100 // This function returns true if it finds the MixerAudioSource in the |
| 105 // specified list of MixerAudioSources. | 101 // specified list of MixerAudioSources. |
| 106 bool IsAudioSourceInList(const MixerAudioSource& audio_source, | 102 bool IsAudioSourceInList(const MixerAudioSource& audio_source, |
| 107 const MixerAudioSourceList& audioSourceList) const; | 103 const MixerAudioSourceList& audioSourceList) const; |
| 108 | 104 |
| 109 // Add/remove the MixerAudioSource to the specified | 105 // Add/remove the MixerAudioSource to the specified |
| 110 // MixerAudioSource list. | 106 // MixerAudioSource list. |
| 111 bool AddAudioSourceToList(MixerAudioSource* audio_source, | 107 bool AddAudioSourceToList(MixerAudioSource* audio_source, |
| 112 MixerAudioSourceList* audioSourceList) const; | 108 MixerAudioSourceList* audioSourceList) const; |
| 113 bool RemoveAudioSourceFromList(MixerAudioSource* removeAudioSource, | 109 bool RemoveAudioSourceFromList(MixerAudioSource* removeAudioSource, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 125 int32_t MixAnonomouslyFromList(AudioFrame* mixedAudio, | 121 int32_t MixAnonomouslyFromList(AudioFrame* mixedAudio, |
| 126 const AudioFrameList& audioFrameList) const; | 122 const AudioFrameList& audioFrameList) const; |
| 127 | 123 |
| 128 bool LimitMixedAudio(AudioFrame* mixedAudio) const; | 124 bool LimitMixedAudio(AudioFrame* mixedAudio) const; |
| 129 | 125 |
| 130 std::unique_ptr<CriticalSectionWrapper> _crit; | 126 std::unique_ptr<CriticalSectionWrapper> _crit; |
| 131 std::unique_ptr<CriticalSectionWrapper> _cbCrit; | 127 std::unique_ptr<CriticalSectionWrapper> _cbCrit; |
| 132 | 128 |
| 133 int32_t _id; | 129 int32_t _id; |
| 134 | 130 |
| 135 Frequency _minimumMixingFreq; | |
| 136 | |
| 137 // The current sample frequency and sample size when mixing. | 131 // The current sample frequency and sample size when mixing. |
| 138 Frequency _outputFrequency; | 132 Frequency _outputFrequency; |
| 139 size_t _sampleSize; | 133 size_t _sampleSize; |
| 140 | 134 |
| 141 // List of all audio sources. Note all lists are disjunct | 135 // List of all audio sources. Note all lists are disjunct |
| 142 MixerAudioSourceList audio_source_list_; // May be mixed. | 136 MixerAudioSourceList audio_source_list_; // May be mixed. |
| 143 | 137 |
| 144 // Always mixed, anonomously. | 138 // Always mixed, anonomously. |
| 145 MixerAudioSourceList additional_audio_source_list_; | 139 MixerAudioSourceList additional_audio_source_list_; |
| 146 | 140 |
| 147 size_t num_mixed_audio_sources_; | 141 size_t num_mixed_audio_sources_; |
| 148 // Determines if we will use a limiter for clipping protection during | 142 // Determines if we will use a limiter for clipping protection during |
| 149 // mixing. | 143 // mixing. |
| 150 bool use_limiter_; | 144 bool use_limiter_; |
| 151 | 145 |
| 152 uint32_t _timeStamp; | 146 uint32_t _timeStamp; |
| 153 | 147 |
| 154 // Ensures that Mix is called from the same thread. | 148 // Ensures that Mix is called from the same thread. |
| 155 rtc::ThreadChecker thread_checker_; | 149 rtc::ThreadChecker thread_checker_; |
| 156 | 150 |
| 157 // Used for inhibiting saturation in mixing. | 151 // Used for inhibiting saturation in mixing. |
| 158 std::unique_ptr<AudioProcessing> _limiter; | 152 std::unique_ptr<AudioProcessing> _limiter; |
| 159 }; | 153 }; |
| 160 } // namespace webrtc | 154 } // namespace webrtc |
| 161 | 155 |
| 162 #endif // WEBRTC_MODULES_AUDIO_MIXER_SOURCE_NEW_AUDIO_CONFERENCE_MIXER_IMPL_H_ | 156 #endif // WEBRTC_MODULES_AUDIO_MIXER_SOURCE_NEW_AUDIO_CONFERENCE_MIXER_IMPL_H_ |
| OLD | NEW |