OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 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_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_H_ |
12 #define WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_H_ | 12 #define WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_H_ |
13 | 13 |
14 #include <memory> | 14 #include <memory> |
15 | 15 |
16 #include "webrtc/modules/audio_mixer/audio_mixer_defines.h" | 16 #include "webrtc/modules/audio_mixer/audio_mixer_defines.h" |
17 #include "webrtc/modules/include/module.h" | 17 #include "webrtc/modules/include/module.h" |
18 #include "webrtc/modules/include/module_common_types.h" | 18 #include "webrtc/modules/include/module_common_types.h" |
19 | 19 |
20 namespace webrtc { | 20 namespace webrtc { |
21 | 21 |
| 22 // !!!: Inherit from public rtc::RefCountInterface (see e.g. AudioDecoderFactory
) |
| 23 // !!!: Document threading assumptions. |
| 24 // so life time of the mixer is less ambiguous when implemented externally. |
22 class AudioMixer { | 25 class AudioMixer { |
23 public: | 26 public: |
| 27 // !!!: This is an implementation detail of the particular mixer we typically
have (top 3). |
| 28 // Move to audio_mixer_impl.h |
24 static const int kMaximumAmountOfMixedAudioSources = 3; | 29 static const int kMaximumAmountOfMixedAudioSources = 3; |
| 30 // !!!: Can we remove this and use an int instead? Just giving the rate in hz, |
| 31 // rather than an enum? |
25 enum Frequency { | 32 enum Frequency { |
26 kNbInHz = 8000, | 33 kNbInHz = 8000, |
27 kWbInHz = 16000, | 34 kWbInHz = 16000, |
28 kSwbInHz = 32000, | 35 kSwbInHz = 32000, |
29 kFbInHz = 48000, | 36 kFbInHz = 48000, |
30 kDefaultFrequency = kWbInHz | 37 kDefaultFrequency = kWbInHz |
31 }; | 38 }; |
32 | 39 |
33 // Factory method. Constructor disabled. | 40 // Factory method. Constructor disabled. |
| 41 // !!!: Move out from class and rename to CreateTopThreeMixer() |
34 static std::unique_ptr<AudioMixer> Create(int id); | 42 static std::unique_ptr<AudioMixer> Create(int id); |
35 virtual ~AudioMixer() {} | 43 virtual ~AudioMixer() {} |
36 | 44 |
| 45 // !!!: Cut in two functions: AddSource(), RemoveSource(). What is mixability |
| 46 // status and what does it do with ownership of the objects? Is the return |
| 47 // value necessary? |
| 48 |
37 // Add/remove audio sources as candidates for mixing. | 49 // Add/remove audio sources as candidates for mixing. |
38 virtual int32_t SetMixabilityStatus(MixerAudioSource* audio_source, | 50 virtual int32_t SetMixabilityStatus(MixerAudioSource* audio_source, |
39 bool mixable) = 0; | 51 bool mixable) = 0; |
| 52 // !!!: Only used by unit test - remove from interface. |
40 // Returns true if an audio source is a candidate for mixing. | 53 // Returns true if an audio source is a candidate for mixing. |
41 virtual bool MixabilityStatus(const MixerAudioSource& audio_source) const = 0; | 54 virtual bool MixabilityStatus(const MixerAudioSource& audio_source) const = 0; |
42 | 55 |
| 56 |
| 57 // !!!: Name this something more sensible and add a todo that it should be |
| 58 // deprecated. It is only here to support the VoEFile API, which is legacy. |
| 59 // Also, what is the return value? |
| 60 |
43 // Inform the mixer that the audio source should always be mixed and not | 61 // Inform the mixer that the audio source should always be mixed and not |
44 // count toward the number of mixed audio sources. Note that an audio source | 62 // count toward the number of mixed audio sources. Note that an audio source |
45 // must have been added to the mixer (by calling SetMixabilityStatus()) | 63 // must have been added to the mixer (by calling SetMixabilityStatus()) |
46 // before this function can be successfully called. | 64 // before this function can be successfully called. |
47 virtual int32_t SetAnonymousMixabilityStatus(MixerAudioSource* audio_source, | 65 virtual int32_t SetAnonymousMixabilityStatus(MixerAudioSource* audio_source, |
48 bool mixable) = 0; | 66 bool mixable) = 0; |
49 | 67 |
50 // Performs mixing by asking registered audio sources for audio. The | 68 // Performs mixing by asking registered audio sources for audio. The |
51 // mixed result is placed in the provided AudioFrame. Can only be | 69 // mixed result is placed in the provided AudioFrame. Can only be |
52 // called from a single thread. The rate and channels arguments | 70 // called from a single thread. The rate and channels arguments |
53 // specify the rate and number of channels of the mix result. | 71 // specify the rate and number of channels of the mix result. |
54 virtual void Mix(int sample_rate, | 72 virtual void Mix(int sample_rate, |
55 size_t number_of_channels, | 73 size_t number_of_channels, // !!!: There's a num_channels in
AudioFrame. Either use that or get rid of AudioFrame. |
56 AudioFrame* audio_frame_for_mixing) = 0; | 74 AudioFrame* audio_frame_for_mixing) = 0; |
57 | 75 |
| 76 // !!!: Remove from public interface. |
58 // Returns true if the audio source is mixed anonymously. | 77 // Returns true if the audio source is mixed anonymously. |
59 virtual bool AnonymousMixabilityStatus( | 78 virtual bool AnonymousMixabilityStatus( |
60 const MixerAudioSource& audio_source) const = 0; | 79 const MixerAudioSource& audio_source) const = 0; |
61 | 80 |
| 81 // !!!: Can we instead return a float on [0.0, 1.0] and do any legacy adaptati
ons in the legacy code? |
62 // Output level functions for VoEVolumeControl. Return value | 82 // Output level functions for VoEVolumeControl. Return value |
63 // between 0 and 9 is returned by voe::AudioLevel. | 83 // between 0 and 9 is returned by voe::AudioLevel. |
64 virtual int GetOutputAudioLevel() = 0; | 84 virtual int GetOutputAudioLevel() = 0; |
65 | 85 |
66 // Return value between 0 and 0x7fff is returned by voe::AudioLevel. | 86 // Return value between 0 and 0x7fff is returned by voe::AudioLevel. |
67 virtual int GetOutputAudioLevelFullRange() = 0; | 87 virtual int GetOutputAudioLevelFullRange() = 0; |
68 | 88 |
| 89 // !!!: Remove below this point. |
69 protected: | 90 protected: |
70 AudioMixer() {} | 91 AudioMixer() {} |
71 | 92 |
72 private: | 93 private: |
73 RTC_DISALLOW_COPY_AND_ASSIGN(AudioMixer); | 94 RTC_DISALLOW_COPY_AND_ASSIGN(AudioMixer); |
74 }; | 95 }; |
75 } // namespace webrtc | 96 } // namespace webrtc |
76 | 97 |
77 #endif // WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_H_ | 98 #endif // WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_H_ |
OLD | NEW |