Make the complexity of the square generator configurable.
This adds and extra param to SquareGenerator's constructor that sets the number of squares used. By default, it uses the same value that was previously hard-coded. Bug: webrtc:8326 Change-Id: Ie7cff94e4a54fd5bb91f981930cad5e624e0e132 Reviewed-on: https://webrtc-review.googlesource.com/6020 Commit-Queue: Erik Varga <erikvarga@webrtc.org> Reviewed-by: Patrik Höglund <phoglund@webrtc.org> Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20223}
This commit is contained in:
parent
735a8389f2
commit
c774d5d13a
@ -28,14 +28,14 @@ namespace webrtc {
|
|||||||
namespace test {
|
namespace test {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
// SquareGenerator is a FrameGenerator that draws 10 randomly sized and colored
|
// SquareGenerator is a FrameGenerator that draws a given amount of randomly
|
||||||
// squares. Between each new generated frame, the squares are moved slightly
|
// sized and colored squares. Between each new generated frame, the squares
|
||||||
// towards the lower right corner.
|
// are moved slightly towards the lower right corner.
|
||||||
class SquareGenerator : public FrameGenerator {
|
class SquareGenerator : public FrameGenerator {
|
||||||
public:
|
public:
|
||||||
SquareGenerator(int width, int height) {
|
SquareGenerator(int width, int height, int num_squares) {
|
||||||
ChangeResolution(width, height);
|
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));
|
squares_.emplace_back(new Square(width, height, i + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -397,7 +397,14 @@ bool FrameForwarder::has_sinks() const {
|
|||||||
std::unique_ptr<FrameGenerator> FrameGenerator::CreateSquareGenerator(
|
std::unique_ptr<FrameGenerator> FrameGenerator::CreateSquareGenerator(
|
||||||
int width,
|
int width,
|
||||||
int height) {
|
int height) {
|
||||||
return std::unique_ptr<FrameGenerator>(new SquareGenerator(width, height));
|
return std::unique_ptr<FrameGenerator>(
|
||||||
|
new SquareGenerator(width, height, 10));
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<FrameGenerator>
|
||||||
|
FrameGenerator::CreateSquareGenerator(int width, int height, int num_squares) {
|
||||||
|
return std::unique_ptr<FrameGenerator>(
|
||||||
|
new SquareGenerator(width, height, num_squares));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<FrameGenerator> FrameGenerator::CreateSlideGenerator(
|
std::unique_ptr<FrameGenerator> FrameGenerator::CreateSlideGenerator(
|
||||||
|
|||||||
@ -62,6 +62,9 @@ class FrameGenerator {
|
|||||||
// move randomly towards the lower right corner.
|
// move randomly towards the lower right corner.
|
||||||
static std::unique_ptr<FrameGenerator> CreateSquareGenerator(int width,
|
static std::unique_ptr<FrameGenerator> CreateSquareGenerator(int width,
|
||||||
int height);
|
int height);
|
||||||
|
static std::unique_ptr<FrameGenerator> CreateSquareGenerator(int width,
|
||||||
|
int height,
|
||||||
|
int num_squares);
|
||||||
|
|
||||||
// Creates a frame generator that repeatedly plays a set of yuv files.
|
// Creates a frame generator that repeatedly plays a set of yuv files.
|
||||||
// The frame_repeat_count determines how many times each frame is shown,
|
// The frame_repeat_count determines how many times each frame is shown,
|
||||||
|
|||||||
@ -97,6 +97,20 @@ FrameGeneratorCapturer* FrameGeneratorCapturer::Create(int width,
|
|||||||
return capturer.release();
|
return capturer.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FrameGeneratorCapturer* FrameGeneratorCapturer::Create(int width,
|
||||||
|
int height,
|
||||||
|
int num_squares,
|
||||||
|
int target_fps,
|
||||||
|
Clock* clock) {
|
||||||
|
std::unique_ptr<FrameGeneratorCapturer> capturer(new FrameGeneratorCapturer(
|
||||||
|
clock, FrameGenerator::CreateSquareGenerator(width, height, num_squares),
|
||||||
|
target_fps));
|
||||||
|
if (!capturer->Init())
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
return capturer.release();
|
||||||
|
}
|
||||||
|
|
||||||
FrameGeneratorCapturer* FrameGeneratorCapturer::CreateFromYuvFile(
|
FrameGeneratorCapturer* FrameGeneratorCapturer::CreateFromYuvFile(
|
||||||
const std::string& file_name,
|
const std::string& file_name,
|
||||||
size_t width,
|
size_t width,
|
||||||
|
|||||||
@ -45,6 +45,12 @@ class FrameGeneratorCapturer : public VideoCapturer {
|
|||||||
int target_fps,
|
int target_fps,
|
||||||
Clock* clock);
|
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,
|
static FrameGeneratorCapturer* CreateFromYuvFile(const std::string& file_name,
|
||||||
size_t width,
|
size_t width,
|
||||||
size_t height,
|
size_t height,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user