mflodman | 351424e | 2017-08-10 02:43:14 -0700 | [diff] [blame] | 1 | /* |
| 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 Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 10 | #ifndef TEST_VIDEO_CODEC_SETTINGS_H_ |
| 11 | #define TEST_VIDEO_CODEC_SETTINGS_H_ |
mflodman | 351424e | 2017-08-10 02:43:14 -0700 | [diff] [blame] | 12 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 13 | #include "api/video_codecs/video_encoder.h" |
mflodman | 351424e | 2017-08-10 02:43:14 -0700 | [diff] [blame] | 14 | |
| 15 | namespace webrtc { |
| 16 | namespace test { |
| 17 | |
| 18 | const uint16_t kTestWidth = 352; |
| 19 | const uint16_t kTestHeight = 288; |
| 20 | const uint32_t kTestFrameRate = 30; |
| 21 | const unsigned int kTestMinBitrateKbps = 30; |
| 22 | const unsigned int kTestStartBitrateKbps = 300; |
| 23 | const uint8_t kTestPayloadType = 100; |
| 24 | const int64_t kTestTimingFramesDelayMs = 200; |
| 25 | const uint16_t kTestOutlierFrameSizePercent = 250; |
| 26 | |
| 27 | static void CodecSettings(VideoCodecType codec_type, VideoCodec* settings) { |
| 28 | memset(settings, 0, sizeof(VideoCodec)); |
Rasmus Brandt | 2b304f1 | 2018-02-05 09:52:47 +0100 | [diff] [blame] | 29 | |
| 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 | |
mflodman | 351424e | 2017-08-10 02:43:14 -0700 | [diff] [blame] | 51 | switch (codec_type) { |
| 52 | case kVideoCodecVP8: |
mflodman | 351424e | 2017-08-10 02:43:14 -0700 | [diff] [blame] | 53 | settings->codecType = kVideoCodecVP8; |
mflodman | 351424e | 2017-08-10 02:43:14 -0700 | [diff] [blame] | 54 | *(settings->VP8()) = VideoEncoder::GetDefaultVp8Settings(); |
| 55 | return; |
| 56 | case kVideoCodecVP9: |
mflodman | 351424e | 2017-08-10 02:43:14 -0700 | [diff] [blame] | 57 | settings->codecType = kVideoCodecVP9; |
mflodman | 351424e | 2017-08-10 02:43:14 -0700 | [diff] [blame] | 58 | *(settings->VP9()) = VideoEncoder::GetDefaultVp9Settings(); |
| 59 | return; |
| 60 | case kVideoCodecH264: |
mflodman | 351424e | 2017-08-10 02:43:14 -0700 | [diff] [blame] | 61 | settings->codecType = kVideoCodecH264; |
Rasmus Brandt | 2b304f1 | 2018-02-05 09:52:47 +0100 | [diff] [blame] | 62 | // TODO(brandtr): Set |qpMax| here, when the OpenH264 wrapper supports it. |
mflodman | 351424e | 2017-08-10 02:43:14 -0700 | [diff] [blame] | 63 | *(settings->H264()) = VideoEncoder::GetDefaultH264Settings(); |
| 64 | return; |
| 65 | case kVideoCodecI420: |
mflodman | 351424e | 2017-08-10 02:43:14 -0700 | [diff] [blame] | 66 | settings->codecType = kVideoCodecI420; |
mflodman | 351424e | 2017-08-10 02:43:14 -0700 | [diff] [blame] | 67 | // Bitrate needed for this size and framerate. |
| 68 | settings->startBitrate = |
| 69 | 3 * kTestWidth * kTestHeight * 8 * kTestFrameRate / 1000 / 2; |
| 70 | settings->maxBitrate = settings->startBitrate; |
mflodman | 351424e | 2017-08-10 02:43:14 -0700 | [diff] [blame] | 71 | return; |
Emircan Uysaler | d7ae3c3 | 2018-01-25 13:01:09 -0800 | [diff] [blame] | 72 | case kVideoCodecMultiplex: |
mflodman | 351424e | 2017-08-10 02:43:14 -0700 | [diff] [blame] | 73 | case kVideoCodecGeneric: |
| 74 | case kVideoCodecUnknown: |
| 75 | RTC_NOTREACHED(); |
| 76 | return; |
| 77 | } |
| 78 | } |
| 79 | } // namespace test |
| 80 | } // namespace webrtc |
| 81 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 82 | #endif // TEST_VIDEO_CODEC_SETTINGS_H_ |