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