2017-09-14 14:46:47 +02: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_end_to_end_test.h"
|
2019-07-05 19:08:33 +02:00
|
|
|
|
2017-09-14 14:46:47 +02:00
|
|
|
#include <algorithm>
|
2019-09-17 17:06:18 +02:00
|
|
|
#include <memory>
|
2017-09-14 14:46:47 +02:00
|
|
|
|
2019-09-30 04:16:28 +02:00
|
|
|
#include "api/task_queue/task_queue_base.h"
|
2018-08-20 13:30:39 +02:00
|
|
|
#include "call/fake_network_pipe.h"
|
2023-04-11 16:37:38 +02:00
|
|
|
#include "modules/audio_device/include/test_audio_device.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "system_wrappers/include/sleep.h"
|
|
|
|
|
#include "test/gtest.h"
|
2023-04-25 09:56:49 +02:00
|
|
|
#include "test/video_test_constants.h"
|
2017-09-14 14:46:47 +02:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
namespace test {
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
constexpr int kSampleRate = 48000;
|
2023-04-11 16:37:38 +02:00
|
|
|
|
2017-09-14 14:46:47 +02:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
AudioEndToEndTest::AudioEndToEndTest()
|
2023-04-25 09:56:49 +02:00
|
|
|
: EndToEndTest(VideoTestConstants::kDefaultTimeout) {}
|
2017-09-14 14:46:47 +02:00
|
|
|
|
|
|
|
|
size_t AudioEndToEndTest::GetNumVideoStreams() const {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
size_t AudioEndToEndTest::GetNumAudioStreams() const {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
size_t AudioEndToEndTest::GetNumFlexfecStreams() const {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-07 14:44:00 +01:00
|
|
|
std::unique_ptr<TestAudioDeviceModule::Capturer>
|
|
|
|
|
AudioEndToEndTest::CreateCapturer() {
|
|
|
|
|
return TestAudioDeviceModule::CreatePulsedNoiseCapturer(32000, kSampleRate);
|
2017-09-14 14:46:47 +02:00
|
|
|
}
|
|
|
|
|
|
2018-03-07 14:44:00 +01:00
|
|
|
std::unique_ptr<TestAudioDeviceModule::Renderer>
|
|
|
|
|
AudioEndToEndTest::CreateRenderer() {
|
|
|
|
|
return TestAudioDeviceModule::CreateDiscardRenderer(kSampleRate);
|
2017-09-14 14:46:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AudioEndToEndTest::OnFakeAudioDevicesCreated(
|
2023-04-11 16:37:38 +02:00
|
|
|
AudioDeviceModule* send_audio_device,
|
|
|
|
|
AudioDeviceModule* recv_audio_device) {
|
2017-09-14 14:46:47 +02:00
|
|
|
send_audio_device_ = send_audio_device;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AudioEndToEndTest::ModifyAudioConfigs(
|
|
|
|
|
AudioSendStream::Config* send_config,
|
2022-05-22 20:47:28 +02:00
|
|
|
std::vector<AudioReceiveStreamInterface::Config>* receive_configs) {
|
2017-09-14 14:46:47 +02:00
|
|
|
// Large bitrate by default.
|
|
|
|
|
const webrtc::SdpAudioFormat kDefaultFormat("opus", 48000, 2,
|
|
|
|
|
{{"stereo", "1"}});
|
2017-11-16 10:57:35 +01:00
|
|
|
send_config->send_codec_spec = AudioSendStream::Config::SendCodecSpec(
|
2023-04-25 09:56:49 +02:00
|
|
|
test::VideoTestConstants::kAudioSendPayloadType, kDefaultFormat);
|
2021-07-01 11:16:05 +02:00
|
|
|
send_config->min_bitrate_bps = 32000;
|
|
|
|
|
send_config->max_bitrate_bps = 32000;
|
2017-09-14 14:46:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AudioEndToEndTest::OnAudioStreamsCreated(
|
|
|
|
|
AudioSendStream* send_stream,
|
2022-05-22 20:47:28 +02:00
|
|
|
const std::vector<AudioReceiveStreamInterface*>& receive_streams) {
|
2017-09-14 14:46:47 +02:00
|
|
|
ASSERT_NE(nullptr, send_stream);
|
|
|
|
|
ASSERT_EQ(1u, receive_streams.size());
|
|
|
|
|
ASSERT_NE(nullptr, receive_streams[0]);
|
|
|
|
|
send_stream_ = send_stream;
|
|
|
|
|
receive_stream_ = receive_streams[0];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace test
|
|
|
|
|
} // namespace webrtc
|