OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 | 10 |
11 #include <stdio.h> | 11 #include <stdio.h> |
12 | 12 |
13 #include <map> | 13 #include <map> |
14 | 14 |
15 #include "gflags/gflags.h" | 15 #include "gflags/gflags.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
17 | 17 |
| 18 #include "webrtc/base/checks.h" |
18 #include "webrtc/test/field_trial.h" | 19 #include "webrtc/test/field_trial.h" |
19 #include "webrtc/test/frame_generator.h" | 20 #include "webrtc/test/frame_generator.h" |
20 #include "webrtc/test/frame_generator_capturer.h" | 21 #include "webrtc/test/frame_generator_capturer.h" |
21 #include "webrtc/test/run_test.h" | 22 #include "webrtc/test/run_test.h" |
22 #include "webrtc/test/testsupport/fileutils.h" | 23 #include "webrtc/test/testsupport/fileutils.h" |
23 #include "webrtc/typedefs.h" | 24 #include "webrtc/typedefs.h" |
24 #include "webrtc/video/loopback.h" | 25 #include "webrtc/video/loopback.h" |
25 #include "webrtc/video/video_send_stream.h" | 26 #include "webrtc/video/video_send_stream.h" |
26 | 27 |
27 namespace webrtc { | 28 namespace webrtc { |
28 namespace flags { | 29 namespace flags { |
29 | 30 |
30 // Fixed for prerecorded screenshare content. | 31 DEFINE_int32(width, 1850, "Video width (crops source)."); |
31 size_t Width() { | 32 size_t Width() { |
32 return 1850; | 33 return static_cast<size_t>(FLAGS_width); |
33 } | 34 } |
| 35 |
| 36 DEFINE_int32(height, 1110, "Video height (crops source)."); |
34 size_t Height() { | 37 size_t Height() { |
35 return 1110; | 38 return static_cast<size_t>(FLAGS_height); |
36 } | 39 } |
37 | 40 |
38 DEFINE_int32(fps, 5, "Frames per second."); | 41 DEFINE_int32(fps, 5, "Frames per second."); |
39 int Fps() { | 42 int Fps() { |
40 return static_cast<int>(FLAGS_fps); | 43 return static_cast<int>(FLAGS_fps); |
41 } | 44 } |
42 | 45 |
| 46 DEFINE_int32(slide_change_interval, |
| 47 10, |
| 48 "Interval (in seconds) between simulated slide changes."); |
| 49 int SlideChangeInterval() { |
| 50 return static_cast<int>(FLAGS_slide_change_interval); |
| 51 } |
| 52 |
| 53 DEFINE_int32( |
| 54 scroll_duration, |
| 55 0, |
| 56 "Duration (in seconds) during which a slide will be scrolled into place."); |
| 57 int ScrollDuration() { |
| 58 return static_cast<int>(FLAGS_scroll_duration); |
| 59 } |
| 60 |
43 DEFINE_int32(min_bitrate, 50, "Minimum video bitrate."); | 61 DEFINE_int32(min_bitrate, 50, "Minimum video bitrate."); |
44 size_t MinBitrate() { | 62 size_t MinBitrate() { |
45 return static_cast<size_t>(FLAGS_min_bitrate); | 63 return static_cast<size_t>(FLAGS_min_bitrate); |
46 } | 64 } |
47 | 65 |
48 DEFINE_int32(tl0_bitrate, 200, "Temporal layer 0 target bitrate."); | 66 DEFINE_int32(tl0_bitrate, 200, "Temporal layer 0 target bitrate."); |
49 size_t StartBitrate() { | 67 size_t StartBitrate() { |
50 return static_cast<size_t>(FLAGS_tl0_bitrate); | 68 return static_cast<size_t>(FLAGS_tl0_bitrate); |
51 } | 69 } |
52 | 70 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 return encoder_config; | 149 return encoder_config; |
132 } | 150 } |
133 | 151 |
134 test::VideoCapturer* CreateCapturer(VideoSendStream* send_stream) override { | 152 test::VideoCapturer* CreateCapturer(VideoSendStream* send_stream) override { |
135 std::vector<std::string> slides; | 153 std::vector<std::string> slides; |
136 slides.push_back(test::ResourcePath("web_screenshot_1850_1110", "yuv")); | 154 slides.push_back(test::ResourcePath("web_screenshot_1850_1110", "yuv")); |
137 slides.push_back(test::ResourcePath("presentation_1850_1110", "yuv")); | 155 slides.push_back(test::ResourcePath("presentation_1850_1110", "yuv")); |
138 slides.push_back(test::ResourcePath("photo_1850_1110", "yuv")); | 156 slides.push_back(test::ResourcePath("photo_1850_1110", "yuv")); |
139 slides.push_back(test::ResourcePath("difficult_photo_1850_1110", "yuv")); | 157 slides.push_back(test::ResourcePath("difficult_photo_1850_1110", "yuv")); |
140 | 158 |
| 159 // Fixed for input resolution for prerecorded screenshare content. |
| 160 const size_t kWidth = 1850; |
| 161 const size_t kHeight = 1110; |
| 162 CHECK_LE(flags::Width(), kWidth); |
| 163 CHECK_LE(flags::Height(), kHeight); |
| 164 CHECK_GT(flags::SlideChangeInterval(), 0); |
| 165 const int kPauseDurationMs = |
| 166 (flags::SlideChangeInterval() - flags::ScrollDuration()) * 1000; |
| 167 CHECK_LE(flags::ScrollDuration(), flags::SlideChangeInterval()); |
| 168 |
141 test::FrameGenerator* frame_generator = | 169 test::FrameGenerator* frame_generator = |
142 test::FrameGenerator::CreateFromYuvFile( | 170 test::FrameGenerator::CreateScrollingInputFromYuvFiles( |
143 slides, flags::Width(), flags::Height(), 10 * flags::Fps()); | 171 Clock::GetRealTimeClock(), slides, kWidth, kHeight, flags::Width(), |
| 172 flags::Height(), flags::ScrollDuration() * 1000, kPauseDurationMs); |
| 173 |
144 test::FrameGeneratorCapturer* capturer(new test::FrameGeneratorCapturer( | 174 test::FrameGeneratorCapturer* capturer(new test::FrameGeneratorCapturer( |
145 clock_, send_stream->Input(), frame_generator, flags::Fps())); | 175 clock_, send_stream->Input(), frame_generator, flags::Fps())); |
146 EXPECT_TRUE(capturer->Init()); | 176 EXPECT_TRUE(capturer->Init()); |
147 return capturer; | 177 return capturer; |
148 } | 178 } |
149 | 179 |
150 VideoCodecVP8 vp8_settings_; | 180 VideoCodecVP8 vp8_settings_; |
151 }; | 181 }; |
152 | 182 |
153 void Loopback() { | 183 void Loopback() { |
(...skipping 18 matching lines...) Expand all Loading... |
172 } // namespace webrtc | 202 } // namespace webrtc |
173 | 203 |
174 int main(int argc, char* argv[]) { | 204 int main(int argc, char* argv[]) { |
175 ::testing::InitGoogleTest(&argc, argv); | 205 ::testing::InitGoogleTest(&argc, argv); |
176 google::ParseCommandLineFlags(&argc, &argv, true); | 206 google::ParseCommandLineFlags(&argc, &argv, true); |
177 webrtc::test::InitFieldTrialsFromString( | 207 webrtc::test::InitFieldTrialsFromString( |
178 webrtc::flags::FLAGS_force_fieldtrials); | 208 webrtc::flags::FLAGS_force_fieldtrials); |
179 webrtc::test::RunTest(webrtc::Loopback); | 209 webrtc::test::RunTest(webrtc::Loopback); |
180 return 0; | 210 return 0; |
181 } | 211 } |
OLD | NEW |