blob: 14257d27dd80b237bf7a0c7747cdb23eb9e50fd7 [file] [log] [blame]
aleloi24899e52017-02-21 05:06:29 -08001/*
2 * Copyright (c) 2017 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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_AUDIO_MIXER_FRAME_COMBINER_H_
12#define MODULES_AUDIO_MIXER_FRAME_COMBINER_H_
aleloi24899e52017-02-21 05:06:29 -080013
14#include <memory>
15#include <vector>
16
Alex Loiko507e8d12018-02-27 13:51:47 +010017#include "modules/audio_processing/agc2/fixed_gain_controller.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020018#include "modules/audio_processing/include/audio_processing.h"
19#include "modules/include/module_common_types.h"
aleloi24899e52017-02-21 05:06:29 -080020
21namespace webrtc {
Alex Loiko507e8d12018-02-27 13:51:47 +010022class ApmDataDumper;
23class FixedGainController;
aleloi24899e52017-02-21 05:06:29 -080024
25class FrameCombiner {
26 public:
Alex Loiko507e8d12018-02-27 13:51:47 +010027 enum class LimiterType { kNoLimiter, kApmAgcLimiter, kApmAgc2Limiter };
28 explicit FrameCombiner(LimiterType limiter_type);
29 explicit FrameCombiner(bool use_limiter);
aleloi24899e52017-02-21 05:06:29 -080030 ~FrameCombiner();
31
Alex Loiko99a2c5d2018-02-27 14:09:47 +010032 void SetLimiterType(LimiterType limiter_type);
33
aleloi24899e52017-02-21 05:06:29 -080034 // Combine several frames into one. Assumes sample_rate,
35 // samples_per_channel of the input frames match the parameters. The
aleloi2c9306e2017-03-29 04:25:16 -070036 // parameters 'number_of_channels' and 'sample_rate' are needed
37 // because 'mix_list' can be empty. The parameter
38 // 'number_of_streams' is used for determining whether to pass the
39 // data through a limiter.
aleloi24899e52017-02-21 05:06:29 -080040 void Combine(const std::vector<AudioFrame*>& mix_list,
41 size_t number_of_channels,
42 int sample_rate,
aleloi2c9306e2017-03-29 04:25:16 -070043 size_t number_of_streams,
Alex Loiko507e8d12018-02-27 13:51:47 +010044 AudioFrame* audio_frame_for_mixing);
aleloi24899e52017-02-21 05:06:29 -080045
46 private:
Alex Loiko6f2fcb42018-03-14 12:27:05 +010047 void LogMixingStats(const std::vector<AudioFrame*>& mix_list,
48 int sample_rate,
49 size_t number_of_streams) const;
50
Alex Loiko99a2c5d2018-02-27 14:09:47 +010051 LimiterType limiter_type_;
Alex Loiko507e8d12018-02-27 13:51:47 +010052 std::unique_ptr<AudioProcessing> apm_agc_limiter_;
53 std::unique_ptr<ApmDataDumper> data_dumper_;
54 FixedGainController apm_agc2_limiter_;
Alex Loiko6f2fcb42018-03-14 12:27:05 +010055 mutable int uma_logging_counter_ = 0;
aleloi24899e52017-02-21 05:06:29 -080056};
57} // namespace webrtc
58
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020059#endif // MODULES_AUDIO_MIXER_FRAME_COMBINER_H_