Moving src/webrtc into src/.

In order to eliminate the WebRTC Subtree mirror in Chromium, 
WebRTC is moving the content of the src/webrtc directory up
to the src/ directory.

NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
TBR=tommi@webrtc.org

Bug: chromium:611808
Change-Id: Iac59c5b51b950f174119565bac87955a7994bc38
Reviewed-on: https://webrtc-review.googlesource.com/1560
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Henrik Kjellander <kjellander@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#19845}
This commit is contained in:
Mirko Bonadei
2017-09-15 06:15:48 +02:00
committed by Commit Bot
parent 6674846b4a
commit bb547203bf
4576 changed files with 1092 additions and 1196 deletions

View File

@ -0,0 +1,63 @@
/*
* Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
*
* 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.
*/
#include "webrtc/modules/audio_coding/codecs/pcm16b/audio_decoder_pcm16b.h"
#include "webrtc/modules/audio_coding/codecs/legacy_encoded_audio_frame.h"
#include "webrtc/modules/audio_coding/codecs/pcm16b/pcm16b.h"
#include "webrtc/rtc_base/checks.h"
namespace webrtc {
AudioDecoderPcm16B::AudioDecoderPcm16B(int sample_rate_hz, size_t num_channels)
: sample_rate_hz_(sample_rate_hz), num_channels_(num_channels) {
RTC_DCHECK(sample_rate_hz == 8000 || sample_rate_hz == 16000 ||
sample_rate_hz == 32000 || sample_rate_hz == 48000)
<< "Unsupported sample rate " << sample_rate_hz;
RTC_DCHECK_GE(num_channels, 1);
}
void AudioDecoderPcm16B::Reset() {}
int AudioDecoderPcm16B::SampleRateHz() const {
return sample_rate_hz_;
}
size_t AudioDecoderPcm16B::Channels() const {
return num_channels_;
}
int AudioDecoderPcm16B::DecodeInternal(const uint8_t* encoded,
size_t encoded_len,
int sample_rate_hz,
int16_t* decoded,
SpeechType* speech_type) {
RTC_DCHECK_EQ(sample_rate_hz_, sample_rate_hz);
size_t ret = WebRtcPcm16b_Decode(encoded, encoded_len, decoded);
*speech_type = ConvertSpeechType(1);
return static_cast<int>(ret);
}
std::vector<AudioDecoder::ParseResult> AudioDecoderPcm16B::ParsePayload(
rtc::Buffer&& payload,
uint32_t timestamp) {
const int samples_per_ms = rtc::CheckedDivExact(sample_rate_hz_, 1000);
return LegacyEncodedAudioFrame::SplitBySamples(
this, std::move(payload), timestamp, samples_per_ms * 2 * num_channels_,
samples_per_ms);
}
int AudioDecoderPcm16B::PacketDuration(const uint8_t* encoded,
size_t encoded_len) const {
// Two encoded byte per sample per channel.
return static_cast<int>(encoded_len / (2 * Channels()));
}
} // namespace webrtc

View File

@ -0,0 +1,44 @@
/*
* Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
*
* 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.
*/
#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_PCM16B_AUDIO_DECODER_PCM16B_H_
#define WEBRTC_MODULES_AUDIO_CODING_CODECS_PCM16B_AUDIO_DECODER_PCM16B_H_
#include "webrtc/api/audio_codecs/audio_decoder.h"
#include "webrtc/rtc_base/constructormagic.h"
namespace webrtc {
class AudioDecoderPcm16B final : public AudioDecoder {
public:
AudioDecoderPcm16B(int sample_rate_hz, size_t num_channels);
void Reset() override;
std::vector<ParseResult> ParsePayload(rtc::Buffer&& payload,
uint32_t timestamp) override;
int PacketDuration(const uint8_t* encoded, size_t encoded_len) const override;
int SampleRateHz() const override;
size_t Channels() const override;
protected:
int DecodeInternal(const uint8_t* encoded,
size_t encoded_len,
int sample_rate_hz,
int16_t* decoded,
SpeechType* speech_type) override;
private:
const int sample_rate_hz_;
const size_t num_channels_;
RTC_DISALLOW_COPY_AND_ASSIGN(AudioDecoderPcm16B);
};
} // namespace webrtc
#endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_PCM16B_AUDIO_DECODER_PCM16B_H_

View File

@ -0,0 +1,60 @@
/*
* Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
*
* 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.
*/
#include "webrtc/modules/audio_coding/codecs/pcm16b/audio_encoder_pcm16b.h"
#include <algorithm>
#include "webrtc/common_types.h"
#include "webrtc/modules/audio_coding/codecs/pcm16b/pcm16b.h"
#include "webrtc/rtc_base/checks.h"
#include "webrtc/rtc_base/safe_conversions.h"
namespace webrtc {
size_t AudioEncoderPcm16B::EncodeCall(const int16_t* audio,
size_t input_len,
uint8_t* encoded) {
return WebRtcPcm16b_Encode(audio, input_len, encoded);
}
size_t AudioEncoderPcm16B::BytesPerSample() const {
return 2;
}
AudioEncoder::CodecType AudioEncoderPcm16B::GetCodecType() const {
return CodecType::kOther;
}
namespace {
AudioEncoderPcm16B::Config CreateConfig(const CodecInst& codec_inst) {
AudioEncoderPcm16B::Config config;
config.num_channels = codec_inst.channels;
config.sample_rate_hz = codec_inst.plfreq;
config.frame_size_ms = rtc::CheckedDivExact(
codec_inst.pacsize, rtc::CheckedDivExact(config.sample_rate_hz, 1000));
config.payload_type = codec_inst.pltype;
return config;
}
} // namespace
bool AudioEncoderPcm16B::Config::IsOk() const {
if ((sample_rate_hz != 8000) && (sample_rate_hz != 16000) &&
(sample_rate_hz != 32000) && (sample_rate_hz != 48000))
return false;
return AudioEncoderPcm::Config::IsOk();
}
AudioEncoderPcm16B::AudioEncoderPcm16B(const CodecInst& codec_inst)
: AudioEncoderPcm16B(CreateConfig(codec_inst)) {}
} // namespace webrtc

View File

@ -0,0 +1,50 @@
/*
* Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
*
* 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.
*/
#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_PCM16B_AUDIO_ENCODER_PCM16B_H_
#define WEBRTC_MODULES_AUDIO_CODING_CODECS_PCM16B_AUDIO_ENCODER_PCM16B_H_
#include "webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.h"
#include "webrtc/rtc_base/constructormagic.h"
namespace webrtc {
struct CodecInst;
class AudioEncoderPcm16B final : public AudioEncoderPcm {
public:
struct Config : public AudioEncoderPcm::Config {
public:
Config() : AudioEncoderPcm::Config(107), sample_rate_hz(8000) {}
bool IsOk() const;
int sample_rate_hz;
};
explicit AudioEncoderPcm16B(const Config& config)
: AudioEncoderPcm(config, config.sample_rate_hz) {}
explicit AudioEncoderPcm16B(const CodecInst& codec_inst);
protected:
size_t EncodeCall(const int16_t* audio,
size_t input_len,
uint8_t* encoded) override;
size_t BytesPerSample() const override;
AudioEncoder::CodecType GetCodecType() const override;
private:
RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderPcm16B);
};
} // namespace webrtc
#endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_PCM16B_AUDIO_ENCODER_PCM16B_H_

View File

@ -0,0 +1,34 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* 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.
*/
#include "pcm16b.h"
#include "webrtc/typedefs.h"
size_t WebRtcPcm16b_Encode(const int16_t* speech,
size_t len,
uint8_t* encoded) {
size_t i;
for (i = 0; i < len; ++i) {
uint16_t s = speech[i];
encoded[2 * i] = s >> 8;
encoded[2 * i + 1] = s;
}
return 2 * len;
}
size_t WebRtcPcm16b_Decode(const uint8_t* encoded,
size_t len,
int16_t* speech) {
size_t i;
for (i = 0; i < len / 2; ++i)
speech[i] = encoded[2 * i] << 8 | encoded[2 * i + 1];
return len / 2;
}

View File

@ -0,0 +1,68 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* 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.
*/
#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_PCM16B_PCM16B_H_
#define WEBRTC_MODULES_AUDIO_CODING_CODECS_PCM16B_PCM16B_H_
/*
* Define the fixpoint numeric formats
*/
#include <stddef.h>
#include "webrtc/typedefs.h"
#ifdef __cplusplus
extern "C" {
#endif
/****************************************************************************
* WebRtcPcm16b_Encode(...)
*
* "Encode" a sample vector to 16 bit linear (Encoded standard is big endian)
*
* Input:
* - speech : Input speech vector
* - len : Number of samples in speech vector
*
* Output:
* - encoded : Encoded data vector (big endian 16 bit)
*
* Returned value : Length (in bytes) of coded data.
* Always equal to twice the len input parameter.
*/
size_t WebRtcPcm16b_Encode(const int16_t* speech,
size_t len,
uint8_t* encoded);
/****************************************************************************
* WebRtcPcm16b_Decode(...)
*
* "Decode" a vector to 16 bit linear (Encoded standard is big endian)
*
* Input:
* - encoded : Encoded data vector (big endian 16 bit)
* - len : Number of bytes in encoded
*
* Output:
* - speech : Decoded speech vector
*
* Returned value : Samples in speech
*/
size_t WebRtcPcm16b_Decode(const uint8_t* encoded,
size_t len,
int16_t* speech);
#ifdef __cplusplus
}
#endif
#endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_PCM16B_PCM16B_H_ */

View File

@ -0,0 +1,25 @@
/*
* Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
*
* 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.
*/
#include "webrtc/modules/audio_coding/codecs/pcm16b/pcm16b_common.h"
namespace webrtc {
void Pcm16BAppendSupportedCodecSpecs(std::vector<AudioCodecSpec>* specs) {
for (uint8_t num_channels : {1, 2}) {
for (int sample_rate_hz : {8000, 16000, 32000}) {
specs->push_back(
{{"L16", sample_rate_hz, num_channels},
{sample_rate_hz, num_channels, sample_rate_hz * num_channels * 16}});
}
}
}
} // namespace webrtc

View File

@ -0,0 +1,22 @@
/*
* Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
*
* 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.
*/
#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_PCM16B_PCM16B_COMMON_H_
#define WEBRTC_MODULES_AUDIO_CODING_CODECS_PCM16B_PCM16B_COMMON_H_
#include <vector>
#include "webrtc/api/audio_codecs/audio_decoder_factory.h"
namespace webrtc {
void Pcm16BAppendSupportedCodecSpecs(std::vector<AudioCodecSpec>* specs);
}
#endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_PCM16B_PCM16B_COMMON_H_