blob: 78cd4e5c79a2ddab2ea9f3bfff383a8f501ac74c [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"
aleloi5bcc00e2016-08-15 03:01:31 -070017#include "webrtc/modules/audio_mixer/new_audio_conference_mixer.h"
18#include "webrtc/modules/audio_mixer/audio_mixer_defines.h"
kwiberg9d7eb132016-08-16 04:08:30 -070019#include "webrtc/modules/utility/include/file_recorder.h"
aleloi77ad3942016-07-04 06:33:02 -070020#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
aleloi77ad3942016-07-04 06:33:02 -070051 int32_t DoOperationsOnCombinedSignal(bool feed_data_to_apm);
52
aleloi09f45102016-07-28 03:52:15 -070053 int32_t SetMixabilityStatus(MixerAudioSource& audio_source, // NOLINT
aleloi77ad3942016-07-04 06:33:02 -070054 bool mixable);
55
aleloi09f45102016-07-28 03:52:15 -070056 int32_t SetAnonymousMixabilityStatus(
57 MixerAudioSource& audio_source, // NOLINT
58 bool mixable);
aleloi77ad3942016-07-04 06:33:02 -070059
60 int GetMixedAudio(int sample_rate_hz,
61 size_t num_channels,
62 AudioFrame* audioFrame);
63
64 // VoEVolumeControl
65 int GetSpeechOutputLevel(uint32_t& level); // NOLINT
66
67 int GetSpeechOutputLevelFullRange(uint32_t& level); // NOLINT
68
69 int SetOutputVolumePan(float left, float right);
70
71 int GetOutputVolumePan(float& left, float& right); // NOLINT
72
73 // VoEFile
74 int StartRecordingPlayout(const char* fileName, const CodecInst* codecInst);
75
76 int StartRecordingPlayout(OutStream* stream, const CodecInst* codecInst);
77 int StopRecordingPlayout();
78
79 virtual ~AudioMixer();
80
aleloi77ad3942016-07-04 06:33:02 -070081 // For file recording
82 void PlayNotification(int32_t id, uint32_t durationMs);
83
84 void RecordNotification(int32_t id, uint32_t durationMs);
85
86 void PlayFileEnded(int32_t id);
87 void RecordFileEnded(int32_t id);
88
89 private:
90 explicit AudioMixer(uint32_t instanceId);
91
92 // uses
93 Statistics* _engineStatisticsPtr;
94 AudioProcessing* _audioProcessingModulePtr;
95
96 rtc::CriticalSection _callbackCritSect;
97 // protect the _outputFileRecorderPtr and _outputFileRecording
98 rtc::CriticalSection _fileCritSect;
99 NewAudioConferenceMixer& _mixerModule;
100 AudioFrame _audioFrame;
aleloi77ad3942016-07-04 06:33:02 -0700101 // Converts mixed audio to the audio processing rate.
102 PushResampler<int16_t> audioproc_resampler_;
103 AudioLevel _audioLevel; // measures audio level for the combined signal
104 int _instanceId;
105 VoEMediaProcess* _externalMediaCallbackPtr;
106 bool _externalMedia;
107 float _panLeft;
108 float _panRight;
109 int _mixingFrequencyHz;
110 FileRecorder* _outputFileRecorderPtr;
111 bool _outputFileRecording;
112};
113
114} // namespace voe
115
116} // namespace webrtc
117
118#endif // WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_H_