blob: 075de6d88800bc43040207d547ec42417ed8ed9e [file] [log] [blame]
stefan@webrtc.org3d7da882014-07-08 13:59:461/*
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 */
10
Mirko Bonadei92ea95e2017-09-15 04:47:3111#ifndef CALL_RAMPUP_TESTS_H_
12#define CALL_RAMPUP_TESTS_H_
stefan@webrtc.org3d7da882014-07-08 13:59:4613
14#include <map>
Danil Chapovalov44db4362019-09-30 02:16:2815#include <memory>
stefan@webrtc.org3d7da882014-07-08 13:59:4616#include <string>
Artem Titov631cafa2018-08-21 19:01:0017#include <utility>
stefan@webrtc.org3d7da882014-07-08 13:59:4618#include <vector>
19
Danil Chapovalov83bbe912019-08-07 10:24:5320#include "api/rtc_event_log/rtc_event_log.h"
Danil Chapovalov44db4362019-09-30 02:16:2821#include "api/task_queue/task_queue_base.h"
Artem Titov46c4e602018-08-17 12:26:5422#include "api/test/simulated_network.h"
Mirko Bonadei92ea95e2017-09-15 04:47:3123#include "call/call.h"
Artem Titov631cafa2018-08-21 19:01:0024#include "call/simulated_network.h"
Mirko Bonadei92ea95e2017-09-15 04:47:3125#include "rtc_base/event.h"
Danil Chapovalov9f5ae7b2019-10-21 09:08:1326#include "rtc_base/task_utils/repeating_task.h"
Mirko Bonadei92ea95e2017-09-15 04:47:3127#include "test/call_test.h"
stefan@webrtc.org3d7da882014-07-08 13:59:4628
29namespace webrtc {
30
31static const int kTransmissionTimeOffsetExtensionId = 6;
32static const int kAbsSendTimeExtensionId = 7;
Erik Språng6b8d3552015-09-24 13:06:5733static const int kTransportSequenceNumberExtensionId = 8;
stefan@webrtc.org3d7da882014-07-08 13:59:4634static const unsigned int kSingleStreamTargetBps = 1000000;
35
36class Clock;
stefan@webrtc.org3d7da882014-07-08 13:59:4637
stefan4fbd1452015-09-28 10:57:1438class RampUpTester : public test::EndToEndTest {
stefan@webrtc.org3d7da882014-07-08 13:59:4639 public:
stefanff483612015-12-21 11:14:0040 RampUpTester(size_t num_video_streams,
41 size_t num_audio_streams,
philipel5ef2bc12017-02-21 15:28:3142 size_t num_flexfec_streams,
stefan4fbd1452015-09-28 10:57:1443 unsigned int start_bitrate_bps,
stefan5a2c5062017-01-27 14:43:1844 int64_t min_run_time_ms,
stefan4fbd1452015-09-28 10:57:1445 const std::string& extension_type,
46 bool rtx,
stefan5a2c5062017-01-27 14:43:1847 bool red,
Tommi5e005f42019-08-05 13:29:1448 bool report_perf_stats,
Danil Chapovalov9f5ae7b2019-10-21 09:08:1349 TaskQueueBase* task_queue);
stefan4fbd1452015-09-28 10:57:1450 ~RampUpTester() override;
stefan@webrtc.org3d7da882014-07-08 13:59:4651
Stefan Holmerd20e6512016-01-12 14:51:2252 size_t GetNumVideoStreams() const override;
Stefan Holmerff2a6352016-01-14 09:00:2153 size_t GetNumAudioStreams() const override;
philipel5ef2bc12017-02-21 15:28:3154 size_t GetNumFlexfecStreams() const override;
Stefan Holmerd20e6512016-01-12 14:51:2255
stefan4fbd1452015-09-28 10:57:1456 void PerformTest() override;
stefan@webrtc.org3d7da882014-07-08 13:59:4657
stefan4fbd1452015-09-28 10:57:1458 protected:
tommi0f8b4032017-02-22 19:22:0559 virtual void PollStats();
stefan@webrtc.org3d7da882014-07-08 13:59:4660
stefan092508a2015-09-29 09:26:4261 void AccumulateStats(const VideoSendStream::StreamStats& stream,
62 size_t* total_packets_sent,
63 size_t* total_sent,
64 size_t* padding_sent,
65 size_t* media_sent) const;
stefan@webrtc.org3d7da882014-07-08 13:59:4666
stefan@webrtc.org3d7da882014-07-08 13:59:4667 void ReportResult(const std::string& measurement,
68 size_t value,
stefan4fbd1452015-09-28 10:57:1469 const std::string& units) const;
70 void TriggerTestDone();
stefan@webrtc.org3d7da882014-07-08 13:59:4671
72 Clock* const clock_;
Artem Titov75e36472018-10-08 10:28:5673 BuiltInNetworkBehaviorConfig forward_transport_config_;
stefanff483612015-12-21 11:14:0074 const size_t num_video_streams_;
75 const size_t num_audio_streams_;
philipel5ef2bc12017-02-21 15:28:3176 const size_t num_flexfec_streams_;
stefan4fbd1452015-09-28 10:57:1477 const bool rtx_;
78 const bool red_;
stefan45b5fe52017-03-09 14:27:0279 const bool report_perf_stats_;
mflodman86cc6ff2016-07-26 11:44:0680 Call* sender_call_;
stefan4fbd1452015-09-28 10:57:1481 VideoSendStream* send_stream_;
stefanf116bd02015-10-27 15:29:4282 test::PacketTransport* send_transport_;
Artem Titov631cafa2018-08-21 19:01:0083 SimulatedNetwork* send_simulated_network_;
stefan@webrtc.org3d7da882014-07-08 13:59:4684
85 private:
stefan4fbd1452015-09-28 10:57:1486 typedef std::map<uint32_t, uint32_t> SsrcMap;
perkjfa10b552016-10-03 06:45:2687 class VideoStreamFactory;
stefan@webrtc.org3d7da882014-07-08 13:59:4688
Niels Möllerde8e6e62018-11-13 14:10:3389 void ModifySenderBitrateConfig(BitrateConstraints* bitrate_config) override;
stefanff483612015-12-21 11:14:0090 void OnVideoStreamsCreated(
stefan4fbd1452015-09-28 10:57:1491 VideoSendStream* send_stream,
92 const std::vector<VideoReceiveStream*>& receive_streams) override;
Danil Chapovalov44db4362019-09-30 02:16:2893 std::unique_ptr<test::PacketTransport> CreateSendTransport(
94 TaskQueueBase* task_queue,
eladalon413ee9a2017-08-22 11:02:5295 Call* sender_call) override;
stefanff483612015-12-21 11:14:0096 void ModifyVideoConfigs(
97 VideoSendStream::Config* send_config,
98 std::vector<VideoReceiveStream::Config>* receive_configs,
99 VideoEncoderConfig* encoder_config) override;
Stefan Holmerff2a6352016-01-14 09:00:21100 void ModifyAudioConfigs(
101 AudioSendStream::Config* send_config,
102 std::vector<AudioReceiveStream::Config>* receive_configs) override;
philipel5ef2bc12017-02-21 15:28:31103 void ModifyFlexfecConfigs(
104 std::vector<FlexfecReceiveStream::Config>* receive_configs) override;
stefan4fbd1452015-09-28 10:57:14105 void OnCallsCreated(Call* sender_call, Call* receiver_call) override;
stefan@webrtc.org3d7da882014-07-08 13:59:46106
stefan4fbd1452015-09-28 10:57:14107 const int start_bitrate_bps_;
stefan5a2c5062017-01-27 14:43:18108 const int64_t min_run_time_ms_;
stefan4fbd1452015-09-28 10:57:14109 int expected_bitrate_bps_;
110 int64_t test_start_ms_;
111 int64_t ramp_up_finished_ms_;
112
113 const std::string extension_type_;
stefanff483612015-12-21 11:14:00114 std::vector<uint32_t> video_ssrcs_;
115 std::vector<uint32_t> video_rtx_ssrcs_;
116 std::vector<uint32_t> audio_ssrcs_;
stefan4fbd1452015-09-28 10:57:14117
Tommi5e005f42019-08-05 13:29:14118 protected:
Danil Chapovalov9f5ae7b2019-10-21 09:08:13119 TaskQueueBase* const task_queue_;
120 RepeatingTaskHandle pending_task_;
stefan@webrtc.org3d7da882014-07-08 13:59:46121};
122
stefan4fbd1452015-09-28 10:57:14123class RampUpDownUpTester : public RampUpTester {
124 public:
Danil Chapovalov9f5ae7b2019-10-21 09:08:13125 RampUpDownUpTester(size_t num_video_streams,
126 size_t num_audio_streams,
127 size_t num_flexfec_streams,
128 unsigned int start_bitrate_bps,
129 const std::string& extension_type,
130 bool rtx,
131 bool red,
132 const std::vector<int>& loss_rates,
133 bool report_perf_stats,
134 TaskQueueBase* task_queue);
stefan4fbd1452015-09-28 10:57:14135 ~RampUpDownUpTester() override;
stefan@webrtc.org3d7da882014-07-08 13:59:46136
stefan4fbd1452015-09-28 10:57:14137 protected:
tommi0f8b4032017-02-22 19:22:05138 void PollStats() override;
stefan4fbd1452015-09-28 10:57:14139
140 private:
philipel5ef2bc12017-02-21 15:28:31141 enum TestStates {
142 kFirstRampup = 0,
143 kLowRate,
144 kSecondRampup,
145 kTestEnd,
146 kTransitionToNextState,
147 };
stefan4fbd1452015-09-28 10:57:14148
Niels Möllerde8e6e62018-11-13 14:10:33149 void ModifyReceiverBitrateConfig(BitrateConstraints* bitrate_config) override;
stefan4fbd1452015-09-28 10:57:14150
151 std::string GetModifierString() const;
stefandb752f92016-12-05 16:23:40152 int GetExpectedHighBitrate() const;
stefan38d8b3c2017-01-09 12:19:24153 int GetHighLinkCapacity() const;
philipel5ef2bc12017-02-21 15:28:31154 size_t GetFecBytes() const;
155 bool ExpectingFec() const;
stefan4fbd1452015-09-28 10:57:14156 void EvolveTestState(int bitrate_bps, bool suspended);
157
philipel5ef2bc12017-02-21 15:28:31158 const std::vector<int> link_rates_;
stefan4fbd1452015-09-28 10:57:14159 TestStates test_state_;
philipel5ef2bc12017-02-21 15:28:31160 TestStates next_state_;
stefan4fbd1452015-09-28 10:57:14161 int64_t state_start_ms_;
162 int64_t interval_start_ms_;
163 int sent_bytes_;
philipel5ef2bc12017-02-21 15:28:31164 std::vector<int> loss_rates_;
stefan@webrtc.org3d7da882014-07-08 13:59:46165};
166} // namespace webrtc
Mirko Bonadei92ea95e2017-09-15 04:47:31167#endif // CALL_RAMPUP_TESTS_H_