OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 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/base/criticalsection.h" | |
17 #include "webrtc/common_audio/resampler/include/push_resampler.h" | |
18 #include "webrtc/common_types.h" | |
19 #include "webrtc/modules/audio_mixer/new_audio_conference_mixer.h" | |
20 #include "webrtc/modules/audio_mixer/audio_mixer_defines.h" | 16 #include "webrtc/modules/audio_mixer/audio_mixer_defines.h" |
21 #include "webrtc/modules/utility/include/file_recorder.h" | 17 #include "webrtc/modules/include/module.h" |
22 #include "webrtc/voice_engine/level_indicator.h" | 18 #include "webrtc/modules/include/module_common_types.h" |
23 #include "webrtc/voice_engine/voice_engine_defines.h" | |
24 | 19 |
25 namespace webrtc { | 20 namespace webrtc { |
| 21 class MixerAudioSource; |
26 | 22 |
27 class AudioProcessing; | 23 class AudioMixer { |
28 class FileWrapper; | 24 public: |
29 class VoEMediaProcess; | 25 static const int kMaximumAmountOfMixedAudioSources = 3; |
| 26 enum Frequency { |
| 27 kNbInHz = 8000, |
| 28 kWbInHz = 16000, |
| 29 kSwbInHz = 32000, |
| 30 kFbInHz = 48000, |
| 31 kLowestPossible = -1, |
| 32 kDefaultFrequency = kWbInHz |
| 33 }; |
30 | 34 |
31 namespace voe { | 35 // Factory method. Constructor disabled. |
32 class Statistics; | 36 static std::unique_ptr<AudioMixer> Create(int id); |
| 37 virtual ~AudioMixer() {} |
33 | 38 |
34 // Note: this class is in the process of being rewritten and merged | 39 // Add/remove audio sources as candidates for mixing. |
35 // with AudioConferenceMixer. Expect inheritance chains to be changed, | 40 virtual int32_t SetMixabilityStatus(MixerAudioSource* audio_source, |
36 // member functions removed or renamed. | 41 bool mixable) = 0; |
37 class AudioMixer : public FileCallback { | 42 // Returns true if an audio source is a candidate for mixing. |
38 public: | 43 virtual bool MixabilityStatus(const MixerAudioSource& audio_source) const = 0; |
39 static int32_t Create(AudioMixer*& mixer, uint32_t instanceId); // NOLINT | |
40 | 44 |
41 static void Destroy(AudioMixer*& mixer); // NOLINT | 45 // Inform the mixer that the audio source should always be mixed and not |
| 46 // count toward the number of mixed audio sources. Note that an audio source |
| 47 // must have been added to the mixer (by calling SetMixabilityStatus()) |
| 48 // before this function can be successfully called. |
| 49 virtual int32_t SetAnonymousMixabilityStatus(MixerAudioSource* audio_source, |
| 50 bool mixable) = 0; |
42 | 51 |
43 int32_t SetEngineInformation(Statistics& engineStatistics); // NOLINT | 52 // Performs mixing by asking registered audio sources for audio. The |
| 53 // mixed result is placed in the provided AudioFrame. Can only be |
| 54 // called from a single thread. The rate and channels arguments |
| 55 // specify the rate and number of channels of the mix result. |
| 56 virtual void Mix(int sample_rate, |
| 57 size_t number_of_channels, |
| 58 AudioFrame* audio_frame_for_mixing) = 0; |
44 | 59 |
45 int32_t SetAudioProcessingModule(AudioProcessing* audioProcessingModule); | 60 // Returns true if the audio source is mixed anonymously. |
| 61 virtual bool AnonymousMixabilityStatus( |
| 62 const MixerAudioSource& audio_source) const = 0; |
46 | 63 |
47 // VoEExternalMedia | 64 // Output level functions for VoEVolumeControl. Return value |
48 int RegisterExternalMediaProcessing(VoEMediaProcess& // NOLINT | 65 // between 0 and 9 is returned by voe::AudioLevel. |
49 proccess_object); | 66 virtual int GetOutputAudioLevel() = 0; |
50 | 67 |
51 int DeRegisterExternalMediaProcessing(); | 68 // Return value between 0 and 0x7fff is returned by voe::AudioLevel. |
| 69 virtual int GetOutputAudioLevelFullRange() = 0; |
52 | 70 |
53 int32_t DoOperationsOnCombinedSignal(bool feed_data_to_apm); | 71 protected: |
54 | 72 AudioMixer() {} |
55 int32_t SetMixabilityStatus(MixerAudioSource& audio_source, // NOLINT | |
56 bool mixable); | |
57 | |
58 int32_t SetAnonymousMixabilityStatus( | |
59 MixerAudioSource& audio_source, // NOLINT | |
60 bool mixable); | |
61 | |
62 int GetMixedAudio(int sample_rate_hz, | |
63 size_t num_channels, | |
64 AudioFrame* audioFrame); | |
65 | |
66 // VoEVolumeControl | |
67 int GetSpeechOutputLevel(uint32_t& level); // NOLINT | |
68 | |
69 int GetSpeechOutputLevelFullRange(uint32_t& level); // NOLINT | |
70 | |
71 int SetOutputVolumePan(float left, float right); | |
72 | |
73 int GetOutputVolumePan(float& left, float& right); // NOLINT | |
74 | |
75 // VoEFile | |
76 int StartRecordingPlayout(const char* fileName, const CodecInst* codecInst); | |
77 | |
78 int StartRecordingPlayout(OutStream* stream, const CodecInst* codecInst); | |
79 int StopRecordingPlayout(); | |
80 | |
81 virtual ~AudioMixer(); | |
82 | |
83 // For file recording | |
84 void PlayNotification(int32_t id, uint32_t durationMs); | |
85 | |
86 void RecordNotification(int32_t id, uint32_t durationMs); | |
87 | |
88 void PlayFileEnded(int32_t id); | |
89 void RecordFileEnded(int32_t id); | |
90 | |
91 private: | |
92 explicit AudioMixer(uint32_t instanceId); | |
93 | |
94 // uses | |
95 Statistics* _engineStatisticsPtr; | |
96 AudioProcessing* _audioProcessingModulePtr; | |
97 | |
98 rtc::CriticalSection _callbackCritSect; | |
99 // protect the _outputFileRecorderPtr and _outputFileRecording | |
100 rtc::CriticalSection _fileCritSect; | |
101 NewAudioConferenceMixer& _mixerModule; | |
102 AudioFrame _audioFrame; | |
103 // Converts mixed audio to the audio processing rate. | |
104 PushResampler<int16_t> audioproc_resampler_; | |
105 AudioLevel _audioLevel; // measures audio level for the combined signal | |
106 int _instanceId; | |
107 VoEMediaProcess* _externalMediaCallbackPtr; | |
108 bool _externalMedia; | |
109 float _panLeft; | |
110 float _panRight; | |
111 int _mixingFrequencyHz; | |
112 std::unique_ptr<FileRecorder> _outputFileRecorderPtr; | |
113 bool _outputFileRecording; | |
114 }; | 73 }; |
115 | |
116 } // namespace voe | |
117 | |
118 } // namespace webrtc | 74 } // namespace webrtc |
119 | 75 |
120 #endif // WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_H_ | 76 #endif // WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_H_ |
OLD | NEW |