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 11 #ifndef MODULES_AUDIO_MIXER_FRAME_COMBINER_H_ 12 #define MODULES_AUDIO_MIXER_FRAME_COMBINER_H_ 13 14 #include <memory> 15 #include <vector> 16 17 #include "api/audio/audio_frame.h" 18 #include "modules/audio_processing/agc2/limiter.h" 19 20 namespace webrtc { 21 class ApmDataDumper; 22 23 class FrameCombiner { 24 public: 25 enum class LimiterType { kNoLimiter, kApmAgcLimiter, kApmAgc2Limiter }; 26 explicit FrameCombiner(bool use_limiter); 27 ~FrameCombiner(); 28 29 // Combine several frames into one. Assumes sample_rate, 30 // samples_per_channel of the input frames match the parameters. The 31 // 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. 35 void Combine(const std::vector<AudioFrame*>& mix_list, 36 size_t number_of_channels, 37 int sample_rate, 38 size_t number_of_streams, 39 AudioFrame* audio_frame_for_mixing); 40 41 // Stereo, 48 kHz, 10 ms. 42 static constexpr size_t kMaximumNumberOfChannels = 8; 43 static constexpr size_t kMaximumChannelSize = 48 * 10; 44 45 using MixingBuffer = std::array<std::array<float, kMaximumChannelSize>, 46 kMaximumNumberOfChannels>; 47 48 private: 49 void LogMixingStats(const std::vector<AudioFrame*>& mix_list, 50 int sample_rate, 51 size_t number_of_streams) const; 52 53 std::unique_ptr<ApmDataDumper> data_dumper_; 54 std::unique_ptr<MixingBuffer> mixing_buffer_; 55 Limiter limiter_; 56 const bool use_limiter_; 57 mutable int uma_logging_counter_ = 0; 58 }; 59 } // namespace webrtc 60 61 #endif // MODULES_AUDIO_MIXER_FRAME_COMBINER_H_ 62