OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 #ifndef WEBRTC_TEST_FRAME_GENERATOR_H_ | 10 #ifndef WEBRTC_TEST_FRAME_GENERATOR_H_ |
11 #define WEBRTC_TEST_FRAME_GENERATOR_H_ | 11 #define WEBRTC_TEST_FRAME_GENERATOR_H_ |
12 | 12 |
| 13 #include <memory> |
13 #include <string> | 14 #include <string> |
14 #include <vector> | 15 #include <vector> |
15 | 16 |
16 #include "webrtc/api/video/video_frame.h" | 17 #include "webrtc/api/video/video_frame.h" |
17 #include "webrtc/base/criticalsection.h" | 18 #include "webrtc/base/criticalsection.h" |
18 #include "webrtc/media/base/videosourceinterface.h" | 19 #include "webrtc/media/base/videosourceinterface.h" |
19 #include "webrtc/typedefs.h" | 20 #include "webrtc/typedefs.h" |
20 | 21 |
21 namespace webrtc { | 22 namespace webrtc { |
22 class Clock; | 23 class Clock; |
(...skipping 17 matching lines...) Expand all Loading... |
40 const rtc::VideoSinkWants& wants) override; | 41 const rtc::VideoSinkWants& wants) override; |
41 void RemoveSink(rtc::VideoSinkInterface<VideoFrame>* sink) override; | 42 void RemoveSink(rtc::VideoSinkInterface<VideoFrame>* sink) override; |
42 | 43 |
43 rtc::CriticalSection crit_; | 44 rtc::CriticalSection crit_; |
44 rtc::VideoSinkInterface<VideoFrame>* sink_ GUARDED_BY(crit_); | 45 rtc::VideoSinkInterface<VideoFrame>* sink_ GUARDED_BY(crit_); |
45 rtc::VideoSinkWants sink_wants_ GUARDED_BY(crit_); | 46 rtc::VideoSinkWants sink_wants_ GUARDED_BY(crit_); |
46 }; | 47 }; |
47 | 48 |
48 class FrameGenerator { | 49 class FrameGenerator { |
49 public: | 50 public: |
50 FrameGenerator() {} | 51 virtual ~FrameGenerator() = default; |
51 virtual ~FrameGenerator() {} | |
52 | 52 |
53 // Returns video frame that remains valid until next call. | 53 // Returns video frame that remains valid until next call. |
54 virtual VideoFrame* NextFrame() = 0; | 54 virtual VideoFrame* NextFrame() = 0; |
55 | 55 |
56 // Change the capture resolution. | 56 // Change the capture resolution. |
57 virtual void ChangeResolution(size_t width, size_t height) { | 57 virtual void ChangeResolution(size_t width, size_t height) { |
58 RTC_NOTREACHED(); | 58 RTC_NOTREACHED(); |
59 } | 59 } |
60 | 60 |
61 // Creates a test frame generator that creates fully saturated frames with | 61 // Creates a frame generator that produces frames with small squares that |
62 // varying U, V values over time. | 62 // move randomly towards the lower right corner. |
63 static FrameGenerator* CreateChromaGenerator(size_t width, size_t height); | 63 static std::unique_ptr<FrameGenerator> CreateSquareGenerator(int width, |
| 64 int height); |
64 | 65 |
65 // Creates a frame generator that repeatedly plays a set of yuv files. | 66 // Creates a frame generator that repeatedly plays a set of yuv files. |
66 // The frame_repeat_count determines how many times each frame is shown, | 67 // The frame_repeat_count determines how many times each frame is shown, |
67 // with 1 = show each frame once, etc. | 68 // with 1 = show each frame once, etc. |
68 static FrameGenerator* CreateFromYuvFile(std::vector<std::string> files, | 69 static std::unique_ptr<FrameGenerator> CreateFromYuvFile( |
69 size_t width, | 70 std::vector<std::string> files, |
70 size_t height, | 71 size_t width, |
71 int frame_repeat_count); | 72 size_t height, |
| 73 int frame_repeat_count); |
72 | 74 |
73 // Creates a frame generator which takes a set of yuv files (wrapping a | 75 // Creates a frame generator which takes a set of yuv files (wrapping a |
74 // frame generator created by CreateFromYuvFile() above), but outputs frames | 76 // frame generator created by CreateFromYuvFile() above), but outputs frames |
75 // that have been cropped to specified resolution: source_width/source_height | 77 // that have been cropped to specified resolution: source_width/source_height |
76 // is the size of the source images, target_width/target_height is the size of | 78 // is the size of the source images, target_width/target_height is the size of |
77 // the cropped output. For each source image read, the cropped viewport will | 79 // the cropped output. For each source image read, the cropped viewport will |
78 // be scrolled top to bottom/left to right for scroll_tim_ms milliseconds. | 80 // be scrolled top to bottom/left to right for scroll_tim_ms milliseconds. |
79 // After that the image will stay in place for pause_time_ms milliseconds, | 81 // After that the image will stay in place for pause_time_ms milliseconds, |
80 // and then this will be repeated with the next file from the input set. | 82 // and then this will be repeated with the next file from the input set. |
81 static FrameGenerator* CreateScrollingInputFromYuvFiles( | 83 static std::unique_ptr<FrameGenerator> CreateScrollingInputFromYuvFiles( |
82 Clock* clock, | 84 Clock* clock, |
83 std::vector<std::string> filenames, | 85 std::vector<std::string> filenames, |
84 size_t source_width, | 86 size_t source_width, |
85 size_t source_height, | 87 size_t source_height, |
86 size_t target_width, | 88 size_t target_width, |
87 size_t target_height, | 89 size_t target_height, |
88 int64_t scroll_time_ms, | 90 int64_t scroll_time_ms, |
89 int64_t pause_time_ms); | 91 int64_t pause_time_ms); |
90 }; | 92 }; |
91 } // namespace test | 93 } // namespace test |
92 } // namespace webrtc | 94 } // namespace webrtc |
93 | 95 |
94 #endif // WEBRTC_TEST_FRAME_GENERATOR_H_ | 96 #endif // WEBRTC_TEST_FRAME_GENERATOR_H_ |
OLD | NEW |