2017-07-17 01:41:41 -07:00
|
|
|
/*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "audio/test/audio_bwe_integration_test.h"
|
2017-07-17 01:41:41 -07:00
|
|
|
|
Use absl::make_unique and absl::WrapUnique directly
Instead of going through our wrappers in ptr_util.h.
This CL was generated by the following script:
git grep -l ptr_util | xargs perl -pi -e 's,#include "rtc_base/ptr_util.h",#include "absl/memory/memory.h",'
git grep -l MakeUnique | xargs perl -pi -e 's,\b(rtc::)?MakeUnique\b,absl::make_unique,g'
git grep -l WrapUnique | xargs perl -pi -e 's,\b(rtc::)?WrapUnique\b,absl::WrapUnique,g'
git checkout -- rtc_base/ptr_util{.h,_unittest.cc}
git cl format
Followed by manually adding dependencies on
//third_party/abseil-cpp/absl/memory until `gn check` stopped
complaining.
Bug: webrtc:9473
Change-Id: I89ccd363f070479b8c431eb2c3d404a46eaacc1c
Reviewed-on: https://webrtc-review.googlesource.com/86600
Commit-Queue: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23850}
2018-07-05 11:40:33 +02:00
|
|
|
#include "absl/memory/memory.h"
|
2018-08-20 13:30:39 +02:00
|
|
|
#include "call/fake_network_pipe.h"
|
|
|
|
|
#include "call/simulated_network.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "common_audio/wav_file.h"
|
|
|
|
|
#include "system_wrappers/include/sleep.h"
|
|
|
|
|
#include "test/field_trial.h"
|
|
|
|
|
#include "test/gtest.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "test/testsupport/file_utils.h"
|
2017-07-17 01:41:41 -07:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
namespace test {
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
// Wait a second between stopping sending and stopping receiving audio.
|
|
|
|
|
constexpr int kExtraProcessTimeMs = 1000;
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
AudioBweTest::AudioBweTest() : EndToEndTest(CallTest::kDefaultTimeoutMs) {}
|
|
|
|
|
|
|
|
|
|
size_t AudioBweTest::GetNumVideoStreams() const {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
size_t AudioBweTest::GetNumAudioStreams() const {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
size_t AudioBweTest::GetNumFlexfecStreams() const {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-07 14:44:00 +01:00
|
|
|
std::unique_ptr<TestAudioDeviceModule::Capturer>
|
2017-07-17 01:41:41 -07:00
|
|
|
AudioBweTest::CreateCapturer() {
|
2018-03-07 14:44:00 +01:00
|
|
|
return TestAudioDeviceModule::CreateWavFileReader(AudioInputFile());
|
2017-07-17 01:41:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AudioBweTest::OnFakeAudioDevicesCreated(
|
2018-03-07 14:44:00 +01:00
|
|
|
TestAudioDeviceModule* send_audio_device,
|
|
|
|
|
TestAudioDeviceModule* recv_audio_device) {
|
2017-07-17 01:41:41 -07:00
|
|
|
send_audio_device_ = send_audio_device;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-22 04:02:52 -07:00
|
|
|
test::PacketTransport* AudioBweTest::CreateSendTransport(
|
|
|
|
|
SingleThreadedTaskQueueForTesting* task_queue,
|
|
|
|
|
Call* sender_call) {
|
2017-07-17 01:41:41 -07:00
|
|
|
return new test::PacketTransport(
|
2017-08-22 04:02:52 -07:00
|
|
|
task_queue, sender_call, this, test::PacketTransport::kSender,
|
2018-08-20 13:30:39 +02:00
|
|
|
test::CallTest::payload_type_map_,
|
|
|
|
|
absl::make_unique<FakeNetworkPipe>(
|
|
|
|
|
Clock::GetRealTimeClock(),
|
|
|
|
|
absl::make_unique<SimulatedNetwork>(GetNetworkPipeConfig())));
|
2017-07-17 01:41:41 -07:00
|
|
|
}
|
|
|
|
|
|
2017-08-22 04:02:52 -07:00
|
|
|
test::PacketTransport* AudioBweTest::CreateReceiveTransport(
|
|
|
|
|
SingleThreadedTaskQueueForTesting* task_queue) {
|
2017-07-17 01:41:41 -07:00
|
|
|
return new test::PacketTransport(
|
2017-08-22 04:02:52 -07:00
|
|
|
task_queue, nullptr, this, test::PacketTransport::kReceiver,
|
2018-08-20 13:30:39 +02:00
|
|
|
test::CallTest::payload_type_map_,
|
|
|
|
|
absl::make_unique<FakeNetworkPipe>(
|
|
|
|
|
Clock::GetRealTimeClock(),
|
|
|
|
|
absl::make_unique<SimulatedNetwork>(GetNetworkPipeConfig())));
|
2017-07-17 01:41:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AudioBweTest::PerformTest() {
|
|
|
|
|
send_audio_device_->WaitForRecordingEnd();
|
|
|
|
|
SleepMs(GetNetworkPipeConfig().queue_delay_ms + kExtraProcessTimeMs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class StatsPollTask : public rtc::QueuedTask {
|
|
|
|
|
public:
|
|
|
|
|
explicit StatsPollTask(Call* sender_call) : sender_call_(sender_call) {}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
bool Run() override {
|
|
|
|
|
RTC_CHECK(sender_call_);
|
|
|
|
|
Call::Stats call_stats = sender_call_->GetStats();
|
|
|
|
|
EXPECT_GT(call_stats.send_bandwidth_bps, 25000);
|
|
|
|
|
rtc::TaskQueue::Current()->PostDelayedTask(
|
|
|
|
|
std::unique_ptr<QueuedTask>(this), 100);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
Call* sender_call_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class NoBandwidthDropAfterDtx : public AudioBweTest {
|
|
|
|
|
public:
|
|
|
|
|
NoBandwidthDropAfterDtx()
|
|
|
|
|
: sender_call_(nullptr), stats_poller_("stats poller task queue") {}
|
|
|
|
|
|
|
|
|
|
void ModifyAudioConfigs(
|
|
|
|
|
AudioSendStream::Config* send_config,
|
|
|
|
|
std::vector<AudioReceiveStream::Config>* receive_configs) override {
|
2017-11-16 10:57:35 +01:00
|
|
|
send_config->send_codec_spec = AudioSendStream::Config::SendCodecSpec(
|
|
|
|
|
test::CallTest::kAudioSendPayloadType,
|
|
|
|
|
{"OPUS",
|
|
|
|
|
48000,
|
|
|
|
|
2,
|
|
|
|
|
{{"ptime", "60"}, {"usedtx", "1"}, {"stereo", "1"}}});
|
2017-07-17 01:41:41 -07:00
|
|
|
|
|
|
|
|
send_config->min_bitrate_bps = 6000;
|
|
|
|
|
send_config->max_bitrate_bps = 100000;
|
|
|
|
|
send_config->rtp.extensions.push_back(
|
|
|
|
|
RtpExtension(RtpExtension::kTransportSequenceNumberUri,
|
|
|
|
|
kTransportSequenceNumberExtensionId));
|
|
|
|
|
for (AudioReceiveStream::Config& recv_config : *receive_configs) {
|
|
|
|
|
recv_config.rtp.transport_cc = true;
|
|
|
|
|
recv_config.rtp.extensions = send_config->rtp.extensions;
|
|
|
|
|
recv_config.rtp.remote_ssrc = send_config->rtp.ssrc;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string AudioInputFile() override {
|
|
|
|
|
return test::ResourcePath("voice_engine/audio_dtx16", "wav");
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-08 12:28:56 +02:00
|
|
|
BuiltInNetworkBehaviorConfig GetNetworkPipeConfig() override {
|
|
|
|
|
BuiltInNetworkBehaviorConfig pipe_config;
|
2017-07-17 01:41:41 -07:00
|
|
|
pipe_config.link_capacity_kbps = 50;
|
|
|
|
|
pipe_config.queue_length_packets = 1500;
|
|
|
|
|
pipe_config.queue_delay_ms = 300;
|
|
|
|
|
return pipe_config;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OnCallsCreated(Call* sender_call, Call* receiver_call) override {
|
|
|
|
|
sender_call_ = sender_call;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PerformTest() override {
|
|
|
|
|
stats_poller_.PostDelayedTask(
|
|
|
|
|
std::unique_ptr<rtc::QueuedTask>(new StatsPollTask(sender_call_)), 100);
|
2018-10-04 15:21:55 +02:00
|
|
|
sender_call_->OnAudioTransportOverheadChanged(0);
|
2017-07-17 01:41:41 -07:00
|
|
|
AudioBweTest::PerformTest();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
Call* sender_call_;
|
|
|
|
|
rtc::TaskQueue stats_poller_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
using AudioBweIntegrationTest = CallTest;
|
|
|
|
|
|
2017-07-19 07:52:47 -07:00
|
|
|
// TODO(tschumim): This test is flaky when run on android and mac. Re-enable the
|
|
|
|
|
// test for when the issue is fixed.
|
|
|
|
|
TEST_F(AudioBweIntegrationTest, DISABLED_NoBandwidthDropAfterDtx) {
|
2017-07-17 01:41:41 -07:00
|
|
|
webrtc::test::ScopedFieldTrials override_field_trials(
|
|
|
|
|
"WebRTC-Audio-SendSideBwe/Enabled/"
|
|
|
|
|
"WebRTC-SendSideBwe-WithOverhead/Enabled/");
|
|
|
|
|
NoBandwidthDropAfterDtx test;
|
|
|
|
|
RunBaseTest(&test);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace test
|
|
|
|
|
} // namespace webrtc
|