blob: 9842d1ed127e9d4658707a71825087f0ed82fa09 [file] [log] [blame]
pbos@webrtc.orgf577ae92014-03-19 08:43:57 +00001/*
2 * Copyright (c) 2014 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 "webrtc/test/encoder_settings.h"
11
12#include <assert.h>
13#include <string.h>
14
15#include "webrtc/video_engine/vie_defines.h"
16
17namespace webrtc {
18namespace test {
pbos@webrtc.org6ae48c62014-06-06 10:49:19 +000019std::vector<VideoStream> CreateVideoStreams(size_t num_streams) {
pbos@webrtc.orgf577ae92014-03-19 08:43:57 +000020 assert(num_streams > 0);
21
22 // Add more streams to the settings above with reasonable values if required.
23 static const size_t kNumSettings = 3;
24 assert(num_streams <= kNumSettings);
25
pbos@webrtc.org6ae48c62014-06-06 10:49:19 +000026 std::vector<VideoStream> stream_settings(kNumSettings);
pbos@webrtc.orgf577ae92014-03-19 08:43:57 +000027
28 stream_settings[0].width = 320;
29 stream_settings[0].height = 180;
30 stream_settings[0].max_framerate = 30;
31 stream_settings[0].min_bitrate_bps = 50000;
32 stream_settings[0].target_bitrate_bps = stream_settings[0].max_bitrate_bps =
33 150000;
34 stream_settings[0].max_qp = 56;
35
36 stream_settings[1].width = 640;
37 stream_settings[1].height = 360;
38 stream_settings[1].max_framerate = 30;
39 stream_settings[1].min_bitrate_bps = 200000;
40 stream_settings[1].target_bitrate_bps = stream_settings[1].max_bitrate_bps =
41 450000;
42 stream_settings[1].max_qp = 56;
43
44 stream_settings[2].width = 1280;
45 stream_settings[2].height = 720;
46 stream_settings[2].max_framerate = 30;
47 stream_settings[2].min_bitrate_bps = 700000;
48 stream_settings[2].target_bitrate_bps = stream_settings[2].max_bitrate_bps =
49 1500000;
50 stream_settings[2].max_qp = 56;
pbos@webrtc.org6ae48c62014-06-06 10:49:19 +000051 stream_settings.resize(num_streams);
52 return stream_settings;
pbos@webrtc.orgf577ae92014-03-19 08:43:57 +000053}
54
55VideoCodec CreateDecoderVideoCodec(
pbos@webrtc.org6ae48c62014-06-06 10:49:19 +000056 const VideoSendStream::Config::EncoderSettings& encoder_settings) {
pbos@webrtc.orgf577ae92014-03-19 08:43:57 +000057 VideoCodec codec;
58 memset(&codec, 0, sizeof(codec));
59
pbos@webrtc.org6ae48c62014-06-06 10:49:19 +000060 codec.plType = encoder_settings.payload_type;
61 strcpy(codec.plName, encoder_settings.payload_name.c_str());
stefan@webrtc.orgb9f54532014-07-04 12:42:07 +000062 if (encoder_settings.payload_name == "VP8") {
63 codec.codecType = kVideoCodecVP8;
64 } else if (encoder_settings.payload_name == "H264") {
65 codec.codecType = kVideoCodecH264;
66 } else {
67 codec.codecType = kVideoCodecGeneric;
68 }
pbos@webrtc.orgf577ae92014-03-19 08:43:57 +000069
70 if (codec.codecType == kVideoCodecVP8) {
71 codec.codecSpecific.VP8.resilience = kResilientStream;
72 codec.codecSpecific.VP8.numberOfTemporalLayers = 1;
73 codec.codecSpecific.VP8.denoisingOn = true;
74 codec.codecSpecific.VP8.errorConcealmentOn = false;
75 codec.codecSpecific.VP8.automaticResizeOn = false;
76 codec.codecSpecific.VP8.frameDroppingOn = true;
77 codec.codecSpecific.VP8.keyFrameInterval = 3000;
78 }
79
stefan@webrtc.orgb9f54532014-07-04 12:42:07 +000080 if (codec.codecType == kVideoCodecH264) {
81 codec.codecSpecific.H264.profile = kProfileBase;
82 codec.codecSpecific.H264.frameDroppingOn = true;
83 codec.codecSpecific.H264.keyFrameInterval = 3000;
84 }
85
pbos@webrtc.org6ae48c62014-06-06 10:49:19 +000086 codec.width = 320;
87 codec.height = 180;
88 codec.startBitrate = codec.minBitrate = codec.maxBitrate = 300;
pbos@webrtc.orgf577ae92014-03-19 08:43:57 +000089
90 return codec;
91}
92
93} // namespace test
94} // namespace webrtc