Use AudioDeviceModule instead of TestAudioDeviceModule.

This is step to allow migration of Test ADM to the AudioDeviceModuleImpl
as a base class to include AudioDeviceBuffer into SUT.

Also it will allow to remove WaitForRecordingEnd() method from Test
ADM

Bug: b/272350185, webrtc:15081
Change-Id: If2aa43ec0c31f6ad9aab8aa3e36cabc4a7a73c22
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/300862
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Reviewed-by: Henrik Andreassson <henrika@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39849}
This commit is contained in:
Artem Titov 2023-04-11 16:37:38 +02:00 committed by WebRTC LUCI CQ
parent 1b77daea81
commit fb8e3de0a8
10 changed files with 32 additions and 29 deletions

View File

@ -134,6 +134,8 @@ if (rtc_include_tests) {
"../api/task_queue",
"../call:fake_network",
"../call:simulated_network",
"../modules/audio_device:audio_device_api",
"../modules/audio_device:audio_device_impl",
"../system_wrappers",
"../test:test_common",
"../test:test_support",

View File

@ -16,16 +16,16 @@
#include "api/task_queue/task_queue_base.h"
#include "call/fake_network_pipe.h"
#include "call/simulated_network.h"
#include "modules/audio_device/include/test_audio_device.h"
#include "system_wrappers/include/sleep.h"
#include "test/gtest.h"
namespace webrtc {
namespace test {
namespace {
// Wait half a second between stopping sending and stopping receiving audio.
constexpr int kExtraRecordTimeMs = 500;
constexpr int kSampleRate = 48000;
} // namespace
AudioEndToEndTest::AudioEndToEndTest()
@ -54,8 +54,8 @@ AudioEndToEndTest::CreateRenderer() {
}
void AudioEndToEndTest::OnFakeAudioDevicesCreated(
TestAudioDeviceModule* send_audio_device,
TestAudioDeviceModule* recv_audio_device) {
AudioDeviceModule* send_audio_device,
AudioDeviceModule* recv_audio_device) {
send_audio_device_ = send_audio_device;
}
@ -81,11 +81,5 @@ void AudioEndToEndTest::OnAudioStreamsCreated(
receive_stream_ = receive_streams[0];
}
void AudioEndToEndTest::PerformTest() {
// Wait until the input audio file is done...
send_audio_device_->WaitForRecordingEnd();
// and some extra time to account for network delay.
SleepMs(GetSendTransportConfig().queue_delay_ms + kExtraRecordTimeMs);
}
} // namespace test
} // namespace webrtc

View File

@ -16,6 +16,8 @@
#include "api/task_queue/task_queue_base.h"
#include "api/test/simulated_network.h"
#include "modules/audio_device/include/audio_device.h"
#include "modules/audio_device/include/test_audio_device.h"
#include "test/call_test.h"
namespace webrtc {
@ -26,7 +28,7 @@ class AudioEndToEndTest : public test::EndToEndTest {
AudioEndToEndTest();
protected:
TestAudioDeviceModule* send_audio_device() { return send_audio_device_; }
AudioDeviceModule* send_audio_device() { return send_audio_device_; }
const AudioSendStream* send_stream() const { return send_stream_; }
const AudioReceiveStreamInterface* receive_stream() const {
return receive_stream_;
@ -39,9 +41,8 @@ class AudioEndToEndTest : public test::EndToEndTest {
std::unique_ptr<TestAudioDeviceModule::Capturer> CreateCapturer() override;
std::unique_ptr<TestAudioDeviceModule::Renderer> CreateRenderer() override;
void OnFakeAudioDevicesCreated(
TestAudioDeviceModule* send_audio_device,
TestAudioDeviceModule* recv_audio_device) override;
void OnFakeAudioDevicesCreated(AudioDeviceModule* send_audio_device,
AudioDeviceModule* recv_audio_device) override;
void ModifyAudioConfigs(AudioSendStream::Config* send_config,
std::vector<AudioReceiveStreamInterface::Config>*
@ -50,10 +51,8 @@ class AudioEndToEndTest : public test::EndToEndTest {
const std::vector<AudioReceiveStreamInterface*>&
receive_streams) override;
void PerformTest() override;
private:
TestAudioDeviceModule* send_audio_device_ = nullptr;
AudioDeviceModule* send_audio_device_ = nullptr;
AudioSendStream* send_stream_ = nullptr;
AudioReceiveStreamInterface* receive_stream_ = nullptr;
};

View File

@ -17,6 +17,9 @@ namespace webrtc {
namespace test {
namespace {
// Wait half a second between stopping sending and stopping receiving audio.
constexpr int kExtraRecordTimeMs = 500;
bool IsNear(int reference, int v) {
// Margin is 10%.
const int error = reference / 10 + 1;
@ -41,7 +44,8 @@ class NoLossTest : public AudioEndToEndTest {
void PerformTest() override {
SleepMs(kTestDurationMs);
send_audio_device()->StopRecording();
AudioEndToEndTest::PerformTest();
// and some extra time to account for network delay.
SleepMs(GetSendTransportConfig().queue_delay_ms + kExtraRecordTimeMs);
}
void OnStreamsStopped() override {

View File

@ -57,7 +57,8 @@ class AudioQualityTest : public AudioEndToEndTest {
// Let the recording run for a small amount of time to check if it works.
SleepMs(1000);
} else {
AudioEndToEndTest::PerformTest();
// Sleep for whole audio duration which is 5.4 seconds.
SleepMs(5400);
}
}

View File

@ -439,7 +439,7 @@ size_t TestAudioDeviceModule::SamplesPerFrame(int sampling_frequency_in_hz) {
return rtc::CheckedDivExact(sampling_frequency_in_hz, kFramesPerSecond);
}
rtc::scoped_refptr<TestAudioDeviceModule> TestAudioDeviceModule::Create(
rtc::scoped_refptr<AudioDeviceModule> TestAudioDeviceModule::Create(
TaskQueueFactory* task_queue_factory,
std::unique_ptr<TestAudioDeviceModule::Capturer> capturer,
std::unique_ptr<TestAudioDeviceModule::Renderer> renderer,

View File

@ -82,7 +82,7 @@ class TestAudioDeviceModule : public AudioDeviceModule {
// `renderer` is an object that receives audio data that would have been
// played out. Can be nullptr if this device is never used for playing.
// Use one of the Create... functions to get these instances.
static rtc::scoped_refptr<TestAudioDeviceModule> Create(
static rtc::scoped_refptr<AudioDeviceModule> Create(
TaskQueueFactory* task_queue_factory,
std::unique_ptr<Capturer> capturer,
std::unique_ptr<Renderer> renderer,

View File

@ -1099,6 +1099,7 @@ rtc_library("test_common") {
"../call:simulated_network",
"../call:simulated_packet_receiver",
"../call:video_stream_api",
"../modules/audio_device:audio_device_api",
"../modules/audio_device:audio_device_impl",
"../modules/audio_mixer:audio_mixer_impl",
"../modules/rtp_rtcp",

View File

@ -22,6 +22,8 @@
#include "call/fake_network_pipe.h"
#include "call/packet_receiver.h"
#include "call/simulated_network.h"
#include "modules/audio_device/include/audio_device.h"
#include "modules/audio_device/include/test_audio_device.h"
#include "modules/audio_mixer/audio_mixer_impl.h"
#include "rtc_base/checks.h"
#include "rtc_base/event.h"
@ -770,9 +772,9 @@ std::unique_ptr<TestAudioDeviceModule::Renderer> BaseTest::CreateRenderer() {
return TestAudioDeviceModule::CreateDiscardRenderer(48000);
}
void BaseTest::OnFakeAudioDevicesCreated(
TestAudioDeviceModule* send_audio_device,
TestAudioDeviceModule* recv_audio_device) {}
void BaseTest::OnFakeAudioDevicesCreated(AudioDeviceModule* send_audio_device,
AudioDeviceModule* recv_audio_device) {
}
void BaseTest::ModifySenderBitrateConfig(BitrateConstraints* bitrate_config) {}

View File

@ -26,6 +26,7 @@
#include "api/units/time_delta.h"
#include "api/video/video_bitrate_allocator_factory.h"
#include "call/call.h"
#include "modules/audio_device/include/audio_device.h"
#include "modules/audio_device/include/test_audio_device.h"
#include "test/encoder_settings.h"
#include "test/fake_decoder.h"
@ -271,8 +272,8 @@ class CallTest : public ::testing::Test, public RtpPacketSinkInterface {
std::vector<RtpExtension> rtp_extensions_;
rtc::scoped_refptr<AudioProcessing> apm_send_;
rtc::scoped_refptr<AudioProcessing> apm_recv_;
rtc::scoped_refptr<TestAudioDeviceModule> fake_send_audio_device_;
rtc::scoped_refptr<TestAudioDeviceModule> fake_recv_audio_device_;
rtc::scoped_refptr<AudioDeviceModule> fake_send_audio_device_;
rtc::scoped_refptr<AudioDeviceModule> fake_recv_audio_device_;
};
class BaseTest : public RtpRtcpObserver {
@ -290,9 +291,8 @@ class BaseTest : public RtpRtcpObserver {
virtual std::unique_ptr<TestAudioDeviceModule::Capturer> CreateCapturer();
virtual std::unique_ptr<TestAudioDeviceModule::Renderer> CreateRenderer();
virtual void OnFakeAudioDevicesCreated(
TestAudioDeviceModule* send_audio_device,
TestAudioDeviceModule* recv_audio_device);
virtual void OnFakeAudioDevicesCreated(AudioDeviceModule* send_audio_device,
AudioDeviceModule* recv_audio_device);
virtual void ModifySenderBitrateConfig(BitrateConstraints* bitrate_config);
virtual void ModifyReceiverBitrateConfig(BitrateConstraints* bitrate_config);