1 /* 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_encoder.h" 16 #include "webrtc/video_engine/vie_defines.h" 17 18 namespace webrtc { 19 namespace test { 20 std::vector<VideoStream> CreateVideoStreams(size_t num_streams) { 21 assert(num_streams > 0); 22 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); 26 27 std::vector<VideoStream> stream_settings(kNumSettings); 28 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 = 34 150000; 35 stream_settings[0].max_qp = 56; 36 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 = 42 450000; 43 stream_settings[1].max_qp = 56; 44 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 = 50 1500000; 51 stream_settings[2].max_qp = 56; 52 stream_settings.resize(num_streams); 53 return stream_settings; 54 } 55 56 VideoCodec CreateDecoderVideoCodec( 57 const VideoSendStream::Config::EncoderSettings& encoder_settings) { 58 VideoCodec codec; 59 memset(&codec, 0, sizeof(codec)); 60 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; 67 } else { 68 codec.codecType = kVideoCodecGeneric; 69 } 70 71 if (codec.codecType == kVideoCodecVP8) { 72 codec.codecSpecific.VP8 = VideoEncoder::GetDefaultVp8Settings(); 73 } else if (codec.codecType == kVideoCodecH264) { 74 codec.codecSpecific.H264 = VideoEncoder::GetDefaultH264Settings(); 75 } 76 77 codec.width = 320; 78 codec.height = 180; 79 codec.startBitrate = codec.minBitrate = codec.maxBitrate = 300; 80 81 return codec; 82 } 83 84 } // namespace test 85 } // namespace webrtc 86