blob: b98f88ead9105744cb300447eca93370d5736adb [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.org6141e132013-04-09 10:09:10 +000039 static int32_t Create(OutputMixer*& mixer, const 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
pbos@webrtc.org6141e132013-04-09 10:09:10 +000063 int32_t DoOperationsOnCombinedSignal();
niklase@google.com470e71d2011-07-07 08:21:25 +000064
pbos@webrtc.org6141e132013-04-09 10:09:10 +000065 int32_t SetMixabilityStatus(MixerParticipant& participant,
66 const 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,
69 const 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.org6141e132013-04-09 10:09:10 +000095 const int32_t id,
niklase@google.com470e71d2011-07-07 08:21:25 +000096 const AudioFrame& generalAudioFrame,
97 const AudioFrame** uniqueAudioFrames,
pbos@webrtc.org6141e132013-04-09 10:09:10 +000098 const 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.org6141e132013-04-09 10:09:10 +0000102 const int32_t id,
niklase@google.com470e71d2011-07-07 08:21:25 +0000103 const ParticipantStatistics* participantStatistics,
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000104 const uint32_t size);
niklase@google.com470e71d2011-07-07 08:21:25 +0000105
106 virtual void VADPositiveParticipants(
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000107 const int32_t id,
niklase@google.com470e71d2011-07-07 08:21:25 +0000108 const ParticipantStatistics* participantStatistics,
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000109 const uint32_t size);
niklase@google.com470e71d2011-07-07 08:21:25 +0000110
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000111 virtual void MixedAudioLevel(const int32_t id, const 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.org6141e132013-04-09 10:09:10 +0000114 void PlayNotification(const int32_t id, const uint32_t durationMs);
niklase@google.com470e71d2011-07-07 08:21:25 +0000115
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000116 void RecordNotification(const int32_t id, const uint32_t durationMs);
niklase@google.com470e71d2011-07-07 08:21:25 +0000117
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000118 void PlayFileEnded(const int32_t id);
119 void RecordFileEnded(const int32_t id);
niklase@google.com470e71d2011-07-07 08:21:25 +0000120
121private:
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000122 OutputMixer(const 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.org50b2efe2013-04-29 17:27:29 +0000136 PushResampler resampler_; // converts mixed audio to fit ADM format
137 PushResampler audioproc_resampler_; // converts mixed audio to fit APM rate
niklase@google.com470e71d2011-07-07 08:21:25 +0000138 AudioLevel _audioLevel; // measures audio level for the combined signal
139 DtmfInband _dtmfGenerator;
xians@google.com0b0665a2011-08-08 08:18:44 +0000140 int _instanceId;
niklase@google.com470e71d2011-07-07 08:21:25 +0000141 VoEMediaProcess* _externalMediaCallbackPtr;
142 bool _externalMedia;
143 float _panLeft;
144 float _panRight;
xians@google.com0b0665a2011-08-08 08:18:44 +0000145 int _mixingFrequencyHz;
niklase@google.com470e71d2011-07-07 08:21:25 +0000146 FileRecorder* _outputFileRecorderPtr;
147 bool _outputFileRecording;
148};
149
150} // namespace voe
151
152} // namespace werbtc
153
andrew@webrtc.org4ecea3e2012-06-27 03:25:31 +0000154#endif // VOICE_ENGINE_OUTPUT_MIXER_H_