blob: 859ce64bdd86282158b427ffa1aac20b1ae71dd9 [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
andrew@webrtc.org50b2efe2013-04-29 17:27:29 +000014#include "webrtc/common_audio/resampler/include/push_resampler.h"
15#include "webrtc/common_types.h"
16#include "webrtc/modules/audio_conference_mixer/interface/audio_conference_mixer.h"
17#include "webrtc/modules/audio_conference_mixer/interface/audio_conference_mixer_defines.h"
18#include "webrtc/modules/utility/interface/file_recorder.h"
19#include "webrtc/voice_engine/dtmf_inband.h"
20#include "webrtc/voice_engine/level_indicator.h"
21#include "webrtc/voice_engine/voice_engine_defines.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000022
23namespace webrtc {
24
25class AudioProcessing;
26class CriticalSectionWrapper;
27class FileWrapper;
28class VoEMediaProcess;
29
30namespace voe {
31
32class Statistics;
33
34class OutputMixer : public AudioMixerOutputReceiver,
35 public AudioMixerStatusReceiver,
36 public FileCallback
37{
38public:
pbos@webrtc.org92135212013-05-14 08:31:39 +000039 static int32_t Create(OutputMixer*& mixer, uint32_t instanceId);
niklase@google.com470e71d2011-07-07 08:21:25 +000040
41 static void Destroy(OutputMixer*& mixer);
42
pbos@webrtc.org6141e132013-04-09 10:09:10 +000043 int32_t SetEngineInformation(Statistics& engineStatistics);
niklase@google.com470e71d2011-07-07 08:21:25 +000044
pbos@webrtc.org6141e132013-04-09 10:09:10 +000045 int32_t SetAudioProcessingModule(
niklase@google.com470e71d2011-07-07 08:21:25 +000046 AudioProcessing* audioProcessingModule);
47
48 // VoEExternalMedia
49 int RegisterExternalMediaProcessing(
50 VoEMediaProcess& proccess_object);
51
52 int DeRegisterExternalMediaProcessing();
53
54 // VoEDtmf
pbos@webrtc.org6141e132013-04-09 10:09:10 +000055 int PlayDtmfTone(uint8_t eventCode, int lengthMs, int attenuationDb);
niklase@google.com470e71d2011-07-07 08:21:25 +000056
pbos@webrtc.org6141e132013-04-09 10:09:10 +000057 int StartPlayingDtmfTone(uint8_t eventCode, int attenuationDb);
niklase@google.com470e71d2011-07-07 08:21:25 +000058
59 int StopPlayingDtmfTone();
60
pbos@webrtc.org6141e132013-04-09 10:09:10 +000061 int32_t MixActiveChannels();
niklase@google.com470e71d2011-07-07 08:21:25 +000062
xians@webrtc.org56925312014-04-14 10:50:37 +000063 int32_t DoOperationsOnCombinedSignal(bool feed_data_to_apm);
niklase@google.com470e71d2011-07-07 08:21:25 +000064
pbos@webrtc.org6141e132013-04-09 10:09:10 +000065 int32_t SetMixabilityStatus(MixerParticipant& participant,
pbos@webrtc.org92135212013-05-14 08:31:39 +000066 bool mixable);
niklase@google.com470e71d2011-07-07 08:21:25 +000067
pbos@webrtc.org6141e132013-04-09 10:09:10 +000068 int32_t SetAnonymousMixabilityStatus(MixerParticipant& participant,
pbos@webrtc.org92135212013-05-14 08:31:39 +000069 bool mixable);
henrike@webrtc.org066f9e52011-10-28 23:15:47 +000070
andrew@webrtc.org4ecea3e2012-06-27 03:25:31 +000071 int GetMixedAudio(int sample_rate_hz, int num_channels,
72 AudioFrame* audioFrame);
niklase@google.com470e71d2011-07-07 08:21:25 +000073
74 // VoEVolumeControl
pbos@webrtc.org6141e132013-04-09 10:09:10 +000075 int GetSpeechOutputLevel(uint32_t& level);
niklase@google.com470e71d2011-07-07 08:21:25 +000076
pbos@webrtc.org6141e132013-04-09 10:09:10 +000077 int GetSpeechOutputLevelFullRange(uint32_t& level);
niklase@google.com470e71d2011-07-07 08:21:25 +000078
79 int SetOutputVolumePan(float left, float right);
80
81 int GetOutputVolumePan(float& left, float& right);
82
83 // VoEFile
84 int StartRecordingPlayout(const char* fileName,
85 const CodecInst* codecInst);
86
87 int StartRecordingPlayout(OutStream* stream,
88 const CodecInst* codecInst);
89 int StopRecordingPlayout();
90
91 virtual ~OutputMixer();
92
andrew@webrtc.org4ecea3e2012-06-27 03:25:31 +000093 // from AudioMixerOutputReceiver
niklase@google.com470e71d2011-07-07 08:21:25 +000094 virtual void NewMixedAudio(
pbos@webrtc.org92135212013-05-14 08:31:39 +000095 int32_t id,
niklase@google.com470e71d2011-07-07 08:21:25 +000096 const AudioFrame& generalAudioFrame,
97 const AudioFrame** uniqueAudioFrames,
pbos@webrtc.org92135212013-05-14 08:31:39 +000098 uint32_t size);
niklase@google.com470e71d2011-07-07 08:21:25 +000099
andrew@webrtc.org4ecea3e2012-06-27 03:25:31 +0000100 // from AudioMixerStatusReceiver
niklase@google.com470e71d2011-07-07 08:21:25 +0000101 virtual void MixedParticipants(
pbos@webrtc.org92135212013-05-14 08:31:39 +0000102 int32_t id,
niklase@google.com470e71d2011-07-07 08:21:25 +0000103 const ParticipantStatistics* participantStatistics,
pbos@webrtc.org92135212013-05-14 08:31:39 +0000104 uint32_t size);
niklase@google.com470e71d2011-07-07 08:21:25 +0000105
106 virtual void VADPositiveParticipants(
pbos@webrtc.org92135212013-05-14 08:31:39 +0000107 int32_t id,
niklase@google.com470e71d2011-07-07 08:21:25 +0000108 const ParticipantStatistics* participantStatistics,
pbos@webrtc.org92135212013-05-14 08:31:39 +0000109 uint32_t size);
niklase@google.com470e71d2011-07-07 08:21:25 +0000110
pbos@webrtc.org92135212013-05-14 08:31:39 +0000111 virtual void MixedAudioLevel(int32_t id, uint32_t level);
niklase@google.com470e71d2011-07-07 08:21:25 +0000112
andrew@webrtc.org4ecea3e2012-06-27 03:25:31 +0000113 // For file recording
pbos@webrtc.org92135212013-05-14 08:31:39 +0000114 void PlayNotification(int32_t id, uint32_t durationMs);
niklase@google.com470e71d2011-07-07 08:21:25 +0000115
pbos@webrtc.org92135212013-05-14 08:31:39 +0000116 void RecordNotification(int32_t id, uint32_t durationMs);
niklase@google.com470e71d2011-07-07 08:21:25 +0000117
pbos@webrtc.org92135212013-05-14 08:31:39 +0000118 void PlayFileEnded(int32_t id);
119 void RecordFileEnded(int32_t id);
niklase@google.com470e71d2011-07-07 08:21:25 +0000120
121private:
pbos@webrtc.org92135212013-05-14 08:31:39 +0000122 OutputMixer(uint32_t instanceId);
andrew@webrtc.org4ecea3e2012-06-27 03:25:31 +0000123 void APMAnalyzeReverseStream();
niklase@google.com470e71d2011-07-07 08:21:25 +0000124 int InsertInbandDtmfTone();
125
andrew@webrtc.org4ecea3e2012-06-27 03:25:31 +0000126 // uses
niklase@google.com470e71d2011-07-07 08:21:25 +0000127 Statistics* _engineStatisticsPtr;
128 AudioProcessing* _audioProcessingModulePtr;
129
andrew@webrtc.org4ecea3e2012-06-27 03:25:31 +0000130 // owns
niklase@google.com470e71d2011-07-07 08:21:25 +0000131 CriticalSectionWrapper& _callbackCritSect;
132 // protect the _outputFileRecorderPtr and _outputFileRecording
133 CriticalSectionWrapper& _fileCritSect;
134 AudioConferenceMixer& _mixerModule;
135 AudioFrame _audioFrame;
andrew@webrtc.orgf5a33f12014-04-19 00:32:07 +0000136 // Converts mixed audio to the audio device output rate.
137 PushResampler<int16_t> resampler_;
138 // Converts mixed audio to the audio processing rate.
139 PushResampler<int16_t> audioproc_resampler_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000140 AudioLevel _audioLevel; // measures audio level for the combined signal
141 DtmfInband _dtmfGenerator;
xians@google.com0b0665a2011-08-08 08:18:44 +0000142 int _instanceId;
niklase@google.com470e71d2011-07-07 08:21:25 +0000143 VoEMediaProcess* _externalMediaCallbackPtr;
144 bool _externalMedia;
145 float _panLeft;
146 float _panRight;
xians@google.com0b0665a2011-08-08 08:18:44 +0000147 int _mixingFrequencyHz;
niklase@google.com470e71d2011-07-07 08:21:25 +0000148 FileRecorder* _outputFileRecorderPtr;
149 bool _outputFileRecording;
150};
151
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +0000152} // namespace voe
niklase@google.com470e71d2011-07-07 08:21:25 +0000153
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +0000154} // namespace werbtc
niklase@google.com470e71d2011-07-07 08:21:25 +0000155
andrew@webrtc.org4ecea3e2012-06-27 03:25:31 +0000156#endif // VOICE_ENGINE_OUTPUT_MIXER_H_