blob: 5e3e2e708e3bd706e9fc34827866099022b27b75 [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
kwiberg5a25d952016-08-17 07:31:12 -070014#include <memory>
15
tommi31fc21f2016-01-21 10:37:37 -080016#include "webrtc/base/criticalsection.h"
andrew@webrtc.org50b2efe2013-04-29 17:27:29 +000017#include "webrtc/common_audio/resampler/include/push_resampler.h"
18#include "webrtc/common_types.h"
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010019#include "webrtc/modules/audio_conference_mixer/include/audio_conference_mixer.h"
20#include "webrtc/modules/audio_conference_mixer/include/audio_conference_mixer_defines.h"
kwiberg97744472017-01-10 01:12:51 -080021#include "webrtc/voice_engine/file_recorder.h"
andrew@webrtc.org50b2efe2013-04-29 17:27:29 +000022#include "webrtc/voice_engine/level_indicator.h"
23#include "webrtc/voice_engine/voice_engine_defines.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000024
25namespace webrtc {
26
27class AudioProcessing;
niklase@google.com470e71d2011-07-07 08:21:25 +000028class FileWrapper;
29class VoEMediaProcess;
30
31namespace voe {
32
33class Statistics;
34
35class OutputMixer : public AudioMixerOutputReceiver,
niklase@google.com470e71d2011-07-07 08:21:25 +000036 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
pbos@webrtc.org6141e132013-04-09 10:09:10 +000054 int32_t MixActiveChannels();
niklase@google.com470e71d2011-07-07 08:21:25 +000055
xians@webrtc.org56925312014-04-14 10:50:37 +000056 int32_t DoOperationsOnCombinedSignal(bool feed_data_to_apm);
niklase@google.com470e71d2011-07-07 08:21:25 +000057
pbos@webrtc.org6141e132013-04-09 10:09:10 +000058 int32_t SetMixabilityStatus(MixerParticipant& participant,
pbos@webrtc.org92135212013-05-14 08:31:39 +000059 bool mixable);
niklase@google.com470e71d2011-07-07 08:21:25 +000060
pbos@webrtc.org6141e132013-04-09 10:09:10 +000061 int32_t SetAnonymousMixabilityStatus(MixerParticipant& participant,
pbos@webrtc.org92135212013-05-14 08:31:39 +000062 bool mixable);
henrike@webrtc.org066f9e52011-10-28 23:15:47 +000063
Peter Kasting69558702016-01-12 16:26:35 -080064 int GetMixedAudio(int sample_rate_hz, size_t num_channels,
andrew@webrtc.org4ecea3e2012-06-27 03:25:31 +000065 AudioFrame* audioFrame);
niklase@google.com470e71d2011-07-07 08:21:25 +000066
67 // VoEVolumeControl
pbos@webrtc.org6141e132013-04-09 10:09:10 +000068 int GetSpeechOutputLevel(uint32_t& level);
niklase@google.com470e71d2011-07-07 08:21:25 +000069
pbos@webrtc.org6141e132013-04-09 10:09:10 +000070 int GetSpeechOutputLevelFullRange(uint32_t& level);
niklase@google.com470e71d2011-07-07 08:21:25 +000071
72 int SetOutputVolumePan(float left, float right);
73
74 int GetOutputVolumePan(float& left, float& right);
75
76 // VoEFile
77 int StartRecordingPlayout(const char* fileName,
78 const CodecInst* codecInst);
79
80 int StartRecordingPlayout(OutStream* stream,
81 const CodecInst* codecInst);
82 int StopRecordingPlayout();
83
84 virtual ~OutputMixer();
85
andrew@webrtc.org4ecea3e2012-06-27 03:25:31 +000086 // from AudioMixerOutputReceiver
niklase@google.com470e71d2011-07-07 08:21:25 +000087 virtual void NewMixedAudio(
pbos@webrtc.org92135212013-05-14 08:31:39 +000088 int32_t id,
niklase@google.com470e71d2011-07-07 08:21:25 +000089 const AudioFrame& generalAudioFrame,
90 const AudioFrame** uniqueAudioFrames,
pbos@webrtc.org92135212013-05-14 08:31:39 +000091 uint32_t size);
niklase@google.com470e71d2011-07-07 08:21:25 +000092
andrew@webrtc.org4ecea3e2012-06-27 03:25:31 +000093 // For file recording
pbos@webrtc.org92135212013-05-14 08:31:39 +000094 void PlayNotification(int32_t id, uint32_t durationMs);
niklase@google.com470e71d2011-07-07 08:21:25 +000095
pbos@webrtc.org92135212013-05-14 08:31:39 +000096 void RecordNotification(int32_t id, uint32_t durationMs);
niklase@google.com470e71d2011-07-07 08:21:25 +000097
pbos@webrtc.org92135212013-05-14 08:31:39 +000098 void PlayFileEnded(int32_t id);
99 void RecordFileEnded(int32_t id);
niklase@google.com470e71d2011-07-07 08:21:25 +0000100
101private:
pbos@webrtc.org92135212013-05-14 08:31:39 +0000102 OutputMixer(uint32_t instanceId);
niklase@google.com470e71d2011-07-07 08:21:25 +0000103
andrew@webrtc.org4ecea3e2012-06-27 03:25:31 +0000104 // uses
niklase@google.com470e71d2011-07-07 08:21:25 +0000105 Statistics* _engineStatisticsPtr;
106 AudioProcessing* _audioProcessingModulePtr;
107
tommi31fc21f2016-01-21 10:37:37 -0800108 rtc::CriticalSection _callbackCritSect;
kwiberg5a25d952016-08-17 07:31:12 -0700109 // Protects output_file_recorder_ and _outputFileRecording.
tommi31fc21f2016-01-21 10:37:37 -0800110 rtc::CriticalSection _fileCritSect;
niklase@google.com470e71d2011-07-07 08:21:25 +0000111 AudioConferenceMixer& _mixerModule;
112 AudioFrame _audioFrame;
andrew@webrtc.orgf5a33f12014-04-19 00:32:07 +0000113 // Converts mixed audio to the audio device output rate.
114 PushResampler<int16_t> resampler_;
115 // Converts mixed audio to the audio processing rate.
116 PushResampler<int16_t> audioproc_resampler_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000117 AudioLevel _audioLevel; // measures audio level for the combined signal
xians@google.com0b0665a2011-08-08 08:18:44 +0000118 int _instanceId;
niklase@google.com470e71d2011-07-07 08:21:25 +0000119 VoEMediaProcess* _externalMediaCallbackPtr;
120 bool _externalMedia;
121 float _panLeft;
122 float _panRight;
xians@google.com0b0665a2011-08-08 08:18:44 +0000123 int _mixingFrequencyHz;
kwiberg5a25d952016-08-17 07:31:12 -0700124 std::unique_ptr<FileRecorder> output_file_recorder_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000125 bool _outputFileRecording;
126};
127
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +0000128} // namespace voe
niklase@google.com470e71d2011-07-07 08:21:25 +0000129
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +0000130} // namespace werbtc
niklase@google.com470e71d2011-07-07 08:21:25 +0000131
andrew@webrtc.org4ecea3e2012-06-27 03:25:31 +0000132#endif // VOICE_ENGINE_OUTPUT_MIXER_H_