Index: webrtc/video/video_send_stream_tests.cc |
diff --git a/webrtc/video/video_send_stream_tests.cc b/webrtc/video/video_send_stream_tests.cc |
index cc76b13515a54c33a7dce5667c03691b28f8b40b..8cfa43e1d4d7932656f0492e39ed0b38b6b0d12b 100644 |
--- a/webrtc/video/video_send_stream_tests.cc |
+++ b/webrtc/video/video_send_stream_tests.cc |
@@ -36,6 +36,7 @@ |
#include "webrtc/test/null_transport.h" |
#include "webrtc/test/rtcp_packet_parser.h" |
#include "webrtc/test/testsupport/perf_test.h" |
+#include "webrtc/test/field_trial.h" |
#include "webrtc/video/send_statistics_proxy.h" |
#include "webrtc/video/transport_adapter.h" |
@@ -3174,4 +3175,77 @@ TEST_F(VideoSendStreamTest, |
TestRequestSourceRotateVideo(true); |
} |
+TEST_F(VideoSendStreamTest, RemoveOverheadFromBandwith) { |
minyue-webrtc
2016/11/24 10:09:49
Add comment that "This test verifies that overhead
minyue-webrtc
2016/11/24 10:09:49
Bandwi"d"th
michaelt
2016/11/24 14:38:53
Done.
michaelt
2016/11/24 14:38:53
Done.
|
+ class RemoveOverheadFromBandwithTest : public test::EndToEndTest, |
+ public test::FakeEncoder { |
+ public: |
+ RemoveOverheadFromBandwithTest() |
+ : EndToEndTest(test::CallTest::kDefaultTimeoutMs), |
+ FakeEncoder(Clock::GetRealTimeClock()), |
+ call_(nullptr), |
+ reached_bitrate_event_(false, false), |
+ target_bitrate_kbps_(0) {} |
+ |
+ int32_t SetRateAllocation(const BitrateAllocation& bitrate, |
+ uint32_t frameRate) override { |
+ { |
+ rtc::CritScope lock(&crit_); |
+ if (target_bitrate_kbps_ > bitrate.get_sum_kbps()) { |
minyue-webrtc
2016/11/24 10:09:49
prefer
if (bitrate.get_sum_kbps() >= target_bitr
michaelt
2016/11/24 14:38:53
Changed the impl. to wait for Max.
|
+ return FakeEncoder::SetRateAllocation(bitrate, frameRate); |
+ } |
+ } |
+ reached_bitrate_event_.Set(); |
+ return FakeEncoder::SetRateAllocation(bitrate, frameRate); |
+ } |
+ |
+ bool WaitForBitrate(int bitrate_bps) { |
+ { |
+ rtc::CritScope lock(&crit_); |
+ target_bitrate_kbps_ = bitrate_bps / 1000; |
+ } |
+ return reached_bitrate_event_.Wait(1000 * 5); |
minyue-webrtc
2016/11/24 10:09:49
why 1000 * 5?
michaelt
2016/11/24 14:38:53
Changed the impl. to wait for Max.
|
+ } |
+ |
+ void OnCallsCreated(Call* sender_call, Call* receiver_call) override { |
+ call_ = sender_call; |
+ } |
+ |
+ void ModifyVideoConfigs( |
+ VideoSendStream::Config* send_config, |
+ std::vector<VideoReceiveStream::Config>* receive_configs, |
+ VideoEncoderConfig* encoder_config) override { |
+ send_config->rtp.max_packet_size = 1200; |
+ send_config->encoder_settings.encoder = this; |
+ EXPECT_FALSE(send_config->rtp.extensions.empty()); |
+ } |
+ |
+ void PerformTest() override { |
+ call_->OnTransportOverheadChanged(webrtc::MediaType::VIDEO, 20); |
+ Call::Config::BitrateConfig bitrate_config; |
+ constexpr int kStartBitrateBps = 50000; |
+ constexpr int kMaxBitrateBps = 60000; |
+ bitrate_config.start_bitrate_bps = kStartBitrateBps; |
+ bitrate_config.max_bitrate_bps = kMaxBitrateBps; |
+ |
+ test::ScopedFieldTrials override_field_trials_( |
+ "WebRTC-SendSideBwe-WithOverhead/Enabled/"); |
+ call_->SetBitrateConfig(bitrate_config); |
+ |
+ // At a bitrate of 60kbps with a packet size of 1200B video and a overhead |
minyue-webrtc
2016/11/24 10:09:49
a overhead -> an overhead
michaelt
2016/11/24 14:38:53
Done.
|
+ // of 40B per packet video produces 2kbps overhead. |
+ // So with a BWE should reach 58kbps but not 60kbps. |
+ EXPECT_TRUE(WaitForBitrate(kMaxBitrateBps - 2000)); |
+ EXPECT_FALSE(WaitForBitrate(kMaxBitrateBps)); |
minyue-webrtc
2016/11/24 10:09:49
should test FALSE on kMaxBitrateBps - 1999
But I
michaelt
2016/11/24 14:38:53
Done.
|
+ } |
+ |
+ private: |
+ Call* call_; |
+ rtc::Event reached_bitrate_event_; |
+ rtc::CriticalSection crit_; |
+ uint32_t target_bitrate_kbps_; |
+ } test; |
+ |
+ RunBaseTest(&test); |
+} |
+ |
} // namespace webrtc |