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