mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 13:50:40 +01:00

This is a reland of 5ccdc1331f
Original change's description:
> Prefix flag macros with WEBRTC_.
>
> Macros defined in rtc_base/flags.h are intended to be used to define
> flags in WebRTC's binaries (e.g. tests).
>
> They are currently not prefixed and this could cause problems with
> downstream clients since these names are quite common.
>
> This CL adds the 'WEBRTC_' prefix to them.
>
> Generated with:
>
> for x in DECLARE DEFINE; do
> for y in bool int float string FLAG; do
> git grep -l "\b$x\_$y\b" | \
> xargs sed -i "s/\b$x\_$y\b/WEBRTC_$x\_$y/g"
> done
> done
> git cl format
>
> Bug: webrtc:9884
> Change-Id: I7b524762b6a3e5aa5b2fc2395edd3e1a0fe72591
> Reviewed-on: https://webrtc-review.googlesource.com/c/106682
> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#25270}
TBR=kwiberg@webrtc.org
Bug: webrtc:9884
Change-Id: I5ba5368a231a334d135ed5e6fd7a279629ced8a3
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://webrtc-review.googlesource.com/c/107161
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25277}
80 lines
2.5 KiB
C++
80 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/g711/audio_encoder_pcm.h"
|
|
#include "modules/audio_coding/neteq/tools/neteq_quality_test.h"
|
|
#include "rtc_base/checks.h"
|
|
#include "rtc_base/flags.h"
|
|
#include "rtc_base/numerics/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;
|
|
|
|
WEBRTC_DEFINE_int(frame_size_ms, 20, "Codec frame size (milliseconds).");
|
|
|
|
} // namespace
|
|
|
|
class NetEqPcmuQualityTest : public NetEqQualityTest {
|
|
protected:
|
|
NetEqPcmuQualityTest()
|
|
: NetEqQualityTest(FLAG_frame_size_ms,
|
|
kInputSampleRateKhz,
|
|
kOutputSampleRateKhz,
|
|
NetEqDecoder::kDecoderPCMu) {
|
|
// Flag validation
|
|
RTC_CHECK(FLAG_frame_size_ms >= 10 && FLAG_frame_size_ms <= 60 &&
|
|
(FLAG_frame_size_ms % 10) == 0)
|
|
<< "Invalid frame size, should be 10, 20, ..., 60 ms.";
|
|
}
|
|
|
|
void SetUp() override {
|
|
ASSERT_EQ(1u, channels_) << "PCMu supports only mono audio.";
|
|
AudioEncoderPcmU::Config config;
|
|
config.frame_size_ms = FLAG_frame_size_ms;
|
|
encoder_.reset(new AudioEncoderPcmU(config));
|
|
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<AudioEncoderPcmU> encoder_;
|
|
};
|
|
|
|
TEST_F(NetEqPcmuQualityTest, Test) {
|
|
Simulate();
|
|
}
|
|
|
|
} // namespace test
|
|
} // namespace webrtc
|