blob: 3287860f7f34b46751a2f15797afcc2b62f3b3f3 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
andrew@webrtc.org4ecea3e2012-06-27 03:25:31 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
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
andrew@webrtc.org4ecea3e2012-06-27 03:25:31 +000011#ifndef WEBRTC_VOICE_ENGINE_OUTPUT_MIXER_H_
12#define WEBRTC_VOICE_ENGINE_OUTPUT_MIXER_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
tommi31fc21f2016-01-21 10:37:37 -080014#include "webrtc/base/criticalsection.h"
andrew@webrtc.org50b2efe2013-04-29 17:27:29 +000015#include "webrtc/common_audio/resampler/include/push_resampler.h"
16#include "webrtc/common_types.h"
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010017#include "webrtc/modules/audio_conference_mixer/include/audio_conference_mixer.h"
18#include "webrtc/modules/audio_conference_mixer/include/audio_conference_mixer_defines.h"
19#include "webrtc/modules/utility/include/file_recorder.h"
andrew@webrtc.org50b2efe2013-04-29 17:27:29 +000020#include "webrtc/voice_engine/dtmf_inband.h"
21#include "webrtc/voice_engine/level_indicator.h"
22#include "webrtc/voice_engine/voice_engine_defines.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000023
24namespace webrtc {
25
26class AudioProcessing;
niklase@google.com470e71d2011-07-07 08:21:25 +000027class FileWrapper;
28class VoEMediaProcess;
29
30namespace voe {
31
32class Statistics;
33
34class OutputMixer : public AudioMixerOutputReceiver,
niklase@google.com470e71d2011-07-07 08:21:25 +000035 public FileCallback
36{
37public:
pbos@webrtc.org92135212013-05-14 08:31:39 +000038 static int32_t Create(OutputMixer*& mixer, uint32_t instanceId);
niklase@google.com470e71d2011-07-07 08:21:25 +000039
40 static void Destroy(OutputMixer*& mixer);
41
pbos@webrtc.org6141e132013-04-09 10:09:10 +000042 int32_t SetEngineInformation(Statistics& engineStatistics);
niklase@google.com470e71d2011-07-07 08:21:25 +000043
pbos@webrtc.org6141e132013-04-09 10:09:10 +000044 int32_t SetAudioProcessingModule(
niklase@google.com470e71d2011-07-07 08:21:25 +000045 AudioProcessing* audioProcessingModule);
46
47 // VoEExternalMedia
48 int RegisterExternalMediaProcessing(
49 VoEMediaProcess& proccess_object);
50
51 int DeRegisterExternalMediaProcessing();
52
53 // VoEDtmf
pbos@webrtc.org6141e132013-04-09 10:09:10 +000054 int PlayDtmfTone(uint8_t eventCode, int lengthMs, int attenuationDb);
niklase@google.com470e71d2011-07-07 08:21:25 +000055
pbos@webrtc.org6141e132013-04-09 10:09:10 +000056 int32_t MixActiveChannels();
niklase@google.com470e71d2011-07-07 08:21:25 +000057
xians@webrtc.org56925312014-04-14 10:50:37 +000058 int32_t DoOperationsOnCombinedSignal(bool feed_data_to_apm);
niklase@google.com470e71d2011-07-07 08:21:25 +000059
pbos@webrtc.org6141e132013-04-09 10:09:10 +000060 int32_t SetMixabilityStatus(MixerParticipant& participant,
pbos@webrtc.org92135212013-05-14 08:31:39 +000061 bool mixable);
niklase@google.com470e71d2011-07-07 08:21:25 +000062
pbos@webrtc.org6141e132013-04-09 10:09:10 +000063 int32_t SetAnonymousMixabilityStatus(MixerParticipant& participant,
pbos@webrtc.org92135212013-05-14 08:31:39 +000064 bool mixable);
henrike@webrtc.org066f9e52011-10-28 23:15:47 +000065
Peter Kasting69558702016-01-12 16:26:35 -080066 int GetMixedAudio(int sample_rate_hz, size_t num_channels,
andrew@webrtc.org4ecea3e2012-06-27 03:25:31 +000067 AudioFrame* audioFrame);
niklase@google.com470e71d2011-07-07 08:21:25 +000068
69 // VoEVolumeControl
pbos@webrtc.org6141e132013-04-09 10:09:10 +000070 int GetSpeechOutputLevel(uint32_t& level);
niklase@google.com470e71d2011-07-07 08:21:25 +000071
pbos@webrtc.org6141e132013-04-09 10:09:10 +000072 int GetSpeechOutputLevelFullRange(uint32_t& level);
niklase@google.com470e71d2011-07-07 08:21:25 +000073
74 int SetOutputVolumePan(float left, float right);
75
76 int GetOutputVolumePan(float& left, float& right);
77
78 // VoEFile
79 int StartRecordingPlayout(const char* fileName,
80 const CodecInst* codecInst);
81
82 int StartRecordingPlayout(OutStream* stream,
83 const CodecInst* codecInst);
84 int StopRecordingPlayout();
85
86 virtual ~OutputMixer();
87
andrew@webrtc.org4ecea3e2012-06-27 03:25:31 +000088 // from AudioMixerOutputReceiver
niklase@google.com470e71d2011-07-07 08:21:25 +000089 virtual void NewMixedAudio(
pbos@webrtc.org92135212013-05-14 08:31:39 +000090 int32_t id,
niklase@google.com470e71d2011-07-07 08:21:25 +000091 const AudioFrame& generalAudioFrame,
92 const AudioFrame** uniqueAudioFrames,
pbos@webrtc.org92135212013-05-14 08:31:39 +000093 uint32_t size);
niklase@google.com470e71d2011-07-07 08:21:25 +000094
andrew@webrtc.org4ecea3e2012-06-27 03:25:31 +000095 // For file recording
pbos@webrtc.org92135212013-05-14 08:31:39 +000096 void PlayNotification(int32_t id, uint32_t durationMs);
niklase@google.com470e71d2011-07-07 08:21:25 +000097
pbos@webrtc.org92135212013-05-14 08:31:39 +000098 void RecordNotification(int32_t id, uint32_t durationMs);
niklase@google.com470e71d2011-07-07 08:21:25 +000099
pbos@webrtc.org92135212013-05-14 08:31:39 +0000100 void PlayFileEnded(int32_t id);
101 void RecordFileEnded(int32_t id);
niklase@google.com470e71d2011-07-07 08:21:25 +0000102
103private:
pbos@webrtc.org92135212013-05-14 08:31:39 +0000104 OutputMixer(uint32_t instanceId);
niklase@google.com470e71d2011-07-07 08:21:25 +0000105 int InsertInbandDtmfTone();
106
andrew@webrtc.org4ecea3e2012-06-27 03:25:31 +0000107 // uses
niklase@google.com470e71d2011-07-07 08:21:25 +0000108 Statistics* _engineStatisticsPtr;
109 AudioProcessing* _audioProcessingModulePtr;
110
tommi31fc21f2016-01-21 10:37:37 -0800111 rtc::CriticalSection _callbackCritSect;
niklase@google.com470e71d2011-07-07 08:21:25 +0000112 // protect the _outputFileRecorderPtr and _outputFileRecording
tommi31fc21f2016-01-21 10:37:37 -0800113 rtc::CriticalSection _fileCritSect;
niklase@google.com470e71d2011-07-07 08:21:25 +0000114 AudioConferenceMixer& _mixerModule;
115 AudioFrame _audioFrame;
andrew@webrtc.orgf5a33f12014-04-19 00:32:07 +0000116 // Converts mixed audio to the audio device output rate.
117 PushResampler<int16_t> resampler_;
118 // Converts mixed audio to the audio processing rate.
119 PushResampler<int16_t> audioproc_resampler_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000120 AudioLevel _audioLevel; // measures audio level for the combined signal
121 DtmfInband _dtmfGenerator;
xians@google.com0b0665a2011-08-08 08:18:44 +0000122 int _instanceId;
niklase@google.com470e71d2011-07-07 08:21:25 +0000123 VoEMediaProcess* _externalMediaCallbackPtr;
124 bool _externalMedia;
125 float _panLeft;
126 float _panRight;
xians@google.com0b0665a2011-08-08 08:18:44 +0000127 int _mixingFrequencyHz;
niklase@google.com470e71d2011-07-07 08:21:25 +0000128 FileRecorder* _outputFileRecorderPtr;
129 bool _outputFileRecording;
130};
131
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +0000132} // namespace voe
niklase@google.com470e71d2011-07-07 08:21:25 +0000133
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +0000134} // namespace werbtc
niklase@google.com470e71d2011-07-07 08:21:25 +0000135
andrew@webrtc.org4ecea3e2012-06-27 03:25:31 +0000136#endif // VOICE_ENGINE_OUTPUT_MIXER_H_