xref: /aosp_15_r20/external/webrtc/audio/remix_resample.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
2  *  Copyright (c) 2012 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 AUDIO_REMIX_RESAMPLE_H_
12 #define AUDIO_REMIX_RESAMPLE_H_
13 
14 #include "api/audio/audio_frame.h"
15 #include "common_audio/resampler/include/push_resampler.h"
16 
17 namespace webrtc {
18 namespace voe {
19 
20 // Upmix or downmix and resample the audio to `dst_frame`. Expects `dst_frame`
21 // to have its sample rate and channels members set to the desired values.
22 // Updates the `samples_per_channel_` member accordingly.
23 //
24 // This version has an AudioFrame `src_frame` as input and sets the output
25 // `timestamp_`, `elapsed_time_ms_` and `ntp_time_ms_` members equals to the
26 // input ones.
27 void RemixAndResample(const AudioFrame& src_frame,
28                       PushResampler<int16_t>* resampler,
29                       AudioFrame* dst_frame);
30 
31 // This version has a pointer to the samples `src_data` as input and receives
32 // `samples_per_channel`, `num_channels` and `sample_rate_hz` of the data as
33 // parameters.
34 void RemixAndResample(const int16_t* src_data,
35                       size_t samples_per_channel,
36                       size_t num_channels,
37                       int sample_rate_hz,
38                       PushResampler<int16_t>* resampler,
39                       AudioFrame* dst_frame);
40 
41 }  // namespace voe
42 }  // namespace webrtc
43 
44 #endif  // AUDIO_REMIX_RESAMPLE_H_
45