From 0676f224f8f46cabd7eebf2172e7fccccc676f00 Mon Sep 17 00:00:00 2001 From: philipel Date: Tue, 17 Apr 2018 16:12:21 +0200 Subject: Probe on video encoder reconfiguration test. This CL includes the changes from this CL: https://webrtc-review.googlesource.com/c/src/+/63642 Bug: webrtc:8955 Change-Id: If95cdec59f25e97c6ff5ea45a52d6113128a0921 Reviewed-on: https://webrtc-review.googlesource.com/64822 Commit-Queue: Philip Eliasson Reviewed-by: Stefan Holmer Reviewed-by: Sebastian Jansson Cr-Commit-Position: refs/heads/master@{#22910} --- video/end_to_end_tests/probing_tests.cc | 106 ++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) (limited to 'video') diff --git a/video/end_to_end_tests/probing_tests.cc b/video/end_to_end_tests/probing_tests.cc index db66f6215d..777a346754 100644 --- a/video/end_to_end_tests/probing_tests.cc +++ b/video/end_to_end_tests/probing_tests.cc @@ -188,4 +188,110 @@ TEST_P(ProbingEndToEndTest, TriggerMidCallProbing) { EXPECT_TRUE(success) << "Failed to perform mid call probing (" << kMaxAttempts << " attempts)."; } + +#if defined(MEMORY_SANITIZER) +TEST_P(ProbingEndToEndTest, DISABLED_ProbeOnVideoEncoderReconfiguration) { +#elif defined(TARGET_IPHONE_SIMULATOR) && TARGET_IPHONE_SIMULATOR +TEST_P(ProbingEndToEndTest, DISABLED_ProbeOnVideoEncoderReconfiguration) { +#else +TEST_P(ProbingEndToEndTest, ProbeOnVideoEncoderReconfiguration) { +#endif + + class ReconfigureTest : public ProbingTest { + public: + ReconfigureTest(test::SingleThreadedTaskQueueForTesting* task_queue, + bool* success) + : ProbingTest(50000), task_queue_(task_queue), success_(success) {} + + void ModifyVideoConfigs( + VideoSendStream::Config* send_config, + std::vector* receive_configs, + VideoEncoderConfig* encoder_config) override { + encoder_config_ = encoder_config; + } + + void OnVideoStreamsCreated( + VideoSendStream* send_stream, + const std::vector& receive_streams) override { + send_stream_ = send_stream; + } + + test::PacketTransport* CreateSendTransport( + test::SingleThreadedTaskQueueForTesting* task_queue, + Call* sender_call) override { + send_transport_ = new test::PacketTransport( + task_queue, sender_call, this, test::PacketTransport::kSender, + CallTest::payload_type_map_, FakeNetworkPipe::Config()); + return send_transport_; + } + + void PerformTest() override { + *success_ = false; + int64_t start_time_ms = clock_->TimeInMilliseconds(); + do { + if (clock_->TimeInMilliseconds() - start_time_ms > kTimeoutMs) + break; + + Call::Stats stats = sender_call_->GetStats(); + + switch (state_) { + case 0: + // Wait until initial probing has been completed (6 times start + // bitrate). + if (stats.send_bandwidth_bps >= 250000 && + stats.send_bandwidth_bps <= 350000) { + FakeNetworkPipe::Config config; + config.link_capacity_kbps = 200; + send_transport_->SetConfig(config); + + ++state_; + } + break; + case 1: + if (stats.send_bandwidth_bps <= 210000) { + FakeNetworkPipe::Config config; + config.link_capacity_kbps = 5000; + send_transport_->SetConfig(config); + + encoder_config_->max_bitrate_bps = 2000000; + encoder_config_->simulcast_layers[0].max_bitrate_bps = 1200000; + task_queue_->SendTask([this]() { + send_stream_->ReconfigureVideoEncoder(encoder_config_->Copy()); + }); + + ++state_; + } + break; + case 2: + if (stats.send_bandwidth_bps >= 1000000) { + *success_ = true; + observation_complete_.Set(); + } + break; + } + } while (!observation_complete_.Wait(20)); + } + + private: + const int kTimeoutMs = 3000; + test::SingleThreadedTaskQueueForTesting* const task_queue_; + bool* const success_; + test::PacketTransport* send_transport_; + VideoSendStream* send_stream_; + VideoEncoderConfig* encoder_config_; + }; + + bool success = false; + const int kMaxAttempts = 3; + for (int i = 0; i < kMaxAttempts; ++i) { + ReconfigureTest test(&task_queue_, &success); + RunBaseTest(&test); + if (success) { + return; + } + } + EXPECT_TRUE(success) << "Failed to perform mid call probing (" << kMaxAttempts + << " attempts)."; +} + } // namespace webrtc -- cgit v1.2.3