Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: webrtc/modules/audio_mixer/audio_mixer_impl.h

Issue 2396483002: Made MixerAudioSource a pure interface. (Closed)
Patch Set: Removing dependency patch set. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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" 21 #include "webrtc/modules/audio_mixer/audio_mixer_defines.h"
22 #include "webrtc/modules/audio_mixer/audio_source_with_mix_status.h"
22 #include "webrtc/modules/audio_processing/include/audio_processing.h" 23 #include "webrtc/modules/audio_processing/include/audio_processing.h"
23 #include "webrtc/modules/include/module_common_types.h" 24 #include "webrtc/modules/include/module_common_types.h"
24 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" 25 #include "webrtc/system_wrappers/include/critical_section_wrapper.h"
25 #include "webrtc/voice_engine/level_indicator.h" 26 #include "webrtc/voice_engine/level_indicator.h"
26 #include "webrtc/voice_engine_configurations.h" 27 #include "webrtc/voice_engine_configurations.h"
27 28
28 namespace webrtc { 29 namespace webrtc {
29 30
30 typedef std::vector<AudioFrame*> AudioFrameList; 31 typedef std::vector<AudioFrame*> AudioFrameList;
31 typedef std::vector<MixerAudioSource*> MixerAudioSourceList; 32 typedef std::vector<AudioSourceWithMixStatus> MixerAudioSourceList;
32 33
33 class AudioMixerImpl : public AudioMixer { 34 class AudioMixerImpl : public AudioMixer {
34 public: 35 public:
35 // AudioProcessing only accepts 10 ms frames. 36 // AudioProcessing only accepts 10 ms frames.
36 static const int kFrameDurationInMs = 10; 37 static const int kFrameDurationInMs = 10;
37 38
38 static std::unique_ptr<AudioMixer> Create(int id); 39 static std::unique_ptr<AudioMixerImpl> Create(int id);
39 40
40 ~AudioMixerImpl() override; 41 ~AudioMixerImpl() override;
41 42
42 // AudioMixer functions 43 // AudioMixer functions
43 int32_t SetMixabilityStatus(MixerAudioSource* audio_source, 44 int32_t SetMixabilityStatus(MixerAudioSource* audio_source,
44 bool mixable) override; 45 bool mixable) override;
45 bool MixabilityStatus(const MixerAudioSource& audio_source) const override; 46 bool MixabilityStatus(const MixerAudioSource& audio_source) const override;
46 int32_t SetAnonymousMixabilityStatus(MixerAudioSource* audio_source, 47 int32_t SetAnonymousMixabilityStatus(MixerAudioSource* audio_source,
47 bool mixable) override; 48 bool mixable) override;
48 void Mix(int sample_rate, 49 void Mix(int sample_rate,
49 size_t number_of_channels, 50 size_t number_of_channels,
50 AudioFrame* audio_frame_for_mixing) override; 51 AudioFrame* audio_frame_for_mixing) override;
51 bool AnonymousMixabilityStatus( 52 bool AnonymousMixabilityStatus(
52 const MixerAudioSource& audio_source) const override; 53 const MixerAudioSource& audio_source) const override;
53 54
55 // Returns true if the source was mixed last round. Returns
56 // false and logs an error if the source was never added to the
57 // mixer.
58 bool GetAudioSourceMixabilityStatusForTest(MixerAudioSource* audio_source);
59
54 private: 60 private:
55 AudioMixerImpl(int id, std::unique_ptr<AudioProcessing> limiter); 61 AudioMixerImpl(int id, std::unique_ptr<AudioProcessing> limiter);
56 62
57 // Set/get mix frequency 63 // Set/get mix frequency
58 int32_t SetOutputFrequency(const Frequency& frequency); 64 int32_t SetOutputFrequency(const Frequency& frequency);
59 Frequency OutputFrequency() const; 65 Frequency OutputFrequency() const;
60 66
61 // Compute what audio sources to mix from audio_source_list_. Ramp 67 // Compute what audio sources to mix from audio_source_list_. Ramp
62 // in and out. Update mixed status. Mixes up to 68 // in and out. Update mixed status. Mixes up to
63 // kMaximumAmountOfMixedAudioSources audio sources. 69 // kMaximumAmountOfMixedAudioSources audio sources.
64 AudioFrameList GetNonAnonymousAudio() const EXCLUSIVE_LOCKS_REQUIRED(crit_); 70 AudioFrameList GetNonAnonymousAudio() EXCLUSIVE_LOCKS_REQUIRED(crit_);
65 71
66 // Return the AudioFrames that should be mixed anonymously. Ramp in 72 // Return the AudioFrames that should be mixed anonymously. Ramp in
67 // and out. Update mixed status. 73 // and out. Update mixed status.
68 AudioFrameList GetAnonymousAudio() const EXCLUSIVE_LOCKS_REQUIRED(crit_); 74 AudioFrameList GetAnonymousAudio() EXCLUSIVE_LOCKS_REQUIRED(crit_);
69
70 // This function returns true if it finds the MixerAudioSource in the
71 // specified list of MixerAudioSources.
72 bool IsAudioSourceInList(const MixerAudioSource& audio_source,
73 const MixerAudioSourceList& audio_source_list) const;
74 75
75 // Add/remove the MixerAudioSource to the specified 76 // Add/remove the MixerAudioSource to the specified
76 // MixerAudioSource list. 77 // MixerAudioSource list.
77 bool AddAudioSourceToList(MixerAudioSource* audio_source, 78 bool AddAudioSourceToList(MixerAudioSource* audio_source,
78 MixerAudioSourceList* audio_source_list) const; 79 MixerAudioSourceList* audio_source_list) const;
79 bool RemoveAudioSourceFromList(MixerAudioSource* remove_audio_source, 80 bool RemoveAudioSourceFromList(MixerAudioSource* remove_audio_source,
80 MixerAudioSourceList* audio_source_list) const; 81 MixerAudioSourceList* audio_source_list) const;
81 82
82 bool LimitMixedAudio(AudioFrame* mixed_audio) const; 83 bool LimitMixedAudio(AudioFrame* mixed_audio) const;
83 84
(...skipping 30 matching lines...) Expand all
114 std::unique_ptr<AudioProcessing> limiter_ ACCESS_ON(&thread_checker_); 115 std::unique_ptr<AudioProcessing> limiter_ ACCESS_ON(&thread_checker_);
115 116
116 // Measures audio level for the combined signal. 117 // Measures audio level for the combined signal.
117 voe::AudioLevel audio_level_ ACCESS_ON(&thread_checker_); 118 voe::AudioLevel audio_level_ ACCESS_ON(&thread_checker_);
118 119
119 RTC_DISALLOW_COPY_AND_ASSIGN(AudioMixerImpl); 120 RTC_DISALLOW_COPY_AND_ASSIGN(AudioMixerImpl);
120 }; 121 };
121 } // namespace webrtc 122 } // namespace webrtc
122 123
123 #endif // WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_IMPL_H_ 124 #endif // WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_IMPL_H_
OLDNEW
« no previous file with comments | « webrtc/modules/audio_mixer/audio_mixer_defines.cc ('k') | webrtc/modules/audio_mixer/audio_mixer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698