blob: c50a2cfa708dbf394b6be3b90c284573c41ad6c7 [file] [log] [blame]
aleloi77ad3942016-07-04 06:33:02 -07001/*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#ifndef WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_H_
12#define WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_H_
13
14#include "webrtc/base/criticalsection.h"
15#include "webrtc/common_audio/resampler/include/push_resampler.h"
16#include "webrtc/common_types.h"
17#include "webrtc/modules/audio_mixer/include/new_audio_conference_mixer.h"
18#include "webrtc/modules/audio_mixer/include/audio_mixer_defines.h"
19#include "webrtc/modules/utility/include/file_recorder.h"
20#include "webrtc/voice_engine/level_indicator.h"
21#include "webrtc/voice_engine/voice_engine_defines.h"
22
23namespace webrtc {
24
25class AudioProcessing;
26class FileWrapper;
27class VoEMediaProcess;
28
29namespace voe {
30class Statistics;
31
32// Note: this class is in the process of being rewritten and merged
33// with AudioConferenceMixer. Expect inheritance chains to be changed,
34// member functions removed or renamed.
aleloi09f45102016-07-28 03:52:15 -070035class AudioMixer : public FileCallback {
aleloi77ad3942016-07-04 06:33:02 -070036 public:
37 static int32_t Create(AudioMixer*& mixer, uint32_t instanceId); // NOLINT
38
39 static void Destroy(AudioMixer*& mixer); // NOLINT
40
41 int32_t SetEngineInformation(Statistics& engineStatistics); // NOLINT
42
43 int32_t SetAudioProcessingModule(AudioProcessing* audioProcessingModule);
44
45 // VoEExternalMedia
46 int RegisterExternalMediaProcessing(VoEMediaProcess& // NOLINT
47 proccess_object);
48
49 int DeRegisterExternalMediaProcessing();
50
51 int32_t MixActiveChannels();
52
53 int32_t DoOperationsOnCombinedSignal(bool feed_data_to_apm);
54
aleloi09f45102016-07-28 03:52:15 -070055 int32_t SetMixabilityStatus(MixerAudioSource& audio_source, // NOLINT
aleloi77ad3942016-07-04 06:33:02 -070056 bool mixable);
57
aleloi09f45102016-07-28 03:52:15 -070058 int32_t SetAnonymousMixabilityStatus(
59 MixerAudioSource& audio_source, // NOLINT
60 bool mixable);
aleloi77ad3942016-07-04 06:33:02 -070061
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
aleloi77ad3942016-07-04 06:33:02 -070083 // 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 device output rate.
104 PushResampler<int16_t> resampler_;
105 // Converts mixed audio to the audio processing rate.
106 PushResampler<int16_t> audioproc_resampler_;
107 AudioLevel _audioLevel; // measures audio level for the combined signal
108 int _instanceId;
109 VoEMediaProcess* _externalMediaCallbackPtr;
110 bool _externalMedia;
111 float _panLeft;
112 float _panRight;
113 int _mixingFrequencyHz;
114 FileRecorder* _outputFileRecorderPtr;
115 bool _outputFileRecording;
116};
117
118} // namespace voe
119
120} // namespace webrtc
121
122#endif // WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_H_