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/*
12 *  Contains functions often used by different parts of VoiceEngine.
13 */
14
15#ifndef WEBRTC_VOICE_ENGINE_UTILITY_H_
16#define WEBRTC_VOICE_ENGINE_UTILITY_H_
17
18#include "webrtc/common_audio/resampler/include/push_resampler.h"
19#include "webrtc/typedefs.h"
20
21namespace webrtc {
22
23class AudioFrame;
24
25namespace voe {
26
27// 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.
34void RemixAndResample(const AudioFrame& src_frame,
35                      PushResampler<int16_t>* resampler,
36                      AudioFrame* dst_frame);
37
38// 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,
43                      size_t num_channels,
44                      int sample_rate_hz,
45                      PushResampler<int16_t>* resampler,
46                      AudioFrame* dst_frame);
47
48void MixWithSat(int16_t target[],
49                size_t target_channel,
50                const int16_t source[],
51                size_t source_channel,
52                size_t source_len);
53
54}  // namespace voe
55}  // namespace webrtc
56
57#endif  // WEBRTC_VOICE_ENGINE_UTILITY_H_
58