Home | History | Annotate | Download | only in test
      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/test/fake_decoder.h"
     16 #include "webrtc/video_decoder.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 VideoReceiveStream::Decoder CreateMatchingDecoder(
     57     const VideoSendStream::Config::EncoderSettings& encoder_settings) {
     58   VideoReceiveStream::Decoder decoder;
     59   decoder.payload_type = encoder_settings.payload_type;
     60   decoder.payload_name = encoder_settings.payload_name;
     61   if (encoder_settings.payload_name == "VP8") {
     62     decoder.decoder = VideoDecoder::Create(VideoDecoder::kVp8);
     63   } else if (encoder_settings.payload_name == "VP9") {
     64     decoder.decoder = VideoDecoder::Create(VideoDecoder::kVp9);
     65   } else {
     66     decoder.decoder = new FakeDecoder();
     67   }
     68   return decoder;
     69 }
     70 }  // namespace test
     71 }  // namespace webrtc
     72