create_frame_generator.h (3603B)
1 /* 2 * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef API_TEST_CREATE_FRAME_GENERATOR_H_ 12 #define API_TEST_CREATE_FRAME_GENERATOR_H_ 13 14 #include <cstddef> 15 #include <cstdint> 16 #include <memory> 17 #include <optional> 18 #include <string> 19 #include <vector> 20 21 #include "absl/base/nullability.h" 22 #include "absl/strings/string_view.h" 23 #include "api/environment/environment.h" 24 #include "api/test/frame_generator_interface.h" 25 #include "system_wrappers/include/clock.h" 26 27 namespace webrtc { 28 namespace test { 29 30 // Creates a frame generator that produces frames with small squares that 31 // move randomly towards the lower right corner. 32 // `type` has the default value FrameGeneratorInterface::OutputType::I420. 33 // `num_squares` has the default value 10. 34 std::unique_ptr<FrameGeneratorInterface> CreateSquareFrameGenerator( 35 int width, 36 int height, 37 std::optional<FrameGeneratorInterface::OutputType> type, 38 std::optional<int> num_squares); 39 40 // Creates a frame generator that repeatedly plays a set of yuv files. 41 // The frame_repeat_count determines how many times each frame is shown, 42 // with 1 = show each frame once, etc. 43 std::unique_ptr<FrameGeneratorInterface> CreateFromYuvFileFrameGenerator( 44 std::vector<std::string> filenames, 45 size_t width, 46 size_t height, 47 int frame_repeat_count); 48 49 // Creates a frame generator that repeatedly plays a set of nv12 files. 50 // The frame_repeat_count determines how many times each frame is shown, 51 // with 1 = show each frame once, etc. 52 std::unique_ptr<FrameGeneratorInterface> CreateFromNV12FileFrameGenerator( 53 std::vector<std::string> filenames, 54 size_t width, 55 size_t height, 56 int frame_repeat_count = 1); 57 58 absl_nonnull std::unique_ptr<FrameGeneratorInterface> 59 CreateFromIvfFileFrameGenerator(const Environment& env, 60 absl::string_view filename, 61 std::optional<int> fps_hint = std::nullopt); 62 63 // Creates a frame generator which takes a set of yuv files (wrapping a 64 // frame generator created by CreateFromYuvFile() above), but outputs frames 65 // that have been cropped to specified resolution: source_width/source_height 66 // is the size of the source images, target_width/target_height is the size of 67 // the cropped output. For each source image read, the cropped viewport will 68 // be scrolled top to bottom/left to right for scroll_tim_ms milliseconds. 69 // After that the image will stay in place for pause_time_ms milliseconds, 70 // and then this will be repeated with the next file from the input set. 71 std::unique_ptr<FrameGeneratorInterface> 72 CreateScrollingInputFromYuvFilesFrameGenerator( 73 Clock* clock, 74 std::vector<std::string> filenames, 75 size_t source_width, 76 size_t source_height, 77 size_t target_width, 78 size_t target_height, 79 int64_t scroll_time_ms, 80 int64_t pause_time_ms); 81 82 // Creates a frame generator that produces randomly generated slides. It fills 83 // the frames with randomly sized and colored squares. 84 // `frame_repeat_count` determines how many times each slide is shown. 85 std::unique_ptr<FrameGeneratorInterface> 86 CreateSlideFrameGenerator(int width, int height, int frame_repeat_count); 87 88 } // namespace test 89 } // namespace webrtc 90 91 #endif // API_TEST_CREATE_FRAME_GENERATOR_H_