blob: e5c65e41bc13a9c74415a5a4a10c39ec6b6f1d10 [file] [log] [blame]
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +00001/*
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_VOICE_ENGINE_OUTPUT_MIXER_H_
12#define WEBRTC_VOICE_ENGINE_OUTPUT_MIXER_H_
13
andrew@webrtc.orgb6fadb12013-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"
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +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.orgca7a9a22013-05-14 08:31:39 +000039 static int32_t Create(OutputMixer*& mixer, uint32_t instanceId);
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000040
41 static void Destroy(OutputMixer*& mixer);
42
pbos@webrtc.org54f03bc2013-04-09 10:09:10 +000043 int32_t SetEngineInformation(Statistics& engineStatistics);
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000044
pbos@webrtc.org54f03bc2013-04-09 10:09:10 +000045 int32_t SetAudioProcessingModule(
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000046 AudioProcessing* audioProcessingModule);
47
48 // VoEExternalMedia
49 int RegisterExternalMediaProcessing(
50 VoEMediaProcess& proccess_object);
51
52 int DeRegisterExternalMediaProcessing();
53
54 // VoEDtmf
pbos@webrtc.org54f03bc2013-04-09 10:09:10 +000055 int PlayDtmfTone(uint8_t eventCode, int lengthMs, int attenuationDb);
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000056
pbos@webrtc.org54f03bc2013-04-09 10:09:10 +000057 int32_t MixActiveChannels();
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000058
xians@webrtc.org91d88e12014-04-14 10:50:37 +000059 int32_t DoOperationsOnCombinedSignal(bool feed_data_to_apm);
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000060
pbos@webrtc.org54f03bc2013-04-09 10:09:10 +000061 int32_t SetMixabilityStatus(MixerParticipant& participant,
pbos@webrtc.orgca7a9a22013-05-14 08:31:39 +000062 bool mixable);
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000063
pbos@webrtc.org54f03bc2013-04-09 10:09:10 +000064 int32_t SetAnonymousMixabilityStatus(MixerParticipant& participant,
pbos@webrtc.orgca7a9a22013-05-14 08:31:39 +000065 bool mixable);
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000066
67 int GetMixedAudio(int sample_rate_hz, int num_channels,
68 AudioFrame* audioFrame);
69
70 // VoEVolumeControl
pbos@webrtc.org54f03bc2013-04-09 10:09:10 +000071 int GetSpeechOutputLevel(uint32_t& level);
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000072
pbos@webrtc.org54f03bc2013-04-09 10:09:10 +000073 int GetSpeechOutputLevelFullRange(uint32_t& level);
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000074
75 int SetOutputVolumePan(float left, float right);
76
77 int GetOutputVolumePan(float& left, float& right);
78
79 // VoEFile
80 int StartRecordingPlayout(const char* fileName,
81 const CodecInst* codecInst);
82
83 int StartRecordingPlayout(OutStream* stream,
84 const CodecInst* codecInst);
85 int StopRecordingPlayout();
86
87 virtual ~OutputMixer();
88
89 // from AudioMixerOutputReceiver
90 virtual void NewMixedAudio(
pbos@webrtc.orgca7a9a22013-05-14 08:31:39 +000091 int32_t id,
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000092 const AudioFrame& generalAudioFrame,
93 const AudioFrame** uniqueAudioFrames,
pbos@webrtc.orgca7a9a22013-05-14 08:31:39 +000094 uint32_t size);
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000095
96 // from AudioMixerStatusReceiver
97 virtual void MixedParticipants(
pbos@webrtc.orgca7a9a22013-05-14 08:31:39 +000098 int32_t id,
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000099 const ParticipantStatistics* participantStatistics,
pbos@webrtc.orgca7a9a22013-05-14 08:31:39 +0000100 uint32_t size);
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000101
102 virtual void VADPositiveParticipants(
pbos@webrtc.orgca7a9a22013-05-14 08:31:39 +0000103 int32_t id,
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000104 const ParticipantStatistics* participantStatistics,
pbos@webrtc.orgca7a9a22013-05-14 08:31:39 +0000105 uint32_t size);
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000106
pbos@webrtc.orgca7a9a22013-05-14 08:31:39 +0000107 virtual void MixedAudioLevel(int32_t id, uint32_t level);
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000108
109 // For file recording
pbos@webrtc.orgca7a9a22013-05-14 08:31:39 +0000110 void PlayNotification(int32_t id, uint32_t durationMs);
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000111
pbos@webrtc.orgca7a9a22013-05-14 08:31:39 +0000112 void RecordNotification(int32_t id, uint32_t durationMs);
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000113
pbos@webrtc.orgca7a9a22013-05-14 08:31:39 +0000114 void PlayFileEnded(int32_t id);
115 void RecordFileEnded(int32_t id);
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000116
117private:
pbos@webrtc.orgca7a9a22013-05-14 08:31:39 +0000118 OutputMixer(uint32_t instanceId);
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000119 void APMAnalyzeReverseStream();
120 int InsertInbandDtmfTone();
121
122 // uses
123 Statistics* _engineStatisticsPtr;
124 AudioProcessing* _audioProcessingModulePtr;
125
126 // owns
127 CriticalSectionWrapper& _callbackCritSect;
128 // protect the _outputFileRecorderPtr and _outputFileRecording
129 CriticalSectionWrapper& _fileCritSect;
130 AudioConferenceMixer& _mixerModule;
131 AudioFrame _audioFrame;
andrew@webrtc.org708ff4d2014-04-19 00:32:07 +0000132 // Converts mixed audio to the audio device output rate.
133 PushResampler<int16_t> resampler_;
134 // Converts mixed audio to the audio processing rate.
135 PushResampler<int16_t> audioproc_resampler_;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000136 AudioLevel _audioLevel; // measures audio level for the combined signal
137 DtmfInband _dtmfGenerator;
138 int _instanceId;
139 VoEMediaProcess* _externalMediaCallbackPtr;
140 bool _externalMedia;
141 float _panLeft;
142 float _panRight;
143 int _mixingFrequencyHz;
144 FileRecorder* _outputFileRecorderPtr;
145 bool _outputFileRecording;
146};
147
pbos@webrtc.org3b89e102013-07-03 15:12:26 +0000148} // namespace voe
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000149
pbos@webrtc.org3b89e102013-07-03 15:12:26 +0000150} // namespace werbtc
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000151
152#endif // VOICE_ENGINE_OUTPUT_MIXER_H_