From fb6d32602c89fcecf43a123c432a648fbdb3b86b Mon Sep 17 00:00:00 2001 From: Rasmus Brandt Date: Wed, 25 Oct 2017 14:25:21 +0200 Subject: [PATCH] Delete unused PredictivePacketManipulator. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BUG=webrtc:8448 Change-Id: I07ff9db5cb49f84d98b6076e748a990aa560b5b5 Reviewed-on: https://webrtc-review.googlesource.com/15400 Reviewed-by: Åsa Persson Commit-Queue: Rasmus Brandt Cr-Commit-Position: refs/heads/master@{#20437} --- modules/video_coding/BUILD.gn | 2 - .../test/packet_manipulator_unittest.cc | 52 ------------------- .../test/predictive_packet_manipulator.cc | 47 ----------------- .../test/predictive_packet_manipulator.h | 46 ---------------- 4 files changed, 147 deletions(-) delete mode 100644 modules/video_coding/codecs/test/predictive_packet_manipulator.cc delete mode 100644 modules/video_coding/codecs/test/predictive_packet_manipulator.h diff --git a/modules/video_coding/BUILD.gn b/modules/video_coding/BUILD.gn index 48636e9be2..c91c849cb1 100644 --- a/modules/video_coding/BUILD.gn +++ b/modules/video_coding/BUILD.gn @@ -362,8 +362,6 @@ if (rtc_include_tests) { "codecs/test/mock/mock_packet_manipulator.h", "codecs/test/packet_manipulator.cc", "codecs/test/packet_manipulator.h", - "codecs/test/predictive_packet_manipulator.cc", - "codecs/test/predictive_packet_manipulator.h", "codecs/test/stats.cc", "codecs/test/stats.h", "codecs/test/test_config.cc", diff --git a/modules/video_coding/codecs/test/packet_manipulator_unittest.cc b/modules/video_coding/codecs/test/packet_manipulator_unittest.cc index 296e6850ab..3a226d64b6 100644 --- a/modules/video_coding/codecs/test/packet_manipulator_unittest.cc +++ b/modules/video_coding/codecs/test/packet_manipulator_unittest.cc @@ -12,7 +12,6 @@ #include -#include "modules/video_coding/codecs/test/predictive_packet_manipulator.h" #include "modules/video_coding/include/video_codec_interface.h" #include "test/gtest.h" #include "test/testsupport/unittest_utils.h" @@ -93,56 +92,5 @@ TEST_F(PacketManipulatorTest, UniformDropAll) { packet_data_, image_); } -// Use our customized test class to make the second packet being lost -TEST_F(PacketManipulatorTest, UniformDropSinglePacket) { - drop_config_.packet_loss_probability = 0.5; - PredictivePacketManipulator manipulator(&packet_reader_, drop_config_); - manipulator.AddRandomResult(1.0); - manipulator.AddRandomResult(0.3); // less than 0.5 will cause packet loss - manipulator.AddRandomResult(1.0); - - // Execute the test target method: - int nbr_packets_dropped = manipulator.ManipulatePackets(&image_); - - // Since we setup the predictive packet manipulator, it will throw away the - // second packet. The third packet is also lost because when we have lost one, - // the remains shall also be discarded (in the current implementation). - VerifyPacketLoss(2, nbr_packets_dropped, kPacketSizeInBytes, packet1_, - image_); -} - -// Use our customized test class to make the second packet being lost -TEST_F(PacketManipulatorTest, BurstDropNinePackets) { - // Create a longer packet data structure (10 packets) - const int kNbrPackets = 10; - const size_t kDataLength = kPacketSizeInBytes * kNbrPackets; - uint8_t data[kDataLength]; - uint8_t* data_pointer = data; - // Fill with 0s, 1s and so on to be able to easily verify which were dropped: - for (int i = 0; i < kNbrPackets; ++i) { - memset(data_pointer + i * kPacketSizeInBytes, i, kPacketSizeInBytes); - } - // Overwrite the defaults from the test fixture: - image_._buffer = data; - image_._length = kDataLength; - image_._size = kDataLength; - - drop_config_.packet_loss_probability = 0.5; - drop_config_.packet_loss_burst_length = 5; - drop_config_.packet_loss_mode = kBurst; - PredictivePacketManipulator manipulator(&packet_reader_, drop_config_); - manipulator.AddRandomResult(1.0); - manipulator.AddRandomResult(0.3); // less than 0.5 will cause packet loss - for (int i = 0; i < kNbrPackets - 2; ++i) { - manipulator.AddRandomResult(1.0); - } - - // Execute the test target method: - int nbr_packets_dropped = manipulator.ManipulatePackets(&image_); - - // Should discard every packet after the first one. - VerifyPacketLoss(9, nbr_packets_dropped, kPacketSizeInBytes, data, image_); -} - } // namespace test } // namespace webrtc diff --git a/modules/video_coding/codecs/test/predictive_packet_manipulator.cc b/modules/video_coding/codecs/test/predictive_packet_manipulator.cc deleted file mode 100644 index d2544d0daf..0000000000 --- a/modules/video_coding/codecs/test/predictive_packet_manipulator.cc +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "modules/video_coding/codecs/test/predictive_packet_manipulator.h" - -#include -#include - -#include "test/testsupport/packet_reader.h" - -namespace webrtc { -namespace test { - -PredictivePacketManipulator::PredictivePacketManipulator( - PacketReader* packet_reader, - const NetworkingConfig& config) - : PacketManipulatorImpl(packet_reader, config, false) {} - -PredictivePacketManipulator::~PredictivePacketManipulator() {} - -void PredictivePacketManipulator::AddRandomResult(double result) { - assert(result >= 0.0 && result <= 1.0); - random_results_.push(result); -} - -double PredictivePacketManipulator::RandomUniform() { - if (random_results_.size() == 0u) { - fprintf(stderr, - "No more stored results, please make sure AddRandomResult()" - "is called same amount of times you're going to invoke the " - "RandomUniform() function, i.e. once per packet.\n"); - assert(false); - } - double result = random_results_.front(); - random_results_.pop(); - return result; -} - -} // namespace test -} // namespace webrtc diff --git a/modules/video_coding/codecs/test/predictive_packet_manipulator.h b/modules/video_coding/codecs/test/predictive_packet_manipulator.h deleted file mode 100644 index 2a44cc81c5..0000000000 --- a/modules/video_coding/codecs/test/predictive_packet_manipulator.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef MODULES_VIDEO_CODING_CODECS_TEST_PREDICTIVE_PACKET_MANIPULATOR_H_ -#define MODULES_VIDEO_CODING_CODECS_TEST_PREDICTIVE_PACKET_MANIPULATOR_H_ - -#include - -#include "modules/video_coding/codecs/test/packet_manipulator.h" -#include "test/testsupport/packet_reader.h" - -namespace webrtc { -namespace test { - -// Predictive packet manipulator that allows for setup of the result of -// the random invocations. -class PredictivePacketManipulator : public PacketManipulatorImpl { - public: - PredictivePacketManipulator(PacketReader* packet_reader, - const NetworkingConfig& config); - virtual ~PredictivePacketManipulator(); - // Adds a result. You must add at least the same number of results as the - // expected calls to the RandomUniform method. The results are added to a - // FIFO queue so they will be returned in the same order they were added. - // Result parameter must be 0.0 to 1.0. - void AddRandomResult(double result); - - protected: - // Returns a uniformly distributed random value between 0.0 and 1.0 - double RandomUniform() override; - - private: - std::queue random_results_; -}; - -} // namespace test -} // namespace webrtc - -#endif // MODULES_VIDEO_CODING_CODECS_TEST_PREDICTIVE_PACKET_MANIPULATOR_H_