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. |
ivoc
2016/08/18 15:47:23
This looks a bit odd, is the new mixer older than
aleloi
2016/08/19 12:06:08
The old mixer is a different file. I think we had
ivoc
2016/08/19 12:37:37
Acknowledged.
| |
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> | |
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" | 14 #include "webrtc/modules/audio_mixer/audio_mixer_defines.h" |
21 #include "webrtc/modules/utility/include/file_recorder.h" | 15 #include "webrtc/modules/include/module.h" |
22 #include "webrtc/voice_engine/level_indicator.h" | 16 #include "webrtc/modules/include/module_common_types.h" |
23 #include "webrtc/voice_engine/voice_engine_defines.h" | |
24 | 17 |
25 namespace webrtc { | 18 namespace webrtc { |
19 class MixerAudioSource; | |
26 | 20 |
27 class AudioProcessing; | 21 class AudioMixer { |
28 class FileWrapper; | 22 public: |
29 class VoEMediaProcess; | 23 enum { kMaximumAmountOfMixedAudioSources = 3 }; |
ivoc
2016/08/18 15:47:23
I think this should be a static const int.
aleloi
2016/08/19 12:06:08
There are apparently some differences between anon
ivoc
2016/08/19 12:37:37
Interesting, but I agree that I prefer static cons
| |
24 enum Frequency { | |
25 kNbInHz = 8000, | |
26 kWbInHz = 16000, | |
27 kSwbInHz = 32000, | |
28 kFbInHz = 48000, | |
29 kLowestPossible = -1, | |
30 kDefaultFrequency = kWbInHz | |
31 }; | |
30 | 32 |
31 namespace voe { | 33 // Factory method. Constructor disabled. |
32 class Statistics; | 34 static AudioMixer* Create(int id); |
ivoc
2016/08/18 15:47:23
You can consider to change this to return a unique
aleloi
2016/08/19 12:06:09
That makes sense! Done.
| |
35 virtual ~AudioMixer() {} | |
33 | 36 |
34 // Note: this class is in the process of being rewritten and merged | 37 // Add/remove audio sources as candidates for mixing. |
35 // with AudioConferenceMixer. Expect inheritance chains to be changed, | 38 virtual int32_t SetMixabilityStatus(MixerAudioSource* audio_source, |
36 // member functions removed or renamed. | 39 bool mixable) = 0; |
37 class AudioMixer : public FileCallback { | 40 // Returns true if an audio source is a candidate for mixing. |
38 public: | 41 virtual bool MixabilityStatus(const MixerAudioSource& audio_source) const = 0; |
39 static int32_t Create(AudioMixer*& mixer, uint32_t instanceId); // NOLINT | |
40 | 42 |
41 static void Destroy(AudioMixer*& mixer); // NOLINT | 43 // 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 | |
45 // must have been added to the mixer (by calling SetMixabilityStatus()) | |
46 // before this function can be successfully called. | |
47 virtual int32_t SetAnonymousMixabilityStatus(MixerAudioSource* audio_source, | |
48 bool mixable) = 0; | |
42 | 49 |
43 int32_t SetEngineInformation(Statistics& engineStatistics); // NOLINT | 50 // Performs mixing by asking registered audio sources for audio. The |
51 // mixed result is placed in the provided AudioFrame. Can only be | |
52 // called from a single thread. The rate and channels arguments | |
53 // specify the rate and number of channels of the mix result. | |
54 virtual void Mix(int sample_rate, | |
55 size_t number_of_channels, | |
56 AudioFrame* audio_frame_for_mixing) = 0; | |
44 | 57 |
45 int32_t SetAudioProcessingModule(AudioProcessing* audioProcessingModule); | 58 // Returns true if the audio source is mixed anonymously. |
59 virtual bool AnonymousMixabilityStatus( | |
60 const MixerAudioSource& audio_source) const = 0; | |
46 | 61 |
47 // VoEExternalMedia | 62 // Output level functions for VoEVolumeControl. Return value |
48 int RegisterExternalMediaProcessing(VoEMediaProcess& // NOLINT | 63 // between 0 and 9 is returned by voe::AudioLevel. |
49 proccess_object); | 64 virtual uint32_t GetOutputAudioLevel() = 0; |
50 | 65 |
51 int DeRegisterExternalMediaProcessing(); | 66 // Return value between 0 and 0x7fff is returned by voe::AudioLevel. |
67 virtual uint32_t GetOutputAudioLevelFullRange() = 0; | |
52 | 68 |
53 int32_t DoOperationsOnCombinedSignal(bool feed_data_to_apm); | 69 protected: |
54 | 70 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 }; | 71 }; |
115 | |
116 } // namespace voe | |
117 | |
118 } // namespace webrtc | 72 } // namespace webrtc |
119 | 73 |
120 #endif // WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_H_ | 74 #endif // WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_H_ |
OLD | NEW |