pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 1 | /* |
| 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 | */ |
brandtr | 841de6a | 2016-11-15 15:10:52 | [diff] [blame] | 10 | |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 11 | #include "test/call_test.h" |
brandtr | 841de6a | 2016-11-15 15:10:52 | [diff] [blame] | 12 | |
| 13 | #include <algorithm> |
Mirko Bonadei | 317a1f0 | 2019-09-17 15:06:18 | [diff] [blame] | 14 | #include <memory> |
brandtr | 841de6a | 2016-11-15 15:10:52 | [diff] [blame] | 15 | |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 16 | #include "api/audio_codecs/builtin_audio_decoder_factory.h" |
| 17 | #include "api/audio_codecs/builtin_audio_encoder_factory.h" |
Danil Chapovalov | c03d8b6 | 2023-11-29 14:54:32 | [diff] [blame] | 18 | #include "api/environment/environment.h" |
| 19 | #include "api/environment/environment_factory.h" |
Danil Chapovalov | 44db436 | 2019-09-30 02:16:28 | [diff] [blame] | 20 | #include "api/task_queue/task_queue_base.h" |
Artem Titov | 33f9d2b | 2019-12-05 14:59:00 | [diff] [blame] | 21 | #include "api/test/create_frame_generator.h" |
Jiawei Ou | c2ebe21 | 2018-11-08 18:02:56 | [diff] [blame] | 22 | #include "api/video/builtin_video_bitrate_allocator_factory.h" |
Artem Titov | 4e199e9 | 2018-08-20 11:30:39 | [diff] [blame] | 23 | #include "call/fake_network_pipe.h" |
Per Kjellander | 89870ff | 2023-01-19 15:45:58 | [diff] [blame] | 24 | #include "call/packet_receiver.h" |
Artem Titov | 4e199e9 | 2018-08-20 11:30:39 | [diff] [blame] | 25 | #include "call/simulated_network.h" |
Artem Titov | fb8e3de | 2023-04-11 14:37:38 | [diff] [blame] | 26 | #include "modules/audio_device/include/audio_device.h" |
| 27 | #include "modules/audio_device/include/test_audio_device.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 28 | #include "modules/audio_mixer/audio_mixer_impl.h" |
| 29 | #include "rtc_base/checks.h" |
| 30 | #include "rtc_base/event.h" |
Danil Chapovalov | 82a3f0a | 2019-10-21 07:24:27 | [diff] [blame] | 31 | #include "rtc_base/task_queue_for_test.h" |
Niels Möller | 4db138e | 2018-04-19 07:04:13 | [diff] [blame] | 32 | #include "test/fake_encoder.h" |
Per Kjellander | 89870ff | 2023-01-19 15:45:58 | [diff] [blame] | 33 | #include "test/rtp_rtcp_observer.h" |
Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 34 | #include "test/testsupport/file_utils.h" |
Artem Titov | 8a9f3a8 | 2023-04-25 07:56:49 | [diff] [blame] | 35 | #include "test/video_test_constants.h" |
Jonas Oreland | 6c2dae2 | 2022-09-29 08:28:24 | [diff] [blame] | 36 | #include "video/config/video_encoder_config.h" |
eladalon | 413ee9a | 2017-08-22 11:02:52 | [diff] [blame] | 37 | |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 38 | namespace webrtc { |
| 39 | namespace test { |
| 40 | |
| 41 | CallTest::CallTest() |
Danil Chapovalov | c03d8b6 | 2023-11-29 14:54:32 | [diff] [blame] | 42 | : env_(CreateEnvironment(&field_trials_)), |
| 43 | send_env_(env_), |
| 44 | recv_env_(env_), |
Bjorn A Mellem | 7a9a092 | 2019-11-26 17:19:40 | [diff] [blame] | 45 | audio_send_config_(/*send_transport=*/nullptr), |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 46 | audio_send_stream_(nullptr), |
Erik Språng | 6a32de4 | 2019-01-09 14:46:36 | [diff] [blame] | 47 | frame_generator_capturer_(nullptr), |
Niels Möller | 4db138e | 2018-04-19 07:04:13 | [diff] [blame] | 48 | fake_encoder_factory_([this]() { |
Ilya Nikolaevskiy | b0588e6 | 2018-08-27 12:12:27 | [diff] [blame] | 49 | std::unique_ptr<FakeEncoder> fake_encoder; |
| 50 | if (video_encoder_configs_[0].codec_type == kVideoCodecVP8) { |
Danil Chapovalov | c03d8b6 | 2023-11-29 14:54:32 | [diff] [blame] | 51 | fake_encoder = std::make_unique<FakeVp8Encoder>(&env_.clock()); |
Ilya Nikolaevskiy | b0588e6 | 2018-08-27 12:12:27 | [diff] [blame] | 52 | } else { |
Danil Chapovalov | c03d8b6 | 2023-11-29 14:54:32 | [diff] [blame] | 53 | fake_encoder = std::make_unique<FakeEncoder>(&env_.clock()); |
Ilya Nikolaevskiy | b0588e6 | 2018-08-27 12:12:27 | [diff] [blame] | 54 | } |
| 55 | fake_encoder->SetMaxBitrate(fake_encoder_max_bitrate_); |
| 56 | return fake_encoder; |
Niels Möller | 4db138e | 2018-04-19 07:04:13 | [diff] [blame] | 57 | }), |
Mirko Bonadei | 317a1f0 | 2019-09-17 15:06:18 | [diff] [blame] | 58 | fake_decoder_factory_([]() { return std::make_unique<FakeDecoder>(); }), |
Jiawei Ou | c2ebe21 | 2018-11-08 18:02:56 | [diff] [blame] | 59 | bitrate_allocator_factory_(CreateBuiltinVideoBitrateAllocatorFactory()), |
Stefan Holmer | 04cb763 | 2016-01-14 19:34:30 | [diff] [blame] | 60 | num_video_streams_(1), |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 61 | num_audio_streams_(0), |
brandtr | 841de6a | 2016-11-15 15:10:52 | [diff] [blame] | 62 | num_flexfec_streams_(0), |
Niels Möller | 2784a03 | 2018-03-28 12:16:04 | [diff] [blame] | 63 | audio_decoder_factory_(CreateBuiltinAudioDecoderFactory()), |
| 64 | audio_encoder_factory_(CreateBuiltinAudioEncoderFactory()), |
Danil Chapovalov | c03d8b6 | 2023-11-29 14:54:32 | [diff] [blame] | 65 | task_queue_(env_.task_queue_factory().CreateTaskQueue( |
Danil Chapovalov | 1b66890 | 2019-11-13 10:19:53 | [diff] [blame] | 66 | "CallTestTaskQueue", |
| 67 | TaskQueueFactory::Priority::NORMAL)) {} |
pbos@webrtc.org | 32452b2 | 2014-10-22 12:15:24 | [diff] [blame] | 68 | |
Danil Chapovalov | 577c580 | 2019-10-31 11:33:17 | [diff] [blame] | 69 | CallTest::~CallTest() = default; |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 70 | |
Danil Chapovalov | c03d8b6 | 2023-11-29 14:54:32 | [diff] [blame] | 71 | void 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 | |
| 77 | void 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 Alon | d8d3248 | 2019-02-18 22:45:57 | [diff] [blame] | 83 | void 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 Olsson | b2b2031 | 2020-01-14 11:11:31 | [diff] [blame] | 99 | "ID (" |
| 100 | << extension.id << " vs. " << registered_extension.id << ")."; |
Elad Alon | d8d3248 | 2019-02-18 22:45:57 | [diff] [blame] | 101 | } |
| 102 | } |
| 103 | rtp_extensions_.push_back(extension); |
| 104 | } |
| 105 | |
stefan | e74eef1 | 2016-01-08 14:47:13 | [diff] [blame] | 106 | void CallTest::RunBaseTest(BaseTest* test) { |
Danil Chapovalov | e519f38 | 2022-08-11 10:26:09 | [diff] [blame] | 107 | SendTask(task_queue(), [this, test]() { |
eladalon | 413ee9a | 2017-08-22 11:02:52 | [diff] [blame] | 108 | 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 Chapovalov | c03d8b6 | 2023-11-29 14:54:32 | [diff] [blame] | 112 | CallConfig send_config = SendCallConfig(); |
Niels Möller | de8e6e6 | 2018-11-13 14:10:33 | [diff] [blame] | 113 | test->ModifySenderBitrateConfig(&send_config.bitrate_config); |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 114 | if (num_audio_streams_ > 0) { |
eladalon | 413ee9a | 2017-08-22 11:02:52 | [diff] [blame] | 115 | CreateFakeAudioDevices(test->CreateCapturer(), test->CreateRenderer()); |
| 116 | test->OnFakeAudioDevicesCreated(fake_send_audio_device_.get(), |
| 117 | fake_recv_audio_device_.get()); |
Ivo Creusen | 62337e5 | 2018-01-09 13:17:33 | [diff] [blame] | 118 | apm_send_ = AudioProcessingBuilder().Create(); |
| 119 | apm_recv_ = AudioProcessingBuilder().Create(); |
Fredrik Solenberg | 8f5787a | 2018-01-11 12:52:30 | [diff] [blame] | 120 | EXPECT_EQ(0, fake_send_audio_device_->Init()); |
| 121 | EXPECT_EQ(0, fake_recv_audio_device_->Init()); |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 122 | AudioState::Config audio_state_config; |
aleloi | 10111bc | 2016-11-17 14:48:48 | [diff] [blame] | 123 | audio_state_config.audio_mixer = AudioMixerImpl::Create(); |
eladalon | 413ee9a | 2017-08-22 11:02:52 | [diff] [blame] | 124 | audio_state_config.audio_processing = apm_send_; |
Fredrik Solenberg | 2a87797 | 2017-12-15 15:42:15 | [diff] [blame] | 125 | audio_state_config.audio_device_module = fake_send_audio_device_; |
eladalon | 413ee9a | 2017-08-22 11:02:52 | [diff] [blame] | 126 | send_config.audio_state = AudioState::Create(audio_state_config); |
Fredrik Solenberg | d319534 | 2017-11-21 19:33:05 | [diff] [blame] | 127 | fake_send_audio_device_->RegisterAudioCallback( |
| 128 | send_config.audio_state->audio_transport()); |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 129 | } |
eladalon | 413ee9a | 2017-08-22 11:02:52 | [diff] [blame] | 130 | CreateSenderCall(send_config); |
eladalon | 413ee9a | 2017-08-22 11:02:52 | [diff] [blame] | 131 | if (test->ShouldCreateReceivers()) { |
Danil Chapovalov | c03d8b6 | 2023-11-29 14:54:32 | [diff] [blame] | 132 | CallConfig recv_config = RecvCallConfig(); |
Niels Möller | de8e6e6 | 2018-11-13 14:10:33 | [diff] [blame] | 133 | test->ModifyReceiverBitrateConfig(&recv_config.bitrate_config); |
eladalon | 413ee9a | 2017-08-22 11:02:52 | [diff] [blame] | 134 | if (num_audio_streams_ > 0) { |
| 135 | AudioState::Config audio_state_config; |
eladalon | 413ee9a | 2017-08-22 11:02:52 | [diff] [blame] | 136 | audio_state_config.audio_mixer = AudioMixerImpl::Create(); |
| 137 | audio_state_config.audio_processing = apm_recv_; |
Fredrik Solenberg | 2a87797 | 2017-12-15 15:42:15 | [diff] [blame] | 138 | audio_state_config.audio_device_module = fake_recv_audio_device_; |
eladalon | 413ee9a | 2017-08-22 11:02:52 | [diff] [blame] | 139 | recv_config.audio_state = AudioState::Create(audio_state_config); |
Fredrik Solenberg | d319534 | 2017-11-21 19:33:05 | [diff] [blame] | 140 | fake_recv_audio_device_->RegisterAudioCallback( |
Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 141 | recv_config.audio_state->audio_transport()); |
| 142 | } |
eladalon | 413ee9a | 2017-08-22 11:02:52 | [diff] [blame] | 143 | CreateReceiverCall(recv_config); |
| 144 | } |
| 145 | test->OnCallsCreated(sender_call_.get(), receiver_call_.get()); |
Per Kjellander | 89870ff | 2023-01-19 15:45:58 | [diff] [blame] | 146 | 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_); |
eladalon | 413ee9a | 2017-08-22 11:02:52 | [diff] [blame] | 151 | if (test->ShouldCreateReceivers()) { |
eladalon | 413ee9a | 2017-08-22 11:02:52 | [diff] [blame] | 152 | 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.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 161 | |
eladalon | 413ee9a | 2017-08-22 11:02:52 | [diff] [blame] | 162 | CreateSendConfig(num_video_streams_, num_audio_streams_, |
| 163 | num_flexfec_streams_, send_transport_.get()); |
| 164 | if (test->ShouldCreateReceivers()) { |
Per Kjellander | 89870ff | 2023-01-19 15:45:58 | [diff] [blame] | 165 | CreateMatchingReceiveConfigs(); |
eladalon | 413ee9a | 2017-08-22 11:02:52 | [diff] [blame] | 166 | } |
| 167 | if (num_video_streams_ > 0) { |
Sebastian Jansson | f33905d | 2018-07-13 07:49:00 | [diff] [blame] | 168 | test->ModifyVideoConfigs(GetVideoSendConfig(), &video_receive_configs_, |
| 169 | GetVideoEncoderConfig()); |
eladalon | 413ee9a | 2017-08-22 11:02:52 | [diff] [blame] | 170 | } |
| 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 Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 177 | |
eladalon | 413ee9a | 2017-08-22 11:02:52 | [diff] [blame] | 178 | if (num_flexfec_streams_ > 0) { |
| 179 | CreateFlexfecStreams(); |
| 180 | test->OnFlexfecStreamsCreated(flexfec_receive_streams_); |
| 181 | } |
| 182 | if (num_video_streams_ > 0) { |
| 183 | CreateVideoStreams(); |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 184 | test->OnVideoStreamsCreated(GetVideoSendStream(), video_receive_streams_); |
eladalon | 413ee9a | 2017-08-22 11:02:52 | [diff] [blame] | 185 | } |
| 186 | if (num_audio_streams_ > 0) { |
| 187 | CreateAudioStreams(); |
| 188 | test->OnAudioStreamsCreated(audio_send_stream_, audio_receive_streams_); |
| 189 | } |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 190 | |
eladalon | 413ee9a | 2017-08-22 11:02:52 | [diff] [blame] | 191 | if (num_video_streams_ > 0) { |
Artem Titov | 8a9f3a8 | 2023-04-25 07:56:49 | [diff] [blame] | 192 | int width = VideoTestConstants::kDefaultWidth; |
| 193 | int height = VideoTestConstants::kDefaultHeight; |
| 194 | int frame_rate = VideoTestConstants::kDefaultFramerate; |
eladalon | 413ee9a | 2017-08-22 11:02:52 | [diff] [blame] | 195 | test->ModifyVideoCaptureStartResolution(&width, &height, &frame_rate); |
Åsa Persson | cb7eddb | 2018-11-05 13:11:44 | [diff] [blame] | 196 | test->ModifyVideoDegradationPreference(°radation_preference_); |
eladalon | 413ee9a | 2017-08-22 11:02:52 | [diff] [blame] | 197 | CreateFrameGeneratorCapturer(frame_rate, width, height); |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 198 | test->OnFrameGeneratorCapturerCreated(frame_generator_capturer_); |
eladalon | 413ee9a | 2017-08-22 11:02:52 | [diff] [blame] | 199 | } |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 200 | |
eladalon | 413ee9a | 2017-08-22 11:02:52 | [diff] [blame] | 201 | Start(); |
| 202 | }); |
| 203 | |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 204 | test->PerformTest(); |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 205 | |
Danil Chapovalov | e519f38 | 2022-08-11 10:26:09 | [diff] [blame] | 206 | SendTask(task_queue(), [this, test]() { |
eladalon | 413ee9a | 2017-08-22 11:02:52 | [diff] [blame] | 207 | Stop(); |
Fredrik Solenberg | 73276ad | 2017-09-14 12:46:47 | [diff] [blame] | 208 | test->OnStreamsStopped(); |
eladalon | 413ee9a | 2017-08-22 11:02:52 | [diff] [blame] | 209 | DestroyStreams(); |
| 210 | send_transport_.reset(); |
| 211 | receive_transport_.reset(); |
Tommi | 31d1bce | 2019-08-27 09:34:20 | [diff] [blame] | 212 | |
Erik Språng | 6a32de4 | 2019-01-09 14:46:36 | [diff] [blame] | 213 | frame_generator_capturer_ = nullptr; |
eladalon | 413ee9a | 2017-08-22 11:02:52 | [diff] [blame] | 214 | DestroyCalls(); |
Tommi | 31d1bce | 2019-08-27 09:34:20 | [diff] [blame] | 215 | |
| 216 | fake_send_audio_device_ = nullptr; |
| 217 | fake_recv_audio_device_ = nullptr; |
eladalon | 413ee9a | 2017-08-22 11:02:52 | [diff] [blame] | 218 | }); |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 219 | } |
| 220 | |
Danil Chapovalov | c03d8b6 | 2023-11-29 14:54:32 | [diff] [blame] | 221 | CallConfig 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 | |
| 229 | CallConfig CallTest::RecvCallConfig() const { |
| 230 | return CallConfig(recv_env_); |
| 231 | } |
| 232 | |
Sebastian Jansson | 8e6602f | 2018-07-13 08:43:20 | [diff] [blame] | 233 | void CallTest::CreateCalls() { |
Danil Chapovalov | c03d8b6 | 2023-11-29 14:54:32 | [diff] [blame] | 234 | CreateCalls(SendCallConfig(), RecvCallConfig()); |
Sebastian Jansson | 8e6602f | 2018-07-13 08:43:20 | [diff] [blame] | 235 | } |
| 236 | |
Danil Chapovalov | a3ce407 | 2023-10-13 11:53:00 | [diff] [blame] | 237 | void CallTest::CreateCalls(const CallConfig& sender_config, |
| 238 | const CallConfig& receiver_config) { |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 239 | CreateSenderCall(sender_config); |
| 240 | CreateReceiverCall(receiver_config); |
| 241 | } |
| 242 | |
Sebastian Jansson | 8e6602f | 2018-07-13 08:43:20 | [diff] [blame] | 243 | void CallTest::CreateSenderCall() { |
Danil Chapovalov | c03d8b6 | 2023-11-29 14:54:32 | [diff] [blame] | 244 | CreateSenderCall(SendCallConfig()); |
Sebastian Jansson | 8e6602f | 2018-07-13 08:43:20 | [diff] [blame] | 245 | } |
| 246 | |
Danil Chapovalov | a3ce407 | 2023-10-13 11:53:00 | [diff] [blame] | 247 | void CallTest::CreateSenderCall(const CallConfig& config) { |
Danil Chapovalov | c03d8b6 | 2023-11-29 14:54:32 | [diff] [blame] | 248 | sender_call_ = Call::Create(config); |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 249 | } |
| 250 | |
Danil Chapovalov | a3ce407 | 2023-10-13 11:53:00 | [diff] [blame] | 251 | void CallTest::CreateReceiverCall(const CallConfig& config) { |
Danil Chapovalov | c03d8b6 | 2023-11-29 14:54:32 | [diff] [blame] | 252 | receiver_call_ = Call::Create(config); |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 253 | } |
| 254 | |
Fredrik Solenberg | 4f4ec0a | 2015-10-22 08:49:27 | [diff] [blame] | 255 | void CallTest::DestroyCalls() { |
Per Kjellander | 89870ff | 2023-01-19 15:45:58 | [diff] [blame] | 256 | send_transport_.reset(); |
| 257 | receive_transport_.reset(); |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 258 | sender_call_.reset(); |
| 259 | receiver_call_.reset(); |
Fredrik Solenberg | 4f4ec0a | 2015-10-22 08:49:27 | [diff] [blame] | 260 | } |
| 261 | |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 17:02:59 | [diff] [blame] | 262 | void CallTest::CreateVideoSendConfig(VideoSendStream::Config* video_config, |
| 263 | size_t num_video_streams, |
| 264 | size_t num_used_ssrcs, |
| 265 | Transport* send_transport) { |
Artem Titov | 8a9f3a8 | 2023-04-25 07:56:49 | [diff] [blame] | 266 | RTC_DCHECK_LE(num_video_streams + num_used_ssrcs, |
| 267 | VideoTestConstants::kNumSsrcs); |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 17:02:59 | [diff] [blame] | 268 | *video_config = VideoSendStream::Config(send_transport); |
Niels Möller | 4db138e | 2018-04-19 07:04:13 | [diff] [blame] | 269 | video_config->encoder_settings.encoder_factory = &fake_encoder_factory_; |
Jiawei Ou | c2ebe21 | 2018-11-08 18:02:56 | [diff] [blame] | 270 | video_config->encoder_settings.bitrate_allocator_factory = |
| 271 | bitrate_allocator_factory_.get(); |
Niels Möller | 259a497 | 2018-04-05 13:36:51 | [diff] [blame] | 272 | video_config->rtp.payload_name = "FAKE"; |
Artem Titov | 8a9f3a8 | 2023-04-25 07:56:49 | [diff] [blame] | 273 | video_config->rtp.payload_type = |
| 274 | VideoTestConstants::kFakeVideoSendPayloadType; |
Johannes Kron | f7f13e0 | 2018-12-12 10:17:43 | [diff] [blame] | 275 | video_config->rtp.extmap_allow_mixed = true; |
Elad Alon | d8d3248 | 2019-02-18 22:45:57 | [diff] [blame] | 276 | AddRtpExtensionByUri(RtpExtension::kTransportSequenceNumberUri, |
| 277 | &video_config->rtp.extensions); |
Per K | 5671c64 | 2023-01-25 11:58:50 | [diff] [blame] | 278 | AddRtpExtensionByUri(RtpExtension::kAbsSendTimeUri, |
| 279 | &video_config->rtp.extensions); |
| 280 | AddRtpExtensionByUri(RtpExtension::kTimestampOffsetUri, |
| 281 | &video_config->rtp.extensions); |
Elad Alon | d8d3248 | 2019-02-18 22:45:57 | [diff] [blame] | 282 | AddRtpExtensionByUri(RtpExtension::kVideoContentTypeUri, |
| 283 | &video_config->rtp.extensions); |
Elad Alon | ccb9b75 | 2019-02-19 12:01:31 | [diff] [blame] | 284 | AddRtpExtensionByUri(RtpExtension::kGenericFrameDescriptorUri00, |
| 285 | &video_config->rtp.extensions); |
Danil Chapovalov | ce515f7 | 2020-02-24 13:29:27 | [diff] [blame] | 286 | AddRtpExtensionByUri(RtpExtension::kDependencyDescriptorUri, |
| 287 | &video_config->rtp.extensions); |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 288 | if (video_encoder_configs_.empty()) { |
| 289 | video_encoder_configs_.emplace_back(); |
| 290 | FillEncoderConfiguration(kVideoCodecGeneric, num_video_streams, |
| 291 | &video_encoder_configs_.back()); |
| 292 | } |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 17:02:59 | [diff] [blame] | 293 | for (size_t i = 0; i < num_video_streams; ++i) |
Artem Titov | 8a9f3a8 | 2023-04-25 07:56:49 | [diff] [blame] | 294 | video_config->rtp.ssrcs.push_back( |
| 295 | VideoTestConstants::kVideoSendSsrcs[num_used_ssrcs + i]); |
Elad Alon | d8d3248 | 2019-02-18 22:45:57 | [diff] [blame] | 296 | AddRtpExtensionByUri(RtpExtension::kVideoRotationUri, |
| 297 | &video_config->rtp.extensions); |
| 298 | AddRtpExtensionByUri(RtpExtension::kColorSpaceUri, |
| 299 | &video_config->rtp.extensions); |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 17:02:59 | [diff] [blame] | 300 | } |
| 301 | |
| 302 | void CallTest::CreateAudioAndFecSendConfigs(size_t num_audio_streams, |
| 303 | size_t num_flexfec_streams, |
| 304 | Transport* send_transport) { |
kwiberg | af476c7 | 2016-11-28 23:21:39 | [diff] [blame] | 305 | RTC_DCHECK_LE(num_audio_streams, 1); |
| 306 | RTC_DCHECK_LE(num_flexfec_streams, 1); |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 307 | if (num_audio_streams > 0) { |
Bjorn A Mellem | 7a9a092 | 2019-11-26 17:19:40 | [diff] [blame] | 308 | AudioSendStream::Config audio_send_config(send_transport); |
Artem Titov | 8a9f3a8 | 2023-04-25 07:56:49 | [diff] [blame] | 309 | audio_send_config.rtp.ssrc = VideoTestConstants::kAudioSendSsrc; |
Per K | 5671c64 | 2023-01-25 11:58:50 | [diff] [blame] | 310 | AddRtpExtensionByUri(RtpExtension::kTransportSequenceNumberUri, |
| 311 | &audio_send_config.rtp.extensions); |
| 312 | |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 313 | audio_send_config.send_codec_spec = AudioSendStream::Config::SendCodecSpec( |
Artem Titov | 8a9f3a8 | 2023-04-25 07:56:49 | [diff] [blame] | 314 | VideoTestConstants::kAudioSendPayloadType, |
| 315 | {"opus", 48000, 2, {{"stereo", "1"}}}); |
Per K | b0d8a37 | 2023-01-26 15:11:31 | [diff] [blame] | 316 | audio_send_config.min_bitrate_bps = 6000; |
| 317 | audio_send_config.max_bitrate_bps = 60000; |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 318 | audio_send_config.encoder_factory = audio_encoder_factory_; |
| 319 | SetAudioConfig(audio_send_config); |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 320 | } |
brandtr | 841de6a | 2016-11-15 15:10:52 | [diff] [blame] | 321 | |
| 322 | // TODO(brandtr): Update this when we support multistream protection. |
| 323 | if (num_flexfec_streams > 0) { |
Artem Titov | 8a9f3a8 | 2023-04-25 07:56:49 | [diff] [blame] | 324 | SetSendFecConfig({VideoTestConstants::kVideoSendSsrcs[0]}); |
brandtr | 841de6a | 2016-11-15 15:10:52 | [diff] [blame] | 325 | } |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 326 | } |
| 327 | |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 328 | void CallTest::SetAudioConfig(const AudioSendStream::Config& config) { |
| 329 | audio_send_config_ = config; |
| 330 | } |
| 331 | |
| 332 | void CallTest::SetSendFecConfig(std::vector<uint32_t> video_send_ssrcs) { |
Artem Titov | 8a9f3a8 | 2023-04-25 07:56:49 | [diff] [blame] | 333 | GetVideoSendConfig()->rtp.flexfec.payload_type = |
| 334 | VideoTestConstants::kFlexfecPayloadType; |
| 335 | GetVideoSendConfig()->rtp.flexfec.ssrc = VideoTestConstants::kFlexfecSendSsrc; |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 336 | GetVideoSendConfig()->rtp.flexfec.protected_media_ssrcs = video_send_ssrcs; |
| 337 | } |
| 338 | |
| 339 | void CallTest::SetSendUlpFecConfig(VideoSendStream::Config* send_config) { |
Artem Titov | 8a9f3a8 | 2023-04-25 07:56:49 | [diff] [blame] | 340 | 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 Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 346 | } |
| 347 | |
| 348 | void CallTest::SetReceiveUlpFecConfig( |
Tommi | f6f4543 | 2022-05-20 13:21:20 | [diff] [blame] | 349 | VideoReceiveStreamInterface::Config* receive_config) { |
Artem Titov | 8a9f3a8 | 2023-04-25 07:56:49 | [diff] [blame] | 350 | 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 Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 356 | } |
| 357 | |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 17:02:59 | [diff] [blame] | 358 | void 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 Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 363 | video_send_configs_.clear(); |
| 364 | video_send_configs_.emplace_back(nullptr); |
| 365 | CreateVideoSendConfig(&video_send_configs_.back(), num_video_streams, 0, |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 17:02:59 | [diff] [blame] | 366 | send_transport); |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 367 | } |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 17:02:59 | [diff] [blame] | 368 | CreateAudioAndFecSendConfigs(num_audio_streams, num_flexfec_streams, |
| 369 | send_transport); |
| 370 | } |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 371 | |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 372 | void CallTest::CreateMatchingVideoReceiveConfigs( |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 17:02:59 | [diff] [blame] | 373 | const VideoSendStream::Config& video_send_config, |
| 374 | Transport* rtcp_send_transport) { |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 375 | CreateMatchingVideoReceiveConfigs(video_send_config, rtcp_send_transport, |
Per K | 9253240 | 2023-01-02 15:57:18 | [diff] [blame] | 376 | &fake_decoder_factory_, absl::nullopt, |
Niels Möller | cbcbc22 | 2018-09-28 07:07:24 | [diff] [blame] | 377 | false, 0); |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 378 | } |
| 379 | |
| 380 | void CallTest::CreateMatchingVideoReceiveConfigs( |
| 381 | const VideoSendStream::Config& video_send_config, |
| 382 | Transport* rtcp_send_transport, |
Niels Möller | cbcbc22 | 2018-09-28 07:07:24 | [diff] [blame] | 383 | VideoDecoderFactory* decoder_factory, |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 384 | 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 K | 9253240 | 2023-01-02 15:57:18 | [diff] [blame] | 389 | decoder_factory, decode_sub_stream, receiver_reference_time_report, |
| 390 | rtp_history_ms); |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 391 | } |
| 392 | |
| 393 | void CallTest::AddMatchingVideoReceiveConfigs( |
Tommi | f6f4543 | 2022-05-20 13:21:20 | [diff] [blame] | 394 | std::vector<VideoReceiveStreamInterface::Config>* receive_configs, |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 395 | const VideoSendStream::Config& video_send_config, |
| 396 | Transport* rtcp_send_transport, |
Niels Möller | cbcbc22 | 2018-09-28 07:07:24 | [diff] [blame] | 397 | VideoDecoderFactory* decoder_factory, |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 398 | absl::optional<size_t> decode_sub_stream, |
| 399 | bool receiver_reference_time_report, |
| 400 | int rtp_history_ms) { |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 17:02:59 | [diff] [blame] | 401 | RTC_DCHECK(!video_send_config.rtp.ssrcs.empty()); |
Tommi | f6f4543 | 2022-05-20 13:21:20 | [diff] [blame] | 402 | VideoReceiveStreamInterface::Config default_config(rtcp_send_transport); |
Artem Titov | 8a9f3a8 | 2023-04-25 07:56:49 | [diff] [blame] | 403 | default_config.rtp.local_ssrc = VideoTestConstants::kReceiverLocalVideoSsrc; |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 404 | 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 Nikolaevskiy | 255d1cd | 2017-12-21 17:02:59 | [diff] [blame] | 410 | for (size_t i = 0; i < video_send_config.rtp.ssrcs.size(); ++i) { |
Tommi | f6f4543 | 2022-05-20 13:21:20 | [diff] [blame] | 411 | VideoReceiveStreamInterface::Config video_recv_config( |
| 412 | default_config.Copy()); |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 413 | 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 Titov | 8a9f3a8 | 2023-04-25 07:56:49 | [diff] [blame] | 416 | video_recv_config.rtp.rtx_associated_payload_types |
| 417 | [VideoTestConstants::kSendRtxPayloadType] = |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 418 | video_send_config.rtp.payload_type; |
| 419 | } |
| 420 | video_recv_config.rtp.remote_ssrc = video_send_config.rtp.ssrcs[i]; |
Tommi | f6f4543 | 2022-05-20 13:21:20 | [diff] [blame] | 421 | VideoReceiveStreamInterface::Decoder decoder; |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 422 | |
Niels Möller | cbcbc22 | 2018-09-28 07:07:24 | [diff] [blame] | 423 | decoder.payload_type = video_send_config.rtp.payload_type; |
| 424 | decoder.video_format = SdpVideoFormat(video_send_config.rtp.payload_name); |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 425 | // Force fake decoders on non-selected simulcast streams. |
| 426 | if (!decode_sub_stream || i == *decode_sub_stream) { |
Philip Eliasson | 2b068ce | 2020-08-03 15:55:10 | [diff] [blame] | 427 | video_recv_config.decoder_factory = decoder_factory; |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 428 | } else { |
Philip Eliasson | 2b068ce | 2020-08-03 15:55:10 | [diff] [blame] | 429 | video_recv_config.decoder_factory = &fake_decoder_factory_; |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 430 | } |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 431 | video_recv_config.decoders.push_back(decoder); |
| 432 | receive_configs->emplace_back(std::move(video_recv_config)); |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 17:02:59 | [diff] [blame] | 433 | } |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 17:02:59 | [diff] [blame] | 434 | } |
| 435 | |
| 436 | void CallTest::CreateMatchingAudioAndFecConfigs( |
| 437 | Transport* rtcp_send_transport) { |
kwiberg | af476c7 | 2016-11-28 23:21:39 | [diff] [blame] | 438 | RTC_DCHECK_GE(1, num_audio_streams_); |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 439 | if (num_audio_streams_ == 1) { |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 440 | CreateMatchingAudioConfigs(rtcp_send_transport, ""); |
pbos@webrtc.org | be9d2a4 | 2014-06-30 13:19:09 | [diff] [blame] | 441 | } |
brandtr | 841de6a | 2016-11-15 15:10:52 | [diff] [blame] | 442 | |
| 443 | // TODO(brandtr): Update this when we support multistream protection. |
| 444 | RTC_DCHECK(num_flexfec_streams_ <= 1); |
| 445 | if (num_flexfec_streams_ == 1) { |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 446 | CreateMatchingFecConfig(rtcp_send_transport, *GetVideoSendConfig()); |
brandtr | 841de6a | 2016-11-15 15:10:52 | [diff] [blame] | 447 | } |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 448 | } |
| 449 | |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 450 | void 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 | |
Tommi | 3176ef7 | 2022-05-22 18:47:28 | [diff] [blame] | 456 | AudioReceiveStreamInterface::Config CallTest::CreateMatchingAudioConfig( |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 457 | const AudioSendStream::Config& send_config, |
| 458 | rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory, |
| 459 | Transport* transport, |
| 460 | std::string sync_group) { |
Tommi | 3176ef7 | 2022-05-22 18:47:28 | [diff] [blame] | 461 | AudioReceiveStreamInterface::Config audio_config; |
Artem Titov | 8a9f3a8 | 2023-04-25 07:56:49 | [diff] [blame] | 462 | audio_config.rtp.local_ssrc = VideoTestConstants::kReceiverLocalAudioSsrc; |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 463 | audio_config.rtcp_send_transport = transport; |
| 464 | audio_config.rtp.remote_ssrc = send_config.rtp.ssrc; |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 465 | audio_config.decoder_factory = audio_decoder_factory; |
Artem Titov | 8a9f3a8 | 2023-04-25 07:56:49 | [diff] [blame] | 466 | audio_config.decoder_map = { |
| 467 | {VideoTestConstants::kAudioSendPayloadType, {"opus", 48000, 2}}}; |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 468 | audio_config.sync_group = sync_group; |
| 469 | return audio_config; |
| 470 | } |
| 471 | |
| 472 | void 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; |
Tommi | 1c1f540 | 2021-06-14 08:54:20 | [diff] [blame] | 477 | config.rtp.remote_ssrc = send_config.rtp.flexfec.ssrc; |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 478 | config.protected_media_ssrcs = send_config.rtp.flexfec.protected_media_ssrcs; |
Artem Titov | 8a9f3a8 | 2023-04-25 07:56:49 | [diff] [blame] | 479 | config.rtp.local_ssrc = VideoTestConstants::kReceiverLocalVideoSsrc; |
Tomas Gunnarsson | 8408c99 | 2021-02-14 13:19:12 | [diff] [blame] | 480 | if (!video_receive_configs_.empty()) { |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 481 | video_receive_configs_[0].rtp.protected_by_flexfec = true; |
Tomas Gunnarsson | 8408c99 | 2021-02-14 13:19:12 | [diff] [blame] | 482 | video_receive_configs_[0].rtp.packet_sink_ = this; |
| 483 | } |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 484 | flexfec_receive_configs_.push_back(config); |
| 485 | } |
| 486 | |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 17:02:59 | [diff] [blame] | 487 | void CallTest::CreateMatchingReceiveConfigs(Transport* rtcp_send_transport) { |
| 488 | video_receive_configs_.clear(); |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 489 | for (VideoSendStream::Config& video_send_config : video_send_configs_) { |
| 490 | CreateMatchingVideoReceiveConfigs(video_send_config, rtcp_send_transport); |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 17:02:59 | [diff] [blame] | 491 | } |
| 492 | CreateMatchingAudioAndFecConfigs(rtcp_send_transport); |
| 493 | } |
| 494 | |
danilchap | 9c6a0c7 | 2016-02-10 18:54:47 | [diff] [blame] | 495 | void CallTest::CreateFrameGeneratorCapturerWithDrift(Clock* clock, |
perkj | fa10b55 | 2016-10-03 06:45:26 | [diff] [blame] | 496 | float speed, |
| 497 | int framerate, |
| 498 | int width, |
| 499 | int height) { |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 500 | video_sources_.clear(); |
Danil Chapovalov | a92e624 | 2019-04-18 08:58:56 | [diff] [blame] | 501 | auto frame_generator_capturer = |
Mirko Bonadei | 317a1f0 | 2019-09-17 15:06:18 | [diff] [blame] | 502 | std::make_unique<test::FrameGeneratorCapturer>( |
Danil Chapovalov | a92e624 | 2019-04-18 08:58:56 | [diff] [blame] | 503 | clock, |
Artem Titov | 33f9d2b | 2019-12-05 14:59:00 | [diff] [blame] | 504 | test::CreateSquareFrameGenerator(width, height, absl::nullopt, |
| 505 | absl::nullopt), |
Danil Chapovalov | c03d8b6 | 2023-11-29 14:54:32 | [diff] [blame] | 506 | framerate * speed, env_.task_queue_factory()); |
Danil Chapovalov | a92e624 | 2019-04-18 08:58:56 | [diff] [blame] | 507 | frame_generator_capturer_ = frame_generator_capturer.get(); |
| 508 | frame_generator_capturer->Init(); |
| 509 | video_sources_.push_back(std::move(frame_generator_capturer)); |
Sebastian Jansson | f33905d | 2018-07-13 07:49:00 | [diff] [blame] | 510 | ConnectVideoSourcesToStreams(); |
danilchap | 9c6a0c7 | 2016-02-10 18:54:47 | [diff] [blame] | 511 | } |
| 512 | |
perkj | fa10b55 | 2016-10-03 06:45:26 | [diff] [blame] | 513 | void CallTest::CreateFrameGeneratorCapturer(int framerate, |
| 514 | int width, |
| 515 | int height) { |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 516 | video_sources_.clear(); |
Danil Chapovalov | a92e624 | 2019-04-18 08:58:56 | [diff] [blame] | 517 | auto frame_generator_capturer = |
Mirko Bonadei | 317a1f0 | 2019-09-17 15:06:18 | [diff] [blame] | 518 | std::make_unique<test::FrameGeneratorCapturer>( |
Danil Chapovalov | c03d8b6 | 2023-11-29 14:54:32 | [diff] [blame] | 519 | &env_.clock(), |
Artem Titov | 33f9d2b | 2019-12-05 14:59:00 | [diff] [blame] | 520 | test::CreateSquareFrameGenerator(width, height, absl::nullopt, |
| 521 | absl::nullopt), |
Danil Chapovalov | c03d8b6 | 2023-11-29 14:54:32 | [diff] [blame] | 522 | framerate, env_.task_queue_factory()); |
Danil Chapovalov | a92e624 | 2019-04-18 08:58:56 | [diff] [blame] | 523 | frame_generator_capturer_ = frame_generator_capturer.get(); |
| 524 | frame_generator_capturer->Init(); |
| 525 | video_sources_.push_back(std::move(frame_generator_capturer)); |
Sebastian Jansson | f33905d | 2018-07-13 07:49:00 | [diff] [blame] | 526 | ConnectVideoSourcesToStreams(); |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 527 | } |
pbos | f1828e8 | 2015-07-28 15:20:59 | [diff] [blame] | 528 | |
oprypin | 92220ff | 2017-03-23 10:40:03 | [diff] [blame] | 529 | void CallTest::CreateFakeAudioDevices( |
Artem Titov | 3faa832 | 2018-03-07 13:44:00 | [diff] [blame] | 530 | std::unique_ptr<TestAudioDeviceModule::Capturer> capturer, |
| 531 | std::unique_ptr<TestAudioDeviceModule::Renderer> renderer) { |
Danil Chapovalov | 08fa953 | 2019-06-12 11:49:17 | [diff] [blame] | 532 | fake_send_audio_device_ = TestAudioDeviceModule::Create( |
Danil Chapovalov | c03d8b6 | 2023-11-29 14:54:32 | [diff] [blame] | 533 | &env_.task_queue_factory(), std::move(capturer), nullptr, 1.f); |
Danil Chapovalov | 08fa953 | 2019-06-12 11:49:17 | [diff] [blame] | 534 | fake_recv_audio_device_ = TestAudioDeviceModule::Create( |
Danil Chapovalov | c03d8b6 | 2023-11-29 14:54:32 | [diff] [blame] | 535 | &env_.task_queue_factory(), nullptr, std::move(renderer), 1.f); |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 536 | } |
| 537 | |
| 538 | void CallTest::CreateVideoStreams() { |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 539 | RTC_DCHECK(video_receive_streams_.empty()); |
Sebastian Jansson | f33905d | 2018-07-13 07:49:00 | [diff] [blame] | 540 | CreateVideoSendStreams(); |
stefan | ff48361 | 2015-12-21 11:14:00 | [diff] [blame] | 541 | for (size_t i = 0; i < video_receive_configs_.size(); ++i) { |
Tommi | 733b547 | 2016-06-10 15:58:01 | [diff] [blame] | 542 | video_receive_streams_.push_back(receiver_call_->CreateVideoReceiveStream( |
| 543 | video_receive_configs_[i].Copy())); |
pbos@webrtc.org | be9d2a4 | 2014-06-30 13:19:09 | [diff] [blame] | 544 | } |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 545 | } |
| 546 | |
Sebastian Jansson | f33905d | 2018-07-13 07:49:00 | [diff] [blame] | 547 | void CallTest::CreateVideoSendStreams() { |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 548 | 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 Chapovalov | 55a6189 | 2024-01-03 17:39:27 | [diff] [blame] | 575 | fec_controller_factory_->CreateFecController(send_env_)); |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 576 | } else { |
| 577 | video_send_streams_[i] = sender_call_->CreateVideoSendStream( |
| 578 | video_send_configs_[i].Copy(), video_encoder_configs_[i].Copy()); |
| 579 | } |
| 580 | } |
Sebastian Jansson | f33905d | 2018-07-13 07:49:00 | [diff] [blame] | 581 | } |
| 582 | |
| 583 | void CallTest::CreateVideoSendStream(const VideoEncoderConfig& encoder_config) { |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 584 | RTC_DCHECK(video_send_streams_.empty()); |
| 585 | video_send_streams_.push_back(sender_call_->CreateVideoSendStream( |
| 586 | GetVideoSendConfig()->Copy(), encoder_config.Copy())); |
Sebastian Jansson | f33905d | 2018-07-13 07:49:00 | [diff] [blame] | 587 | } |
| 588 | |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 589 | void CallTest::CreateAudioStreams() { |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 17:02:59 | [diff] [blame] | 590 | RTC_DCHECK(audio_send_stream_ == nullptr); |
| 591 | RTC_DCHECK(audio_receive_streams_.empty()); |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 592 | 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 Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 597 | } |
| 598 | |
brandtr | 841de6a | 2016-11-15 15:10:52 | [diff] [blame] | 599 | void 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 | } |
eladalon | c0d481a | 2017-08-02 14:39:07 | [diff] [blame] | 605 | } |
| 606 | |
Per Kjellander | 89870ff | 2023-01-19 15:45:58 | [diff] [blame] | 607 | void 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 | |
| 622 | void 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 Jansson | f33905d | 2018-07-13 07:49:00 | [diff] [blame] | 636 | void CallTest::ConnectVideoSourcesToStreams() { |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 637 | for (size_t i = 0; i < video_sources_.size(); ++i) |
Niels Möller | 1c931c4 | 2018-12-18 15:08:11 | [diff] [blame] | 638 | video_send_streams_[i]->SetSource(video_sources_[i].get(), |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 639 | degradation_preference_); |
Sebastian Jansson | f33905d | 2018-07-13 07:49:00 | [diff] [blame] | 640 | } |
| 641 | |
eladalon | 445f1a1 | 2017-08-09 08:52:36 | [diff] [blame] | 642 | void CallTest::Start() { |
Sebastian Jansson | f33905d | 2018-07-13 07:49:00 | [diff] [blame] | 643 | StartVideoStreams(); |
eladalon | 445f1a1 | 2017-08-09 08:52:36 | [diff] [blame] | 644 | if (audio_send_stream_) { |
| 645 | audio_send_stream_->Start(); |
| 646 | } |
Tommi | 3176ef7 | 2022-05-22 18:47:28 | [diff] [blame] | 647 | for (AudioReceiveStreamInterface* audio_recv_stream : audio_receive_streams_) |
eladalon | 445f1a1 | 2017-08-09 08:52:36 | [diff] [blame] | 648 | audio_recv_stream->Start(); |
Sebastian Jansson | f33905d | 2018-07-13 07:49:00 | [diff] [blame] | 649 | } |
| 650 | |
Artem Titov | f92cc6d | 2023-06-29 12:56:59 | [diff] [blame] | 651 | void CallTest::StartVideoSources() { |
| 652 | for (size_t i = 0; i < video_sources_.size(); ++i) { |
| 653 | video_sources_[i]->Start(); |
| 654 | } |
| 655 | } |
| 656 | |
Sebastian Jansson | f33905d | 2018-07-13 07:49:00 | [diff] [blame] | 657 | void CallTest::StartVideoStreams() { |
Artem Titov | f92cc6d | 2023-06-29 12:56:59 | [diff] [blame] | 658 | StartVideoSources(); |
Per Kjellander | 59ade01 | 2022-12-02 08:09:37 | [diff] [blame] | 659 | for (size_t i = 0; i < video_send_streams_.size(); ++i) { |
Per K | 9c166e0 | 2024-01-26 07:34:34 | [diff] [blame] | 660 | video_send_streams_[i]->Start(); |
Per Kjellander | 59ade01 | 2022-12-02 08:09:37 | [diff] [blame] | 661 | } |
Tommi | f6f4543 | 2022-05-20 13:21:20 | [diff] [blame] | 662 | for (VideoReceiveStreamInterface* video_recv_stream : video_receive_streams_) |
Sebastian Jansson | f33905d | 2018-07-13 07:49:00 | [diff] [blame] | 663 | video_recv_stream->Start(); |
| 664 | } |
| 665 | |
eladalon | 445f1a1 | 2017-08-09 08:52:36 | [diff] [blame] | 666 | void CallTest::Stop() { |
Tommi | 3176ef7 | 2022-05-22 18:47:28 | [diff] [blame] | 667 | for (AudioReceiveStreamInterface* audio_recv_stream : audio_receive_streams_) |
eladalon | 445f1a1 | 2017-08-09 08:52:36 | [diff] [blame] | 668 | audio_recv_stream->Stop(); |
| 669 | if (audio_send_stream_) { |
| 670 | audio_send_stream_->Stop(); |
| 671 | } |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 672 | StopVideoStreams(); |
| 673 | } |
| 674 | |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 675 | void CallTest::StopVideoStreams() { |
| 676 | for (VideoSendStream* video_send_stream : video_send_streams_) |
| 677 | video_send_stream->Stop(); |
Tommi | f6f4543 | 2022-05-20 13:21:20 | [diff] [blame] | 678 | for (VideoReceiveStreamInterface* video_recv_stream : video_receive_streams_) |
eladalon | 445f1a1 | 2017-08-09 08:52:36 | [diff] [blame] | 679 | video_recv_stream->Stop(); |
eladalon | 445f1a1 | 2017-08-09 08:52:36 | [diff] [blame] | 680 | } |
| 681 | |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 682 | void CallTest::DestroyStreams() { |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 683 | if (audio_send_stream_) |
| 684 | sender_call_->DestroyAudioSendStream(audio_send_stream_); |
| 685 | audio_send_stream_ = nullptr; |
Tommi | 3176ef7 | 2022-05-22 18:47:28 | [diff] [blame] | 686 | for (AudioReceiveStreamInterface* audio_recv_stream : audio_receive_streams_) |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 687 | receiver_call_->DestroyAudioReceiveStream(audio_recv_stream); |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 688 | |
Sebastian Jansson | f33905d | 2018-07-13 07:49:00 | [diff] [blame] | 689 | DestroyVideoSendStreams(); |
ilnik | a014cc5 | 2017-03-07 12:21:04 | [diff] [blame] | 690 | |
Tommi | f6f4543 | 2022-05-20 13:21:20 | [diff] [blame] | 691 | for (VideoReceiveStreamInterface* video_recv_stream : video_receive_streams_) |
brandtr | fb45c6c | 2017-01-27 14:47:55 | [diff] [blame] | 692 | receiver_call_->DestroyVideoReceiveStream(video_recv_stream); |
| 693 | |
brandtr | 841de6a | 2016-11-15 15:10:52 | [diff] [blame] | 694 | for (FlexfecReceiveStream* flexfec_recv_stream : flexfec_receive_streams_) |
| 695 | receiver_call_->DestroyFlexfecReceiveStream(flexfec_recv_stream); |
| 696 | |
| 697 | video_receive_streams_.clear(); |
Niels Möller | 3b819f3 | 2019-10-10 10:42:41 | [diff] [blame] | 698 | video_sources_.clear(); |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 699 | } |
| 700 | |
Sebastian Jansson | f33905d | 2018-07-13 07:49:00 | [diff] [blame] | 701 | void CallTest::DestroyVideoSendStreams() { |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 702 | for (VideoSendStream* video_send_stream : video_send_streams_) |
| 703 | sender_call_->DestroyVideoSendStream(video_send_stream); |
| 704 | video_send_streams_.clear(); |
Sebastian Jansson | f33905d | 2018-07-13 07:49:00 | [diff] [blame] | 705 | } |
| 706 | |
eladalon | 445f1a1 | 2017-08-09 08:52:36 | [diff] [blame] | 707 | void CallTest::SetFakeVideoCaptureRotation(VideoRotation rotation) { |
| 708 | frame_generator_capturer_->SetFakeRotation(rotation); |
| 709 | } |
| 710 | |
Sebastian Jansson | f33905d | 2018-07-13 07:49:00 | [diff] [blame] | 711 | void CallTest::SetVideoDegradation(DegradationPreference preference) { |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 712 | GetVideoSendStream()->SetSource(frame_generator_capturer_, preference); |
Sebastian Jansson | f33905d | 2018-07-13 07:49:00 | [diff] [blame] | 713 | } |
| 714 | |
| 715 | VideoSendStream::Config* CallTest::GetVideoSendConfig() { |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 716 | return &video_send_configs_[0]; |
Sebastian Jansson | f33905d | 2018-07-13 07:49:00 | [diff] [blame] | 717 | } |
| 718 | |
| 719 | void CallTest::SetVideoSendConfig(const VideoSendStream::Config& config) { |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 720 | video_send_configs_.clear(); |
| 721 | video_send_configs_.push_back(config.Copy()); |
Sebastian Jansson | f33905d | 2018-07-13 07:49:00 | [diff] [blame] | 722 | } |
| 723 | |
| 724 | VideoEncoderConfig* CallTest::GetVideoEncoderConfig() { |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 725 | return &video_encoder_configs_[0]; |
Sebastian Jansson | f33905d | 2018-07-13 07:49:00 | [diff] [blame] | 726 | } |
| 727 | |
| 728 | void CallTest::SetVideoEncoderConfig(const VideoEncoderConfig& config) { |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 729 | video_encoder_configs_.clear(); |
| 730 | video_encoder_configs_.push_back(config.Copy()); |
Sebastian Jansson | f33905d | 2018-07-13 07:49:00 | [diff] [blame] | 731 | } |
| 732 | |
| 733 | VideoSendStream* CallTest::GetVideoSendStream() { |
Sebastian Jansson | 3bd2c79 | 2018-07-13 11:29:03 | [diff] [blame] | 734 | return video_send_streams_[0]; |
| 735 | } |
| 736 | FlexfecReceiveStream::Config* CallTest::GetFlexFecConfig() { |
| 737 | return &flexfec_receive_configs_[0]; |
Sebastian Jansson | f33905d | 2018-07-13 07:49:00 | [diff] [blame] | 738 | } |
| 739 | |
Tomas Gunnarsson | 8408c99 | 2021-02-14 13:19:12 | [diff] [blame] | 740 | void 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 Alon | d8d3248 | 2019-02-18 22:45:57 | [diff] [blame] | 746 | absl::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 | |
| 756 | void 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 | |
minyue | 20c84cc | 2017-04-10 23:57:57 | [diff] [blame] | 765 | const std::map<uint8_t, MediaType> CallTest::payload_type_map_ = { |
Artem Titov | 8a9f3a8 | 2023-04-25 07:56:49 | [diff] [blame] | 766 | {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}}; |
minyue | 20c84cc | 2017-04-10 23:57:57 | [diff] [blame] | 778 | |
Sebastian Jansson | 7258224 | 2018-07-13 11:19:42 | [diff] [blame] | 779 | BaseTest::BaseTest() {} |
philipel | e828c96 | 2017-03-21 10:24:27 | [diff] [blame] | 780 | |
Markus Handell | f4f2287 | 2022-08-16 11:02:45 | [diff] [blame] | 781 | BaseTest::BaseTest(TimeDelta timeout) : RtpRtcpObserver(timeout) {} |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 782 | |
Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 783 | BaseTest::~BaseTest() {} |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 784 | |
Artem Titov | 3faa832 | 2018-03-07 13:44:00 | [diff] [blame] | 785 | std::unique_ptr<TestAudioDeviceModule::Capturer> BaseTest::CreateCapturer() { |
| 786 | return TestAudioDeviceModule::CreatePulsedNoiseCapturer(256, 48000); |
oprypin | 92220ff | 2017-03-23 10:40:03 | [diff] [blame] | 787 | } |
| 788 | |
Artem Titov | 3faa832 | 2018-03-07 13:44:00 | [diff] [blame] | 789 | std::unique_ptr<TestAudioDeviceModule::Renderer> BaseTest::CreateRenderer() { |
| 790 | return TestAudioDeviceModule::CreateDiscardRenderer(48000); |
oprypin | 92220ff | 2017-03-23 10:40:03 | [diff] [blame] | 791 | } |
| 792 | |
Artem Titov | fb8e3de | 2023-04-11 14:37:38 | [diff] [blame] | 793 | void BaseTest::OnFakeAudioDevicesCreated(AudioDeviceModule* send_audio_device, |
| 794 | AudioDeviceModule* recv_audio_device) { |
| 795 | } |
oprypin | 92220ff | 2017-03-23 10:40:03 | [diff] [blame] | 796 | |
Niels Möller | de8e6e6 | 2018-11-13 14:10:33 | [diff] [blame] | 797 | void BaseTest::ModifySenderBitrateConfig(BitrateConstraints* bitrate_config) {} |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 798 | |
Niels Möller | de8e6e6 | 2018-11-13 14:10:33 | [diff] [blame] | 799 | void BaseTest::ModifyReceiverBitrateConfig(BitrateConstraints* bitrate_config) { |
| 800 | } |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 801 | |
Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 802 | void BaseTest::OnCallsCreated(Call* sender_call, Call* receiver_call) {} |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 803 | |
Per Kjellander | 89870ff | 2023-01-19 15:45:58 | [diff] [blame] | 804 | void BaseTest::OnTransportCreated(PacketTransport* to_receiver, |
| 805 | SimulatedNetworkInterface* sender_network, |
| 806 | PacketTransport* to_sender, |
| 807 | SimulatedNetworkInterface* receiver_network) { |
stefan | e74eef1 | 2016-01-08 14:47:13 | [diff] [blame] | 808 | } |
| 809 | |
Per Kjellander | 89870ff | 2023-01-19 15:45:58 | [diff] [blame] | 810 | BuiltInNetworkBehaviorConfig BaseTest::GetSendTransportConfig() const { |
| 811 | return BuiltInNetworkBehaviorConfig(); |
stefan | e74eef1 | 2016-01-08 14:47:13 | [diff] [blame] | 812 | } |
Per Kjellander | 89870ff | 2023-01-19 15:45:58 | [diff] [blame] | 813 | BuiltInNetworkBehaviorConfig BaseTest::GetReceiveTransportConfig() const { |
| 814 | return BuiltInNetworkBehaviorConfig(); |
| 815 | } |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 816 | size_t BaseTest::GetNumVideoStreams() const { |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 817 | return 1; |
| 818 | } |
| 819 | |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 820 | size_t BaseTest::GetNumAudioStreams() const { |
| 821 | return 0; |
| 822 | } |
| 823 | |
brandtr | 841de6a | 2016-11-15 15:10:52 | [diff] [blame] | 824 | size_t BaseTest::GetNumFlexfecStreams() const { |
| 825 | return 0; |
| 826 | } |
| 827 | |
stefan | ff48361 | 2015-12-21 11:14:00 | [diff] [blame] | 828 | void BaseTest::ModifyVideoConfigs( |
pbos@webrtc.org | be9d2a4 | 2014-06-30 13:19:09 | [diff] [blame] | 829 | VideoSendStream::Config* send_config, |
Tommi | f6f4543 | 2022-05-20 13:21:20 | [diff] [blame] | 830 | std::vector<VideoReceiveStreamInterface::Config>* receive_configs, |
stefan | ff48361 | 2015-12-21 11:14:00 | [diff] [blame] | 831 | VideoEncoderConfig* encoder_config) {} |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 832 | |
perkj | fa10b55 | 2016-10-03 06:45:26 | [diff] [blame] | 833 | void BaseTest::ModifyVideoCaptureStartResolution(int* width, |
| 834 | int* heigt, |
| 835 | int* frame_rate) {} |
| 836 | |
Åsa Persson | cb7eddb | 2018-11-05 13:11:44 | [diff] [blame] | 837 | void BaseTest::ModifyVideoDegradationPreference( |
| 838 | DegradationPreference* degradation_preference) {} |
| 839 | |
stefan | ff48361 | 2015-12-21 11:14:00 | [diff] [blame] | 840 | void BaseTest::OnVideoStreamsCreated( |
pbos@webrtc.org | be9d2a4 | 2014-06-30 13:19:09 | [diff] [blame] | 841 | VideoSendStream* send_stream, |
Tommi | f6f4543 | 2022-05-20 13:21:20 | [diff] [blame] | 842 | const std::vector<VideoReceiveStreamInterface*>& receive_streams) {} |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 843 | |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 844 | void BaseTest::ModifyAudioConfigs( |
| 845 | AudioSendStream::Config* send_config, |
Tommi | 3176ef7 | 2022-05-22 18:47:28 | [diff] [blame] | 846 | std::vector<AudioReceiveStreamInterface::Config>* receive_configs) {} |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 847 | |
| 848 | void BaseTest::OnAudioStreamsCreated( |
| 849 | AudioSendStream* send_stream, |
Tommi | 3176ef7 | 2022-05-22 18:47:28 | [diff] [blame] | 850 | const std::vector<AudioReceiveStreamInterface*>& receive_streams) {} |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 851 | |
brandtr | 841de6a | 2016-11-15 15:10:52 | [diff] [blame] | 852 | void BaseTest::ModifyFlexfecConfigs( |
| 853 | std::vector<FlexfecReceiveStream::Config>* receive_configs) {} |
| 854 | |
| 855 | void BaseTest::OnFlexfecStreamsCreated( |
| 856 | const std::vector<FlexfecReceiveStream*>& receive_streams) {} |
| 857 | |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 858 | void BaseTest::OnFrameGeneratorCapturerCreated( |
Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 859 | FrameGeneratorCapturer* frame_generator_capturer) {} |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 860 | |
Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 861 | void BaseTest::OnStreamsStopped() {} |
oprypin | 92220ff | 2017-03-23 10:40:03 | [diff] [blame] | 862 | |
Markus Handell | f4f2287 | 2022-08-16 11:02:45 | [diff] [blame] | 863 | SendTest::SendTest(TimeDelta timeout) : BaseTest(timeout) {} |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 864 | |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 865 | bool SendTest::ShouldCreateReceivers() const { |
| 866 | return false; |
| 867 | } |
| 868 | |
philipel | e828c96 | 2017-03-21 10:24:27 | [diff] [blame] | 869 | EndToEndTest::EndToEndTest() {} |
| 870 | |
Markus Handell | f4f2287 | 2022-08-16 11:02:45 | [diff] [blame] | 871 | EndToEndTest::EndToEndTest(TimeDelta timeout) : BaseTest(timeout) {} |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 872 | |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 873 | bool EndToEndTest::ShouldCreateReceivers() const { |
| 874 | return true; |
| 875 | } |
| 876 | |
| 877 | } // namespace test |
| 878 | } // namespace webrtc |