2011-07-07 08:21:25 +00:00
|
|
|
/*
|
2012-03-29 10:39:44 +00:00
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
2011-07-07 08:21:25 +00:00
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Contains functions often used by different parts of VoiceEngine.
|
|
|
|
|
*/
|
|
|
|
|
|
Consolidate audio conversion from Channel and TransmitMixer.
Replace the two versions with a single DownConvertToCodecFormat. As
mentioned in comments, this could be further consolidated with
RemixAndResample but we should write a full audio converter class in
that case.
Along the way:
- Fix the bug present in Channel::Demultiplex with mono input and a
stereo codec.
- Remove the 32 kHz max from the OnDataAvailable path. This avoids a
48 -> 32 -> 48 conversion when VoE is passed 48 kHz audio; instead we
get a straight pass-through to ACM. The 32 kHz conversion is still
needed in the RecordedDataIsAvailable path until APM natively supports
48 kHz.
- Merge resampler improvements from ACM1 to ACM2. This allows ACM to
handle 44.1 kHz audio passed to VoE and was originally done here:
https://webrtc-codereview.appspot.com/1590004
- Reuse the RemixAndResample unit tests for DownConvertToCodecFormat.
- Remove unused functions from utility.cc.
BUG=3155,3000,b/12867572
TESTED=voe_cmd_test using both the OnDataAvailable and
RecordedDataIsAvailable paths, with a captured audio format of all
combinations of {44.1,48} kHz and {1,2} channels, running through all
codecs, and finally using both ACM1 and ACM2.
R=henrika@webrtc.org, turaj@webrtc.org, xians@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/11019005
git-svn-id: http://webrtc.googlecode.com/svn/trunk@5843 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-04-03 21:56:01 +00:00
|
|
|
#ifndef WEBRTC_VOICE_ENGINE_UTILITY_H_
|
|
|
|
|
#define WEBRTC_VOICE_ENGINE_UTILITY_H_
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2013-05-21 13:52:32 +00:00
|
|
|
#include "webrtc/typedefs.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
|
Consolidate audio conversion from Channel and TransmitMixer.
Replace the two versions with a single DownConvertToCodecFormat. As
mentioned in comments, this could be further consolidated with
RemixAndResample but we should write a full audio converter class in
that case.
Along the way:
- Fix the bug present in Channel::Demultiplex with mono input and a
stereo codec.
- Remove the 32 kHz max from the OnDataAvailable path. This avoids a
48 -> 32 -> 48 conversion when VoE is passed 48 kHz audio; instead we
get a straight pass-through to ACM. The 32 kHz conversion is still
needed in the RecordedDataIsAvailable path until APM natively supports
48 kHz.
- Merge resampler improvements from ACM1 to ACM2. This allows ACM to
handle 44.1 kHz audio passed to VoE and was originally done here:
https://webrtc-codereview.appspot.com/1590004
- Reuse the RemixAndResample unit tests for DownConvertToCodecFormat.
- Remove unused functions from utility.cc.
BUG=3155,3000,b/12867572
TESTED=voe_cmd_test using both the OnDataAvailable and
RecordedDataIsAvailable paths, with a captured audio format of all
combinations of {44.1,48} kHz and {1,2} channels, running through all
codecs, and finally using both ACM1 and ACM2.
R=henrika@webrtc.org, turaj@webrtc.org, xians@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/11019005
git-svn-id: http://webrtc.googlecode.com/svn/trunk@5843 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-04-03 21:56:01 +00:00
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
class AudioFrame;
|
|
|
|
|
class PushResampler;
|
|
|
|
|
|
|
|
|
|
namespace voe {
|
|
|
|
|
|
|
|
|
|
// Upmix or downmix and resample the audio in |src_frame| to |dst_frame|.
|
|
|
|
|
// Expects |dst_frame| to have its |num_channels_| and |sample_rate_hz_| set to
|
|
|
|
|
// the desired values. Updates |samples_per_channel_| accordingly.
|
|
|
|
|
//
|
|
|
|
|
// On failure, returns -1 and copies |src_frame| to |dst_frame|.
|
|
|
|
|
void RemixAndResample(const AudioFrame& src_frame,
|
|
|
|
|
PushResampler* resampler,
|
|
|
|
|
AudioFrame* dst_frame);
|
|
|
|
|
|
|
|
|
|
// Downmix and downsample the audio in |src_data| to |dst_af| as necessary,
|
|
|
|
|
// specified by |codec_num_channels| and |codec_rate_hz|. |mono_buffer| is
|
|
|
|
|
// temporary space and must be of sufficient size to hold the downmixed source
|
|
|
|
|
// audio (recommend using a size of kMaxMonoDataSizeSamples).
|
|
|
|
|
void DownConvertToCodecFormat(const int16_t* src_data,
|
|
|
|
|
int samples_per_channel,
|
|
|
|
|
int num_channels,
|
|
|
|
|
int sample_rate_hz,
|
|
|
|
|
int codec_num_channels,
|
|
|
|
|
int codec_rate_hz,
|
|
|
|
|
int16_t* mono_buffer,
|
|
|
|
|
PushResampler* resampler,
|
|
|
|
|
AudioFrame* dst_af);
|
|
|
|
|
|
|
|
|
|
void MixWithSat(int16_t target[],
|
|
|
|
|
int target_channel,
|
|
|
|
|
const int16_t source[],
|
|
|
|
|
int source_channel,
|
|
|
|
|
int source_len);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2013-07-03 15:12:26 +00:00
|
|
|
} // namespace voe
|
|
|
|
|
} // namespace webrtc
|
2011-07-07 08:21:25 +00:00
|
|
|
|
Consolidate audio conversion from Channel and TransmitMixer.
Replace the two versions with a single DownConvertToCodecFormat. As
mentioned in comments, this could be further consolidated with
RemixAndResample but we should write a full audio converter class in
that case.
Along the way:
- Fix the bug present in Channel::Demultiplex with mono input and a
stereo codec.
- Remove the 32 kHz max from the OnDataAvailable path. This avoids a
48 -> 32 -> 48 conversion when VoE is passed 48 kHz audio; instead we
get a straight pass-through to ACM. The 32 kHz conversion is still
needed in the RecordedDataIsAvailable path until APM natively supports
48 kHz.
- Merge resampler improvements from ACM1 to ACM2. This allows ACM to
handle 44.1 kHz audio passed to VoE and was originally done here:
https://webrtc-codereview.appspot.com/1590004
- Reuse the RemixAndResample unit tests for DownConvertToCodecFormat.
- Remove unused functions from utility.cc.
BUG=3155,3000,b/12867572
TESTED=voe_cmd_test using both the OnDataAvailable and
RecordedDataIsAvailable paths, with a captured audio format of all
combinations of {44.1,48} kHz and {1,2} channels, running through all
codecs, and finally using both ACM1 and ACM2.
R=henrika@webrtc.org, turaj@webrtc.org, xians@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/11019005
git-svn-id: http://webrtc.googlecode.com/svn/trunk@5843 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-04-03 21:56:01 +00:00
|
|
|
#endif // WEBRTC_VOICE_ENGINE_UTILITY_H_
|