2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
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.
11 #ifndef WEBRTC_VOICE_ENGINE_OUTPUT_MIXER_H
12 #define WEBRTC_VOICE_ENGINE_OUTPUT_MIXER_H
14 #include "audio_conference_mixer.h"
15 #include "audio_conference_mixer_defines.h"
16 #include "common_types.h"
17 #include "dtmf_inband.h"
18 #include "file_recorder.h"
19 #include "level_indicator.h"
20 #include "resampler.h"
21 #include "voice_engine_defines.h"
25 class AudioProcessing
;
26 class CriticalSectionWrapper
;
28 class VoEMediaProcess
;
34 class OutputMixer
: public AudioMixerOutputReceiver
,
35 public AudioMixerStatusReceiver
,
39 static WebRtc_Word32
Create(OutputMixer
*& mixer
,
40 const WebRtc_UWord32 instanceId
);
42 static void Destroy(OutputMixer
*& mixer
);
44 WebRtc_Word32
SetEngineInformation(Statistics
& engineStatistics
);
46 WebRtc_Word32
SetAudioProcessingModule(
47 AudioProcessing
* audioProcessingModule
);
50 int RegisterExternalMediaProcessing(
51 VoEMediaProcess
& proccess_object
);
53 int DeRegisterExternalMediaProcessing();
56 int PlayDtmfTone(WebRtc_UWord8 eventCode
,
60 int StartPlayingDtmfTone(WebRtc_UWord8 eventCode
,
63 int StopPlayingDtmfTone();
65 WebRtc_Word32
MixActiveChannels();
67 WebRtc_Word32
DoOperationsOnCombinedSignal();
69 WebRtc_Word32
SetMixabilityStatus(MixerParticipant
& participant
,
72 WebRtc_Word32
SetAnonymousMixabilityStatus(MixerParticipant
& participant
,
75 WebRtc_Word32
GetMixedAudio(const WebRtc_Word32 desiredFreqHz
,
76 const WebRtc_UWord8 channels
,
77 AudioFrame
& audioFrame
);
80 int GetSpeechOutputLevel(WebRtc_UWord32
& level
);
82 int GetSpeechOutputLevelFullRange(WebRtc_UWord32
& level
);
84 int SetOutputVolumePan(float left
, float right
);
86 int GetOutputVolumePan(float& left
, float& right
);
89 int StartRecordingPlayout(const char* fileName
,
90 const CodecInst
* codecInst
);
92 int StartRecordingPlayout(OutStream
* stream
,
93 const CodecInst
* codecInst
);
94 int StopRecordingPlayout();
96 virtual ~OutputMixer();
98 public: // from AudioMixerOutputReceiver
99 virtual void NewMixedAudio(
100 const WebRtc_Word32 id
,
101 const AudioFrame
& generalAudioFrame
,
102 const AudioFrame
** uniqueAudioFrames
,
103 const WebRtc_UWord32 size
);
105 public: // from AudioMixerStatusReceiver
106 virtual void MixedParticipants(
107 const WebRtc_Word32 id
,
108 const ParticipantStatistics
* participantStatistics
,
109 const WebRtc_UWord32 size
);
111 virtual void VADPositiveParticipants(
112 const WebRtc_Word32 id
,
113 const ParticipantStatistics
* participantStatistics
,
114 const WebRtc_UWord32 size
);
116 virtual void MixedAudioLevel(const WebRtc_Word32 id
,
117 const WebRtc_UWord32 level
);
119 public: // For file recording
120 void PlayNotification(const WebRtc_Word32 id
,
121 const WebRtc_UWord32 durationMs
);
123 void RecordNotification(const WebRtc_Word32 id
,
124 const WebRtc_UWord32 durationMs
);
126 void PlayFileEnded(const WebRtc_Word32 id
);
127 void RecordFileEnded(const WebRtc_Word32 id
);
130 OutputMixer(const WebRtc_UWord32 instanceId
);
131 int APMAnalyzeReverseStream();
132 int InsertInbandDtmfTone();
135 Statistics
* _engineStatisticsPtr
;
136 AudioProcessing
* _audioProcessingModulePtr
;
139 CriticalSectionWrapper
& _callbackCritSect
;
140 // protect the _outputFileRecorderPtr and _outputFileRecording
141 CriticalSectionWrapper
& _fileCritSect
;
142 AudioConferenceMixer
& _mixerModule
;
143 AudioFrame _audioFrame
;
144 Resampler _resampler
; // converts mixed audio to fit ADM format
145 Resampler _apmResampler
; // converts mixed audio to fit APM rate
146 AudioLevel _audioLevel
; // measures audio level for the combined signal
147 DtmfInband _dtmfGenerator
;
149 VoEMediaProcess
* _externalMediaCallbackPtr
;
153 int _mixingFrequencyHz
;
154 FileRecorder
* _outputFileRecorderPtr
;
155 bool _outputFileRecording
;
160 } // namespace werbtc
162 #endif // VOICE_ENGINE_OUTPUT_MIXER_H