| 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 { |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 "trials are separated by \"/\""); | 108 "trials are separated by \"/\""); |
| 108 } // namespace flags | 109 } // namespace flags |
| 109 | 110 |
| 110 class ScreenshareLoopback : public test::Loopback { | 111 class ScreenshareLoopback : public test::Loopback { |
| 111 public: | 112 public: |
| 112 explicit ScreenshareLoopback(const Config& config) : Loopback(config) { | 113 explicit ScreenshareLoopback(const Config& config) : Loopback(config) { |
| 113 vp8_settings_ = VideoEncoder::GetDefaultVp8Settings(); | 114 vp8_settings_ = VideoEncoder::GetDefaultVp8Settings(); |
| 114 vp8_settings_.denoisingOn = false; | 115 vp8_settings_.denoisingOn = false; |
| 115 vp8_settings_.frameDroppingOn = false; | 116 vp8_settings_.frameDroppingOn = false; |
| 116 vp8_settings_.numberOfTemporalLayers = 2; | 117 vp8_settings_.numberOfTemporalLayers = 2; |
| 118 |
| 119 vp9_settings_ = VideoEncoder::GetDefaultVp9Settings(); |
| 120 vp9_settings_.denoisingOn = false; |
| 121 vp9_settings_.frameDroppingOn = false; |
| 122 vp9_settings_.numberOfTemporalLayers = 2; |
| 117 } | 123 } |
| 118 virtual ~ScreenshareLoopback() {} | 124 virtual ~ScreenshareLoopback() {} |
| 119 | 125 |
| 120 protected: | 126 protected: |
| 121 VideoEncoderConfig CreateEncoderConfig() override { | 127 VideoEncoderConfig CreateEncoderConfig() override { |
| 122 VideoEncoderConfig encoder_config(test::Loopback::CreateEncoderConfig()); | 128 VideoEncoderConfig encoder_config(test::Loopback::CreateEncoderConfig()); |
| 123 VideoStream* stream = &encoder_config.streams[0]; | 129 VideoStream* stream = &encoder_config.streams[0]; |
| 124 encoder_config.content_type = VideoEncoderConfig::ContentType::kScreen; | 130 encoder_config.content_type = VideoEncoderConfig::ContentType::kScreen; |
| 125 encoder_config.min_transmit_bitrate_bps = flags::MinTransmitBitrate(); | 131 encoder_config.min_transmit_bitrate_bps = flags::MinTransmitBitrate(); |
| 126 encoder_config.encoder_specific_settings = &vp8_settings_; | 132 if (config_.codec == "VP8") { |
| 133 encoder_config.encoder_specific_settings = &vp8_settings_; |
| 134 } else if (config_.codec == "VP9") { |
| 135 encoder_config.encoder_specific_settings = &vp9_settings_; |
| 136 } else { |
| 137 RTC_NOTREACHED() << "Codec not supported!"; |
| 138 abort(); |
| 139 } |
| 127 stream->temporal_layer_thresholds_bps.clear(); | 140 stream->temporal_layer_thresholds_bps.clear(); |
| 128 stream->target_bitrate_bps = | 141 stream->target_bitrate_bps = |
| 129 static_cast<int>(config_.start_bitrate_kbps) * 1000; | 142 static_cast<int>(config_.start_bitrate_kbps) * 1000; |
| 130 stream->temporal_layer_thresholds_bps.push_back(stream->target_bitrate_bps); | 143 stream->temporal_layer_thresholds_bps.push_back(stream->target_bitrate_bps); |
| 131 return encoder_config; | 144 return encoder_config; |
| 132 } | 145 } |
| 133 | 146 |
| 134 test::VideoCapturer* CreateCapturer(VideoSendStream* send_stream) override { | 147 test::VideoCapturer* CreateCapturer(VideoSendStream* send_stream) override { |
| 135 std::vector<std::string> slides; | 148 std::vector<std::string> slides; |
| 136 slides.push_back(test::ResourcePath("web_screenshot_1850_1110", "yuv")); | 149 slides.push_back(test::ResourcePath("web_screenshot_1850_1110", "yuv")); |
| 137 slides.push_back(test::ResourcePath("presentation_1850_1110", "yuv")); | 150 slides.push_back(test::ResourcePath("presentation_1850_1110", "yuv")); |
| 138 slides.push_back(test::ResourcePath("photo_1850_1110", "yuv")); | 151 slides.push_back(test::ResourcePath("photo_1850_1110", "yuv")); |
| 139 slides.push_back(test::ResourcePath("difficult_photo_1850_1110", "yuv")); | 152 slides.push_back(test::ResourcePath("difficult_photo_1850_1110", "yuv")); |
| 140 | 153 |
| 141 test::FrameGenerator* frame_generator = | 154 test::FrameGenerator* frame_generator = |
| 142 test::FrameGenerator::CreateFromYuvFile( | 155 test::FrameGenerator::CreateFromYuvFile( |
| 143 slides, flags::Width(), flags::Height(), 10 * flags::Fps()); | 156 slides, flags::Width(), flags::Height(), 10 * flags::Fps()); |
| 144 test::FrameGeneratorCapturer* capturer(new test::FrameGeneratorCapturer( | 157 test::FrameGeneratorCapturer* capturer(new test::FrameGeneratorCapturer( |
| 145 clock_, send_stream->Input(), frame_generator, flags::Fps())); | 158 clock_, send_stream->Input(), frame_generator, flags::Fps())); |
| 146 EXPECT_TRUE(capturer->Init()); | 159 EXPECT_TRUE(capturer->Init()); |
| 147 return capturer; | 160 return capturer; |
| 148 } | 161 } |
| 149 | 162 |
| 150 VideoCodecVP8 vp8_settings_; | 163 VideoCodecVP8 vp8_settings_; |
| 164 VideoCodecVP9 vp9_settings_; |
| 151 }; | 165 }; |
| 152 | 166 |
| 153 void Loopback() { | 167 void Loopback() { |
| 154 test::Loopback::Config config{flags::Width(), | 168 test::Loopback::Config config{flags::Width(), |
| 155 flags::Height(), | 169 flags::Height(), |
| 156 flags::Fps(), | 170 flags::Fps(), |
| 157 flags::MinBitrate(), | 171 flags::MinBitrate(), |
| 158 flags::StartBitrate(), | 172 flags::StartBitrate(), |
| 159 flags::MaxBitrate(), | 173 flags::MaxBitrate(), |
| 160 flags::MinTransmitBitrate(), | 174 flags::MinTransmitBitrate(), |
| (...skipping 11 matching lines...) Expand all Loading... |
| 172 } // namespace webrtc | 186 } // namespace webrtc |
| 173 | 187 |
| 174 int main(int argc, char* argv[]) { | 188 int main(int argc, char* argv[]) { |
| 175 ::testing::InitGoogleTest(&argc, argv); | 189 ::testing::InitGoogleTest(&argc, argv); |
| 176 google::ParseCommandLineFlags(&argc, &argv, true); | 190 google::ParseCommandLineFlags(&argc, &argv, true); |
| 177 webrtc::test::InitFieldTrialsFromString( | 191 webrtc::test::InitFieldTrialsFromString( |
| 178 webrtc::flags::FLAGS_force_fieldtrials); | 192 webrtc::flags::FLAGS_force_fieldtrials); |
| 179 webrtc::test::RunTest(webrtc::Loopback); | 193 webrtc::test::RunTest(webrtc::Loopback); |
| 180 return 0; | 194 return 0; |
| 181 } | 195 } |
| OLD | NEW |