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_MIXER_AUDIO_MIXER_IMPL_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_IMPL_H_ |
12 #define WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_IMPL_H_ | 12 #define WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_IMPL_H_ |
13 | 13 |
14 #include <map> | 14 #include <map> |
15 #include <memory> | 15 #include <memory> |
16 #include <vector> | 16 #include <vector> |
17 | 17 |
| 18 #include "webrtc/base/thread_annotations.h" |
18 #include "webrtc/base/thread_checker.h" | 19 #include "webrtc/base/thread_checker.h" |
19 #include "webrtc/engine_configurations.h" | 20 #include "webrtc/engine_configurations.h" |
20 #include "webrtc/modules/audio_mixer/audio_mixer.h" | 21 #include "webrtc/modules/audio_mixer/audio_mixer.h" |
| 22 #include "webrtc/modules/audio_mixer/audio_mixer_defines.h" |
| 23 #include "webrtc/modules/audio_processing/include/audio_processing.h" |
21 #include "webrtc/modules/include/module_common_types.h" | 24 #include "webrtc/modules/include/module_common_types.h" |
| 25 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" |
22 #include "webrtc/voice_engine/level_indicator.h" | 26 #include "webrtc/voice_engine/level_indicator.h" |
23 | 27 |
24 namespace webrtc { | 28 namespace webrtc { |
25 class AudioProcessing; | |
26 class CriticalSectionWrapper; | |
27 | 29 |
28 typedef std::vector<AudioFrame*> AudioFrameList; | 30 typedef std::vector<AudioFrame*> AudioFrameList; |
29 typedef std::vector<MixerAudioSource*> MixerAudioSourceList; | 31 typedef std::vector<MixerAudioSource*> MixerAudioSourceList; |
30 | 32 |
31 // Cheshire cat implementation of MixerAudioSource's non virtual functions. | |
32 class NewMixHistory { | |
33 public: | |
34 NewMixHistory(); | |
35 ~NewMixHistory(); | |
36 | |
37 // Returns true if the audio source is being mixed. | |
38 bool IsMixed() const; | |
39 | |
40 // Returns true if the audio source was mixed previous mix | |
41 // iteration. | |
42 bool WasMixed() const; | |
43 | |
44 // Updates the mixed status. | |
45 int32_t SetIsMixed(bool mixed); | |
46 | |
47 void ResetMixedStatus(); | |
48 | |
49 private: | |
50 bool is_mixed_; | |
51 }; | |
52 | |
53 class AudioMixerImpl : public AudioMixer { | 33 class AudioMixerImpl : public AudioMixer { |
54 public: | 34 public: |
55 // AudioProcessing only accepts 10 ms frames. | 35 // AudioProcessing only accepts 10 ms frames. |
56 static const int kFrameDurationInMs = 10; | 36 static const int kFrameDurationInMs = 10; |
57 | 37 |
58 static std::unique_ptr<AudioMixer> Create(int id); | 38 static std::unique_ptr<AudioMixer> Create(int id); |
59 | 39 |
60 ~AudioMixerImpl() override; | 40 ~AudioMixerImpl() override; |
61 | 41 |
62 // AudioMixer functions | 42 // AudioMixer functions |
(...skipping 29 matching lines...) Expand all Loading... |
92 bool IsAudioSourceInList(const MixerAudioSource& audio_source, | 72 bool IsAudioSourceInList(const MixerAudioSource& audio_source, |
93 const MixerAudioSourceList& audio_source_list) const; | 73 const MixerAudioSourceList& audio_source_list) const; |
94 | 74 |
95 // Add/remove the MixerAudioSource to the specified | 75 // Add/remove the MixerAudioSource to the specified |
96 // MixerAudioSource list. | 76 // MixerAudioSource list. |
97 bool AddAudioSourceToList(MixerAudioSource* audio_source, | 77 bool AddAudioSourceToList(MixerAudioSource* audio_source, |
98 MixerAudioSourceList* audio_source_list) const; | 78 MixerAudioSourceList* audio_source_list) const; |
99 bool RemoveAudioSourceFromList(MixerAudioSource* remove_audio_source, | 79 bool RemoveAudioSourceFromList(MixerAudioSource* remove_audio_source, |
100 MixerAudioSourceList* audio_source_list) const; | 80 MixerAudioSourceList* audio_source_list) const; |
101 | 81 |
102 // Mix the AudioFrames stored in audioFrameList into mixed_audio. | |
103 static int32_t MixFromList(AudioFrame* mixed_audio, | |
104 const AudioFrameList& audio_frame_list, | |
105 int32_t id, | |
106 bool use_limiter); | |
107 | |
108 bool LimitMixedAudio(AudioFrame* mixed_audio) const; | 82 bool LimitMixedAudio(AudioFrame* mixed_audio) const; |
109 | 83 |
110 // Output level functions for VoEVolumeControl. | 84 // Output level functions for VoEVolumeControl. |
111 int GetOutputAudioLevel() override; | 85 int GetOutputAudioLevel() override; |
112 | 86 |
113 int GetOutputAudioLevelFullRange() override; | 87 int GetOutputAudioLevelFullRange() override; |
114 | 88 |
115 rtc::CriticalSection crit_; | 89 rtc::CriticalSection crit_; |
116 | 90 |
117 const int32_t id_; | 91 const int32_t id_; |
(...skipping 22 matching lines...) Expand all Loading... |
140 std::unique_ptr<AudioProcessing> limiter_ ACCESS_ON(&thread_checker_); | 114 std::unique_ptr<AudioProcessing> limiter_ ACCESS_ON(&thread_checker_); |
141 | 115 |
142 // Measures audio level for the combined signal. | 116 // Measures audio level for the combined signal. |
143 voe::AudioLevel audio_level_ ACCESS_ON(&thread_checker_); | 117 voe::AudioLevel audio_level_ ACCESS_ON(&thread_checker_); |
144 | 118 |
145 RTC_DISALLOW_COPY_AND_ASSIGN(AudioMixerImpl); | 119 RTC_DISALLOW_COPY_AND_ASSIGN(AudioMixerImpl); |
146 }; | 120 }; |
147 } // namespace webrtc | 121 } // namespace webrtc |
148 | 122 |
149 #endif // WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_IMPL_H_ | 123 #endif // WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_IMPL_H_ |
OLD | NEW |