niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 1 | /* |
braveyao@webrtc.org | d713143 | 2012-03-29 10:39:44 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 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 | |
Fredrik Solenberg | a8b7c7f | 2018-01-17 10:18:31 | [diff] [blame] | 11 | #ifndef AUDIO_REMIX_RESAMPLE_H_ |
| 12 | #define AUDIO_REMIX_RESAMPLE_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 13 | |
Fredrik Solenberg | bbf21a3 | 2018-04-12 20:44:09 | [diff] [blame] | 14 | #include "api/audio/audio_frame.h" |
Tommi | 32c3398 | 2024-07-03 07:34:18 | [diff] [blame] | 15 | #include "api/audio/audio_view.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 16 | #include "common_audio/resampler/include/push_resampler.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 17 | |
andrew@webrtc.org | 40ee3d0 | 2014-04-03 21:56:01 | [diff] [blame] | 18 | namespace webrtc { |
andrew@webrtc.org | 40ee3d0 | 2014-04-03 21:56:01 | [diff] [blame] | 19 | namespace voe { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 20 | |
Tommi | 1f36798 | 2024-04-30 12:04:44 | [diff] [blame] | 21 | // Note: The RemixAndResample methods assume 10ms buffer sizes. |
| 22 | |
Artem Titov | b0ea637 | 2021-07-26 09:47:07 | [diff] [blame] | 23 | // Upmix or downmix and resample the audio to `dst_frame`. Expects `dst_frame` |
Alejandro Luebs | cdfe20b | 2015-09-23 19:49:12 | [diff] [blame] | 24 | // to have its sample rate and channels members set to the desired values. |
Artem Titov | b0ea637 | 2021-07-26 09:47:07 | [diff] [blame] | 25 | // Updates the `samples_per_channel_` member accordingly. |
Alejandro Luebs | cdfe20b | 2015-09-23 19:49:12 | [diff] [blame] | 26 | // |
Artem Titov | b0ea637 | 2021-07-26 09:47:07 | [diff] [blame] | 27 | // This version has an AudioFrame `src_frame` as input and sets the output |
| 28 | // `timestamp_`, `elapsed_time_ms_` and `ntp_time_ms_` members equals to the |
Alejandro Luebs | cdfe20b | 2015-09-23 19:49:12 | [diff] [blame] | 29 | // input ones. |
andrew@webrtc.org | 40ee3d0 | 2014-04-03 21:56:01 | [diff] [blame] | 30 | void RemixAndResample(const AudioFrame& src_frame, |
andrew@webrtc.org | f5a33f1 | 2014-04-19 00:32:07 | [diff] [blame] | 31 | PushResampler<int16_t>* resampler, |
andrew@webrtc.org | 40ee3d0 | 2014-04-03 21:56:01 | [diff] [blame] | 32 | AudioFrame* dst_frame); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 33 | |
Tommi | 32c3398 | 2024-07-03 07:34:18 | [diff] [blame] | 34 | // TODO(tommi): The `sample_rate_hz` argument can probably be removed since it's |
| 35 | // always related to `src_data.samples_per_frame()'. |
| 36 | void RemixAndResample(InterleavedView<const int16_t> src_data, |
Alejandro Luebs | cdfe20b | 2015-09-23 19:49:12 | [diff] [blame] | 37 | int sample_rate_hz, |
| 38 | PushResampler<int16_t>* resampler, |
| 39 | AudioFrame* dst_frame); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 40 | |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 | [diff] [blame] | 41 | } // namespace voe |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 | [diff] [blame] | 42 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 43 | |
Fredrik Solenberg | a8b7c7f | 2018-01-17 10:18:31 | [diff] [blame] | 44 | #endif // AUDIO_REMIX_RESAMPLE_H_ |