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:
parent
1b77daea81
commit
fb8e3de0a8
@ -134,6 +134,8 @@ if (rtc_include_tests) {
|
|||||||
"../api/task_queue",
|
"../api/task_queue",
|
||||||
"../call:fake_network",
|
"../call:fake_network",
|
||||||
"../call:simulated_network",
|
"../call:simulated_network",
|
||||||
|
"../modules/audio_device:audio_device_api",
|
||||||
|
"../modules/audio_device:audio_device_impl",
|
||||||
"../system_wrappers",
|
"../system_wrappers",
|
||||||
"../test:test_common",
|
"../test:test_common",
|
||||||
"../test:test_support",
|
"../test:test_support",
|
||||||
|
|||||||
@ -16,16 +16,16 @@
|
|||||||
#include "api/task_queue/task_queue_base.h"
|
#include "api/task_queue/task_queue_base.h"
|
||||||
#include "call/fake_network_pipe.h"
|
#include "call/fake_network_pipe.h"
|
||||||
#include "call/simulated_network.h"
|
#include "call/simulated_network.h"
|
||||||
|
#include "modules/audio_device/include/test_audio_device.h"
|
||||||
#include "system_wrappers/include/sleep.h"
|
#include "system_wrappers/include/sleep.h"
|
||||||
#include "test/gtest.h"
|
#include "test/gtest.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
namespace test {
|
namespace test {
|
||||||
namespace {
|
namespace {
|
||||||
// Wait half a second between stopping sending and stopping receiving audio.
|
|
||||||
constexpr int kExtraRecordTimeMs = 500;
|
|
||||||
|
|
||||||
constexpr int kSampleRate = 48000;
|
constexpr int kSampleRate = 48000;
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
AudioEndToEndTest::AudioEndToEndTest()
|
AudioEndToEndTest::AudioEndToEndTest()
|
||||||
@ -54,8 +54,8 @@ AudioEndToEndTest::CreateRenderer() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AudioEndToEndTest::OnFakeAudioDevicesCreated(
|
void AudioEndToEndTest::OnFakeAudioDevicesCreated(
|
||||||
TestAudioDeviceModule* send_audio_device,
|
AudioDeviceModule* send_audio_device,
|
||||||
TestAudioDeviceModule* recv_audio_device) {
|
AudioDeviceModule* recv_audio_device) {
|
||||||
send_audio_device_ = send_audio_device;
|
send_audio_device_ = send_audio_device;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,11 +81,5 @@ void AudioEndToEndTest::OnAudioStreamsCreated(
|
|||||||
receive_stream_ = receive_streams[0];
|
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 test
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|||||||
@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
#include "api/task_queue/task_queue_base.h"
|
#include "api/task_queue/task_queue_base.h"
|
||||||
#include "api/test/simulated_network.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"
|
#include "test/call_test.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
@ -26,7 +28,7 @@ class AudioEndToEndTest : public test::EndToEndTest {
|
|||||||
AudioEndToEndTest();
|
AudioEndToEndTest();
|
||||||
|
|
||||||
protected:
|
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 AudioSendStream* send_stream() const { return send_stream_; }
|
||||||
const AudioReceiveStreamInterface* receive_stream() const {
|
const AudioReceiveStreamInterface* receive_stream() const {
|
||||||
return receive_stream_;
|
return receive_stream_;
|
||||||
@ -39,9 +41,8 @@ class AudioEndToEndTest : public test::EndToEndTest {
|
|||||||
std::unique_ptr<TestAudioDeviceModule::Capturer> CreateCapturer() override;
|
std::unique_ptr<TestAudioDeviceModule::Capturer> CreateCapturer() override;
|
||||||
std::unique_ptr<TestAudioDeviceModule::Renderer> CreateRenderer() override;
|
std::unique_ptr<TestAudioDeviceModule::Renderer> CreateRenderer() override;
|
||||||
|
|
||||||
void OnFakeAudioDevicesCreated(
|
void OnFakeAudioDevicesCreated(AudioDeviceModule* send_audio_device,
|
||||||
TestAudioDeviceModule* send_audio_device,
|
AudioDeviceModule* recv_audio_device) override;
|
||||||
TestAudioDeviceModule* recv_audio_device) override;
|
|
||||||
|
|
||||||
void ModifyAudioConfigs(AudioSendStream::Config* send_config,
|
void ModifyAudioConfigs(AudioSendStream::Config* send_config,
|
||||||
std::vector<AudioReceiveStreamInterface::Config>*
|
std::vector<AudioReceiveStreamInterface::Config>*
|
||||||
@ -50,10 +51,8 @@ class AudioEndToEndTest : public test::EndToEndTest {
|
|||||||
const std::vector<AudioReceiveStreamInterface*>&
|
const std::vector<AudioReceiveStreamInterface*>&
|
||||||
receive_streams) override;
|
receive_streams) override;
|
||||||
|
|
||||||
void PerformTest() override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TestAudioDeviceModule* send_audio_device_ = nullptr;
|
AudioDeviceModule* send_audio_device_ = nullptr;
|
||||||
AudioSendStream* send_stream_ = nullptr;
|
AudioSendStream* send_stream_ = nullptr;
|
||||||
AudioReceiveStreamInterface* receive_stream_ = nullptr;
|
AudioReceiveStreamInterface* receive_stream_ = nullptr;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -17,6 +17,9 @@ namespace webrtc {
|
|||||||
namespace test {
|
namespace test {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
// Wait half a second between stopping sending and stopping receiving audio.
|
||||||
|
constexpr int kExtraRecordTimeMs = 500;
|
||||||
|
|
||||||
bool IsNear(int reference, int v) {
|
bool IsNear(int reference, int v) {
|
||||||
// Margin is 10%.
|
// Margin is 10%.
|
||||||
const int error = reference / 10 + 1;
|
const int error = reference / 10 + 1;
|
||||||
@ -41,7 +44,8 @@ class NoLossTest : public AudioEndToEndTest {
|
|||||||
void PerformTest() override {
|
void PerformTest() override {
|
||||||
SleepMs(kTestDurationMs);
|
SleepMs(kTestDurationMs);
|
||||||
send_audio_device()->StopRecording();
|
send_audio_device()->StopRecording();
|
||||||
AudioEndToEndTest::PerformTest();
|
// and some extra time to account for network delay.
|
||||||
|
SleepMs(GetSendTransportConfig().queue_delay_ms + kExtraRecordTimeMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnStreamsStopped() override {
|
void OnStreamsStopped() override {
|
||||||
|
|||||||
@ -57,7 +57,8 @@ class AudioQualityTest : public AudioEndToEndTest {
|
|||||||
// Let the recording run for a small amount of time to check if it works.
|
// Let the recording run for a small amount of time to check if it works.
|
||||||
SleepMs(1000);
|
SleepMs(1000);
|
||||||
} else {
|
} else {
|
||||||
AudioEndToEndTest::PerformTest();
|
// Sleep for whole audio duration which is 5.4 seconds.
|
||||||
|
SleepMs(5400);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -439,7 +439,7 @@ size_t TestAudioDeviceModule::SamplesPerFrame(int sampling_frequency_in_hz) {
|
|||||||
return rtc::CheckedDivExact(sampling_frequency_in_hz, kFramesPerSecond);
|
return rtc::CheckedDivExact(sampling_frequency_in_hz, kFramesPerSecond);
|
||||||
}
|
}
|
||||||
|
|
||||||
rtc::scoped_refptr<TestAudioDeviceModule> TestAudioDeviceModule::Create(
|
rtc::scoped_refptr<AudioDeviceModule> TestAudioDeviceModule::Create(
|
||||||
TaskQueueFactory* task_queue_factory,
|
TaskQueueFactory* task_queue_factory,
|
||||||
std::unique_ptr<TestAudioDeviceModule::Capturer> capturer,
|
std::unique_ptr<TestAudioDeviceModule::Capturer> capturer,
|
||||||
std::unique_ptr<TestAudioDeviceModule::Renderer> renderer,
|
std::unique_ptr<TestAudioDeviceModule::Renderer> renderer,
|
||||||
|
|||||||
@ -82,7 +82,7 @@ class TestAudioDeviceModule : public AudioDeviceModule {
|
|||||||
// `renderer` is an object that receives audio data that would have been
|
// `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.
|
// played out. Can be nullptr if this device is never used for playing.
|
||||||
// Use one of the Create... functions to get these instances.
|
// 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,
|
TaskQueueFactory* task_queue_factory,
|
||||||
std::unique_ptr<Capturer> capturer,
|
std::unique_ptr<Capturer> capturer,
|
||||||
std::unique_ptr<Renderer> renderer,
|
std::unique_ptr<Renderer> renderer,
|
||||||
|
|||||||
@ -1099,6 +1099,7 @@ rtc_library("test_common") {
|
|||||||
"../call:simulated_network",
|
"../call:simulated_network",
|
||||||
"../call:simulated_packet_receiver",
|
"../call:simulated_packet_receiver",
|
||||||
"../call:video_stream_api",
|
"../call:video_stream_api",
|
||||||
|
"../modules/audio_device:audio_device_api",
|
||||||
"../modules/audio_device:audio_device_impl",
|
"../modules/audio_device:audio_device_impl",
|
||||||
"../modules/audio_mixer:audio_mixer_impl",
|
"../modules/audio_mixer:audio_mixer_impl",
|
||||||
"../modules/rtp_rtcp",
|
"../modules/rtp_rtcp",
|
||||||
|
|||||||
@ -22,6 +22,8 @@
|
|||||||
#include "call/fake_network_pipe.h"
|
#include "call/fake_network_pipe.h"
|
||||||
#include "call/packet_receiver.h"
|
#include "call/packet_receiver.h"
|
||||||
#include "call/simulated_network.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 "modules/audio_mixer/audio_mixer_impl.h"
|
||||||
#include "rtc_base/checks.h"
|
#include "rtc_base/checks.h"
|
||||||
#include "rtc_base/event.h"
|
#include "rtc_base/event.h"
|
||||||
@ -770,9 +772,9 @@ std::unique_ptr<TestAudioDeviceModule::Renderer> BaseTest::CreateRenderer() {
|
|||||||
return TestAudioDeviceModule::CreateDiscardRenderer(48000);
|
return TestAudioDeviceModule::CreateDiscardRenderer(48000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTest::OnFakeAudioDevicesCreated(
|
void BaseTest::OnFakeAudioDevicesCreated(AudioDeviceModule* send_audio_device,
|
||||||
TestAudioDeviceModule* send_audio_device,
|
AudioDeviceModule* recv_audio_device) {
|
||||||
TestAudioDeviceModule* recv_audio_device) {}
|
}
|
||||||
|
|
||||||
void BaseTest::ModifySenderBitrateConfig(BitrateConstraints* bitrate_config) {}
|
void BaseTest::ModifySenderBitrateConfig(BitrateConstraints* bitrate_config) {}
|
||||||
|
|
||||||
|
|||||||
@ -26,6 +26,7 @@
|
|||||||
#include "api/units/time_delta.h"
|
#include "api/units/time_delta.h"
|
||||||
#include "api/video/video_bitrate_allocator_factory.h"
|
#include "api/video/video_bitrate_allocator_factory.h"
|
||||||
#include "call/call.h"
|
#include "call/call.h"
|
||||||
|
#include "modules/audio_device/include/audio_device.h"
|
||||||
#include "modules/audio_device/include/test_audio_device.h"
|
#include "modules/audio_device/include/test_audio_device.h"
|
||||||
#include "test/encoder_settings.h"
|
#include "test/encoder_settings.h"
|
||||||
#include "test/fake_decoder.h"
|
#include "test/fake_decoder.h"
|
||||||
@ -271,8 +272,8 @@ class CallTest : public ::testing::Test, public RtpPacketSinkInterface {
|
|||||||
std::vector<RtpExtension> rtp_extensions_;
|
std::vector<RtpExtension> rtp_extensions_;
|
||||||
rtc::scoped_refptr<AudioProcessing> apm_send_;
|
rtc::scoped_refptr<AudioProcessing> apm_send_;
|
||||||
rtc::scoped_refptr<AudioProcessing> apm_recv_;
|
rtc::scoped_refptr<AudioProcessing> apm_recv_;
|
||||||
rtc::scoped_refptr<TestAudioDeviceModule> fake_send_audio_device_;
|
rtc::scoped_refptr<AudioDeviceModule> fake_send_audio_device_;
|
||||||
rtc::scoped_refptr<TestAudioDeviceModule> fake_recv_audio_device_;
|
rtc::scoped_refptr<AudioDeviceModule> fake_recv_audio_device_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class BaseTest : public RtpRtcpObserver {
|
class BaseTest : public RtpRtcpObserver {
|
||||||
@ -290,9 +291,8 @@ class BaseTest : public RtpRtcpObserver {
|
|||||||
|
|
||||||
virtual std::unique_ptr<TestAudioDeviceModule::Capturer> CreateCapturer();
|
virtual std::unique_ptr<TestAudioDeviceModule::Capturer> CreateCapturer();
|
||||||
virtual std::unique_ptr<TestAudioDeviceModule::Renderer> CreateRenderer();
|
virtual std::unique_ptr<TestAudioDeviceModule::Renderer> CreateRenderer();
|
||||||
virtual void OnFakeAudioDevicesCreated(
|
virtual void OnFakeAudioDevicesCreated(AudioDeviceModule* send_audio_device,
|
||||||
TestAudioDeviceModule* send_audio_device,
|
AudioDeviceModule* recv_audio_device);
|
||||||
TestAudioDeviceModule* recv_audio_device);
|
|
||||||
|
|
||||||
virtual void ModifySenderBitrateConfig(BitrateConstraints* bitrate_config);
|
virtual void ModifySenderBitrateConfig(BitrateConstraints* bitrate_config);
|
||||||
virtual void ModifyReceiverBitrateConfig(BitrateConstraints* bitrate_config);
|
virtual void ModifyReceiverBitrateConfig(BitrateConstraints* bitrate_config);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user