blob: f6fa35bf73d0473b78b5a56fc501398b3c01a569 [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
pbos@webrtc.org956aa7e2013-05-21 13:52:32 +000018#include "webrtc/typedefs.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000019
andrew@webrtc.org40ee3d02014-04-03 21:56:01 +000020namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000021
andrew@webrtc.org40ee3d02014-04-03 21:56:01 +000022class AudioFrame;
23class PushResampler;
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
andrew@webrtc.org40ee3d02014-04-03 21:56:01 +000027// Upmix or downmix and resample the audio in |src_frame| to |dst_frame|.
28// Expects |dst_frame| to have its |num_channels_| and |sample_rate_hz_| set to
29// the desired values. Updates |samples_per_channel_| accordingly.
30//
31// On failure, returns -1 and copies |src_frame| to |dst_frame|.
32void RemixAndResample(const AudioFrame& src_frame,
33 PushResampler* resampler,
34 AudioFrame* dst_frame);
niklase@google.com470e71d2011-07-07 08:21:25 +000035
andrew@webrtc.org40ee3d02014-04-03 21:56:01 +000036// Downmix and downsample the audio in |src_data| to |dst_af| as necessary,
37// specified by |codec_num_channels| and |codec_rate_hz|. |mono_buffer| is
38// temporary space and must be of sufficient size to hold the downmixed source
39// audio (recommend using a size of kMaxMonoDataSizeSamples).
40void DownConvertToCodecFormat(const int16_t* src_data,
41 int samples_per_channel,
42 int num_channels,
43 int sample_rate_hz,
44 int codec_num_channels,
45 int codec_rate_hz,
46 int16_t* mono_buffer,
47 PushResampler* resampler,
48 AudioFrame* dst_af);
niklase@google.com470e71d2011-07-07 08:21:25 +000049
andrew@webrtc.org40ee3d02014-04-03 21:56:01 +000050void MixWithSat(int16_t target[],
51 int target_channel,
52 const int16_t source[],
53 int source_channel,
54 int source_len);
niklase@google.com470e71d2011-07-07 08:21:25 +000055
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +000056} // namespace voe
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +000057} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000058
andrew@webrtc.org40ee3d02014-04-03 21:56:01 +000059#endif // WEBRTC_VOICE_ENGINE_UTILITY_H_