blob: df7adba50d7d8cbe640f22bec44515733ca859bf [file] [log] [blame]
Sebastian Jansson5fbebd52019-02-20 11:16:19 +01001/*
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
15namespace webrtc {
16namespace test {
17namespace {
18using Codec = VideoStreamConfig::Encoder::Codec;
19using CodecImpl = VideoStreamConfig::Encoder::Implementation;
20} // namespace
21
Sergey Silkin45af00f2019-02-22 08:11:43 +000022// TODO(srte): Enable after landing fix causing flakiness.
23TEST(VideoStreamTest, DISABLED_RecievesVp8SimulcastFrames) {
Sebastian Jansson5fbebd52019-02-20 11:16:19 +010024 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