| 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" | |
| 19 #include "webrtc/test/field_trial.h" | 18 #include "webrtc/test/field_trial.h" |
| 20 #include "webrtc/test/frame_generator.h" | 19 #include "webrtc/test/frame_generator.h" |
| 21 #include "webrtc/test/frame_generator_capturer.h" | 20 #include "webrtc/test/frame_generator_capturer.h" |
| 22 #include "webrtc/test/run_test.h" | 21 #include "webrtc/test/run_test.h" |
| 23 #include "webrtc/test/testsupport/fileutils.h" | 22 #include "webrtc/test/testsupport/fileutils.h" |
| 24 #include "webrtc/typedefs.h" | 23 #include "webrtc/typedefs.h" |
| 25 #include "webrtc/video/loopback.h" | 24 #include "webrtc/video/loopback.h" |
| 26 #include "webrtc/video/video_send_stream.h" | 25 #include "webrtc/video/video_send_stream.h" |
| 27 | 26 |
| 28 namespace webrtc { | 27 namespace webrtc { |
| 29 namespace flags { | 28 namespace flags { |
| 30 | 29 |
| 31 DEFINE_int32(width, 1850, "Video width (crops source)."); | 30 // Fixed for prerecorded screenshare content. |
| 32 size_t Width() { | 31 size_t Width() { |
| 33 return static_cast<size_t>(FLAGS_width); | 32 return 1850; |
| 34 } | 33 } |
| 35 | |
| 36 DEFINE_int32(height, 1110, "Video height (crops source)."); | |
| 37 size_t Height() { | 34 size_t Height() { |
| 38 return static_cast<size_t>(FLAGS_height); | 35 return 1110; |
| 39 } | 36 } |
| 40 | 37 |
| 41 DEFINE_int32(fps, 5, "Frames per second."); | 38 DEFINE_int32(fps, 5, "Frames per second."); |
| 42 int Fps() { | 39 int Fps() { |
| 43 return static_cast<int>(FLAGS_fps); | 40 return static_cast<int>(FLAGS_fps); |
| 44 } | 41 } |
| 45 | 42 |
| 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 | |
| 61 DEFINE_int32(min_bitrate, 50, "Minimum video bitrate."); | 43 DEFINE_int32(min_bitrate, 50, "Minimum video bitrate."); |
| 62 size_t MinBitrate() { | 44 size_t MinBitrate() { |
| 63 return static_cast<size_t>(FLAGS_min_bitrate); | 45 return static_cast<size_t>(FLAGS_min_bitrate); |
| 64 } | 46 } |
| 65 | 47 |
| 66 DEFINE_int32(tl0_bitrate, 200, "Temporal layer 0 target bitrate."); | 48 DEFINE_int32(tl0_bitrate, 200, "Temporal layer 0 target bitrate."); |
| 67 size_t StartBitrate() { | 49 size_t StartBitrate() { |
| 68 return static_cast<size_t>(FLAGS_tl0_bitrate); | 50 return static_cast<size_t>(FLAGS_tl0_bitrate); |
| 69 } | 51 } |
| 70 | 52 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 return encoder_config; | 131 return encoder_config; |
| 150 } | 132 } |
| 151 | 133 |
| 152 test::VideoCapturer* CreateCapturer(VideoSendStream* send_stream) override { | 134 test::VideoCapturer* CreateCapturer(VideoSendStream* send_stream) override { |
| 153 std::vector<std::string> slides; | 135 std::vector<std::string> slides; |
| 154 slides.push_back(test::ResourcePath("web_screenshot_1850_1110", "yuv")); | 136 slides.push_back(test::ResourcePath("web_screenshot_1850_1110", "yuv")); |
| 155 slides.push_back(test::ResourcePath("presentation_1850_1110", "yuv")); | 137 slides.push_back(test::ResourcePath("presentation_1850_1110", "yuv")); |
| 156 slides.push_back(test::ResourcePath("photo_1850_1110", "yuv")); | 138 slides.push_back(test::ResourcePath("photo_1850_1110", "yuv")); |
| 157 slides.push_back(test::ResourcePath("difficult_photo_1850_1110", "yuv")); | 139 slides.push_back(test::ResourcePath("difficult_photo_1850_1110", "yuv")); |
| 158 | 140 |
| 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 | |
| 169 test::FrameGenerator* frame_generator = | 141 test::FrameGenerator* frame_generator = |
| 170 test::FrameGenerator::CreateScrollingInputFromYuvFiles( | 142 test::FrameGenerator::CreateFromYuvFile( |
| 171 Clock::GetRealTimeClock(), slides, kWidth, kHeight, flags::Width(), | 143 slides, flags::Width(), flags::Height(), 10 * flags::Fps()); |
| 172 flags::Height(), flags::ScrollDuration() * 1000, kPauseDurationMs); | |
| 173 | |
| 174 test::FrameGeneratorCapturer* capturer(new test::FrameGeneratorCapturer( | 144 test::FrameGeneratorCapturer* capturer(new test::FrameGeneratorCapturer( |
| 175 clock_, send_stream->Input(), frame_generator, flags::Fps())); | 145 clock_, send_stream->Input(), frame_generator, flags::Fps())); |
| 176 EXPECT_TRUE(capturer->Init()); | 146 EXPECT_TRUE(capturer->Init()); |
| 177 return capturer; | 147 return capturer; |
| 178 } | 148 } |
| 179 | 149 |
| 180 VideoCodecVP8 vp8_settings_; | 150 VideoCodecVP8 vp8_settings_; |
| 181 }; | 151 }; |
| 182 | 152 |
| 183 void Loopback() { | 153 void Loopback() { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 202 } // namespace webrtc | 172 } // namespace webrtc |
| 203 | 173 |
| 204 int main(int argc, char* argv[]) { | 174 int main(int argc, char* argv[]) { |
| 205 ::testing::InitGoogleTest(&argc, argv); | 175 ::testing::InitGoogleTest(&argc, argv); |
| 206 google::ParseCommandLineFlags(&argc, &argv, true); | 176 google::ParseCommandLineFlags(&argc, &argv, true); |
| 207 webrtc::test::InitFieldTrialsFromString( | 177 webrtc::test::InitFieldTrialsFromString( |
| 208 webrtc::flags::FLAGS_force_fieldtrials); | 178 webrtc::flags::FLAGS_force_fieldtrials); |
| 209 webrtc::test::RunTest(webrtc::Loopback); | 179 webrtc::test::RunTest(webrtc::Loopback); |
| 210 return 0; | 180 return 0; |
| 211 } | 181 } |
| OLD | NEW |