blob: fe0cb308f162f928b0814d3f3a579de7266dfa73 [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
andrew@webrtc.org50b2efe2013-04-29 17:27:29 +000016#include "webrtc/common_audio/resampler/include/push_resampler.h"
17#include "webrtc/common_types.h"
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010018#include "webrtc/modules/audio_conference_mixer/include/audio_conference_mixer.h"
19#include "webrtc/modules/audio_conference_mixer/include/audio_conference_mixer_defines.h"
Edward Lemurc20978e2017-07-06 19:44:34 +020020#include "webrtc/rtc_base/criticalsection.h"
kwiberg97744472017-01-10 01:12:51 -080021#include "webrtc/voice_engine/file_recorder.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000022
23namespace webrtc {
24
25class AudioProcessing;
niklase@google.com470e71d2011-07-07 08:21:25 +000026class FileWrapper;
niklase@google.com470e71d2011-07-07 08:21:25 +000027
28namespace voe {
29
30class Statistics;
31
32class OutputMixer : public AudioMixerOutputReceiver,
niklase@google.com470e71d2011-07-07 08:21:25 +000033 public FileCallback
34{
35public:
pbos@webrtc.org92135212013-05-14 08:31:39 +000036 static int32_t Create(OutputMixer*& mixer, uint32_t instanceId);
niklase@google.com470e71d2011-07-07 08:21:25 +000037
38 static void Destroy(OutputMixer*& mixer);
39
pbos@webrtc.org6141e132013-04-09 10:09:10 +000040 int32_t SetEngineInformation(Statistics& engineStatistics);
niklase@google.com470e71d2011-07-07 08:21:25 +000041
pbos@webrtc.org6141e132013-04-09 10:09:10 +000042 int32_t SetAudioProcessingModule(
niklase@google.com470e71d2011-07-07 08:21:25 +000043 AudioProcessing* audioProcessingModule);
44
pbos@webrtc.org6141e132013-04-09 10:09:10 +000045 int32_t MixActiveChannels();
niklase@google.com470e71d2011-07-07 08:21:25 +000046
xians@webrtc.org56925312014-04-14 10:50:37 +000047 int32_t DoOperationsOnCombinedSignal(bool feed_data_to_apm);
niklase@google.com470e71d2011-07-07 08:21:25 +000048
pbos@webrtc.org6141e132013-04-09 10:09:10 +000049 int32_t SetMixabilityStatus(MixerParticipant& participant,
pbos@webrtc.org92135212013-05-14 08:31:39 +000050 bool mixable);
niklase@google.com470e71d2011-07-07 08:21:25 +000051
pbos@webrtc.org6141e132013-04-09 10:09:10 +000052 int32_t SetAnonymousMixabilityStatus(MixerParticipant& participant,
pbos@webrtc.org92135212013-05-14 08:31:39 +000053 bool mixable);
henrike@webrtc.org066f9e52011-10-28 23:15:47 +000054
Peter Kasting69558702016-01-12 16:26:35 -080055 int GetMixedAudio(int sample_rate_hz, size_t num_channels,
andrew@webrtc.org4ecea3e2012-06-27 03:25:31 +000056 AudioFrame* audioFrame);
niklase@google.com470e71d2011-07-07 08:21:25 +000057
niklase@google.com470e71d2011-07-07 08:21:25 +000058 // VoEFile
59 int StartRecordingPlayout(const char* fileName,
60 const CodecInst* codecInst);
61
62 int StartRecordingPlayout(OutStream* stream,
63 const CodecInst* codecInst);
64 int StopRecordingPlayout();
65
66 virtual ~OutputMixer();
67
andrew@webrtc.org4ecea3e2012-06-27 03:25:31 +000068 // from AudioMixerOutputReceiver
niklase@google.com470e71d2011-07-07 08:21:25 +000069 virtual void NewMixedAudio(
pbos@webrtc.org92135212013-05-14 08:31:39 +000070 int32_t id,
niklase@google.com470e71d2011-07-07 08:21:25 +000071 const AudioFrame& generalAudioFrame,
72 const AudioFrame** uniqueAudioFrames,
pbos@webrtc.org92135212013-05-14 08:31:39 +000073 uint32_t size);
niklase@google.com470e71d2011-07-07 08:21:25 +000074
andrew@webrtc.org4ecea3e2012-06-27 03:25:31 +000075 // For file recording
pbos@webrtc.org92135212013-05-14 08:31:39 +000076 void PlayNotification(int32_t id, uint32_t durationMs);
niklase@google.com470e71d2011-07-07 08:21:25 +000077
pbos@webrtc.org92135212013-05-14 08:31:39 +000078 void RecordNotification(int32_t id, uint32_t durationMs);
niklase@google.com470e71d2011-07-07 08:21:25 +000079
pbos@webrtc.org92135212013-05-14 08:31:39 +000080 void PlayFileEnded(int32_t id);
81 void RecordFileEnded(int32_t id);
niklase@google.com470e71d2011-07-07 08:21:25 +000082
83private:
pbos@webrtc.org92135212013-05-14 08:31:39 +000084 OutputMixer(uint32_t instanceId);
niklase@google.com470e71d2011-07-07 08:21:25 +000085
andrew@webrtc.org4ecea3e2012-06-27 03:25:31 +000086 // uses
niklase@google.com470e71d2011-07-07 08:21:25 +000087 Statistics* _engineStatisticsPtr;
88 AudioProcessing* _audioProcessingModulePtr;
89
kwiberg5a25d952016-08-17 07:31:12 -070090 // Protects output_file_recorder_ and _outputFileRecording.
tommi31fc21f2016-01-21 10:37:37 -080091 rtc::CriticalSection _fileCritSect;
niklase@google.com470e71d2011-07-07 08:21:25 +000092 AudioConferenceMixer& _mixerModule;
93 AudioFrame _audioFrame;
andrew@webrtc.orgf5a33f12014-04-19 00:32:07 +000094 // Converts mixed audio to the audio device output rate.
95 PushResampler<int16_t> resampler_;
96 // Converts mixed audio to the audio processing rate.
97 PushResampler<int16_t> audioproc_resampler_;
xians@google.com0b0665a2011-08-08 08:18:44 +000098 int _instanceId;
xians@google.com0b0665a2011-08-08 08:18:44 +000099 int _mixingFrequencyHz;
kwiberg5a25d952016-08-17 07:31:12 -0700100 std::unique_ptr<FileRecorder> output_file_recorder_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000101 bool _outputFileRecording;
102};
103
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +0000104} // namespace voe
niklase@google.com470e71d2011-07-07 08:21:25 +0000105
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +0000106} // namespace werbtc
niklase@google.com470e71d2011-07-07 08:21:25 +0000107
andrew@webrtc.org4ecea3e2012-06-27 03:25:31 +0000108#endif // VOICE_ENGINE_OUTPUT_MIXER_H_