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_annotations.h" |
19 #include "webrtc/base/thread_checker.h" | 19 #include "webrtc/base/thread_checker.h" |
20 #include "webrtc/modules/audio_mixer/audio_mixer.h" | 20 #include "webrtc/modules/audio_mixer/audio_mixer.h" |
21 #include "webrtc/modules/audio_mixer/audio_mixer_defines.h" | |
22 #include "webrtc/modules/audio_mixer/audio_source_with_mix_status.h" | |
23 #include "webrtc/modules/audio_processing/include/audio_processing.h" | 21 #include "webrtc/modules/audio_processing/include/audio_processing.h" |
24 #include "webrtc/modules/include/module_common_types.h" | 22 #include "webrtc/modules/include/module_common_types.h" |
25 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" | 23 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" |
26 #include "webrtc/voice_engine/level_indicator.h" | 24 #include "webrtc/voice_engine/level_indicator.h" |
27 #include "webrtc/voice_engine_configurations.h" | 25 #include "webrtc/voice_engine_configurations.h" |
28 | 26 |
29 namespace webrtc { | 27 namespace webrtc { |
30 | 28 |
31 typedef std::vector<AudioFrame*> AudioFrameList; | 29 typedef std::vector<AudioFrame*> AudioFrameList; |
32 typedef std::vector<AudioSourceWithMixStatus> MixerAudioSourceList; | |
33 | 30 |
34 class AudioMixerImpl : public AudioMixer { | 31 class AudioMixerImpl : public AudioMixer { |
35 public: | 32 public: |
33 struct SourceStatus { | |
34 SourceStatus(Source* audio_source, bool is_mixed, float gain) | |
35 : audio_source_(audio_source), is_mixed_(is_mixed), gain_(gain) {} | |
36 Source* audio_source_ = nullptr; | |
37 bool is_mixed_ = false; | |
38 float gain_ = 0; | |
39 }; | |
40 | |
41 typedef std::vector<SourceStatus> MixerAudioSourceList; | |
aleloi
2016/10/07 12:59:21
Question: could we use a type alias instead of typ
| |
42 | |
36 // AudioProcessing only accepts 10 ms frames. | 43 // AudioProcessing only accepts 10 ms frames. |
37 static const int kFrameDurationInMs = 10; | 44 static const int kFrameDurationInMs = 10; |
38 | 45 |
39 static std::unique_ptr<AudioMixerImpl> Create(int id); | 46 static std::unique_ptr<AudioMixerImpl> Create(int id); |
40 | 47 |
41 ~AudioMixerImpl() override; | 48 ~AudioMixerImpl() override; |
42 | 49 |
43 // AudioMixer functions | 50 // AudioMixer functions |
44 int32_t SetMixabilityStatus(MixerAudioSource* audio_source, | 51 int32_t SetMixabilityStatus(Source* audio_source, bool mixable) override; |
45 bool mixable) override; | 52 bool MixabilityStatus(const Source& audio_source) const override; |
46 bool MixabilityStatus(const MixerAudioSource& audio_source) const override; | 53 int32_t SetAnonymousMixabilityStatus(Source* audio_source, |
47 int32_t SetAnonymousMixabilityStatus(MixerAudioSource* audio_source, | |
48 bool mixable) override; | 54 bool mixable) override; |
49 void Mix(int sample_rate, | 55 void Mix(int sample_rate, |
50 size_t number_of_channels, | 56 size_t number_of_channels, |
51 AudioFrame* audio_frame_for_mixing) override; | 57 AudioFrame* audio_frame_for_mixing) override; |
52 bool AnonymousMixabilityStatus( | 58 bool AnonymousMixabilityStatus(const Source& audio_source) const override; |
53 const MixerAudioSource& audio_source) const override; | |
54 | 59 |
55 // Returns true if the source was mixed last round. Returns | 60 // Returns true if the source was mixed last round. Returns |
56 // false and logs an error if the source was never added to the | 61 // false and logs an error if the source was never added to the |
57 // mixer. | 62 // mixer. |
58 bool GetAudioSourceMixabilityStatusForTest(MixerAudioSource* audio_source); | 63 bool GetAudioSourceMixabilityStatusForTest(Source* audio_source); |
59 | 64 |
60 private: | 65 private: |
61 AudioMixerImpl(int id, std::unique_ptr<AudioProcessing> limiter); | 66 AudioMixerImpl(int id, std::unique_ptr<AudioProcessing> limiter); |
62 | 67 |
63 // Set/get mix frequency | 68 // Set/get mix frequency |
64 int32_t SetOutputFrequency(const Frequency& frequency); | 69 int32_t SetOutputFrequency(const Frequency& frequency); |
65 Frequency OutputFrequency() const; | 70 Frequency OutputFrequency() const; |
66 | 71 |
67 // Compute what audio sources to mix from audio_source_list_. Ramp | 72 // Compute what audio sources to mix from audio_source_list_. Ramp |
68 // in and out. Update mixed status. Mixes up to | 73 // in and out. Update mixed status. Mixes up to |
69 // kMaximumAmountOfMixedAudioSources audio sources. | 74 // kMaximumAmountOfMixedAudioSources audio sources. |
70 AudioFrameList GetNonAnonymousAudio() EXCLUSIVE_LOCKS_REQUIRED(crit_); | 75 AudioFrameList GetNonAnonymousAudio() EXCLUSIVE_LOCKS_REQUIRED(crit_); |
71 | 76 |
72 // Return the AudioFrames that should be mixed anonymously. Ramp in | 77 // Return the AudioFrames that should be mixed anonymously. Ramp in |
73 // and out. Update mixed status. | 78 // and out. Update mixed status. |
74 AudioFrameList GetAnonymousAudio() EXCLUSIVE_LOCKS_REQUIRED(crit_); | 79 AudioFrameList GetAnonymousAudio() EXCLUSIVE_LOCKS_REQUIRED(crit_); |
75 | 80 |
76 // Add/remove the MixerAudioSource to the specified | 81 // Add/remove the MixerAudioSource to the specified |
77 // MixerAudioSource list. | 82 // MixerAudioSource list. |
78 bool AddAudioSourceToList(MixerAudioSource* audio_source, | 83 bool AddAudioSourceToList(Source* audio_source, |
79 MixerAudioSourceList* audio_source_list) const; | 84 MixerAudioSourceList* audio_source_list) const; |
80 bool RemoveAudioSourceFromList(MixerAudioSource* remove_audio_source, | 85 bool RemoveAudioSourceFromList(Source* remove_audio_source, |
81 MixerAudioSourceList* audio_source_list) const; | 86 MixerAudioSourceList* audio_source_list) const; |
82 | 87 |
83 bool LimitMixedAudio(AudioFrame* mixed_audio) const; | 88 bool LimitMixedAudio(AudioFrame* mixed_audio) const; |
84 | 89 |
85 // Output level functions for VoEVolumeControl. | 90 // Output level functions for VoEVolumeControl. |
86 int GetOutputAudioLevel() override; | 91 int GetOutputAudioLevel() override; |
87 | 92 |
88 int GetOutputAudioLevelFullRange() override; | 93 int GetOutputAudioLevelFullRange() override; |
89 | 94 |
90 rtc::CriticalSection crit_; | 95 rtc::CriticalSection crit_; |
(...skipping 24 matching lines...) Expand all Loading... | |
115 std::unique_ptr<AudioProcessing> limiter_ ACCESS_ON(&thread_checker_); | 120 std::unique_ptr<AudioProcessing> limiter_ ACCESS_ON(&thread_checker_); |
116 | 121 |
117 // Measures audio level for the combined signal. | 122 // Measures audio level for the combined signal. |
118 voe::AudioLevel audio_level_ ACCESS_ON(&thread_checker_); | 123 voe::AudioLevel audio_level_ ACCESS_ON(&thread_checker_); |
119 | 124 |
120 RTC_DISALLOW_COPY_AND_ASSIGN(AudioMixerImpl); | 125 RTC_DISALLOW_COPY_AND_ASSIGN(AudioMixerImpl); |
121 }; | 126 }; |
122 } // namespace webrtc | 127 } // namespace webrtc |
123 | 128 |
124 #endif // WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_IMPL_H_ | 129 #endif // WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_IMPL_H_ |
OLD | NEW |