xref: /aosp_15_r20/external/webrtc/api/test/create_frame_generator.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
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 <memory>
15 #include <string>
16 #include <vector>
17 
18 #include "absl/types/optional.h"
19 #include "api/test/frame_generator_interface.h"
20 #include "system_wrappers/include/clock.h"
21 
22 namespace webrtc {
23 namespace test {
24 
25 // Creates a frame generator that produces frames with small squares that
26 // move randomly towards the lower right corner.
27 // `type` has the default value FrameGeneratorInterface::OutputType::I420.
28 // `num_squares` has the default value 10.
29 std::unique_ptr<FrameGeneratorInterface> CreateSquareFrameGenerator(
30     int width,
31     int height,
32     absl::optional<FrameGeneratorInterface::OutputType> type,
33     absl::optional<int> num_squares);
34 
35 // Creates a frame generator that repeatedly plays a set of yuv files.
36 // The frame_repeat_count determines how many times each frame is shown,
37 // with 1 = show each frame once, etc.
38 std::unique_ptr<FrameGeneratorInterface> CreateFromYuvFileFrameGenerator(
39     std::vector<std::string> filenames,
40     size_t width,
41     size_t height,
42     int frame_repeat_count);
43 
44 // Creates a frame generator that repeatedly plays a set of nv12 files.
45 // The frame_repeat_count determines how many times each frame is shown,
46 // with 1 = show each frame once, etc.
47 std::unique_ptr<FrameGeneratorInterface> CreateFromNV12FileFrameGenerator(
48     std::vector<std::string> filenames,
49     size_t width,
50     size_t height,
51     int frame_repeat_count = 1);
52 
53 // Creates a frame generator that repeatedly plays an ivf file.
54 std::unique_ptr<FrameGeneratorInterface> CreateFromIvfFileFrameGenerator(
55     std::string filename);
56 
57 // Creates a frame generator which takes a set of yuv files (wrapping a
58 // frame generator created by CreateFromYuvFile() above), but outputs frames
59 // that have been cropped to specified resolution: source_width/source_height
60 // is the size of the source images, target_width/target_height is the size of
61 // the cropped output. For each source image read, the cropped viewport will
62 // be scrolled top to bottom/left to right for scroll_tim_ms milliseconds.
63 // After that the image will stay in place for pause_time_ms milliseconds,
64 // and then this will be repeated with the next file from the input set.
65 std::unique_ptr<FrameGeneratorInterface>
66 CreateScrollingInputFromYuvFilesFrameGenerator(
67     Clock* clock,
68     std::vector<std::string> filenames,
69     size_t source_width,
70     size_t source_height,
71     size_t target_width,
72     size_t target_height,
73     int64_t scroll_time_ms,
74     int64_t pause_time_ms);
75 
76 // Creates a frame generator that produces randomly generated slides. It fills
77 // the frames with randomly sized and colored squares.
78 // `frame_repeat_count` determines how many times each slide is shown.
79 std::unique_ptr<FrameGeneratorInterface>
80 CreateSlideFrameGenerator(int width, int height, int frame_repeat_count);
81 
82 }  // namespace test
83 }  // namespace webrtc
84 
85 #endif  // API_TEST_CREATE_FRAME_GENERATOR_H_
86