Introduce SimulatedNetworkReceiverInterface and switch DirectTransport on this interface. Also switch part of related users on DefaultNetworkSimulationConfig. This two changes united into single CL to prevent work duplication. Most changes were done because of stop including fake_network_pipe.h into direct_transport.h, so splitting this into 2 CLs will require first fix all imports of fake_network_pipe.h and then replace them on new API imports again. Bug: webrtc:9630 Change-Id: I87d4a6ff1bab72d04a9871a40441f4fbe028f4e6 Reviewed-on: https://webrtc-review.googlesource.com/94762 Commit-Queue: Patrik Höglund <phoglund@webrtc.org> Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Sebastian Jansson <srte@webrtc.org> Reviewed-by: Patrik Höglund <phoglund@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24336}
115 lines
3.5 KiB
C++
115 lines
3.5 KiB
C++
/*
|
|
* 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 "api/test/simulated_network.h"
|
|
#include "audio/test/audio_end_to_end_test.h"
|
|
#include "rtc_base/flags.h"
|
|
#include "system_wrappers/include/sleep.h"
|
|
#include "test/testsupport/fileutils.h"
|
|
|
|
DEFINE_int(sample_rate_hz,
|
|
16000,
|
|
"Sample rate (Hz) of the produced audio files.");
|
|
|
|
DEFINE_bool(quick,
|
|
false,
|
|
"Don't do the full audio recording. "
|
|
"Used to quickly check that the test runs without crashing.");
|
|
|
|
namespace webrtc {
|
|
namespace test {
|
|
namespace {
|
|
|
|
std::string FileSampleRateSuffix() {
|
|
return std::to_string(FLAG_sample_rate_hz / 1000);
|
|
}
|
|
|
|
class AudioQualityTest : public AudioEndToEndTest {
|
|
public:
|
|
AudioQualityTest() = default;
|
|
|
|
private:
|
|
std::string AudioInputFile() const {
|
|
return test::ResourcePath(
|
|
"voice_engine/audio_tiny" + FileSampleRateSuffix(), "wav");
|
|
}
|
|
|
|
std::string AudioOutputFile() const {
|
|
const ::testing::TestInfo* const test_info =
|
|
::testing::UnitTest::GetInstance()->current_test_info();
|
|
return webrtc::test::OutputPath() + "LowBandwidth_" + test_info->name() +
|
|
"_" + FileSampleRateSuffix() + ".wav";
|
|
}
|
|
|
|
std::unique_ptr<TestAudioDeviceModule::Capturer> CreateCapturer() override {
|
|
return TestAudioDeviceModule::CreateWavFileReader(AudioInputFile());
|
|
}
|
|
|
|
std::unique_ptr<TestAudioDeviceModule::Renderer> CreateRenderer() override {
|
|
return TestAudioDeviceModule::CreateBoundedWavFileWriter(
|
|
AudioOutputFile(), FLAG_sample_rate_hz);
|
|
}
|
|
|
|
void PerformTest() override {
|
|
if (FLAG_quick) {
|
|
// Let the recording run for a small amount of time to check if it works.
|
|
SleepMs(1000);
|
|
} else {
|
|
AudioEndToEndTest::PerformTest();
|
|
}
|
|
}
|
|
|
|
void OnStreamsStopped() override {
|
|
const ::testing::TestInfo* const test_info =
|
|
::testing::UnitTest::GetInstance()->current_test_info();
|
|
|
|
// Output information about the input and output audio files so that further
|
|
// processing can be done by an external process.
|
|
printf("TEST %s %s %s\n", test_info->name(), AudioInputFile().c_str(),
|
|
AudioOutputFile().c_str());
|
|
}
|
|
};
|
|
|
|
class Mobile2GNetworkTest : public AudioQualityTest {
|
|
void ModifyAudioConfigs(
|
|
AudioSendStream::Config* send_config,
|
|
std::vector<AudioReceiveStream::Config>* receive_configs) override {
|
|
send_config->send_codec_spec = AudioSendStream::Config::SendCodecSpec(
|
|
test::CallTest::kAudioSendPayloadType,
|
|
{"OPUS",
|
|
48000,
|
|
2,
|
|
{{"maxaveragebitrate", "6000"}, {"ptime", "60"}, {"stereo", "1"}}});
|
|
}
|
|
|
|
DefaultNetworkSimulationConfig GetNetworkPipeConfig() const override {
|
|
DefaultNetworkSimulationConfig pipe_config;
|
|
pipe_config.link_capacity_kbps = 12;
|
|
pipe_config.queue_length_packets = 1500;
|
|
pipe_config.queue_delay_ms = 400;
|
|
return pipe_config;
|
|
}
|
|
};
|
|
} // namespace
|
|
|
|
using LowBandwidthAudioTest = CallTest;
|
|
|
|
TEST_F(LowBandwidthAudioTest, GoodNetworkHighBitrate) {
|
|
AudioQualityTest test;
|
|
RunBaseTest(&test);
|
|
}
|
|
|
|
TEST_F(LowBandwidthAudioTest, Mobile2GNetwork) {
|
|
Mobile2GNetworkTest test;
|
|
RunBaseTest(&test);
|
|
}
|
|
} // namespace test
|
|
} // namespace webrtc
|