Sebastian Jansson | 5fbebd5 | 2019-02-20 11:16:19 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 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 | #include <atomic> |
| 11 | |
| 12 | #include "test/gtest.h" |
| 13 | #include "test/scenario/scenario.h" |
| 14 | |
| 15 | namespace webrtc { |
| 16 | namespace test { |
| 17 | namespace { |
| 18 | using Codec = VideoStreamConfig::Encoder::Codec; |
| 19 | using CodecImpl = VideoStreamConfig::Encoder::Implementation; |
| 20 | } // namespace |
| 21 | |
Sergey Silkin | 45af00f | 2019-02-22 08:11:43 +0000 | [diff] [blame] | 22 | // TODO(srte): Enable after landing fix causing flakiness. |
| 23 | TEST(VideoStreamTest, DISABLED_RecievesVp8SimulcastFrames) { |
Sebastian Jansson | 5fbebd5 | 2019-02-20 11:16:19 +0100 | [diff] [blame] | 24 | TimeDelta kRunTime = TimeDelta::ms(500); |
| 25 | int kFrameRate = 30; |
| 26 | |
| 27 | std::atomic<int> frame_count(0); |
| 28 | { |
| 29 | Scenario s; |
| 30 | auto route = s.CreateRoutes(s.CreateClient("caller", CallClientConfig()), |
| 31 | {s.CreateSimulationNode(NetworkNodeConfig())}, |
| 32 | s.CreateClient("callee", CallClientConfig()), |
| 33 | {s.CreateSimulationNode(NetworkNodeConfig())}); |
| 34 | s.CreateVideoStream(route->forward(), [&](VideoStreamConfig* c) { |
| 35 | // TODO(srte): Replace with code checking for all simulcast streams when |
| 36 | // there's a hook available for that. |
| 37 | c->analyzer.frame_quality_handler = [&](const VideoFrameQualityInfo&) { |
| 38 | frame_count++; |
| 39 | }; |
| 40 | c->source.framerate = kFrameRate; |
| 41 | // The resolution must be high enough to allow smaller layers to be |
| 42 | // created. |
| 43 | c->source.generator.width = 1024; |
| 44 | c->source.generator.height = 768; |
| 45 | |
| 46 | c->encoder.implementation = CodecImpl::kSoftware; |
| 47 | c->encoder.codec = Codec::kVideoCodecVP8; |
| 48 | // By enabling multiple spatial layers, simulcast will be enabled for VP8. |
| 49 | c->encoder.layers.spatial = 3; |
| 50 | }); |
| 51 | s.RunFor(kRunTime); |
| 52 | } |
| 53 | |
| 54 | // Using 20% error margin to avoid flakyness. |
| 55 | const int kExpectedCount = |
| 56 | static_cast<int>(kRunTime.seconds<double>() * kFrameRate * 0.8); |
| 57 | |
| 58 | EXPECT_GE(frame_count, kExpectedCount); |
| 59 | } |
| 60 | } // namespace test |
| 61 | } // namespace webrtc |