| 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 17 matching lines...) Expand all Loading... |
| 28 typedef std::list<AudioFrame*> AudioFrameList; | 28 typedef std::list<AudioFrame*> AudioFrameList; |
| 29 typedef std::list<MixerParticipant*> MixerParticipantList; | 29 typedef std::list<MixerParticipant*> MixerParticipantList; |
| 30 | 30 |
| 31 // Cheshire cat implementation of MixerParticipant's non virtual functions. | 31 // Cheshire cat implementation of MixerParticipant's non virtual functions. |
| 32 class MixHistory | 32 class MixHistory |
| 33 { | 33 { |
| 34 public: | 34 public: |
| 35 MixHistory(); | 35 MixHistory(); |
| 36 ~MixHistory(); | 36 ~MixHistory(); |
| 37 | 37 |
| 38 // MixerParticipant function | 38 // Returns true if the participant is being mixed. |
| 39 int32_t IsMixed(bool& mixed) const; | 39 bool IsMixed() const; |
| 40 | 40 |
| 41 // Sets wasMixed to true if the participant was mixed previous mix | 41 // Returns true if the participant was mixed previous mix |
| 42 // iteration. | 42 // iteration. |
| 43 int32_t WasMixed(bool& wasMixed) const; | 43 bool WasMixed() const; |
| 44 | 44 |
| 45 // Updates the mixed status. | 45 // Updates the mixed status. |
| 46 int32_t SetIsMixed(const bool mixed); | 46 int32_t SetIsMixed(bool mixed); |
| 47 | 47 |
| 48 void ResetMixedStatus(); | 48 void ResetMixedStatus(); |
| 49 private: | 49 private: |
| 50 bool _isMixed; | 50 bool _isMixed; |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 class AudioConferenceMixerImpl : public AudioConferenceMixer | 53 class AudioConferenceMixerImpl : public AudioConferenceMixer |
| 54 { | 54 { |
| 55 public: | 55 public: |
| 56 // AudioProcessing only accepts 10 ms frames. | 56 // AudioProcessing only accepts 10 ms frames. |
| 57 enum {kProcessPeriodicityInMs = 10}; | 57 enum {kProcessPeriodicityInMs = 10}; |
| 58 | 58 |
| 59 AudioConferenceMixerImpl(int id); | 59 AudioConferenceMixerImpl(int id); |
| 60 ~AudioConferenceMixerImpl(); | 60 ~AudioConferenceMixerImpl(); |
| 61 | 61 |
| 62 // Must be called after ctor. | 62 // Must be called after ctor. |
| 63 bool Init(); | 63 bool Init(); |
| 64 | 64 |
| 65 // Module functions | 65 // Module functions |
| 66 int64_t TimeUntilNextProcess() override; | 66 int64_t TimeUntilNextProcess() override; |
| 67 int32_t Process() override; | 67 int32_t Process() override; |
| 68 | 68 |
| 69 // AudioConferenceMixer functions | 69 // AudioConferenceMixer functions |
| 70 int32_t RegisterMixedStreamCallback( | 70 int32_t RegisterMixedStreamCallback( |
| 71 AudioMixerOutputReceiver& mixReceiver) override; | 71 AudioMixerOutputReceiver* mixReceiver) override; |
| 72 int32_t UnRegisterMixedStreamCallback() override; | 72 int32_t UnRegisterMixedStreamCallback() override; |
| 73 int32_t SetMixabilityStatus(MixerParticipant& participant, | 73 int32_t SetMixabilityStatus(MixerParticipant* participant, |
| 74 bool mixable) override; | 74 bool mixable) override; |
| 75 int32_t MixabilityStatus(MixerParticipant& participant, | 75 bool MixabilityStatus(const MixerParticipant& participant) const override; |
| 76 bool& mixable) override; | |
| 77 int32_t SetMinimumMixingFrequency(Frequency freq) override; | 76 int32_t SetMinimumMixingFrequency(Frequency freq) override; |
| 78 int32_t SetAnonymousMixabilityStatus(MixerParticipant& participant, | 77 int32_t SetAnonymousMixabilityStatus( |
| 79 const bool mixable) override; | 78 MixerParticipant* participant, bool mixable) override; |
| 80 int32_t AnonymousMixabilityStatus(MixerParticipant& participant, | 79 bool AnonymousMixabilityStatus( |
| 81 bool& mixable) override; | 80 const MixerParticipant& participant) const override; |
| 82 | 81 |
| 83 private: | 82 private: |
| 84 enum{DEFAULT_AUDIO_FRAME_POOLSIZE = 50}; | 83 enum{DEFAULT_AUDIO_FRAME_POOLSIZE = 50}; |
| 85 | 84 |
| 86 // Set/get mix frequency | 85 // Set/get mix frequency |
| 87 int32_t SetOutputFrequency(const Frequency frequency); | 86 int32_t SetOutputFrequency(const Frequency& frequency); |
| 88 Frequency OutputFrequency() const; | 87 Frequency OutputFrequency() const; |
| 89 | 88 |
| 90 // Fills mixList with the AudioFrames pointers that should be used when | 89 // Fills mixList with the AudioFrames pointers that should be used when |
| 91 // mixing. | 90 // mixing. |
| 92 // maxAudioFrameCounter both input and output specifies how many more | 91 // maxAudioFrameCounter both input and output specifies how many more |
| 93 // AudioFrames that are allowed to be mixed. | 92 // AudioFrames that are allowed to be mixed. |
| 94 // rampOutList contain AudioFrames corresponding to an audio stream that | 93 // rampOutList contain AudioFrames corresponding to an audio stream that |
| 95 // used to be mixed but shouldn't be mixed any longer. These AudioFrames | 94 // used to be mixed but shouldn't be mixed any longer. These AudioFrames |
| 96 // should be ramped out over this AudioFrame to avoid audio discontinuities. | 95 // should be ramped out over this AudioFrame to avoid audio discontinuities. |
| 97 void UpdateToMix( | 96 void UpdateToMix( |
| 98 AudioFrameList* mixList, | 97 AudioFrameList* mixList, |
| 99 AudioFrameList* rampOutList, | 98 AudioFrameList* rampOutList, |
| 100 std::map<int, MixerParticipant*>* mixParticipantList, | 99 std::map<int, MixerParticipant*>* mixParticipantList, |
| 101 size_t& maxAudioFrameCounter); | 100 size_t* maxAudioFrameCounter) const; |
| 102 | 101 |
| 103 // Return the lowest mixing frequency that can be used without having to | 102 // Return the lowest mixing frequency that can be used without having to |
| 104 // downsample any audio. | 103 // downsample any audio. |
| 105 int32_t GetLowestMixingFrequency(); | 104 int32_t GetLowestMixingFrequency() const; |
| 106 int32_t GetLowestMixingFrequencyFromList(MixerParticipantList* mixList); | 105 int32_t GetLowestMixingFrequencyFromList( |
| 106 const MixerParticipantList& mixList) const; |
| 107 | 107 |
| 108 // Return the AudioFrames that should be mixed anonymously. | 108 // Return the AudioFrames that should be mixed anonymously. |
| 109 void GetAdditionalAudio(AudioFrameList* additionalFramesList); | 109 void GetAdditionalAudio(AudioFrameList* additionalFramesList) const; |
| 110 | 110 |
| 111 // Update the MixHistory of all MixerParticipants. mixedParticipantsList | 111 // Update the MixHistory of all MixerParticipants. mixedParticipantsList |
| 112 // should contain a map of MixerParticipants that have been mixed. | 112 // should contain a map of MixerParticipants that have been mixed. |
| 113 void UpdateMixedStatus( | 113 void UpdateMixedStatus( |
| 114 std::map<int, MixerParticipant*>& mixedParticipantsList); | 114 const std::map<int, MixerParticipant*>& mixedParticipantsList) const; |
| 115 | 115 |
| 116 // Clears audioFrameList and reclaims all memory associated with it. | 116 // Clears audioFrameList and reclaims all memory associated with it. |
| 117 void ClearAudioFrameList(AudioFrameList* audioFrameList); | 117 void ClearAudioFrameList(AudioFrameList* audioFrameList) const; |
| 118 | 118 |
| 119 // Update the list of MixerParticipants who have a positive VAD. mixList | 119 // Update the list of MixerParticipants who have a positive VAD. mixList |
| 120 // should be a list of AudioFrames | 120 // should be a list of AudioFrames |
| 121 void UpdateVADPositiveParticipants( | 121 void UpdateVADPositiveParticipants(AudioFrameList* mixList) const; |
| 122 AudioFrameList* mixList); | |
| 123 | 122 |
| 124 // This function returns true if it finds the MixerParticipant in the | 123 // This function returns true if it finds the MixerParticipant in the |
| 125 // specified list of MixerParticipants. | 124 // specified list of MixerParticipants. |
| 126 bool IsParticipantInList( | 125 bool IsParticipantInList(const MixerParticipant& participant, |
| 127 MixerParticipant& participant, | 126 const MixerParticipantList& participantList) const; |
| 128 MixerParticipantList* participantList) const; | |
| 129 | 127 |
| 130 // Add/remove the MixerParticipant to the specified | 128 // Add/remove the MixerParticipant to the specified |
| 131 // MixerParticipant list. | 129 // MixerParticipant list. |
| 132 bool AddParticipantToList( | 130 bool AddParticipantToList( |
| 133 MixerParticipant& participant, | 131 MixerParticipant* participant, |
| 134 MixerParticipantList* participantList); | 132 MixerParticipantList* participantList) const; |
| 135 bool RemoveParticipantFromList( | 133 bool RemoveParticipantFromList( |
| 136 MixerParticipant& removeParticipant, | 134 MixerParticipant* removeParticipant, |
| 137 MixerParticipantList* participantList); | 135 MixerParticipantList* participantList) const; |
| 138 | 136 |
| 139 // Mix the AudioFrames stored in audioFrameList into mixedAudio. | 137 // Mix the AudioFrames stored in audioFrameList into mixedAudio. |
| 140 int32_t MixFromList( | 138 int32_t MixFromList(AudioFrame* mixedAudio, |
| 141 AudioFrame& mixedAudio, | 139 const AudioFrameList& audioFrameList) const; |
| 142 const AudioFrameList* audioFrameList); | 140 |
| 143 // Mix the AudioFrames stored in audioFrameList into mixedAudio. No | 141 // Mix the AudioFrames stored in audioFrameList into mixedAudio. No |
| 144 // record will be kept of this mix (e.g. the corresponding MixerParticipants | 142 // record will be kept of this mix (e.g. the corresponding MixerParticipants |
| 145 // will not be marked as IsMixed() | 143 // will not be marked as IsMixed() |
| 146 int32_t MixAnonomouslyFromList(AudioFrame& mixedAudio, | 144 int32_t MixAnonomouslyFromList(AudioFrame* mixedAudio, |
| 147 const AudioFrameList* audioFrameList); | 145 const AudioFrameList& audioFrameList) const; |
| 148 | 146 |
| 149 bool LimitMixedAudio(AudioFrame& mixedAudio); | 147 bool LimitMixedAudio(AudioFrame* mixedAudio) const; |
| 150 | 148 |
| 151 rtc::scoped_ptr<CriticalSectionWrapper> _crit; | 149 rtc::scoped_ptr<CriticalSectionWrapper> _crit; |
| 152 rtc::scoped_ptr<CriticalSectionWrapper> _cbCrit; | 150 rtc::scoped_ptr<CriticalSectionWrapper> _cbCrit; |
| 153 | 151 |
| 154 int32_t _id; | 152 int32_t _id; |
| 155 | 153 |
| 156 Frequency _minimumMixingFreq; | 154 Frequency _minimumMixingFreq; |
| 157 | 155 |
| 158 // Mix result callback | 156 // Mix result callback |
| 159 AudioMixerOutputReceiver* _mixReceiver; | 157 AudioMixerOutputReceiver* _mixReceiver; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 183 // Counter keeping track of concurrent calls to process. | 181 // Counter keeping track of concurrent calls to process. |
| 184 // Note: should never be higher than 1 or lower than 0. | 182 // Note: should never be higher than 1 or lower than 0. |
| 185 int16_t _processCalls; | 183 int16_t _processCalls; |
| 186 | 184 |
| 187 // Used for inhibiting saturation in mixing. | 185 // Used for inhibiting saturation in mixing. |
| 188 rtc::scoped_ptr<AudioProcessing> _limiter; | 186 rtc::scoped_ptr<AudioProcessing> _limiter; |
| 189 }; | 187 }; |
| 190 } // namespace webrtc | 188 } // namespace webrtc |
| 191 | 189 |
| 192 #endif // WEBRTC_MODULES_AUDIO_CONFERENCE_MIXER_SOURCE_AUDIO_CONFERENCE_MIXER_IM
PL_H_ | 190 #endif // WEBRTC_MODULES_AUDIO_CONFERENCE_MIXER_SOURCE_AUDIO_CONFERENCE_MIXER_IM
PL_H_ |
| OLD | NEW |