// Copyright 2012 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // AudioConverter is a complete mixing, resampling, buffering, and channel // mixing solution for converting data from one set of AudioParameters to // another. // // For efficiency, pieces are only invoked when necessary; i.e., // - The resampler is only used if sample rates differ. // - The FIFO is only used if buffer sizes differ. // - The channel mixer is only used if channel layouts differ. // // Additionally, since resampling is the most expensive operation, input mixing // and channel down mixing are done prior to resampling. Likewise, channel up // mixing is performed after resampling. #ifndef MEDIA_BASE_AUDIO_CONVERTER_H_ #define MEDIA_BASE_AUDIO_CONVERTER_H_ #include <list> #include <memory> #include "base/functional/callback.h" #include "base/memory/raw_ptr.h" #include "media/base/audio_glitch_info.h" #include "media/base/audio_parameters.h" #include "media/base/media_export.h" namespace media { class AudioBus; class AudioPullFifo; class ChannelMixer; class MultiChannelResampler; // Converts audio data between two AudioParameters formats. Sample usage: // AudioParameters input(...), output(...); // AudioConverter ac(input, output); // std::unique_ptr<AudioBus> output_audio_bus = AudioBus::Create(output); // ac.AddInput(<AudioConverter::InputCallback* 1>); // ac.AddInput(<AudioConverter::InputCallback* 2>); // ac.Convert(output_audio_bus.get()); // // Convert() will ask for input audio data from each InputCallback and convert // the data into the provided AudioBus. class MEDIA_EXPORT AudioConverter { … }; } // namespace media #endif // MEDIA_BASE_AUDIO_CONVERTER_H_