blob: 9ee6be222cdf3289e77eb1fedbf6cb8064aaeaf4 [file] [log] [blame]
mflodman351424e2017-08-10 02:43:14 -07001/*
2 * Copyright (c) 2017 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 */
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020010#ifndef TEST_VIDEO_CODEC_SETTINGS_H_
11#define TEST_VIDEO_CODEC_SETTINGS_H_
mflodman351424e2017-08-10 02:43:14 -070012
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020013#include "api/video_codecs/video_encoder.h"
mflodman351424e2017-08-10 02:43:14 -070014
15namespace webrtc {
16namespace test {
17
18const uint16_t kTestWidth = 352;
19const uint16_t kTestHeight = 288;
20const uint32_t kTestFrameRate = 30;
21const unsigned int kTestMinBitrateKbps = 30;
22const unsigned int kTestStartBitrateKbps = 300;
23const uint8_t kTestPayloadType = 100;
24const int64_t kTestTimingFramesDelayMs = 200;
25const uint16_t kTestOutlierFrameSizePercent = 250;
26
27static void CodecSettings(VideoCodecType codec_type, VideoCodec* settings) {
28 memset(settings, 0, sizeof(VideoCodec));
Rasmus Brandt2b304f12018-02-05 09:52:47 +010029
30 settings->plType = kTestPayloadType;
31
32 settings->width = kTestWidth;
33 settings->height = kTestHeight;
34
35 settings->startBitrate = kTestStartBitrateKbps;
36 settings->maxBitrate = 0;
37 settings->minBitrate = kTestMinBitrateKbps;
38 settings->targetBitrate = 0;
39
40 settings->maxFramerate = kTestFrameRate;
41
42 settings->active = true;
43
44 settings->qpMax = 56; // See webrtcvideoengine.h.
45 settings->numberOfSimulcastStreams = 0;
46
47 settings->timing_frame_thresholds = {
48 kTestTimingFramesDelayMs, kTestOutlierFrameSizePercent,
49 };
50
Kári Tristan Helgasone8a2e6c2018-08-23 13:19:00 +020051 settings->codecType = codec_type;
mflodman351424e2017-08-10 02:43:14 -070052 switch (codec_type) {
53 case kVideoCodecVP8:
mflodman351424e2017-08-10 02:43:14 -070054 *(settings->VP8()) = VideoEncoder::GetDefaultVp8Settings();
55 return;
56 case kVideoCodecVP9:
mflodman351424e2017-08-10 02:43:14 -070057 *(settings->VP9()) = VideoEncoder::GetDefaultVp9Settings();
58 return;
59 case kVideoCodecH264:
Rasmus Brandt2b304f12018-02-05 09:52:47 +010060 // TODO(brandtr): Set |qpMax| here, when the OpenH264 wrapper supports it.
mflodman351424e2017-08-10 02:43:14 -070061 *(settings->H264()) = VideoEncoder::GetDefaultH264Settings();
62 return;
63 case kVideoCodecI420:
mflodman351424e2017-08-10 02:43:14 -070064 // Bitrate needed for this size and framerate.
65 settings->startBitrate =
66 3 * kTestWidth * kTestHeight * 8 * kTestFrameRate / 1000 / 2;
67 settings->maxBitrate = settings->startBitrate;
mflodman351424e2017-08-10 02:43:14 -070068 return;
Kári Tristan Helgason84ccb2d2018-08-16 14:35:26 +020069 default:
mflodman351424e2017-08-10 02:43:14 -070070 return;
71 }
72}
73} // namespace test
74} // namespace webrtc
75
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020076#endif // TEST_VIDEO_CODEC_SETTINGS_H_