2017-02-21 05:06:29 -08:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef MODULES_AUDIO_MIXER_FRAME_COMBINER_H_
|
|
|
|
|
#define MODULES_AUDIO_MIXER_FRAME_COMBINER_H_
|
2017-02-21 05:06:29 -08:00
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
2018-06-21 12:04:05 +02:00
|
|
|
#include "api/audio/audio_frame.h"
|
2018-11-01 21:31:38 +01:00
|
|
|
#include "modules/audio_processing/agc2/limiter.h"
|
2017-02-21 05:06:29 -08:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
2018-02-27 13:51:47 +01:00
|
|
|
class ApmDataDumper;
|
2017-02-21 05:06:29 -08:00
|
|
|
|
|
|
|
|
class FrameCombiner {
|
|
|
|
|
public:
|
2018-02-27 13:51:47 +01:00
|
|
|
enum class LimiterType { kNoLimiter, kApmAgcLimiter, kApmAgc2Limiter };
|
|
|
|
|
explicit FrameCombiner(bool use_limiter);
|
2017-02-21 05:06:29 -08:00
|
|
|
~FrameCombiner();
|
|
|
|
|
|
|
|
|
|
// Combine several frames into one. Assumes sample_rate,
|
|
|
|
|
// samples_per_channel of the input frames match the parameters. The
|
2017-03-29 04:25:16 -07:00
|
|
|
// parameters 'number_of_channels' and 'sample_rate' are needed
|
|
|
|
|
// because 'mix_list' can be empty. The parameter
|
|
|
|
|
// 'number_of_streams' is used for determining whether to pass the
|
|
|
|
|
// data through a limiter.
|
2017-02-21 05:06:29 -08:00
|
|
|
void Combine(const std::vector<AudioFrame*>& mix_list,
|
|
|
|
|
size_t number_of_channels,
|
|
|
|
|
int sample_rate,
|
2017-03-29 04:25:16 -07:00
|
|
|
size_t number_of_streams,
|
2018-02-27 13:51:47 +01:00
|
|
|
AudioFrame* audio_frame_for_mixing);
|
2017-02-21 05:06:29 -08:00
|
|
|
|
2019-01-28 16:38:38 +01:00
|
|
|
// Stereo, 48 kHz, 10 ms.
|
|
|
|
|
static constexpr size_t kMaximumNumberOfChannels = 8;
|
|
|
|
|
static constexpr size_t kMaximumChannelSize = 48 * 10;
|
|
|
|
|
|
|
|
|
|
using MixingBuffer = std::array<std::array<float, kMaximumChannelSize>,
|
|
|
|
|
kMaximumNumberOfChannels>;
|
|
|
|
|
|
2017-02-21 05:06:29 -08:00
|
|
|
private:
|
2018-03-14 12:27:05 +01:00
|
|
|
void LogMixingStats(const std::vector<AudioFrame*>& mix_list,
|
|
|
|
|
int sample_rate,
|
|
|
|
|
size_t number_of_streams) const;
|
|
|
|
|
|
2018-02-27 13:51:47 +01:00
|
|
|
std::unique_ptr<ApmDataDumper> data_dumper_;
|
2019-01-28 16:38:38 +01:00
|
|
|
std::unique_ptr<MixingBuffer> mixing_buffer_;
|
2018-11-01 21:31:38 +01:00
|
|
|
Limiter limiter_;
|
2018-06-21 12:04:05 +02:00
|
|
|
const bool use_limiter_;
|
2018-03-14 12:27:05 +01:00
|
|
|
mutable int uma_logging_counter_ = 0;
|
2017-02-21 05:06:29 -08:00
|
|
|
};
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // MODULES_AUDIO_MIXER_FRAME_COMBINER_H_
|