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

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

Issue 2396803004: Moved MixerAudioSource and removed audio_mixer_defines.h. (Closed)
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) 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"
17 #include "webrtc/modules/include/module.h" 16 #include "webrtc/modules/include/module.h"
18 #include "webrtc/modules/include/module_common_types.h" 17 #include "webrtc/modules/include/module_common_types.h"
19 18
20 namespace webrtc { 19 namespace webrtc {
21 20
22 class AudioMixer { 21 class AudioMixer {
23 public: 22 public:
24 static const int kMaximumAmountOfMixedAudioSources = 3; 23 static const int kMaximumAmountOfMixedAudioSources = 3;
25 enum Frequency { 24 enum Frequency {
26 kNbInHz = 8000, 25 kNbInHz = 8000,
27 kWbInHz = 16000, 26 kWbInHz = 16000,
28 kSwbInHz = 32000, 27 kSwbInHz = 32000,
29 kFbInHz = 48000, 28 kFbInHz = 48000,
30 kDefaultFrequency = kWbInHz 29 kDefaultFrequency = kWbInHz
31 }; 30 };
32 31
32 // A callback class that all mixer participants must inherit from/implement.
33 class Source {
34 public:
35 enum class AudioFrameInfo {
36 kNormal, // The samples in audio_frame are valid and should be used.
37 kMuted, // The samples in audio_frame should not be used, but should be
38 // implicitly interpreted as zero. Other fields in audio_frame
39 // may be read and should contain meaningful values.
40 kError // audio_frame will not be used.
41 };
42
43 struct AudioFrameWithMuted {
44 AudioFrame* audio_frame;
45 AudioFrameInfo audio_frame_info;
46 };
47
48 // The implementation of GetAudioFrameWithMuted should update
49 // audio_frame with new audio every time it's called. Implementing
50 // classes are allowed to return the same AudioFrame pointer on
51 // different calls. The pointer must stay valid until the next
52 // mixing call or until this audio source is disconnected from the
53 // mixer.
54 virtual AudioFrameWithMuted GetAudioFrameWithMuted(int32_t id,
55 int sample_rate_hz) = 0;
56
57 protected:
58 virtual ~Source() {}
59 };
60
33 // Factory method. Constructor disabled. 61 // Factory method. Constructor disabled.
34 static std::unique_ptr<AudioMixer> Create(int id); 62 static std::unique_ptr<AudioMixer> Create(int id);
35 virtual ~AudioMixer() {} 63 virtual ~AudioMixer() {}
36 64
37 // Add/remove audio sources as candidates for mixing. 65 // Add/remove audio sources as candidates for mixing.
38 virtual int32_t SetMixabilityStatus(MixerAudioSource* audio_source, 66 virtual int32_t SetMixabilityStatus(Source* audio_source, bool mixable) = 0;
39 bool mixable) = 0;
40 // Returns true if an audio source is a candidate for mixing. 67 // Returns true if an audio source is a candidate for mixing.
41 virtual bool MixabilityStatus(const MixerAudioSource& audio_source) const = 0; 68 virtual bool MixabilityStatus(const Source& audio_source) const = 0;
42 69
43 // Inform the mixer that the audio source should always be mixed and not 70 // 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 71 // count toward the number of mixed audio sources. Note that an audio source
45 // must have been added to the mixer (by calling SetMixabilityStatus()) 72 // must have been added to the mixer (by calling SetMixabilityStatus())
46 // before this function can be successfully called. 73 // before this function can be successfully called.
47 virtual int32_t SetAnonymousMixabilityStatus(MixerAudioSource* audio_source, 74 virtual int32_t SetAnonymousMixabilityStatus(Source* audio_source,
48 bool mixable) = 0; 75 bool mixable) = 0;
49 76
50 // Performs mixing by asking registered audio sources for audio. The 77 // Performs mixing by asking registered audio sources for audio. The
51 // mixed result is placed in the provided AudioFrame. Can only be 78 // mixed result is placed in the provided AudioFrame. Can only be
52 // called from a single thread. The rate and channels arguments 79 // called from a single thread. The rate and channels arguments
53 // specify the rate and number of channels of the mix result. 80 // specify the rate and number of channels of the mix result.
54 virtual void Mix(int sample_rate, 81 virtual void Mix(int sample_rate,
55 size_t number_of_channels, 82 size_t number_of_channels,
56 AudioFrame* audio_frame_for_mixing) = 0; 83 AudioFrame* audio_frame_for_mixing) = 0;
57 84
58 // Returns true if the audio source is mixed anonymously. 85 // Returns true if the audio source is mixed anonymously.
59 virtual bool AnonymousMixabilityStatus( 86 virtual bool AnonymousMixabilityStatus(const Source& audio_source) const = 0;
60 const MixerAudioSource& audio_source) const = 0;
61 87
62 // Output level functions for VoEVolumeControl. Return value 88 // Output level functions for VoEVolumeControl. Return value
63 // between 0 and 9 is returned by voe::AudioLevel. 89 // between 0 and 9 is returned by voe::AudioLevel.
64 virtual int GetOutputAudioLevel() = 0; 90 virtual int GetOutputAudioLevel() = 0;
65 91
66 // Return value between 0 and 0x7fff is returned by voe::AudioLevel. 92 // Return value between 0 and 0x7fff is returned by voe::AudioLevel.
67 virtual int GetOutputAudioLevelFullRange() = 0; 93 virtual int GetOutputAudioLevelFullRange() = 0;
68 94
69 protected: 95 protected:
70 AudioMixer() {} 96 AudioMixer() {}
71 97
72 private: 98 private:
73 RTC_DISALLOW_COPY_AND_ASSIGN(AudioMixer); 99 RTC_DISALLOW_COPY_AND_ASSIGN(AudioMixer);
74 }; 100 };
75 } // namespace webrtc 101 } // namespace webrtc
76 102
77 #endif // WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_H_ 103 #endif // WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698