andrew@webrtc.org | aada86b | 2014-10-27 18:18:17 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2014 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 WEBRTC_COMMON_AUDIO_AUDIO_CONVERTER_H_ |
| 12 | #define WEBRTC_COMMON_AUDIO_AUDIO_CONVERTER_H_ |
| 13 | |
| 14 | // TODO(ajm): Move channel buffer to common_audio. |
| 15 | #include "webrtc/base/constructormagic.h" |
| 16 | #include "webrtc/modules/audio_processing/common.h" |
| 17 | #include "webrtc/system_wrappers/interface/scoped_ptr.h" |
| 18 | #include "webrtc/system_wrappers/interface/scoped_vector.h" |
| 19 | |
| 20 | namespace webrtc { |
| 21 | |
| 22 | class PushSincResampler; |
| 23 | |
| 24 | // Format conversion (remixing and resampling) for audio. Only simple remixing |
| 25 | // conversions are supported: downmix to mono (i.e. |dst_channels| == 1) or |
| 26 | // upmix from mono (i.e. |src_channels == 1|). |
| 27 | // |
| 28 | // The source and destination chunks have the same duration in time; specifying |
| 29 | // the number of frames is equivalent to specifying the sample rates. |
| 30 | class AudioConverter { |
| 31 | public: |
| 32 | AudioConverter(int src_channels, int src_frames, |
| 33 | int dst_channels, int dst_frames); |
| 34 | |
| 35 | void Convert(const float* const* src, |
| 36 | int src_channels, |
| 37 | int src_frames, |
| 38 | int dst_channels, |
| 39 | int dst_frames, |
| 40 | float* const* dest); |
| 41 | |
| 42 | private: |
| 43 | scoped_ptr<ChannelBuffer<float>> downmix_buffer_; |
| 44 | ScopedVector<PushSincResampler> resamplers_; |
| 45 | |
| 46 | DISALLOW_COPY_AND_ASSIGN(AudioConverter); |
| 47 | }; |
| 48 | |
| 49 | } // namespace webrtc |
| 50 | |
| 51 | #endif // WEBRTC_COMMON_AUDIO_AUDIO_CONVERTER_H_ |