blob: 5da2ef21cdaaf42a9faa6c75c6f0b93ba96d3f96 [file] [log] [blame]
Henrik Boström722fa4d2020-04-29 14:46:301/*
2 * Copyright (c) 2020 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
11#include "call/adaptation/video_stream_input_state_provider.h"
12
13#include <utility>
14
15#include "api/video_codecs/video_encoder.h"
16#include "call/adaptation/encoder_settings.h"
17#include "call/adaptation/test/fake_frame_rate_provider.h"
18#include "test/gtest.h"
19
20namespace webrtc {
21
22TEST(VideoStreamInputStateProviderTest, DefaultValues) {
23 FakeFrameRateProvider frame_rate_provider;
24 VideoStreamInputStateProvider input_state_provider(&frame_rate_provider);
25 VideoStreamInputState input_state = input_state_provider.InputState();
26 EXPECT_EQ(false, input_state.has_input());
27 EXPECT_EQ(absl::nullopt, input_state.frame_size_pixels());
28 EXPECT_EQ(0, input_state.frames_per_second());
29 EXPECT_EQ(VideoCodecType::kVideoCodecGeneric, input_state.video_codec_type());
30 EXPECT_EQ(kDefaultMinPixelsPerFrame, input_state.min_pixels_per_frame());
Åsa Persson1dd94a02021-02-18 13:20:0331 EXPECT_EQ(absl::nullopt, input_state.single_active_stream_pixels());
Henrik Boström722fa4d2020-04-29 14:46:3032}
33
34TEST(VideoStreamInputStateProviderTest, ValuesSet) {
35 FakeFrameRateProvider frame_rate_provider;
36 VideoStreamInputStateProvider input_state_provider(&frame_rate_provider);
37 input_state_provider.OnHasInputChanged(true);
38 input_state_provider.OnFrameSizeObserved(42);
39 frame_rate_provider.set_fps(123);
40 VideoEncoder::EncoderInfo encoder_info;
41 encoder_info.scaling_settings.min_pixels_per_frame = 1337;
42 VideoEncoderConfig encoder_config;
43 encoder_config.codec_type = VideoCodecType::kVideoCodecVP9;
Åsa Persson1dd94a02021-02-18 13:20:0344 VideoCodec video_codec;
45 video_codec.codecType = VideoCodecType::kVideoCodecVP8;
46 video_codec.numberOfSimulcastStreams = 2;
47 video_codec.simulcastStream[0].active = false;
48 video_codec.simulcastStream[1].active = true;
49 video_codec.simulcastStream[1].width = 111;
50 video_codec.simulcastStream[1].height = 222;
Henrik Boström722fa4d2020-04-29 14:46:3051 input_state_provider.OnEncoderSettingsChanged(EncoderSettings(
Åsa Persson1dd94a02021-02-18 13:20:0352 std::move(encoder_info), std::move(encoder_config), video_codec));
Henrik Boström722fa4d2020-04-29 14:46:3053 VideoStreamInputState input_state = input_state_provider.InputState();
54 EXPECT_EQ(true, input_state.has_input());
55 EXPECT_EQ(42, input_state.frame_size_pixels());
56 EXPECT_EQ(123, input_state.frames_per_second());
57 EXPECT_EQ(VideoCodecType::kVideoCodecVP9, input_state.video_codec_type());
58 EXPECT_EQ(1337, input_state.min_pixels_per_frame());
Åsa Persson1dd94a02021-02-18 13:20:0359 EXPECT_EQ(111 * 222, input_state.single_active_stream_pixels());
Henrik Boström722fa4d2020-04-29 14:46:3060}
61
62} // namespace webrtc