diff --git a/test/frame_generator.cc b/test/frame_generator.cc index d2d580a718..eb5e5d6b1e 100644 --- a/test/frame_generator.cc +++ b/test/frame_generator.cc @@ -28,14 +28,14 @@ namespace webrtc { namespace test { namespace { -// SquareGenerator is a FrameGenerator that draws 10 randomly sized and colored -// squares. Between each new generated frame, the squares are moved slightly -// towards the lower right corner. +// SquareGenerator is a FrameGenerator that draws a given amount of randomly +// sized and colored squares. Between each new generated frame, the squares +// are moved slightly towards the lower right corner. class SquareGenerator : public FrameGenerator { public: - SquareGenerator(int width, int height) { + SquareGenerator(int width, int height, int num_squares) { ChangeResolution(width, height); - for (int i = 0; i < 10; ++i) { + for (int i = 0; i < num_squares; ++i) { squares_.emplace_back(new Square(width, height, i + 1)); } } @@ -397,7 +397,14 @@ bool FrameForwarder::has_sinks() const { std::unique_ptr FrameGenerator::CreateSquareGenerator( int width, int height) { - return std::unique_ptr(new SquareGenerator(width, height)); + return std::unique_ptr( + new SquareGenerator(width, height, 10)); +} + +std::unique_ptr +FrameGenerator::CreateSquareGenerator(int width, int height, int num_squares) { + return std::unique_ptr( + new SquareGenerator(width, height, num_squares)); } std::unique_ptr FrameGenerator::CreateSlideGenerator( diff --git a/test/frame_generator.h b/test/frame_generator.h index babd9406a3..d37166f2fa 100644 --- a/test/frame_generator.h +++ b/test/frame_generator.h @@ -62,6 +62,9 @@ class FrameGenerator { // move randomly towards the lower right corner. static std::unique_ptr CreateSquareGenerator(int width, int height); + static std::unique_ptr CreateSquareGenerator(int width, + int height, + int num_squares); // Creates a frame generator that repeatedly plays a set of yuv files. // The frame_repeat_count determines how many times each frame is shown, diff --git a/test/frame_generator_capturer.cc b/test/frame_generator_capturer.cc index 532e907a54..9c835791af 100644 --- a/test/frame_generator_capturer.cc +++ b/test/frame_generator_capturer.cc @@ -97,6 +97,20 @@ FrameGeneratorCapturer* FrameGeneratorCapturer::Create(int width, return capturer.release(); } +FrameGeneratorCapturer* FrameGeneratorCapturer::Create(int width, + int height, + int num_squares, + int target_fps, + Clock* clock) { + std::unique_ptr capturer(new FrameGeneratorCapturer( + clock, FrameGenerator::CreateSquareGenerator(width, height, num_squares), + target_fps)); + if (!capturer->Init()) + return nullptr; + + return capturer.release(); +} + FrameGeneratorCapturer* FrameGeneratorCapturer::CreateFromYuvFile( const std::string& file_name, size_t width, diff --git a/test/frame_generator_capturer.h b/test/frame_generator_capturer.h index 5954554425..3a3fe82431 100644 --- a/test/frame_generator_capturer.h +++ b/test/frame_generator_capturer.h @@ -45,6 +45,12 @@ class FrameGeneratorCapturer : public VideoCapturer { int target_fps, Clock* clock); + static FrameGeneratorCapturer* Create(int width, + int height, + int num_squares, + int target_fps, + Clock* clock); + static FrameGeneratorCapturer* CreateFromYuvFile(const std::string& file_name, size_t width, size_t height,