blob: f26a44a341b7ce84df2005268f938854070eb5e6 [file] [log] [blame]
pbos@webrtc.org994d0b72014-06-27 08:47:521/*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
brandtr841de6a2016-11-15 15:10:5210
Mirko Bonadei92ea95e2017-09-15 04:47:3111#include "test/call_test.h"
brandtr841de6a2016-11-15 15:10:5212
13#include <algorithm>
Mirko Bonadei317a1f02019-09-17 15:06:1814#include <memory>
brandtr841de6a2016-11-15 15:10:5215
Mirko Bonadei92ea95e2017-09-15 04:47:3116#include "api/audio_codecs/builtin_audio_decoder_factory.h"
17#include "api/audio_codecs/builtin_audio_encoder_factory.h"
Danil Chapovalovc03d8b62023-11-29 14:54:3218#include "api/environment/environment.h"
19#include "api/environment/environment_factory.h"
Danil Chapovalov44db4362019-09-30 02:16:2820#include "api/task_queue/task_queue_base.h"
Artem Titov33f9d2b2019-12-05 14:59:0021#include "api/test/create_frame_generator.h"
Jiawei Ouc2ebe212018-11-08 18:02:5622#include "api/video/builtin_video_bitrate_allocator_factory.h"
Artem Titov4e199e92018-08-20 11:30:3923#include "call/fake_network_pipe.h"
Per Kjellander89870ff2023-01-19 15:45:5824#include "call/packet_receiver.h"
Artem Titov4e199e92018-08-20 11:30:3925#include "call/simulated_network.h"
Artem Titovfb8e3de2023-04-11 14:37:3826#include "modules/audio_device/include/audio_device.h"
27#include "modules/audio_device/include/test_audio_device.h"
Mirko Bonadei92ea95e2017-09-15 04:47:3128#include "modules/audio_mixer/audio_mixer_impl.h"
29#include "rtc_base/checks.h"
30#include "rtc_base/event.h"
Danil Chapovalov82a3f0a2019-10-21 07:24:2731#include "rtc_base/task_queue_for_test.h"
Niels Möller4db138e2018-04-19 07:04:1332#include "test/fake_encoder.h"
Per Kjellander89870ff2023-01-19 15:45:5833#include "test/rtp_rtcp_observer.h"
Steve Anton10542f22019-01-11 17:11:0034#include "test/testsupport/file_utils.h"
Artem Titov8a9f3a82023-04-25 07:56:4935#include "test/video_test_constants.h"
Jonas Oreland6c2dae22022-09-29 08:28:2436#include "video/config/video_encoder_config.h"
eladalon413ee9a2017-08-22 11:02:5237
pbos@webrtc.org994d0b72014-06-27 08:47:5238namespace webrtc {
39namespace test {
40
41CallTest::CallTest()
Danil Chapovalovc03d8b62023-11-29 14:54:3242 : env_(CreateEnvironment(&field_trials_)),
43 send_env_(env_),
44 recv_env_(env_),
Bjorn A Mellem7a9a0922019-11-26 17:19:4045 audio_send_config_(/*send_transport=*/nullptr),
Stefan Holmer9fea80f2016-01-07 16:43:1846 audio_send_stream_(nullptr),
Erik Språng6a32de42019-01-09 14:46:3647 frame_generator_capturer_(nullptr),
Niels Möller4db138e2018-04-19 07:04:1348 fake_encoder_factory_([this]() {
Ilya Nikolaevskiyb0588e62018-08-27 12:12:2749 std::unique_ptr<FakeEncoder> fake_encoder;
50 if (video_encoder_configs_[0].codec_type == kVideoCodecVP8) {
Danil Chapovalovc03d8b62023-11-29 14:54:3251 fake_encoder = std::make_unique<FakeVp8Encoder>(&env_.clock());
Ilya Nikolaevskiyb0588e62018-08-27 12:12:2752 } else {
Danil Chapovalovc03d8b62023-11-29 14:54:3253 fake_encoder = std::make_unique<FakeEncoder>(&env_.clock());
Ilya Nikolaevskiyb0588e62018-08-27 12:12:2754 }
55 fake_encoder->SetMaxBitrate(fake_encoder_max_bitrate_);
56 return fake_encoder;
Niels Möller4db138e2018-04-19 07:04:1357 }),
Mirko Bonadei317a1f02019-09-17 15:06:1858 fake_decoder_factory_([]() { return std::make_unique<FakeDecoder>(); }),
Jiawei Ouc2ebe212018-11-08 18:02:5659 bitrate_allocator_factory_(CreateBuiltinVideoBitrateAllocatorFactory()),
Stefan Holmer04cb7632016-01-14 19:34:3060 num_video_streams_(1),
Stefan Holmer9fea80f2016-01-07 16:43:1861 num_audio_streams_(0),
brandtr841de6a2016-11-15 15:10:5262 num_flexfec_streams_(0),
Niels Möller2784a032018-03-28 12:16:0463 audio_decoder_factory_(CreateBuiltinAudioDecoderFactory()),
64 audio_encoder_factory_(CreateBuiltinAudioEncoderFactory()),
Danil Chapovalovc03d8b62023-11-29 14:54:3265 task_queue_(env_.task_queue_factory().CreateTaskQueue(
Danil Chapovalov1b668902019-11-13 10:19:5366 "CallTestTaskQueue",
67 TaskQueueFactory::Priority::NORMAL)) {}
pbos@webrtc.org32452b22014-10-22 12:15:2468
Danil Chapovalov577c5802019-10-31 11:33:1769CallTest::~CallTest() = default;
pbos@webrtc.org994d0b72014-06-27 08:47:5270
Danil Chapovalovc03d8b62023-11-29 14:54:3271void CallTest::SetSendEventLog(std::unique_ptr<RtcEventLog> event_log) {
72 EnvironmentFactory f(env_);
73 f.Set(std::move(event_log));
74 send_env_ = f.Create();
75}
76
77void CallTest::SetRecvEventLog(std::unique_ptr<RtcEventLog> event_log) {
78 EnvironmentFactory f(env_);
79 f.Set(std::move(event_log));
80 recv_env_ = f.Create();
81}
82
Elad Alond8d32482019-02-18 22:45:5783void CallTest::RegisterRtpExtension(const RtpExtension& extension) {
84 for (const RtpExtension& registered_extension : rtp_extensions_) {
85 if (registered_extension.id == extension.id) {
86 ASSERT_EQ(registered_extension.uri, extension.uri)
87 << "Different URIs associated with ID " << extension.id << ".";
88 ASSERT_EQ(registered_extension.encrypt, extension.encrypt)
89 << "Encryption mismatch associated with ID " << extension.id << ".";
90 return;
91 } else { // Different IDs.
92 // Different IDs referring to the same extension probably indicate
93 // a mistake in the test.
94 ASSERT_FALSE(registered_extension.uri == extension.uri &&
95 registered_extension.encrypt == extension.encrypt)
96 << "URI " << extension.uri
97 << (extension.encrypt ? " with " : " without ")
98 << "encryption already registered with a different "
Jonas Olssonb2b20312020-01-14 11:11:3199 "ID ("
100 << extension.id << " vs. " << registered_extension.id << ").";
Elad Alond8d32482019-02-18 22:45:57101 }
102 }
103 rtp_extensions_.push_back(extension);
104}
105
stefane74eef12016-01-08 14:47:13106void CallTest::RunBaseTest(BaseTest* test) {
Danil Chapovalove519f382022-08-11 10:26:09107 SendTask(task_queue(), [this, test]() {
eladalon413ee9a2017-08-22 11:02:52108 num_video_streams_ = test->GetNumVideoStreams();
109 num_audio_streams_ = test->GetNumAudioStreams();
110 num_flexfec_streams_ = test->GetNumFlexfecStreams();
111 RTC_DCHECK(num_video_streams_ > 0 || num_audio_streams_ > 0);
Danil Chapovalovc03d8b62023-11-29 14:54:32112 CallConfig send_config = SendCallConfig();
Niels Möllerde8e6e62018-11-13 14:10:33113 test->ModifySenderBitrateConfig(&send_config.bitrate_config);
Stefan Holmer9fea80f2016-01-07 16:43:18114 if (num_audio_streams_ > 0) {
eladalon413ee9a2017-08-22 11:02:52115 CreateFakeAudioDevices(test->CreateCapturer(), test->CreateRenderer());
116 test->OnFakeAudioDevicesCreated(fake_send_audio_device_.get(),
117 fake_recv_audio_device_.get());
Ivo Creusen62337e52018-01-09 13:17:33118 apm_send_ = AudioProcessingBuilder().Create();
119 apm_recv_ = AudioProcessingBuilder().Create();
Fredrik Solenberg8f5787a2018-01-11 12:52:30120 EXPECT_EQ(0, fake_send_audio_device_->Init());
121 EXPECT_EQ(0, fake_recv_audio_device_->Init());
Stefan Holmer9fea80f2016-01-07 16:43:18122 AudioState::Config audio_state_config;
aleloi10111bc2016-11-17 14:48:48123 audio_state_config.audio_mixer = AudioMixerImpl::Create();
eladalon413ee9a2017-08-22 11:02:52124 audio_state_config.audio_processing = apm_send_;
Fredrik Solenberg2a877972017-12-15 15:42:15125 audio_state_config.audio_device_module = fake_send_audio_device_;
eladalon413ee9a2017-08-22 11:02:52126 send_config.audio_state = AudioState::Create(audio_state_config);
Fredrik Solenbergd3195342017-11-21 19:33:05127 fake_send_audio_device_->RegisterAudioCallback(
128 send_config.audio_state->audio_transport());
Stefan Holmer9fea80f2016-01-07 16:43:18129 }
eladalon413ee9a2017-08-22 11:02:52130 CreateSenderCall(send_config);
eladalon413ee9a2017-08-22 11:02:52131 if (test->ShouldCreateReceivers()) {
Danil Chapovalovc03d8b62023-11-29 14:54:32132 CallConfig recv_config = RecvCallConfig();
Niels Möllerde8e6e62018-11-13 14:10:33133 test->ModifyReceiverBitrateConfig(&recv_config.bitrate_config);
eladalon413ee9a2017-08-22 11:02:52134 if (num_audio_streams_ > 0) {
135 AudioState::Config audio_state_config;
eladalon413ee9a2017-08-22 11:02:52136 audio_state_config.audio_mixer = AudioMixerImpl::Create();
137 audio_state_config.audio_processing = apm_recv_;
Fredrik Solenberg2a877972017-12-15 15:42:15138 audio_state_config.audio_device_module = fake_recv_audio_device_;
eladalon413ee9a2017-08-22 11:02:52139 recv_config.audio_state = AudioState::Create(audio_state_config);
Fredrik Solenbergd3195342017-11-21 19:33:05140 fake_recv_audio_device_->RegisterAudioCallback(
Yves Gerey665174f2018-06-19 13:03:05141 recv_config.audio_state->audio_transport());
142 }
eladalon413ee9a2017-08-22 11:02:52143 CreateReceiverCall(recv_config);
144 }
145 test->OnCallsCreated(sender_call_.get(), receiver_call_.get());
Per Kjellander89870ff2023-01-19 15:45:58146 CreateReceiveTransport(test->GetReceiveTransportConfig(), test);
147 CreateSendTransport(test->GetSendTransportConfig(), test);
148 test->OnTransportCreated(send_transport_.get(), send_simulated_network_,
149 receive_transport_.get(),
150 receive_simulated_network_);
eladalon413ee9a2017-08-22 11:02:52151 if (test->ShouldCreateReceivers()) {
eladalon413ee9a2017-08-22 11:02:52152 if (num_video_streams_ > 0)
153 receiver_call_->SignalChannelNetworkState(MediaType::VIDEO, kNetworkUp);
154 if (num_audio_streams_ > 0)
155 receiver_call_->SignalChannelNetworkState(MediaType::AUDIO, kNetworkUp);
156 } else {
157 // Sender-only call delivers to itself.
158 send_transport_->SetReceiver(sender_call_->Receiver());
159 receive_transport_->SetReceiver(nullptr);
160 }
pbos@webrtc.org994d0b72014-06-27 08:47:52161
eladalon413ee9a2017-08-22 11:02:52162 CreateSendConfig(num_video_streams_, num_audio_streams_,
163 num_flexfec_streams_, send_transport_.get());
164 if (test->ShouldCreateReceivers()) {
Per Kjellander89870ff2023-01-19 15:45:58165 CreateMatchingReceiveConfigs();
eladalon413ee9a2017-08-22 11:02:52166 }
167 if (num_video_streams_ > 0) {
Sebastian Janssonf33905d2018-07-13 07:49:00168 test->ModifyVideoConfigs(GetVideoSendConfig(), &video_receive_configs_,
169 GetVideoEncoderConfig());
eladalon413ee9a2017-08-22 11:02:52170 }
171 if (num_audio_streams_ > 0) {
172 test->ModifyAudioConfigs(&audio_send_config_, &audio_receive_configs_);
173 }
174 if (num_flexfec_streams_ > 0) {
175 test->ModifyFlexfecConfigs(&flexfec_receive_configs_);
176 }
Stefan Holmer9fea80f2016-01-07 16:43:18177
eladalon413ee9a2017-08-22 11:02:52178 if (num_flexfec_streams_ > 0) {
179 CreateFlexfecStreams();
180 test->OnFlexfecStreamsCreated(flexfec_receive_streams_);
181 }
182 if (num_video_streams_ > 0) {
183 CreateVideoStreams();
Sebastian Jansson3bd2c792018-07-13 11:29:03184 test->OnVideoStreamsCreated(GetVideoSendStream(), video_receive_streams_);
eladalon413ee9a2017-08-22 11:02:52185 }
186 if (num_audio_streams_ > 0) {
187 CreateAudioStreams();
188 test->OnAudioStreamsCreated(audio_send_stream_, audio_receive_streams_);
189 }
pbos@webrtc.org994d0b72014-06-27 08:47:52190
eladalon413ee9a2017-08-22 11:02:52191 if (num_video_streams_ > 0) {
Artem Titov8a9f3a82023-04-25 07:56:49192 int width = VideoTestConstants::kDefaultWidth;
193 int height = VideoTestConstants::kDefaultHeight;
194 int frame_rate = VideoTestConstants::kDefaultFramerate;
eladalon413ee9a2017-08-22 11:02:52195 test->ModifyVideoCaptureStartResolution(&width, &height, &frame_rate);
Åsa Perssoncb7eddb2018-11-05 13:11:44196 test->ModifyVideoDegradationPreference(&degradation_preference_);
eladalon413ee9a2017-08-22 11:02:52197 CreateFrameGeneratorCapturer(frame_rate, width, height);
Sebastian Jansson3bd2c792018-07-13 11:29:03198 test->OnFrameGeneratorCapturerCreated(frame_generator_capturer_);
eladalon413ee9a2017-08-22 11:02:52199 }
pbos@webrtc.org994d0b72014-06-27 08:47:52200
eladalon413ee9a2017-08-22 11:02:52201 Start();
202 });
203
pbos@webrtc.org994d0b72014-06-27 08:47:52204 test->PerformTest();
pbos@webrtc.org994d0b72014-06-27 08:47:52205
Danil Chapovalove519f382022-08-11 10:26:09206 SendTask(task_queue(), [this, test]() {
eladalon413ee9a2017-08-22 11:02:52207 Stop();
Fredrik Solenberg73276ad2017-09-14 12:46:47208 test->OnStreamsStopped();
eladalon413ee9a2017-08-22 11:02:52209 DestroyStreams();
210 send_transport_.reset();
211 receive_transport_.reset();
Tommi31d1bce2019-08-27 09:34:20212
Erik Språng6a32de42019-01-09 14:46:36213 frame_generator_capturer_ = nullptr;
eladalon413ee9a2017-08-22 11:02:52214 DestroyCalls();
Tommi31d1bce2019-08-27 09:34:20215
216 fake_send_audio_device_ = nullptr;
217 fake_recv_audio_device_ = nullptr;
eladalon413ee9a2017-08-22 11:02:52218 });
pbos@webrtc.org994d0b72014-06-27 08:47:52219}
220
Danil Chapovalovc03d8b62023-11-29 14:54:32221CallConfig CallTest::SendCallConfig() const {
222 CallConfig sender_config(send_env_);
223 sender_config.network_state_predictor_factory =
224 network_state_predictor_factory_.get();
225 sender_config.network_controller_factory = network_controller_factory_.get();
226 return sender_config;
227}
228
229CallConfig CallTest::RecvCallConfig() const {
230 return CallConfig(recv_env_);
231}
232
Sebastian Jansson8e6602f2018-07-13 08:43:20233void CallTest::CreateCalls() {
Danil Chapovalovc03d8b62023-11-29 14:54:32234 CreateCalls(SendCallConfig(), RecvCallConfig());
Sebastian Jansson8e6602f2018-07-13 08:43:20235}
236
Danil Chapovalova3ce4072023-10-13 11:53:00237void CallTest::CreateCalls(const CallConfig& sender_config,
238 const CallConfig& receiver_config) {
pbos@webrtc.org994d0b72014-06-27 08:47:52239 CreateSenderCall(sender_config);
240 CreateReceiverCall(receiver_config);
241}
242
Sebastian Jansson8e6602f2018-07-13 08:43:20243void CallTest::CreateSenderCall() {
Danil Chapovalovc03d8b62023-11-29 14:54:32244 CreateSenderCall(SendCallConfig());
Sebastian Jansson8e6602f2018-07-13 08:43:20245}
246
Danil Chapovalova3ce4072023-10-13 11:53:00247void CallTest::CreateSenderCall(const CallConfig& config) {
Danil Chapovalovc03d8b62023-11-29 14:54:32248 sender_call_ = Call::Create(config);
pbos@webrtc.org994d0b72014-06-27 08:47:52249}
250
Danil Chapovalova3ce4072023-10-13 11:53:00251void CallTest::CreateReceiverCall(const CallConfig& config) {
Danil Chapovalovc03d8b62023-11-29 14:54:32252 receiver_call_ = Call::Create(config);
pbos@webrtc.org994d0b72014-06-27 08:47:52253}
254
Fredrik Solenberg4f4ec0a2015-10-22 08:49:27255void CallTest::DestroyCalls() {
Per Kjellander89870ff2023-01-19 15:45:58256 send_transport_.reset();
257 receive_transport_.reset();
Stefan Holmer9fea80f2016-01-07 16:43:18258 sender_call_.reset();
259 receiver_call_.reset();
Fredrik Solenberg4f4ec0a2015-10-22 08:49:27260}
261
Ilya Nikolaevskiy255d1cd2017-12-21 17:02:59262void CallTest::CreateVideoSendConfig(VideoSendStream::Config* video_config,
263 size_t num_video_streams,
264 size_t num_used_ssrcs,
265 Transport* send_transport) {
Artem Titov8a9f3a82023-04-25 07:56:49266 RTC_DCHECK_LE(num_video_streams + num_used_ssrcs,
267 VideoTestConstants::kNumSsrcs);
Ilya Nikolaevskiy255d1cd2017-12-21 17:02:59268 *video_config = VideoSendStream::Config(send_transport);
Niels Möller4db138e2018-04-19 07:04:13269 video_config->encoder_settings.encoder_factory = &fake_encoder_factory_;
Jiawei Ouc2ebe212018-11-08 18:02:56270 video_config->encoder_settings.bitrate_allocator_factory =
271 bitrate_allocator_factory_.get();
Niels Möller259a4972018-04-05 13:36:51272 video_config->rtp.payload_name = "FAKE";
Artem Titov8a9f3a82023-04-25 07:56:49273 video_config->rtp.payload_type =
274 VideoTestConstants::kFakeVideoSendPayloadType;
Johannes Kronf7f13e02018-12-12 10:17:43275 video_config->rtp.extmap_allow_mixed = true;
Elad Alond8d32482019-02-18 22:45:57276 AddRtpExtensionByUri(RtpExtension::kTransportSequenceNumberUri,
277 &video_config->rtp.extensions);
Per K5671c642023-01-25 11:58:50278 AddRtpExtensionByUri(RtpExtension::kAbsSendTimeUri,
279 &video_config->rtp.extensions);
280 AddRtpExtensionByUri(RtpExtension::kTimestampOffsetUri,
281 &video_config->rtp.extensions);
Elad Alond8d32482019-02-18 22:45:57282 AddRtpExtensionByUri(RtpExtension::kVideoContentTypeUri,
283 &video_config->rtp.extensions);
Elad Alonccb9b752019-02-19 12:01:31284 AddRtpExtensionByUri(RtpExtension::kGenericFrameDescriptorUri00,
285 &video_config->rtp.extensions);
Danil Chapovalovce515f72020-02-24 13:29:27286 AddRtpExtensionByUri(RtpExtension::kDependencyDescriptorUri,
287 &video_config->rtp.extensions);
Sebastian Jansson3bd2c792018-07-13 11:29:03288 if (video_encoder_configs_.empty()) {
289 video_encoder_configs_.emplace_back();
290 FillEncoderConfiguration(kVideoCodecGeneric, num_video_streams,
291 &video_encoder_configs_.back());
292 }
Ilya Nikolaevskiy255d1cd2017-12-21 17:02:59293 for (size_t i = 0; i < num_video_streams; ++i)
Artem Titov8a9f3a82023-04-25 07:56:49294 video_config->rtp.ssrcs.push_back(
295 VideoTestConstants::kVideoSendSsrcs[num_used_ssrcs + i]);
Elad Alond8d32482019-02-18 22:45:57296 AddRtpExtensionByUri(RtpExtension::kVideoRotationUri,
297 &video_config->rtp.extensions);
298 AddRtpExtensionByUri(RtpExtension::kColorSpaceUri,
299 &video_config->rtp.extensions);
Ilya Nikolaevskiy255d1cd2017-12-21 17:02:59300}
301
302void CallTest::CreateAudioAndFecSendConfigs(size_t num_audio_streams,
303 size_t num_flexfec_streams,
304 Transport* send_transport) {
kwibergaf476c72016-11-28 23:21:39305 RTC_DCHECK_LE(num_audio_streams, 1);
306 RTC_DCHECK_LE(num_flexfec_streams, 1);
Stefan Holmer9fea80f2016-01-07 16:43:18307 if (num_audio_streams > 0) {
Bjorn A Mellem7a9a0922019-11-26 17:19:40308 AudioSendStream::Config audio_send_config(send_transport);
Artem Titov8a9f3a82023-04-25 07:56:49309 audio_send_config.rtp.ssrc = VideoTestConstants::kAudioSendSsrc;
Per K5671c642023-01-25 11:58:50310 AddRtpExtensionByUri(RtpExtension::kTransportSequenceNumberUri,
311 &audio_send_config.rtp.extensions);
312
Sebastian Jansson3bd2c792018-07-13 11:29:03313 audio_send_config.send_codec_spec = AudioSendStream::Config::SendCodecSpec(
Artem Titov8a9f3a82023-04-25 07:56:49314 VideoTestConstants::kAudioSendPayloadType,
315 {"opus", 48000, 2, {{"stereo", "1"}}});
Per Kb0d8a372023-01-26 15:11:31316 audio_send_config.min_bitrate_bps = 6000;
317 audio_send_config.max_bitrate_bps = 60000;
Sebastian Jansson3bd2c792018-07-13 11:29:03318 audio_send_config.encoder_factory = audio_encoder_factory_;
319 SetAudioConfig(audio_send_config);
Stefan Holmer9fea80f2016-01-07 16:43:18320 }
brandtr841de6a2016-11-15 15:10:52321
322 // TODO(brandtr): Update this when we support multistream protection.
323 if (num_flexfec_streams > 0) {
Artem Titov8a9f3a82023-04-25 07:56:49324 SetSendFecConfig({VideoTestConstants::kVideoSendSsrcs[0]});
brandtr841de6a2016-11-15 15:10:52325 }
pbos@webrtc.org994d0b72014-06-27 08:47:52326}
327
Sebastian Jansson3bd2c792018-07-13 11:29:03328void CallTest::SetAudioConfig(const AudioSendStream::Config& config) {
329 audio_send_config_ = config;
330}
331
332void CallTest::SetSendFecConfig(std::vector<uint32_t> video_send_ssrcs) {
Artem Titov8a9f3a82023-04-25 07:56:49333 GetVideoSendConfig()->rtp.flexfec.payload_type =
334 VideoTestConstants::kFlexfecPayloadType;
335 GetVideoSendConfig()->rtp.flexfec.ssrc = VideoTestConstants::kFlexfecSendSsrc;
Sebastian Jansson3bd2c792018-07-13 11:29:03336 GetVideoSendConfig()->rtp.flexfec.protected_media_ssrcs = video_send_ssrcs;
337}
338
339void CallTest::SetSendUlpFecConfig(VideoSendStream::Config* send_config) {
Artem Titov8a9f3a82023-04-25 07:56:49340 send_config->rtp.ulpfec.red_payload_type =
341 VideoTestConstants::kRedPayloadType;
342 send_config->rtp.ulpfec.ulpfec_payload_type =
343 VideoTestConstants::kUlpfecPayloadType;
344 send_config->rtp.ulpfec.red_rtx_payload_type =
345 VideoTestConstants::kRtxRedPayloadType;
Sebastian Jansson3bd2c792018-07-13 11:29:03346}
347
348void CallTest::SetReceiveUlpFecConfig(
Tommif6f45432022-05-20 13:21:20349 VideoReceiveStreamInterface::Config* receive_config) {
Artem Titov8a9f3a82023-04-25 07:56:49350 receive_config->rtp.red_payload_type = VideoTestConstants::kRedPayloadType;
351 receive_config->rtp.ulpfec_payload_type =
352 VideoTestConstants::kUlpfecPayloadType;
353 receive_config->rtp
354 .rtx_associated_payload_types[VideoTestConstants::kRtxRedPayloadType] =
355 VideoTestConstants::kRedPayloadType;
Sebastian Jansson3bd2c792018-07-13 11:29:03356}
357
Ilya Nikolaevskiy255d1cd2017-12-21 17:02:59358void CallTest::CreateSendConfig(size_t num_video_streams,
359 size_t num_audio_streams,
360 size_t num_flexfec_streams,
361 Transport* send_transport) {
362 if (num_video_streams > 0) {
Sebastian Jansson3bd2c792018-07-13 11:29:03363 video_send_configs_.clear();
364 video_send_configs_.emplace_back(nullptr);
365 CreateVideoSendConfig(&video_send_configs_.back(), num_video_streams, 0,
Ilya Nikolaevskiy255d1cd2017-12-21 17:02:59366 send_transport);
Stefan Holmer9fea80f2016-01-07 16:43:18367 }
Ilya Nikolaevskiy255d1cd2017-12-21 17:02:59368 CreateAudioAndFecSendConfigs(num_audio_streams, num_flexfec_streams,
369 send_transport);
370}
Stefan Holmer9fea80f2016-01-07 16:43:18371
Sebastian Jansson3bd2c792018-07-13 11:29:03372void CallTest::CreateMatchingVideoReceiveConfigs(
Ilya Nikolaevskiy255d1cd2017-12-21 17:02:59373 const VideoSendStream::Config& video_send_config,
374 Transport* rtcp_send_transport) {
Sebastian Jansson3bd2c792018-07-13 11:29:03375 CreateMatchingVideoReceiveConfigs(video_send_config, rtcp_send_transport,
Per K92532402023-01-02 15:57:18376 &fake_decoder_factory_, absl::nullopt,
Niels Möllercbcbc222018-09-28 07:07:24377 false, 0);
Sebastian Jansson3bd2c792018-07-13 11:29:03378}
379
380void CallTest::CreateMatchingVideoReceiveConfigs(
381 const VideoSendStream::Config& video_send_config,
382 Transport* rtcp_send_transport,
Niels Möllercbcbc222018-09-28 07:07:24383 VideoDecoderFactory* decoder_factory,
Sebastian Jansson3bd2c792018-07-13 11:29:03384 absl::optional<size_t> decode_sub_stream,
385 bool receiver_reference_time_report,
386 int rtp_history_ms) {
387 AddMatchingVideoReceiveConfigs(
388 &video_receive_configs_, video_send_config, rtcp_send_transport,
Per K92532402023-01-02 15:57:18389 decoder_factory, decode_sub_stream, receiver_reference_time_report,
390 rtp_history_ms);
Sebastian Jansson3bd2c792018-07-13 11:29:03391}
392
393void CallTest::AddMatchingVideoReceiveConfigs(
Tommif6f45432022-05-20 13:21:20394 std::vector<VideoReceiveStreamInterface::Config>* receive_configs,
Sebastian Jansson3bd2c792018-07-13 11:29:03395 const VideoSendStream::Config& video_send_config,
396 Transport* rtcp_send_transport,
Niels Möllercbcbc222018-09-28 07:07:24397 VideoDecoderFactory* decoder_factory,
Sebastian Jansson3bd2c792018-07-13 11:29:03398 absl::optional<size_t> decode_sub_stream,
399 bool receiver_reference_time_report,
400 int rtp_history_ms) {
Ilya Nikolaevskiy255d1cd2017-12-21 17:02:59401 RTC_DCHECK(!video_send_config.rtp.ssrcs.empty());
Tommif6f45432022-05-20 13:21:20402 VideoReceiveStreamInterface::Config default_config(rtcp_send_transport);
Artem Titov8a9f3a82023-04-25 07:56:49403 default_config.rtp.local_ssrc = VideoTestConstants::kReceiverLocalVideoSsrc;
Sebastian Jansson3bd2c792018-07-13 11:29:03404 default_config.rtp.nack.rtp_history_ms = rtp_history_ms;
405 // Enable RTT calculation so NTP time estimator will work.
406 default_config.rtp.rtcp_xr.receiver_reference_time_report =
407 receiver_reference_time_report;
408 default_config.renderer = &fake_renderer_;
409
Ilya Nikolaevskiy255d1cd2017-12-21 17:02:59410 for (size_t i = 0; i < video_send_config.rtp.ssrcs.size(); ++i) {
Tommif6f45432022-05-20 13:21:20411 VideoReceiveStreamInterface::Config video_recv_config(
412 default_config.Copy());
Sebastian Jansson3bd2c792018-07-13 11:29:03413 video_recv_config.decoders.clear();
414 if (!video_send_config.rtp.rtx.ssrcs.empty()) {
415 video_recv_config.rtp.rtx_ssrc = video_send_config.rtp.rtx.ssrcs[i];
Artem Titov8a9f3a82023-04-25 07:56:49416 video_recv_config.rtp.rtx_associated_payload_types
417 [VideoTestConstants::kSendRtxPayloadType] =
Sebastian Jansson3bd2c792018-07-13 11:29:03418 video_send_config.rtp.payload_type;
419 }
420 video_recv_config.rtp.remote_ssrc = video_send_config.rtp.ssrcs[i];
Tommif6f45432022-05-20 13:21:20421 VideoReceiveStreamInterface::Decoder decoder;
Sebastian Jansson3bd2c792018-07-13 11:29:03422
Niels Möllercbcbc222018-09-28 07:07:24423 decoder.payload_type = video_send_config.rtp.payload_type;
424 decoder.video_format = SdpVideoFormat(video_send_config.rtp.payload_name);
Sebastian Jansson3bd2c792018-07-13 11:29:03425 // Force fake decoders on non-selected simulcast streams.
426 if (!decode_sub_stream || i == *decode_sub_stream) {
Philip Eliasson2b068ce2020-08-03 15:55:10427 video_recv_config.decoder_factory = decoder_factory;
Sebastian Jansson3bd2c792018-07-13 11:29:03428 } else {
Philip Eliasson2b068ce2020-08-03 15:55:10429 video_recv_config.decoder_factory = &fake_decoder_factory_;
Sebastian Jansson3bd2c792018-07-13 11:29:03430 }
Sebastian Jansson3bd2c792018-07-13 11:29:03431 video_recv_config.decoders.push_back(decoder);
432 receive_configs->emplace_back(std::move(video_recv_config));
Ilya Nikolaevskiy255d1cd2017-12-21 17:02:59433 }
Ilya Nikolaevskiy255d1cd2017-12-21 17:02:59434}
435
436void CallTest::CreateMatchingAudioAndFecConfigs(
437 Transport* rtcp_send_transport) {
kwibergaf476c72016-11-28 23:21:39438 RTC_DCHECK_GE(1, num_audio_streams_);
Stefan Holmer9fea80f2016-01-07 16:43:18439 if (num_audio_streams_ == 1) {
Sebastian Jansson3bd2c792018-07-13 11:29:03440 CreateMatchingAudioConfigs(rtcp_send_transport, "");
pbos@webrtc.orgbe9d2a42014-06-30 13:19:09441 }
brandtr841de6a2016-11-15 15:10:52442
443 // TODO(brandtr): Update this when we support multistream protection.
444 RTC_DCHECK(num_flexfec_streams_ <= 1);
445 if (num_flexfec_streams_ == 1) {
Sebastian Jansson3bd2c792018-07-13 11:29:03446 CreateMatchingFecConfig(rtcp_send_transport, *GetVideoSendConfig());
brandtr841de6a2016-11-15 15:10:52447 }
pbos@webrtc.org994d0b72014-06-27 08:47:52448}
449
Sebastian Jansson3bd2c792018-07-13 11:29:03450void CallTest::CreateMatchingAudioConfigs(Transport* transport,
451 std::string sync_group) {
452 audio_receive_configs_.push_back(CreateMatchingAudioConfig(
453 audio_send_config_, audio_decoder_factory_, transport, sync_group));
454}
455
Tommi3176ef72022-05-22 18:47:28456AudioReceiveStreamInterface::Config CallTest::CreateMatchingAudioConfig(
Sebastian Jansson3bd2c792018-07-13 11:29:03457 const AudioSendStream::Config& send_config,
458 rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory,
459 Transport* transport,
460 std::string sync_group) {
Tommi3176ef72022-05-22 18:47:28461 AudioReceiveStreamInterface::Config audio_config;
Artem Titov8a9f3a82023-04-25 07:56:49462 audio_config.rtp.local_ssrc = VideoTestConstants::kReceiverLocalAudioSsrc;
Sebastian Jansson3bd2c792018-07-13 11:29:03463 audio_config.rtcp_send_transport = transport;
464 audio_config.rtp.remote_ssrc = send_config.rtp.ssrc;
Sebastian Jansson3bd2c792018-07-13 11:29:03465 audio_config.decoder_factory = audio_decoder_factory;
Artem Titov8a9f3a82023-04-25 07:56:49466 audio_config.decoder_map = {
467 {VideoTestConstants::kAudioSendPayloadType, {"opus", 48000, 2}}};
Sebastian Jansson3bd2c792018-07-13 11:29:03468 audio_config.sync_group = sync_group;
469 return audio_config;
470}
471
472void CallTest::CreateMatchingFecConfig(
473 Transport* transport,
474 const VideoSendStream::Config& send_config) {
475 FlexfecReceiveStream::Config config(transport);
476 config.payload_type = send_config.rtp.flexfec.payload_type;
Tommi1c1f5402021-06-14 08:54:20477 config.rtp.remote_ssrc = send_config.rtp.flexfec.ssrc;
Sebastian Jansson3bd2c792018-07-13 11:29:03478 config.protected_media_ssrcs = send_config.rtp.flexfec.protected_media_ssrcs;
Artem Titov8a9f3a82023-04-25 07:56:49479 config.rtp.local_ssrc = VideoTestConstants::kReceiverLocalVideoSsrc;
Tomas Gunnarsson8408c992021-02-14 13:19:12480 if (!video_receive_configs_.empty()) {
Sebastian Jansson3bd2c792018-07-13 11:29:03481 video_receive_configs_[0].rtp.protected_by_flexfec = true;
Tomas Gunnarsson8408c992021-02-14 13:19:12482 video_receive_configs_[0].rtp.packet_sink_ = this;
483 }
Sebastian Jansson3bd2c792018-07-13 11:29:03484 flexfec_receive_configs_.push_back(config);
485}
486
Ilya Nikolaevskiy255d1cd2017-12-21 17:02:59487void CallTest::CreateMatchingReceiveConfigs(Transport* rtcp_send_transport) {
488 video_receive_configs_.clear();
Sebastian Jansson3bd2c792018-07-13 11:29:03489 for (VideoSendStream::Config& video_send_config : video_send_configs_) {
490 CreateMatchingVideoReceiveConfigs(video_send_config, rtcp_send_transport);
Ilya Nikolaevskiy255d1cd2017-12-21 17:02:59491 }
492 CreateMatchingAudioAndFecConfigs(rtcp_send_transport);
493}
494
danilchap9c6a0c72016-02-10 18:54:47495void CallTest::CreateFrameGeneratorCapturerWithDrift(Clock* clock,
perkjfa10b552016-10-03 06:45:26496 float speed,
497 int framerate,
498 int width,
499 int height) {
Sebastian Jansson3bd2c792018-07-13 11:29:03500 video_sources_.clear();
Danil Chapovalova92e6242019-04-18 08:58:56501 auto frame_generator_capturer =
Mirko Bonadei317a1f02019-09-17 15:06:18502 std::make_unique<test::FrameGeneratorCapturer>(
Danil Chapovalova92e6242019-04-18 08:58:56503 clock,
Artem Titov33f9d2b2019-12-05 14:59:00504 test::CreateSquareFrameGenerator(width, height, absl::nullopt,
505 absl::nullopt),
Danil Chapovalovc03d8b62023-11-29 14:54:32506 framerate * speed, env_.task_queue_factory());
Danil Chapovalova92e6242019-04-18 08:58:56507 frame_generator_capturer_ = frame_generator_capturer.get();
508 frame_generator_capturer->Init();
509 video_sources_.push_back(std::move(frame_generator_capturer));
Sebastian Janssonf33905d2018-07-13 07:49:00510 ConnectVideoSourcesToStreams();
danilchap9c6a0c72016-02-10 18:54:47511}
512
perkjfa10b552016-10-03 06:45:26513void CallTest::CreateFrameGeneratorCapturer(int framerate,
514 int width,
515 int height) {
Sebastian Jansson3bd2c792018-07-13 11:29:03516 video_sources_.clear();
Danil Chapovalova92e6242019-04-18 08:58:56517 auto frame_generator_capturer =
Mirko Bonadei317a1f02019-09-17 15:06:18518 std::make_unique<test::FrameGeneratorCapturer>(
Danil Chapovalovc03d8b62023-11-29 14:54:32519 &env_.clock(),
Artem Titov33f9d2b2019-12-05 14:59:00520 test::CreateSquareFrameGenerator(width, height, absl::nullopt,
521 absl::nullopt),
Danil Chapovalovc03d8b62023-11-29 14:54:32522 framerate, env_.task_queue_factory());
Danil Chapovalova92e6242019-04-18 08:58:56523 frame_generator_capturer_ = frame_generator_capturer.get();
524 frame_generator_capturer->Init();
525 video_sources_.push_back(std::move(frame_generator_capturer));
Sebastian Janssonf33905d2018-07-13 07:49:00526 ConnectVideoSourcesToStreams();
pbos@webrtc.org994d0b72014-06-27 08:47:52527}
pbosf1828e82015-07-28 15:20:59528
oprypin92220ff2017-03-23 10:40:03529void CallTest::CreateFakeAudioDevices(
Artem Titov3faa8322018-03-07 13:44:00530 std::unique_ptr<TestAudioDeviceModule::Capturer> capturer,
531 std::unique_ptr<TestAudioDeviceModule::Renderer> renderer) {
Danil Chapovalov08fa9532019-06-12 11:49:17532 fake_send_audio_device_ = TestAudioDeviceModule::Create(
Danil Chapovalovc03d8b62023-11-29 14:54:32533 &env_.task_queue_factory(), std::move(capturer), nullptr, 1.f);
Danil Chapovalov08fa9532019-06-12 11:49:17534 fake_recv_audio_device_ = TestAudioDeviceModule::Create(
Danil Chapovalovc03d8b62023-11-29 14:54:32535 &env_.task_queue_factory(), nullptr, std::move(renderer), 1.f);
Stefan Holmer9fea80f2016-01-07 16:43:18536}
537
538void CallTest::CreateVideoStreams() {
Stefan Holmer9fea80f2016-01-07 16:43:18539 RTC_DCHECK(video_receive_streams_.empty());
Sebastian Janssonf33905d2018-07-13 07:49:00540 CreateVideoSendStreams();
stefanff483612015-12-21 11:14:00541 for (size_t i = 0; i < video_receive_configs_.size(); ++i) {
Tommi733b5472016-06-10 15:58:01542 video_receive_streams_.push_back(receiver_call_->CreateVideoReceiveStream(
543 video_receive_configs_[i].Copy()));
pbos@webrtc.orgbe9d2a42014-06-30 13:19:09544 }
pbos@webrtc.org994d0b72014-06-27 08:47:52545}
546
Sebastian Janssonf33905d2018-07-13 07:49:00547void CallTest::CreateVideoSendStreams() {
Sebastian Jansson3bd2c792018-07-13 11:29:03548 RTC_DCHECK(video_send_streams_.empty());
549
550 // We currently only support testing external fec controllers with a single
551 // VideoSendStream.
552 if (fec_controller_factory_.get()) {
553 RTC_DCHECK_LE(video_send_configs_.size(), 1);
554 }
555
556 // TODO(http://crbug/818127):
557 // Remove this workaround when ALR is not screenshare-specific.
558 std::list<size_t> streams_creation_order;
559 for (size_t i = 0; i < video_send_configs_.size(); ++i) {
560 // If dual streams are created, add the screenshare stream last.
561 if (video_encoder_configs_[i].content_type ==
562 VideoEncoderConfig::ContentType::kScreen) {
563 streams_creation_order.push_back(i);
564 } else {
565 streams_creation_order.push_front(i);
566 }
567 }
568
569 video_send_streams_.resize(video_send_configs_.size(), nullptr);
570
571 for (size_t i : streams_creation_order) {
572 if (fec_controller_factory_.get()) {
573 video_send_streams_[i] = sender_call_->CreateVideoSendStream(
574 video_send_configs_[i].Copy(), video_encoder_configs_[i].Copy(),
Danil Chapovalov55a61892024-01-03 17:39:27575 fec_controller_factory_->CreateFecController(send_env_));
Sebastian Jansson3bd2c792018-07-13 11:29:03576 } else {
577 video_send_streams_[i] = sender_call_->CreateVideoSendStream(
578 video_send_configs_[i].Copy(), video_encoder_configs_[i].Copy());
579 }
580 }
Sebastian Janssonf33905d2018-07-13 07:49:00581}
582
583void CallTest::CreateVideoSendStream(const VideoEncoderConfig& encoder_config) {
Sebastian Jansson3bd2c792018-07-13 11:29:03584 RTC_DCHECK(video_send_streams_.empty());
585 video_send_streams_.push_back(sender_call_->CreateVideoSendStream(
586 GetVideoSendConfig()->Copy(), encoder_config.Copy()));
Sebastian Janssonf33905d2018-07-13 07:49:00587}
588
Stefan Holmer9fea80f2016-01-07 16:43:18589void CallTest::CreateAudioStreams() {
Ilya Nikolaevskiy255d1cd2017-12-21 17:02:59590 RTC_DCHECK(audio_send_stream_ == nullptr);
591 RTC_DCHECK(audio_receive_streams_.empty());
Stefan Holmer9fea80f2016-01-07 16:43:18592 audio_send_stream_ = sender_call_->CreateAudioSendStream(audio_send_config_);
593 for (size_t i = 0; i < audio_receive_configs_.size(); ++i) {
594 audio_receive_streams_.push_back(
595 receiver_call_->CreateAudioReceiveStream(audio_receive_configs_[i]));
596 }
Stefan Holmer9fea80f2016-01-07 16:43:18597}
598
brandtr841de6a2016-11-15 15:10:52599void CallTest::CreateFlexfecStreams() {
600 for (size_t i = 0; i < flexfec_receive_configs_.size(); ++i) {
601 flexfec_receive_streams_.push_back(
602 receiver_call_->CreateFlexfecReceiveStream(
603 flexfec_receive_configs_[i]));
604 }
eladalonc0d481a2017-08-02 14:39:07605}
606
Per Kjellander89870ff2023-01-19 15:45:58607void CallTest::CreateSendTransport(const BuiltInNetworkBehaviorConfig& config,
608 RtpRtcpObserver* observer) {
609 PacketReceiver* receiver =
610 receiver_call_ ? receiver_call_->Receiver() : nullptr;
611
612 auto network = std::make_unique<SimulatedNetwork>(config);
613 send_simulated_network_ = network.get();
614 send_transport_ = std::make_unique<PacketTransport>(
615 task_queue(), sender_call_.get(), observer,
616 test::PacketTransport::kSender, payload_type_map_,
617 std::make_unique<FakeNetworkPipe>(Clock::GetRealTimeClock(),
618 std::move(network), receiver),
619 rtp_extensions_, rtp_extensions_);
620}
621
622void CallTest::CreateReceiveTransport(
623 const BuiltInNetworkBehaviorConfig& config,
624 RtpRtcpObserver* observer) {
625 auto network = std::make_unique<SimulatedNetwork>(config);
626 receive_simulated_network_ = network.get();
627 receive_transport_ = std::make_unique<PacketTransport>(
628 task_queue(), nullptr, observer, test::PacketTransport::kReceiver,
629 payload_type_map_,
630 std::make_unique<FakeNetworkPipe>(Clock::GetRealTimeClock(),
631 std::move(network),
632 sender_call_->Receiver()),
633 rtp_extensions_, rtp_extensions_);
634}
635
Sebastian Janssonf33905d2018-07-13 07:49:00636void CallTest::ConnectVideoSourcesToStreams() {
Sebastian Jansson3bd2c792018-07-13 11:29:03637 for (size_t i = 0; i < video_sources_.size(); ++i)
Niels Möller1c931c42018-12-18 15:08:11638 video_send_streams_[i]->SetSource(video_sources_[i].get(),
Sebastian Jansson3bd2c792018-07-13 11:29:03639 degradation_preference_);
Sebastian Janssonf33905d2018-07-13 07:49:00640}
641
eladalon445f1a12017-08-09 08:52:36642void CallTest::Start() {
Sebastian Janssonf33905d2018-07-13 07:49:00643 StartVideoStreams();
eladalon445f1a12017-08-09 08:52:36644 if (audio_send_stream_) {
645 audio_send_stream_->Start();
646 }
Tommi3176ef72022-05-22 18:47:28647 for (AudioReceiveStreamInterface* audio_recv_stream : audio_receive_streams_)
eladalon445f1a12017-08-09 08:52:36648 audio_recv_stream->Start();
Sebastian Janssonf33905d2018-07-13 07:49:00649}
650
Artem Titovf92cc6d2023-06-29 12:56:59651void CallTest::StartVideoSources() {
652 for (size_t i = 0; i < video_sources_.size(); ++i) {
653 video_sources_[i]->Start();
654 }
655}
656
Sebastian Janssonf33905d2018-07-13 07:49:00657void CallTest::StartVideoStreams() {
Artem Titovf92cc6d2023-06-29 12:56:59658 StartVideoSources();
Per Kjellander59ade012022-12-02 08:09:37659 for (size_t i = 0; i < video_send_streams_.size(); ++i) {
Per K9c166e02024-01-26 07:34:34660 video_send_streams_[i]->Start();
Per Kjellander59ade012022-12-02 08:09:37661 }
Tommif6f45432022-05-20 13:21:20662 for (VideoReceiveStreamInterface* video_recv_stream : video_receive_streams_)
Sebastian Janssonf33905d2018-07-13 07:49:00663 video_recv_stream->Start();
664}
665
eladalon445f1a12017-08-09 08:52:36666void CallTest::Stop() {
Tommi3176ef72022-05-22 18:47:28667 for (AudioReceiveStreamInterface* audio_recv_stream : audio_receive_streams_)
eladalon445f1a12017-08-09 08:52:36668 audio_recv_stream->Stop();
669 if (audio_send_stream_) {
670 audio_send_stream_->Stop();
671 }
Sebastian Jansson3bd2c792018-07-13 11:29:03672 StopVideoStreams();
673}
674
Sebastian Jansson3bd2c792018-07-13 11:29:03675void CallTest::StopVideoStreams() {
676 for (VideoSendStream* video_send_stream : video_send_streams_)
677 video_send_stream->Stop();
Tommif6f45432022-05-20 13:21:20678 for (VideoReceiveStreamInterface* video_recv_stream : video_receive_streams_)
eladalon445f1a12017-08-09 08:52:36679 video_recv_stream->Stop();
eladalon445f1a12017-08-09 08:52:36680}
681
pbos@webrtc.org994d0b72014-06-27 08:47:52682void CallTest::DestroyStreams() {
Stefan Holmer9fea80f2016-01-07 16:43:18683 if (audio_send_stream_)
684 sender_call_->DestroyAudioSendStream(audio_send_stream_);
685 audio_send_stream_ = nullptr;
Tommi3176ef72022-05-22 18:47:28686 for (AudioReceiveStreamInterface* audio_recv_stream : audio_receive_streams_)
Stefan Holmer9fea80f2016-01-07 16:43:18687 receiver_call_->DestroyAudioReceiveStream(audio_recv_stream);
Stefan Holmer9fea80f2016-01-07 16:43:18688
Sebastian Janssonf33905d2018-07-13 07:49:00689 DestroyVideoSendStreams();
ilnika014cc52017-03-07 12:21:04690
Tommif6f45432022-05-20 13:21:20691 for (VideoReceiveStreamInterface* video_recv_stream : video_receive_streams_)
brandtrfb45c6c2017-01-27 14:47:55692 receiver_call_->DestroyVideoReceiveStream(video_recv_stream);
693
brandtr841de6a2016-11-15 15:10:52694 for (FlexfecReceiveStream* flexfec_recv_stream : flexfec_receive_streams_)
695 receiver_call_->DestroyFlexfecReceiveStream(flexfec_recv_stream);
696
697 video_receive_streams_.clear();
Niels Möller3b819f32019-10-10 10:42:41698 video_sources_.clear();
pbos@webrtc.org994d0b72014-06-27 08:47:52699}
700
Sebastian Janssonf33905d2018-07-13 07:49:00701void CallTest::DestroyVideoSendStreams() {
Sebastian Jansson3bd2c792018-07-13 11:29:03702 for (VideoSendStream* video_send_stream : video_send_streams_)
703 sender_call_->DestroyVideoSendStream(video_send_stream);
704 video_send_streams_.clear();
Sebastian Janssonf33905d2018-07-13 07:49:00705}
706
eladalon445f1a12017-08-09 08:52:36707void CallTest::SetFakeVideoCaptureRotation(VideoRotation rotation) {
708 frame_generator_capturer_->SetFakeRotation(rotation);
709}
710
Sebastian Janssonf33905d2018-07-13 07:49:00711void CallTest::SetVideoDegradation(DegradationPreference preference) {
Sebastian Jansson3bd2c792018-07-13 11:29:03712 GetVideoSendStream()->SetSource(frame_generator_capturer_, preference);
Sebastian Janssonf33905d2018-07-13 07:49:00713}
714
715VideoSendStream::Config* CallTest::GetVideoSendConfig() {
Sebastian Jansson3bd2c792018-07-13 11:29:03716 return &video_send_configs_[0];
Sebastian Janssonf33905d2018-07-13 07:49:00717}
718
719void CallTest::SetVideoSendConfig(const VideoSendStream::Config& config) {
Sebastian Jansson3bd2c792018-07-13 11:29:03720 video_send_configs_.clear();
721 video_send_configs_.push_back(config.Copy());
Sebastian Janssonf33905d2018-07-13 07:49:00722}
723
724VideoEncoderConfig* CallTest::GetVideoEncoderConfig() {
Sebastian Jansson3bd2c792018-07-13 11:29:03725 return &video_encoder_configs_[0];
Sebastian Janssonf33905d2018-07-13 07:49:00726}
727
728void CallTest::SetVideoEncoderConfig(const VideoEncoderConfig& config) {
Sebastian Jansson3bd2c792018-07-13 11:29:03729 video_encoder_configs_.clear();
730 video_encoder_configs_.push_back(config.Copy());
Sebastian Janssonf33905d2018-07-13 07:49:00731}
732
733VideoSendStream* CallTest::GetVideoSendStream() {
Sebastian Jansson3bd2c792018-07-13 11:29:03734 return video_send_streams_[0];
735}
736FlexfecReceiveStream::Config* CallTest::GetFlexFecConfig() {
737 return &flexfec_receive_configs_[0];
Sebastian Janssonf33905d2018-07-13 07:49:00738}
739
Tomas Gunnarsson8408c992021-02-14 13:19:12740void CallTest::OnRtpPacket(const RtpPacketReceived& packet) {
741 // All FlexFEC streams protect all of the video streams.
742 for (FlexfecReceiveStream* flexfec_recv_stream : flexfec_receive_streams_)
743 flexfec_recv_stream->OnRtpPacket(packet);
744}
745
Elad Alond8d32482019-02-18 22:45:57746absl::optional<RtpExtension> CallTest::GetRtpExtensionByUri(
747 const std::string& uri) const {
748 for (const auto& extension : rtp_extensions_) {
749 if (extension.uri == uri) {
750 return extension;
751 }
752 }
753 return absl::nullopt;
754}
755
756void CallTest::AddRtpExtensionByUri(
757 const std::string& uri,
758 std::vector<RtpExtension>* extensions) const {
759 const absl::optional<RtpExtension> extension = GetRtpExtensionByUri(uri);
760 if (extension) {
761 extensions->push_back(*extension);
762 }
763}
764
minyue20c84cc2017-04-10 23:57:57765const std::map<uint8_t, MediaType> CallTest::payload_type_map_ = {
Artem Titov8a9f3a82023-04-25 07:56:49766 {VideoTestConstants::kVideoSendPayloadType, MediaType::VIDEO},
767 {VideoTestConstants::kFakeVideoSendPayloadType, MediaType::VIDEO},
768 {VideoTestConstants::kSendRtxPayloadType, MediaType::VIDEO},
769 {VideoTestConstants::kPayloadTypeVP8, MediaType::VIDEO},
770 {VideoTestConstants::kPayloadTypeVP9, MediaType::VIDEO},
771 {VideoTestConstants::kPayloadTypeH264, MediaType::VIDEO},
772 {VideoTestConstants::kPayloadTypeGeneric, MediaType::VIDEO},
773 {VideoTestConstants::kRedPayloadType, MediaType::VIDEO},
774 {VideoTestConstants::kRtxRedPayloadType, MediaType::VIDEO},
775 {VideoTestConstants::kUlpfecPayloadType, MediaType::VIDEO},
776 {VideoTestConstants::kFlexfecPayloadType, MediaType::VIDEO},
777 {VideoTestConstants::kAudioSendPayloadType, MediaType::AUDIO}};
minyue20c84cc2017-04-10 23:57:57778
Sebastian Jansson72582242018-07-13 11:19:42779BaseTest::BaseTest() {}
philipele828c962017-03-21 10:24:27780
Markus Handellf4f22872022-08-16 11:02:45781BaseTest::BaseTest(TimeDelta timeout) : RtpRtcpObserver(timeout) {}
pbos@webrtc.org994d0b72014-06-27 08:47:52782
Yves Gerey665174f2018-06-19 13:03:05783BaseTest::~BaseTest() {}
pbos@webrtc.org994d0b72014-06-27 08:47:52784
Artem Titov3faa8322018-03-07 13:44:00785std::unique_ptr<TestAudioDeviceModule::Capturer> BaseTest::CreateCapturer() {
786 return TestAudioDeviceModule::CreatePulsedNoiseCapturer(256, 48000);
oprypin92220ff2017-03-23 10:40:03787}
788
Artem Titov3faa8322018-03-07 13:44:00789std::unique_ptr<TestAudioDeviceModule::Renderer> BaseTest::CreateRenderer() {
790 return TestAudioDeviceModule::CreateDiscardRenderer(48000);
oprypin92220ff2017-03-23 10:40:03791}
792
Artem Titovfb8e3de2023-04-11 14:37:38793void BaseTest::OnFakeAudioDevicesCreated(AudioDeviceModule* send_audio_device,
794 AudioDeviceModule* recv_audio_device) {
795}
oprypin92220ff2017-03-23 10:40:03796
Niels Möllerde8e6e62018-11-13 14:10:33797void BaseTest::ModifySenderBitrateConfig(BitrateConstraints* bitrate_config) {}
pbos@webrtc.org994d0b72014-06-27 08:47:52798
Niels Möllerde8e6e62018-11-13 14:10:33799void BaseTest::ModifyReceiverBitrateConfig(BitrateConstraints* bitrate_config) {
800}
pbos@webrtc.org994d0b72014-06-27 08:47:52801
Yves Gerey665174f2018-06-19 13:03:05802void BaseTest::OnCallsCreated(Call* sender_call, Call* receiver_call) {}
pbos@webrtc.org994d0b72014-06-27 08:47:52803
Per Kjellander89870ff2023-01-19 15:45:58804void BaseTest::OnTransportCreated(PacketTransport* to_receiver,
805 SimulatedNetworkInterface* sender_network,
806 PacketTransport* to_sender,
807 SimulatedNetworkInterface* receiver_network) {
stefane74eef12016-01-08 14:47:13808}
809
Per Kjellander89870ff2023-01-19 15:45:58810BuiltInNetworkBehaviorConfig BaseTest::GetSendTransportConfig() const {
811 return BuiltInNetworkBehaviorConfig();
stefane74eef12016-01-08 14:47:13812}
Per Kjellander89870ff2023-01-19 15:45:58813BuiltInNetworkBehaviorConfig BaseTest::GetReceiveTransportConfig() const {
814 return BuiltInNetworkBehaviorConfig();
815}
Stefan Holmer9fea80f2016-01-07 16:43:18816size_t BaseTest::GetNumVideoStreams() const {
pbos@webrtc.org994d0b72014-06-27 08:47:52817 return 1;
818}
819
Stefan Holmer9fea80f2016-01-07 16:43:18820size_t BaseTest::GetNumAudioStreams() const {
821 return 0;
822}
823
brandtr841de6a2016-11-15 15:10:52824size_t BaseTest::GetNumFlexfecStreams() const {
825 return 0;
826}
827
stefanff483612015-12-21 11:14:00828void BaseTest::ModifyVideoConfigs(
pbos@webrtc.orgbe9d2a42014-06-30 13:19:09829 VideoSendStream::Config* send_config,
Tommif6f45432022-05-20 13:21:20830 std::vector<VideoReceiveStreamInterface::Config>* receive_configs,
stefanff483612015-12-21 11:14:00831 VideoEncoderConfig* encoder_config) {}
pbos@webrtc.org994d0b72014-06-27 08:47:52832
perkjfa10b552016-10-03 06:45:26833void BaseTest::ModifyVideoCaptureStartResolution(int* width,
834 int* heigt,
835 int* frame_rate) {}
836
Åsa Perssoncb7eddb2018-11-05 13:11:44837void BaseTest::ModifyVideoDegradationPreference(
838 DegradationPreference* degradation_preference) {}
839
stefanff483612015-12-21 11:14:00840void BaseTest::OnVideoStreamsCreated(
pbos@webrtc.orgbe9d2a42014-06-30 13:19:09841 VideoSendStream* send_stream,
Tommif6f45432022-05-20 13:21:20842 const std::vector<VideoReceiveStreamInterface*>& receive_streams) {}
pbos@webrtc.org994d0b72014-06-27 08:47:52843
Stefan Holmer9fea80f2016-01-07 16:43:18844void BaseTest::ModifyAudioConfigs(
845 AudioSendStream::Config* send_config,
Tommi3176ef72022-05-22 18:47:28846 std::vector<AudioReceiveStreamInterface::Config>* receive_configs) {}
Stefan Holmer9fea80f2016-01-07 16:43:18847
848void BaseTest::OnAudioStreamsCreated(
849 AudioSendStream* send_stream,
Tommi3176ef72022-05-22 18:47:28850 const std::vector<AudioReceiveStreamInterface*>& receive_streams) {}
Stefan Holmer9fea80f2016-01-07 16:43:18851
brandtr841de6a2016-11-15 15:10:52852void BaseTest::ModifyFlexfecConfigs(
853 std::vector<FlexfecReceiveStream::Config>* receive_configs) {}
854
855void BaseTest::OnFlexfecStreamsCreated(
856 const std::vector<FlexfecReceiveStream*>& receive_streams) {}
857
pbos@webrtc.org994d0b72014-06-27 08:47:52858void BaseTest::OnFrameGeneratorCapturerCreated(
Yves Gerey665174f2018-06-19 13:03:05859 FrameGeneratorCapturer* frame_generator_capturer) {}
pbos@webrtc.org994d0b72014-06-27 08:47:52860
Yves Gerey665174f2018-06-19 13:03:05861void BaseTest::OnStreamsStopped() {}
oprypin92220ff2017-03-23 10:40:03862
Markus Handellf4f22872022-08-16 11:02:45863SendTest::SendTest(TimeDelta timeout) : BaseTest(timeout) {}
pbos@webrtc.org994d0b72014-06-27 08:47:52864
pbos@webrtc.org994d0b72014-06-27 08:47:52865bool SendTest::ShouldCreateReceivers() const {
866 return false;
867}
868
philipele828c962017-03-21 10:24:27869EndToEndTest::EndToEndTest() {}
870
Markus Handellf4f22872022-08-16 11:02:45871EndToEndTest::EndToEndTest(TimeDelta timeout) : BaseTest(timeout) {}
pbos@webrtc.org994d0b72014-06-27 08:47:52872
pbos@webrtc.org994d0b72014-06-27 08:47:52873bool EndToEndTest::ShouldCreateReceivers() const {
874 return true;
875}
876
877} // namespace test
878} // namespace webrtc