2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
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.
10 #include "webrtc/test/encoder_settings.h"
15 #include "webrtc/video_encoder.h"
16 #include "webrtc/video_engine/vie_defines.h"
20 std::vector<VideoStream> CreateVideoStreams(size_t num_streams) {
21 assert(num_streams > 0);
23 // Add more streams to the settings above with reasonable values if required.
24 static const size_t kNumSettings = 3;
25 assert(num_streams <= kNumSettings);
27 std::vector<VideoStream> stream_settings(kNumSettings);
29 stream_settings[0].width = 320;
30 stream_settings[0].height = 180;
31 stream_settings[0].max_framerate = 30;
32 stream_settings[0].min_bitrate_bps = 50000;
33 stream_settings[0].target_bitrate_bps = stream_settings[0].max_bitrate_bps =
35 stream_settings[0].max_qp = 56;
37 stream_settings[1].width = 640;
38 stream_settings[1].height = 360;
39 stream_settings[1].max_framerate = 30;
40 stream_settings[1].min_bitrate_bps = 200000;
41 stream_settings[1].target_bitrate_bps = stream_settings[1].max_bitrate_bps =
43 stream_settings[1].max_qp = 56;
45 stream_settings[2].width = 1280;
46 stream_settings[2].height = 720;
47 stream_settings[2].max_framerate = 30;
48 stream_settings[2].min_bitrate_bps = 700000;
49 stream_settings[2].target_bitrate_bps = stream_settings[2].max_bitrate_bps =
51 stream_settings[2].max_qp = 56;
52 stream_settings.resize(num_streams);
53 return stream_settings;
56 VideoCodec CreateDecoderVideoCodec(
57 const VideoSendStream::Config::EncoderSettings& encoder_settings) {
59 memset(&codec, 0, sizeof(codec));
61 codec.plType = encoder_settings.payload_type;
62 strcpy(codec.plName, encoder_settings.payload_name.c_str());
63 if (encoder_settings.payload_name == "VP8") {
64 codec.codecType = kVideoCodecVP8;
65 } else if (encoder_settings.payload_name == "H264") {
66 codec.codecType = kVideoCodecH264;
68 codec.codecType = kVideoCodecGeneric;
71 if (codec.codecType == kVideoCodecVP8) {
72 codec.codecSpecific.VP8 = VideoEncoder::GetDefaultVp8Settings();
73 } else if (codec.codecType == kVideoCodecH264) {
74 codec.codecSpecific.H264 = VideoEncoder::GetDefaultH264Settings();
79 codec.startBitrate = codec.minBitrate = codec.maxBitrate = 300;