blob: bd17c3becaa244754987641c43fd939b0e2b48c5 [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 int StartPlayingDtmfTone(uint8_t eventCode, int attenuationDb);
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000058
59 int StopPlayingDtmfTone();
60
pbos@webrtc.org54f03bc2013-04-09 10:09:10 +000061 int32_t MixActiveChannels();
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000062
xians@webrtc.org91d88e12014-04-14 10:50:37 +000063 int32_t DoOperationsOnCombinedSignal(bool feed_data_to_apm);
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000064
pbos@webrtc.org54f03bc2013-04-09 10:09:10 +000065 int32_t SetMixabilityStatus(MixerParticipant& participant,
pbos@webrtc.orgca7a9a22013-05-14 08:31:39 +000066 bool mixable);
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000067
pbos@webrtc.org54f03bc2013-04-09 10:09:10 +000068 int32_t SetAnonymousMixabilityStatus(MixerParticipant& participant,
pbos@webrtc.orgca7a9a22013-05-14 08:31:39 +000069 bool mixable);
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000070
71 int GetMixedAudio(int sample_rate_hz, int num_channels,
72 AudioFrame* audioFrame);
73
74 // VoEVolumeControl
pbos@webrtc.org54f03bc2013-04-09 10:09:10 +000075 int GetSpeechOutputLevel(uint32_t& level);
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000076
pbos@webrtc.org54f03bc2013-04-09 10:09:10 +000077 int GetSpeechOutputLevelFullRange(uint32_t& level);
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +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
93 // from AudioMixerOutputReceiver
94 virtual void NewMixedAudio(
pbos@webrtc.orgca7a9a22013-05-14 08:31:39 +000095 int32_t id,
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000096 const AudioFrame& generalAudioFrame,
97 const AudioFrame** uniqueAudioFrames,
pbos@webrtc.orgca7a9a22013-05-14 08:31:39 +000098 uint32_t size);
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000099
100 // from AudioMixerStatusReceiver
101 virtual void MixedParticipants(
pbos@webrtc.orgca7a9a22013-05-14 08:31:39 +0000102 int32_t id,
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000103 const ParticipantStatistics* participantStatistics,
pbos@webrtc.orgca7a9a22013-05-14 08:31:39 +0000104 uint32_t size);
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000105
106 virtual void VADPositiveParticipants(
pbos@webrtc.orgca7a9a22013-05-14 08:31:39 +0000107 int32_t id,
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000108 const ParticipantStatistics* participantStatistics,
pbos@webrtc.orgca7a9a22013-05-14 08:31:39 +0000109 uint32_t size);
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000110
pbos@webrtc.orgca7a9a22013-05-14 08:31:39 +0000111 virtual void MixedAudioLevel(int32_t id, uint32_t level);
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000112
113 // For file recording
pbos@webrtc.orgca7a9a22013-05-14 08:31:39 +0000114 void PlayNotification(int32_t id, uint32_t durationMs);
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000115
pbos@webrtc.orgca7a9a22013-05-14 08:31:39 +0000116 void RecordNotification(int32_t id, uint32_t durationMs);
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000117
pbos@webrtc.orgca7a9a22013-05-14 08:31:39 +0000118 void PlayFileEnded(int32_t id);
119 void RecordFileEnded(int32_t id);
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000120
121private:
pbos@webrtc.orgca7a9a22013-05-14 08:31:39 +0000122 OutputMixer(uint32_t instanceId);
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000123 void APMAnalyzeReverseStream();
124 int InsertInbandDtmfTone();
125
126 // uses
127 Statistics* _engineStatisticsPtr;
128 AudioProcessing* _audioProcessingModulePtr;
129
130 // owns
131 CriticalSectionWrapper& _callbackCritSect;
132 // protect the _outputFileRecorderPtr and _outputFileRecording
133 CriticalSectionWrapper& _fileCritSect;
134 AudioConferenceMixer& _mixerModule;
135 AudioFrame _audioFrame;
andrew@webrtc.orgb6fadb12013-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
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000138 AudioLevel _audioLevel; // measures audio level for the combined signal
139 DtmfInband _dtmfGenerator;
140 int _instanceId;
141 VoEMediaProcess* _externalMediaCallbackPtr;
142 bool _externalMedia;
143 float _panLeft;
144 float _panRight;
145 int _mixingFrequencyHz;
146 FileRecorder* _outputFileRecorderPtr;
147 bool _outputFileRecording;
148};
149
pbos@webrtc.org3b89e102013-07-03 15:12:26 +0000150} // namespace voe
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000151
pbos@webrtc.org3b89e102013-07-03 15:12:26 +0000152} // namespace werbtc
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000153
154#endif // VOICE_ENGINE_OUTPUT_MIXER_H_