| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include "webrtc/call/rampup_tests.h" | 11 #include "webrtc/call/rampup_tests.h" |
| 12 | 12 |
| 13 #include "webrtc/test/gtest.h" | 13 #include "webrtc/test/gtest.h" |
| 14 #include "webrtc/base/checks.h" | 14 #include "webrtc/base/checks.h" |
| 15 #include "webrtc/base/platform_thread.h" | 15 #include "webrtc/base/platform_thread.h" |
| 16 #include "webrtc/test/encoder_settings.h" | |
| 17 #include "webrtc/test/testsupport/perf_test.h" | 16 #include "webrtc/test/testsupport/perf_test.h" |
| 18 | 17 |
| 19 namespace webrtc { | 18 namespace webrtc { |
| 20 namespace { | 19 namespace { |
| 21 | 20 |
| 22 static const int64_t kPollIntervalMs = 20; | 21 static const int64_t kPollIntervalMs = 20; |
| 23 | 22 |
| 24 std::vector<uint32_t> GenerateSsrcs(size_t num_streams, uint32_t ssrc_offset) { | 23 std::vector<uint32_t> GenerateSsrcs(size_t num_streams, uint32_t ssrc_offset) { |
| 25 std::vector<uint32_t> ssrcs; | 24 std::vector<uint32_t> ssrcs; |
| 26 for (size_t i = 0; i != num_streams; ++i) | 25 for (size_t i = 0; i != num_streams; ++i) |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 } | 89 } |
| 91 | 90 |
| 92 size_t RampUpTester::GetNumVideoStreams() const { | 91 size_t RampUpTester::GetNumVideoStreams() const { |
| 93 return num_video_streams_; | 92 return num_video_streams_; |
| 94 } | 93 } |
| 95 | 94 |
| 96 size_t RampUpTester::GetNumAudioStreams() const { | 95 size_t RampUpTester::GetNumAudioStreams() const { |
| 97 return num_audio_streams_; | 96 return num_audio_streams_; |
| 98 } | 97 } |
| 99 | 98 |
| 100 class RampUpTester::VideoStreamFactory | |
| 101 : public VideoEncoderConfig::VideoStreamFactoryInterface { | |
| 102 public: | |
| 103 VideoStreamFactory() {} | |
| 104 | |
| 105 private: | |
| 106 std::vector<VideoStream> CreateEncoderStreams( | |
| 107 int width, | |
| 108 int height, | |
| 109 const VideoEncoderConfig& encoder_config) override { | |
| 110 std::vector<VideoStream> streams = | |
| 111 test::CreateVideoStreams(width, height, encoder_config); | |
| 112 if (encoder_config.number_of_streams == 1) { | |
| 113 streams[0].target_bitrate_bps = streams[0].max_bitrate_bps = 2000000; | |
| 114 } | |
| 115 return streams; | |
| 116 } | |
| 117 }; | |
| 118 | |
| 119 void RampUpTester::ModifyVideoConfigs( | 99 void RampUpTester::ModifyVideoConfigs( |
| 120 VideoSendStream::Config* send_config, | 100 VideoSendStream::Config* send_config, |
| 121 std::vector<VideoReceiveStream::Config>* receive_configs, | 101 std::vector<VideoReceiveStream::Config>* receive_configs, |
| 122 VideoEncoderConfig* encoder_config) { | 102 VideoEncoderConfig* encoder_config) { |
| 123 send_config->suspend_below_min_bitrate = true; | 103 send_config->suspend_below_min_bitrate = true; |
| 124 encoder_config->number_of_streams = num_video_streams_; | 104 |
| 125 encoder_config->max_bitrate_bps = 2000000; | |
| 126 encoder_config->video_stream_factory = | |
| 127 new rtc::RefCountedObject<RampUpTester::VideoStreamFactory>(); | |
| 128 if (num_video_streams_ == 1) { | 105 if (num_video_streams_ == 1) { |
| 106 encoder_config->streams[0].target_bitrate_bps = |
| 107 encoder_config->streams[0].max_bitrate_bps = 2000000; |
| 129 // For single stream rampup until 1mbps | 108 // For single stream rampup until 1mbps |
| 130 expected_bitrate_bps_ = kSingleStreamTargetBps; | 109 expected_bitrate_bps_ = kSingleStreamTargetBps; |
| 131 } else { | 110 } else { |
| 132 // For multi stream rampup until all streams are being sent. That means | 111 // For multi stream rampup until all streams are being sent. That means |
| 133 // enough bitrate to send all the target streams plus the min bitrate of | 112 // enough birate to send all the target streams plus the min bitrate of |
| 134 // the last one. | 113 // the last one. |
| 135 std::vector<VideoStream> streams = test::CreateVideoStreams( | 114 expected_bitrate_bps_ = encoder_config->streams.back().min_bitrate_bps; |
| 136 test::CallTest::kDefaultWidth, test::CallTest::kDefaultHeight, | 115 for (size_t i = 0; i < encoder_config->streams.size() - 1; ++i) { |
| 137 *encoder_config); | 116 expected_bitrate_bps_ += encoder_config->streams[i].target_bitrate_bps; |
| 138 expected_bitrate_bps_ = streams.back().min_bitrate_bps; | |
| 139 for (size_t i = 0; i < streams.size() - 1; ++i) { | |
| 140 expected_bitrate_bps_ += streams[i].target_bitrate_bps; | |
| 141 } | 117 } |
| 142 } | 118 } |
| 143 | 119 |
| 144 send_config->rtp.extensions.clear(); | 120 send_config->rtp.extensions.clear(); |
| 145 | 121 |
| 146 bool remb; | 122 bool remb; |
| 147 bool transport_cc; | 123 bool transport_cc; |
| 148 if (extension_type_ == RtpExtension::kAbsSendTimeUri) { | 124 if (extension_type_ == RtpExtension::kAbsSendTimeUri) { |
| 149 remb = true; | 125 remb = true; |
| 150 transport_cc = false; | 126 transport_cc = false; |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 true); | 596 true); |
| 621 RunBaseTest(&test); | 597 RunBaseTest(&test); |
| 622 } | 598 } |
| 623 | 599 |
| 624 TEST_F(RampUpTest, TransportSequenceNumberSingleStreamWithHighStartBitrate) { | 600 TEST_F(RampUpTest, TransportSequenceNumberSingleStreamWithHighStartBitrate) { |
| 625 RampUpTester test(1, 0, 0.9 * kSingleStreamTargetBps, | 601 RampUpTester test(1, 0, 0.9 * kSingleStreamTargetBps, |
| 626 RtpExtension::kTransportSequenceNumberUri, false, false); | 602 RtpExtension::kTransportSequenceNumberUri, false, false); |
| 627 RunBaseTest(&test); | 603 RunBaseTest(&test); |
| 628 } | 604 } |
| 629 } // namespace webrtc | 605 } // namespace webrtc |
| OLD | NEW |