aleloi | 24899e5 | 2017-02-21 05:06:29 -0800 | [diff] [blame] | 1 | /* |
| 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 Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef MODULES_AUDIO_MIXER_FRAME_COMBINER_H_ |
| 12 | #define MODULES_AUDIO_MIXER_FRAME_COMBINER_H_ |
aleloi | 24899e5 | 2017-02-21 05:06:29 -0800 | [diff] [blame] | 13 | |
| 14 | #include <memory> |
| 15 | #include <vector> |
| 16 | |
Alex Loiko | 507e8d1 | 2018-02-27 13:51:47 +0100 | [diff] [blame^] | 17 | #include "modules/audio_processing/agc2/fixed_gain_controller.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 18 | #include "modules/audio_processing/include/audio_processing.h" |
| 19 | #include "modules/include/module_common_types.h" |
aleloi | 24899e5 | 2017-02-21 05:06:29 -0800 | [diff] [blame] | 20 | |
| 21 | namespace webrtc { |
Alex Loiko | 507e8d1 | 2018-02-27 13:51:47 +0100 | [diff] [blame^] | 22 | class ApmDataDumper; |
| 23 | class FixedGainController; |
aleloi | 24899e5 | 2017-02-21 05:06:29 -0800 | [diff] [blame] | 24 | |
| 25 | class FrameCombiner { |
| 26 | public: |
Alex Loiko | 507e8d1 | 2018-02-27 13:51:47 +0100 | [diff] [blame^] | 27 | enum class LimiterType { kNoLimiter, kApmAgcLimiter, kApmAgc2Limiter }; |
| 28 | explicit FrameCombiner(LimiterType limiter_type); |
| 29 | explicit FrameCombiner(bool use_limiter); |
aleloi | 24899e5 | 2017-02-21 05:06:29 -0800 | [diff] [blame] | 30 | ~FrameCombiner(); |
| 31 | |
| 32 | // Combine several frames into one. Assumes sample_rate, |
| 33 | // samples_per_channel of the input frames match the parameters. The |
aleloi | 2c9306e | 2017-03-29 04:25:16 -0700 | [diff] [blame] | 34 | // parameters 'number_of_channels' and 'sample_rate' are needed |
| 35 | // because 'mix_list' can be empty. The parameter |
| 36 | // 'number_of_streams' is used for determining whether to pass the |
| 37 | // data through a limiter. |
aleloi | 24899e5 | 2017-02-21 05:06:29 -0800 | [diff] [blame] | 38 | void Combine(const std::vector<AudioFrame*>& mix_list, |
| 39 | size_t number_of_channels, |
| 40 | int sample_rate, |
aleloi | 2c9306e | 2017-03-29 04:25:16 -0700 | [diff] [blame] | 41 | size_t number_of_streams, |
Alex Loiko | 507e8d1 | 2018-02-27 13:51:47 +0100 | [diff] [blame^] | 42 | AudioFrame* audio_frame_for_mixing); |
aleloi | 24899e5 | 2017-02-21 05:06:29 -0800 | [diff] [blame] | 43 | |
| 44 | private: |
Alex Loiko | 507e8d1 | 2018-02-27 13:51:47 +0100 | [diff] [blame^] | 45 | const LimiterType limiter_type_; |
| 46 | std::unique_ptr<AudioProcessing> apm_agc_limiter_; |
| 47 | std::unique_ptr<ApmDataDumper> data_dumper_; |
| 48 | FixedGainController apm_agc2_limiter_; |
aleloi | 24899e5 | 2017-02-21 05:06:29 -0800 | [diff] [blame] | 49 | }; |
| 50 | } // namespace webrtc |
| 51 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 52 | #endif // MODULES_AUDIO_MIXER_FRAME_COMBINER_H_ |