blob: 1c1cd53eff3115ee12ec186fefeb037fdc054e06 [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 Loiko8396e342018-06-21 12:04:05 +020017#include "api/audio/audio_frame.h"
Alessio Bazzica3e4c77f2018-11-01 21:31:38 +010018#include "modules/audio_processing/agc2/limiter.h"
aleloi24899e52017-02-21 05:06:29 -080019
20namespace webrtc {
Alex Loiko507e8d12018-02-27 13:51:47 +010021class ApmDataDumper;
aleloi24899e52017-02-21 05:06:29 -080022
23class FrameCombiner {
24 public:
Alex Loiko507e8d12018-02-27 13:51:47 +010025 enum class LimiterType { kNoLimiter, kApmAgcLimiter, kApmAgc2Limiter };
Alex Loiko507e8d12018-02-27 13:51:47 +010026 explicit FrameCombiner(bool use_limiter);
aleloi24899e52017-02-21 05:06:29 -080027 ~FrameCombiner();
28
29 // Combine several frames into one. Assumes sample_rate,
30 // samples_per_channel of the input frames match the parameters. The
aleloi2c9306e2017-03-29 04:25:16 -070031 // parameters 'number_of_channels' and 'sample_rate' are needed
32 // because 'mix_list' can be empty. The parameter
33 // 'number_of_streams' is used for determining whether to pass the
34 // data through a limiter.
aleloi24899e52017-02-21 05:06:29 -080035 void Combine(const std::vector<AudioFrame*>& mix_list,
36 size_t number_of_channels,
37 int sample_rate,
aleloi2c9306e2017-03-29 04:25:16 -070038 size_t number_of_streams,
Alex Loiko507e8d12018-02-27 13:51:47 +010039 AudioFrame* audio_frame_for_mixing);
aleloi24899e52017-02-21 05:06:29 -080040
41 private:
Alex Loiko6f2fcb42018-03-14 12:27:05 +010042 void LogMixingStats(const std::vector<AudioFrame*>& mix_list,
43 int sample_rate,
44 size_t number_of_streams) const;
45
Alex Loiko507e8d12018-02-27 13:51:47 +010046 std::unique_ptr<ApmDataDumper> data_dumper_;
Alessio Bazzica3e4c77f2018-11-01 21:31:38 +010047 Limiter limiter_;
Alex Loiko8396e342018-06-21 12:04:05 +020048 const bool use_limiter_;
Alex Loiko6f2fcb42018-03-14 12:27:05 +010049 mutable int uma_logging_counter_ = 0;
aleloi24899e52017-02-21 05:06:29 -080050};
51} // namespace webrtc
52
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020053#endif // MODULES_AUDIO_MIXER_FRAME_COMBINER_H_