blob: 4139f05cfddae809543f2a64b100d28fc98b3284 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
braveyao@webrtc.orgd7131432012-03-29 10:39:44 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
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/*
12 * Contains functions often used by different parts of VoiceEngine.
13 */
14
andrew@webrtc.org40ee3d02014-04-03 21:56:01 +000015#ifndef WEBRTC_VOICE_ENGINE_UTILITY_H_
16#define WEBRTC_VOICE_ENGINE_UTILITY_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000017
andrew@webrtc.orgf5a33f12014-04-19 00:32:07 +000018#include "webrtc/common_audio/resampler/include/push_resampler.h"
pbos@webrtc.org956aa7e2013-05-21 13:52:32 +000019#include "webrtc/typedefs.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000020
andrew@webrtc.org40ee3d02014-04-03 21:56:01 +000021namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000022
andrew@webrtc.org40ee3d02014-04-03 21:56:01 +000023class AudioFrame;
niklase@google.com470e71d2011-07-07 08:21:25 +000024
andrew@webrtc.org40ee3d02014-04-03 21:56:01 +000025namespace voe {
niklase@google.com470e71d2011-07-07 08:21:25 +000026
Alejandro Luebscdfe20b2015-09-23 12:49:12 -070027// Upmix or downmix and resample the audio to |dst_frame|. Expects |dst_frame|
28// to have its sample rate and channels members set to the desired values.
29// Updates the |samples_per_channel_| member accordingly.
30//
31// This version has an AudioFrame |src_frame| as input and sets the output
32// |timestamp_|, |elapsed_time_ms_| and |ntp_time_ms_| members equals to the
33// input ones.
andrew@webrtc.org40ee3d02014-04-03 21:56:01 +000034void RemixAndResample(const AudioFrame& src_frame,
andrew@webrtc.orgf5a33f12014-04-19 00:32:07 +000035 PushResampler<int16_t>* resampler,
andrew@webrtc.org40ee3d02014-04-03 21:56:01 +000036 AudioFrame* dst_frame);
niklase@google.com470e71d2011-07-07 08:21:25 +000037
Alejandro Luebscdfe20b2015-09-23 12:49:12 -070038// This version has a pointer to the samples |src_data| as input and receives
39// |samples_per_channel|, |num_channels| and |sample_rate_hz| of the data as
40// parameters.
41void RemixAndResample(const int16_t* src_data,
42 size_t samples_per_channel,
Peter Kasting69558702016-01-12 16:26:35 -080043 size_t num_channels,
Alejandro Luebscdfe20b2015-09-23 12:49:12 -070044 int sample_rate_hz,
45 PushResampler<int16_t>* resampler,
46 AudioFrame* dst_frame);
niklase@google.com470e71d2011-07-07 08:21:25 +000047
andrew@webrtc.org40ee3d02014-04-03 21:56:01 +000048void MixWithSat(int16_t target[],
Peter Kasting69558702016-01-12 16:26:35 -080049 size_t target_channel,
andrew@webrtc.org40ee3d02014-04-03 21:56:01 +000050 const int16_t source[],
Peter Kasting69558702016-01-12 16:26:35 -080051 size_t source_channel,
Peter Kastingdce40cf2015-08-24 14:52:23 -070052 size_t source_len);
niklase@google.com470e71d2011-07-07 08:21:25 +000053
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +000054} // namespace voe
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +000055} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000056
andrew@webrtc.org40ee3d02014-04-03 21:56:01 +000057#endif // WEBRTC_VOICE_ENGINE_UTILITY_H_