stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [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 | */ |
| 10 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef CALL_RAMPUP_TESTS_H_ |
| 12 | #define CALL_RAMPUP_TESTS_H_ |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 13 | |
| 14 | #include <map> |
| 15 | #include <string> |
| 16 | #include <vector> |
| 17 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 18 | #include "call/call.h" |
| 19 | #include "logging/rtc_event_log/rtc_event_log.h" |
| 20 | #include "rtc_base/event.h" |
| 21 | #include "test/call_test.h" |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 22 | |
| 23 | namespace webrtc { |
| 24 | |
| 25 | static const int kTransmissionTimeOffsetExtensionId = 6; |
| 26 | static const int kAbsSendTimeExtensionId = 7; |
Erik Språng | 6b8d355 | 2015-09-24 15:06:57 +0200 | [diff] [blame] | 27 | static const int kTransportSequenceNumberExtensionId = 8; |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 28 | static const unsigned int kSingleStreamTargetBps = 1000000; |
| 29 | |
| 30 | class Clock; |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 31 | |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 32 | class RampUpTester : public test::EndToEndTest { |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 33 | public: |
stefan | ff48361 | 2015-12-21 03:14:00 -0800 | [diff] [blame] | 34 | RampUpTester(size_t num_video_streams, |
| 35 | size_t num_audio_streams, |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 36 | size_t num_flexfec_streams, |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 37 | unsigned int start_bitrate_bps, |
stefan | 5a2c506 | 2017-01-27 06:43:18 -0800 | [diff] [blame] | 38 | int64_t min_run_time_ms, |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 39 | const std::string& extension_type, |
| 40 | bool rtx, |
stefan | 5a2c506 | 2017-01-27 06:43:18 -0800 | [diff] [blame] | 41 | bool red, |
| 42 | bool report_perf_stats); |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 43 | ~RampUpTester() override; |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 44 | |
Stefan Holmer | d20e651 | 2016-01-12 15:51:22 +0100 | [diff] [blame] | 45 | size_t GetNumVideoStreams() const override; |
Stefan Holmer | ff2a635 | 2016-01-14 10:00:21 +0100 | [diff] [blame] | 46 | size_t GetNumAudioStreams() const override; |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 47 | size_t GetNumFlexfecStreams() const override; |
Stefan Holmer | d20e651 | 2016-01-12 15:51:22 +0100 | [diff] [blame] | 48 | |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 49 | void PerformTest() override; |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 50 | |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 51 | protected: |
tommi | 0f8b403 | 2017-02-22 11:22:05 -0800 | [diff] [blame] | 52 | virtual void PollStats(); |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 53 | |
stefan | 092508a | 2015-09-29 02:26:42 -0700 | [diff] [blame] | 54 | void AccumulateStats(const VideoSendStream::StreamStats& stream, |
| 55 | size_t* total_packets_sent, |
| 56 | size_t* total_sent, |
| 57 | size_t* padding_sent, |
| 58 | size_t* media_sent) const; |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 59 | |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 60 | void ReportResult(const std::string& measurement, |
| 61 | size_t value, |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 62 | const std::string& units) const; |
| 63 | void TriggerTestDone(); |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 64 | |
skvlad | 11a9cbf | 2016-10-07 11:53:05 -0700 | [diff] [blame] | 65 | webrtc::RtcEventLogNullImpl event_log_; |
tommi | 0f8b403 | 2017-02-22 11:22:05 -0800 | [diff] [blame] | 66 | rtc::Event stop_event_; |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 67 | Clock* const clock_; |
stefan | f116bd0 | 2015-10-27 08:29:42 -0700 | [diff] [blame] | 68 | FakeNetworkPipe::Config forward_transport_config_; |
stefan | ff48361 | 2015-12-21 03:14:00 -0800 | [diff] [blame] | 69 | const size_t num_video_streams_; |
| 70 | const size_t num_audio_streams_; |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 71 | const size_t num_flexfec_streams_; |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 72 | const bool rtx_; |
| 73 | const bool red_; |
stefan | 45b5fe5 | 2017-03-09 06:27:02 -0800 | [diff] [blame] | 74 | const bool report_perf_stats_; |
mflodman | 86cc6ff | 2016-07-26 04:44:06 -0700 | [diff] [blame] | 75 | Call* sender_call_; |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 76 | VideoSendStream* send_stream_; |
stefan | f116bd0 | 2015-10-27 08:29:42 -0700 | [diff] [blame] | 77 | test::PacketTransport* send_transport_; |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 78 | |
| 79 | private: |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 80 | typedef std::map<uint32_t, uint32_t> SsrcMap; |
perkj | fa10b55 | 2016-10-02 23:45:26 -0700 | [diff] [blame] | 81 | class VideoStreamFactory; |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 82 | |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 83 | Call::Config GetSenderCallConfig() override; |
stefan | ff48361 | 2015-12-21 03:14:00 -0800 | [diff] [blame] | 84 | void OnVideoStreamsCreated( |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 85 | VideoSendStream* send_stream, |
| 86 | const std::vector<VideoReceiveStream*>& receive_streams) override; |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 87 | test::PacketTransport* CreateSendTransport( |
| 88 | test::SingleThreadedTaskQueueForTesting* task_queue, |
| 89 | Call* sender_call) override; |
stefan | ff48361 | 2015-12-21 03:14:00 -0800 | [diff] [blame] | 90 | void ModifyVideoConfigs( |
| 91 | VideoSendStream::Config* send_config, |
| 92 | std::vector<VideoReceiveStream::Config>* receive_configs, |
| 93 | VideoEncoderConfig* encoder_config) override; |
Stefan Holmer | ff2a635 | 2016-01-14 10:00:21 +0100 | [diff] [blame] | 94 | void ModifyAudioConfigs( |
| 95 | AudioSendStream::Config* send_config, |
| 96 | std::vector<AudioReceiveStream::Config>* receive_configs) override; |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 97 | void ModifyFlexfecConfigs( |
| 98 | std::vector<FlexfecReceiveStream::Config>* receive_configs) override; |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 99 | void OnCallsCreated(Call* sender_call, Call* receiver_call) override; |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 100 | |
tommi | 0f8b403 | 2017-02-22 11:22:05 -0800 | [diff] [blame] | 101 | static void BitrateStatsPollingThread(void* obj); |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 102 | |
| 103 | const int start_bitrate_bps_; |
stefan | 5a2c506 | 2017-01-27 06:43:18 -0800 | [diff] [blame] | 104 | const int64_t min_run_time_ms_; |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 105 | int expected_bitrate_bps_; |
| 106 | int64_t test_start_ms_; |
| 107 | int64_t ramp_up_finished_ms_; |
| 108 | |
| 109 | const std::string extension_type_; |
stefan | ff48361 | 2015-12-21 03:14:00 -0800 | [diff] [blame] | 110 | std::vector<uint32_t> video_ssrcs_; |
| 111 | std::vector<uint32_t> video_rtx_ssrcs_; |
| 112 | std::vector<uint32_t> audio_ssrcs_; |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 113 | |
Peter Boström | 8c38e8b | 2015-11-26 17:45:47 +0100 | [diff] [blame] | 114 | rtc::PlatformThread poller_thread_; |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 115 | }; |
| 116 | |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 117 | class RampUpDownUpTester : public RampUpTester { |
| 118 | public: |
Stefan Holmer | ff2a635 | 2016-01-14 10:00:21 +0100 | [diff] [blame] | 119 | RampUpDownUpTester(size_t num_video_streams, |
| 120 | size_t num_audio_streams, |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 121 | size_t num_flexfec_streams, |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 122 | unsigned int start_bitrate_bps, |
Shao Changbin | e62202f | 2015-04-21 20:24:50 +0800 | [diff] [blame] | 123 | const std::string& extension_type, |
| 124 | bool rtx, |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 125 | bool red, |
stefan | 45b5fe5 | 2017-03-09 06:27:02 -0800 | [diff] [blame] | 126 | const std::vector<int>& loss_rates, |
| 127 | bool report_perf_stats); |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 128 | ~RampUpDownUpTester() override; |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 129 | |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 130 | protected: |
tommi | 0f8b403 | 2017-02-22 11:22:05 -0800 | [diff] [blame] | 131 | void PollStats() override; |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 132 | |
| 133 | private: |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 134 | enum TestStates { |
| 135 | kFirstRampup = 0, |
| 136 | kLowRate, |
| 137 | kSecondRampup, |
| 138 | kTestEnd, |
| 139 | kTransitionToNextState, |
| 140 | }; |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 141 | |
| 142 | Call::Config GetReceiverCallConfig() override; |
| 143 | |
| 144 | std::string GetModifierString() const; |
stefan | db752f9 | 2016-12-05 08:23:40 -0800 | [diff] [blame] | 145 | int GetExpectedHighBitrate() const; |
stefan | 38d8b3c | 2017-01-09 04:19:24 -0800 | [diff] [blame] | 146 | int GetHighLinkCapacity() const; |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 147 | size_t GetFecBytes() const; |
| 148 | bool ExpectingFec() const; |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 149 | void EvolveTestState(int bitrate_bps, bool suspended); |
| 150 | |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 151 | const std::vector<int> link_rates_; |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 152 | TestStates test_state_; |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 153 | TestStates next_state_; |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 154 | int64_t state_start_ms_; |
| 155 | int64_t interval_start_ms_; |
| 156 | int sent_bytes_; |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 157 | std::vector<int> loss_rates_; |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 158 | }; |
| 159 | } // namespace webrtc |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 160 | #endif // CALL_RAMPUP_TESTS_H_ |