mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-14 06:10:40 +01:00

In https://webrtc-review.googlesource.com/c/src/+/1560 we moved WebRTC from src/webrtc to src/ (in order to preserve an healthy git history). This CL takes care of fixing header guards, #include paths, etc... NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true TBR=tommi@webrtc.org Bug: chromium:611808 Change-Id: Iea91618212bee0af16aa3f05071eab8f93706578 Reviewed-on: https://webrtc-review.googlesource.com/1561 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Henrik Kjellander <kjellander@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#19846}
79 lines
2.5 KiB
C++
79 lines
2.5 KiB
C++
/*
|
|
* 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 <memory>
|
|
|
|
#include "modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.h"
|
|
#include "modules/audio_coding/neteq/tools/neteq_quality_test.h"
|
|
#include "rtc_base/checks.h"
|
|
#include "rtc_base/flags.h"
|
|
#include "rtc_base/safe_conversions.h"
|
|
#include "test/testsupport/fileutils.h"
|
|
|
|
using testing::InitGoogleTest;
|
|
|
|
namespace webrtc {
|
|
namespace test {
|
|
namespace {
|
|
static const int kInputSampleRateKhz = 8;
|
|
static const int kOutputSampleRateKhz = 8;
|
|
|
|
DEFINE_int(frame_size_ms, 20, "Codec frame size (milliseconds).");
|
|
|
|
} // namespace
|
|
|
|
class NetEqIlbcQualityTest : public NetEqQualityTest {
|
|
protected:
|
|
NetEqIlbcQualityTest()
|
|
: NetEqQualityTest(FLAG_frame_size_ms,
|
|
kInputSampleRateKhz,
|
|
kOutputSampleRateKhz,
|
|
NetEqDecoder::kDecoderILBC) {
|
|
// Flag validation
|
|
RTC_CHECK(FLAG_frame_size_ms == 20 || FLAG_frame_size_ms == 30 ||
|
|
FLAG_frame_size_ms == 40 || FLAG_frame_size_ms == 60)
|
|
<< "Invalid frame size, should be 20, 30, 40, or 60 ms.";
|
|
}
|
|
|
|
void SetUp() override {
|
|
ASSERT_EQ(1u, channels_) << "iLBC supports only mono audio.";
|
|
AudioEncoderIlbcConfig config;
|
|
config.frame_size_ms = FLAG_frame_size_ms;
|
|
encoder_.reset(new AudioEncoderIlbcImpl(config, 102));
|
|
NetEqQualityTest::SetUp();
|
|
}
|
|
|
|
int EncodeBlock(int16_t* in_data,
|
|
size_t block_size_samples,
|
|
rtc::Buffer* payload, size_t max_bytes) override {
|
|
const size_t kFrameSizeSamples = 80; // Samples per 10 ms.
|
|
size_t encoded_samples = 0;
|
|
uint32_t dummy_timestamp = 0;
|
|
AudioEncoder::EncodedInfo info;
|
|
do {
|
|
info = encoder_->Encode(dummy_timestamp,
|
|
rtc::ArrayView<const int16_t>(
|
|
in_data + encoded_samples, kFrameSizeSamples),
|
|
payload);
|
|
encoded_samples += kFrameSizeSamples;
|
|
} while (info.encoded_bytes == 0);
|
|
return rtc::checked_cast<int>(info.encoded_bytes);
|
|
}
|
|
|
|
private:
|
|
std::unique_ptr<AudioEncoderIlbcImpl> encoder_;
|
|
};
|
|
|
|
TEST_F(NetEqIlbcQualityTest, Test) {
|
|
Simulate();
|
|
}
|
|
|
|
} // namespace test
|
|
} // namespace webrtc
|