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 #include <algorithm> // max | 10 #include <algorithm> // max |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "webrtc/system_wrappers/include/sleep.h" | 29 #include "webrtc/system_wrappers/include/sleep.h" |
30 #include "webrtc/test/call_test.h" | 30 #include "webrtc/test/call_test.h" |
31 #include "webrtc/test/configurable_frame_size_encoder.h" | 31 #include "webrtc/test/configurable_frame_size_encoder.h" |
32 #include "webrtc/test/fake_texture_frame.h" | 32 #include "webrtc/test/fake_texture_frame.h" |
33 #include "webrtc/test/frame_generator.h" | 33 #include "webrtc/test/frame_generator.h" |
34 #include "webrtc/test/frame_utils.h" | 34 #include "webrtc/test/frame_utils.h" |
35 #include "webrtc/test/gtest.h" | 35 #include "webrtc/test/gtest.h" |
36 #include "webrtc/test/null_transport.h" | 36 #include "webrtc/test/null_transport.h" |
37 #include "webrtc/test/rtcp_packet_parser.h" | 37 #include "webrtc/test/rtcp_packet_parser.h" |
38 #include "webrtc/test/testsupport/perf_test.h" | 38 #include "webrtc/test/testsupport/perf_test.h" |
| 39 #include "webrtc/test/field_trial.h" |
39 | 40 |
40 #include "webrtc/video/send_statistics_proxy.h" | 41 #include "webrtc/video/send_statistics_proxy.h" |
41 #include "webrtc/video/transport_adapter.h" | 42 #include "webrtc/video/transport_adapter.h" |
42 #include "webrtc/video_frame.h" | 43 #include "webrtc/video_frame.h" |
43 #include "webrtc/video_send_stream.h" | 44 #include "webrtc/video_send_stream.h" |
44 | 45 |
45 namespace webrtc { | 46 namespace webrtc { |
46 | 47 |
47 enum VideoFormat { kGeneric, kVP8, }; | 48 enum VideoFormat { kGeneric, kVP8, }; |
48 | 49 |
(...skipping 1446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1495 : EndToEndTest(test::CallTest::kDefaultTimeoutMs), | 1496 : EndToEndTest(test::CallTest::kDefaultTimeoutMs), |
1496 call_(nullptr), | 1497 call_(nullptr), |
1497 packets_sent_(0), | 1498 packets_sent_(0), |
1498 transport_overhead_(0) {} | 1499 transport_overhead_(0) {} |
1499 | 1500 |
1500 void OnCallsCreated(Call* sender_call, Call* receiver_call) override { | 1501 void OnCallsCreated(Call* sender_call, Call* receiver_call) override { |
1501 call_ = sender_call; | 1502 call_ = sender_call; |
1502 } | 1503 } |
1503 | 1504 |
1504 Action OnSendRtp(const uint8_t* packet, size_t length) override { | 1505 Action OnSendRtp(const uint8_t* packet, size_t length) override { |
1505 EXPECT_LE(length, | 1506 EXPECT_LE(length, kMaxRtpPacketSize); |
1506 IP_PACKET_SIZE - static_cast<size_t>(transport_overhead_)); | |
1507 if (++packets_sent_ < 100) | 1507 if (++packets_sent_ < 100) |
1508 return SEND_PACKET; | 1508 return SEND_PACKET; |
1509 observation_complete_.Set(); | 1509 observation_complete_.Set(); |
1510 return SEND_PACKET; | 1510 return SEND_PACKET; |
1511 } | 1511 } |
1512 | 1512 |
| 1513 void ModifyVideoConfigs( |
| 1514 VideoSendStream::Config* send_config, |
| 1515 std::vector<VideoReceiveStream::Config>* receive_configs, |
| 1516 VideoEncoderConfig* encoder_config) override { |
| 1517 send_config->rtp.max_packet_size = kMaxRtpPacketSize; |
| 1518 } |
| 1519 |
1513 void PerformTest() override { | 1520 void PerformTest() override { |
| 1521 transport_overhead_ = 100; |
| 1522 call_->OnTransportOverheadChanged(webrtc::MediaType::VIDEO, |
| 1523 transport_overhead_); |
| 1524 EXPECT_TRUE(Wait()); |
| 1525 packets_sent_ = 0; |
1514 transport_overhead_ = 500; | 1526 transport_overhead_ = 500; |
1515 call_->OnTransportOverheadChanged(webrtc::MediaType::VIDEO, | 1527 call_->OnTransportOverheadChanged(webrtc::MediaType::VIDEO, |
1516 transport_overhead_); | 1528 transport_overhead_); |
1517 EXPECT_TRUE(Wait()); | 1529 EXPECT_TRUE(Wait()); |
1518 packets_sent_ = 0; | |
1519 transport_overhead_ = 1000; | |
1520 call_->OnTransportOverheadChanged(webrtc::MediaType::VIDEO, | |
1521 transport_overhead_); | |
1522 EXPECT_TRUE(Wait()); | |
1523 } | 1530 } |
1524 | 1531 |
1525 private: | 1532 private: |
1526 Call* call_; | 1533 Call* call_; |
1527 int packets_sent_; | 1534 int packets_sent_; |
1528 int transport_overhead_; | 1535 int transport_overhead_; |
| 1536 const size_t kMaxRtpPacketSize = 1000; |
1529 } test; | 1537 } test; |
1530 | 1538 |
1531 RunBaseTest(&test); | 1539 RunBaseTest(&test); |
1532 } | 1540 } |
1533 | 1541 |
1534 class MaxPaddingSetTest : public test::SendTest { | 1542 class MaxPaddingSetTest : public test::SendTest { |
1535 public: | 1543 public: |
1536 static const uint32_t kMinTransmitBitrateBps = 400000; | 1544 static const uint32_t kMinTransmitBitrateBps = 400000; |
1537 static const uint32_t kActualEncodeBitrateBps = 40000; | 1545 static const uint32_t kActualEncodeBitrateBps = 40000; |
1538 static const uint32_t kMinPacketsToSend = 50; | 1546 static const uint32_t kMinPacketsToSend = 50; |
(...skipping 1627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3166 TEST_F(VideoSendStreamTest, | 3174 TEST_F(VideoSendStreamTest, |
3167 RequestSourceRotateIfVideoOrientationExtensionNotSupported) { | 3175 RequestSourceRotateIfVideoOrientationExtensionNotSupported) { |
3168 TestRequestSourceRotateVideo(false); | 3176 TestRequestSourceRotateVideo(false); |
3169 } | 3177 } |
3170 | 3178 |
3171 TEST_F(VideoSendStreamTest, | 3179 TEST_F(VideoSendStreamTest, |
3172 DoNotRequestsRotationIfVideoOrientationExtensionSupported) { | 3180 DoNotRequestsRotationIfVideoOrientationExtensionSupported) { |
3173 TestRequestSourceRotateVideo(true); | 3181 TestRequestSourceRotateVideo(true); |
3174 } | 3182 } |
3175 | 3183 |
| 3184 // This test verifies that overhead is removed from the bandwidth estimate by |
| 3185 // testing that the maximum possible target payload rate is smaller than the |
| 3186 // maximum bandwidth estimate by the overhead rate. |
| 3187 TEST_F(VideoSendStreamTest, RemoveOverheadFromBandwidth) { |
| 3188 test::ScopedFieldTrials override_field_trials( |
| 3189 "WebRTC-SendSideBwe-WithOverhead/Enabled/"); |
| 3190 class RemoveOverheadFromBandwidthTest : public test::EndToEndTest, |
| 3191 public test::FakeEncoder { |
| 3192 public: |
| 3193 RemoveOverheadFromBandwidthTest() |
| 3194 : EndToEndTest(test::CallTest::kDefaultTimeoutMs), |
| 3195 FakeEncoder(Clock::GetRealTimeClock()), |
| 3196 call_(nullptr), |
| 3197 max_bitrate_kbps_(0) {} |
| 3198 |
| 3199 int32_t SetRateAllocation(const BitrateAllocation& bitrate, |
| 3200 uint32_t frameRate) override { |
| 3201 rtc::CritScope lock(&crit_); |
| 3202 if (max_bitrate_kbps_ < bitrate.get_sum_kbps()) |
| 3203 max_bitrate_kbps_ = bitrate.get_sum_kbps(); |
| 3204 return FakeEncoder::SetRateAllocation(bitrate, frameRate); |
| 3205 } |
| 3206 |
| 3207 void OnCallsCreated(Call* sender_call, Call* receiver_call) override { |
| 3208 call_ = sender_call; |
| 3209 } |
| 3210 |
| 3211 void ModifyVideoConfigs( |
| 3212 VideoSendStream::Config* send_config, |
| 3213 std::vector<VideoReceiveStream::Config>* receive_configs, |
| 3214 VideoEncoderConfig* encoder_config) override { |
| 3215 send_config->rtp.max_packet_size = 1200; |
| 3216 send_config->encoder_settings.encoder = this; |
| 3217 EXPECT_FALSE(send_config->rtp.extensions.empty()); |
| 3218 } |
| 3219 |
| 3220 void PerformTest() override { |
| 3221 call_->OnTransportOverheadChanged(webrtc::MediaType::VIDEO, 20); |
| 3222 Call::Config::BitrateConfig bitrate_config; |
| 3223 constexpr int kStartBitrateBps = 50000; |
| 3224 constexpr int kMaxBitrateBps = 60000; |
| 3225 bitrate_config.start_bitrate_bps = kStartBitrateBps; |
| 3226 bitrate_config.max_bitrate_bps = kMaxBitrateBps; |
| 3227 call_->SetBitrateConfig(bitrate_config); |
| 3228 |
| 3229 // At a bitrate of 60kbps with a packet size of 1200B video and an |
| 3230 // overhead of 40B per packet video produces 2kbps overhead. |
| 3231 // So with a BWE should reach 58kbps but not 60kbps. |
| 3232 Wait(); |
| 3233 { |
| 3234 rtc::CritScope lock(&crit_); |
| 3235 EXPECT_EQ(58u, max_bitrate_kbps_); |
| 3236 } |
| 3237 } |
| 3238 |
| 3239 private: |
| 3240 Call* call_; |
| 3241 rtc::CriticalSection crit_; |
| 3242 uint32_t max_bitrate_kbps_ GUARDED_BY(&crit_); |
| 3243 } test; |
| 3244 |
| 3245 RunBaseTest(&test); |
| 3246 } |
| 3247 |
3176 } // namespace webrtc | 3248 } // namespace webrtc |
OLD | NEW |