• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2011 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 
11 
12 #include <stdlib.h>
13 #include <string.h>
14 
15 #include "gflags/gflags.h"
16 #include "webrtc/modules/video_coding/main/interface/video_coding.h"
17 #include "webrtc/modules/video_coding/main/test/codec_database_test.h"
18 #include "webrtc/modules/video_coding/main/test/generic_codec_test.h"
19 #include "webrtc/modules/video_coding/main/test/media_opt_test.h"
20 #include "webrtc/modules/video_coding/main/test/normal_test.h"
21 #include "webrtc/modules/video_coding/main/test/quality_modes_test.h"
22 #include "webrtc/modules/video_coding/main/test/receiver_tests.h"
23 #include "webrtc/modules/video_coding/main/test/test_util.h"
24 #include "webrtc/test/testsupport/fileutils.h"
25 
26 DEFINE_string(codec, "VP8", "Codec to use (VP8 or I420).");
27 DEFINE_int32(width, 352, "Width in pixels of the frames in the input file.");
28 DEFINE_int32(height, 288, "Height in pixels of the frames in the input file.");
29 DEFINE_int32(bitrate, 500, "Bit rate in kilobits/second.");
30 DEFINE_int32(framerate, 30, "Frame rate of the input file, in FPS "
31              "(frames-per-second). ");
32 DEFINE_int32(packet_loss_percent, 0, "Packet loss probability, in percent.");
33 DEFINE_int32(rtt, 0, "RTT (round-trip time), in milliseconds.");
34 DEFINE_int32(protection_mode, 0, "Protection mode.");
35 DEFINE_int32(cama_enable, 0, "Cama enable.");
36 DEFINE_string(input_filename, webrtc::test::ProjectRootPath() +
37               "/resources/foreman_cif.yuv", "Input file.");
38 DEFINE_string(output_filename, webrtc::test::OutputPath() +
39               "video_coding_test_output_352x288.yuv", "Output file.");
40 DEFINE_string(fv_output_filename, webrtc::test::OutputPath() +
41               "features.txt", "FV output file.");
42 DEFINE_int32(test_number, 0, "Test number.");
43 
44 using namespace webrtc;
45 
46 /*
47  * Build with EVENT_DEBUG defined
48  * to build the tests with simulated events.
49  */
50 
51 int vcmMacrosTests = 0;
52 int vcmMacrosErrors = 0;
53 
ParseArguments(CmdArgs & args)54 int ParseArguments(CmdArgs& args) {
55   args.width = FLAGS_width;
56   args.height = FLAGS_height;
57   args.bitRate = FLAGS_bitrate;
58   args.frameRate = FLAGS_framerate;
59   if (args.width  < 1 || args.height < 1 || args.bitRate < 1 ||
60       args.frameRate < 1) {
61     return -1;
62   }
63   args.codecName = FLAGS_codec;
64   if (args.codecName == "VP8") {
65     args.codecType = kVideoCodecVP8;
66   } else if (args.codecName == "I420") {
67     args.codecType = kVideoCodecI420;
68   } else {
69     printf("Invalid codec: %s\n", args.codecName.c_str());
70     return -1;
71   }
72   args.inputFile = FLAGS_input_filename;
73   args.outputFile = FLAGS_output_filename;
74   args.testNum = FLAGS_test_number;
75   args.packetLoss = FLAGS_packet_loss_percent;
76   args.rtt = FLAGS_rtt;
77   args.protectionMode = FLAGS_protection_mode;
78   args.camaEnable = FLAGS_cama_enable;
79   args.fv_outputfile = FLAGS_fv_output_filename;
80   return 0;
81 }
82 
main(int argc,char ** argv)83 int main(int argc, char **argv) {
84   // Initialize WebRTC fileutils.h so paths to resources can be resolved.
85   webrtc::test::SetExecutablePath(argv[0]);
86   google::ParseCommandLineFlags(&argc, &argv, true);
87 
88   CmdArgs args;
89   if (ParseArguments(args) != 0) {
90     printf("Unable to parse input arguments\n");
91     return -1;
92   }
93 
94   printf("Running video coding tests...\n");
95   int ret = 0;
96   switch (args.testNum) {
97     case 0:
98       ret = NormalTest::RunTest(args);
99       ret |= CodecDataBaseTest::RunTest(args);
100       break;
101     case 1:
102       ret = NormalTest::RunTest(args);
103       break;
104     case 2:
105       ret = MTRxTxTest(args);
106       break;
107     case 3:
108       ret = GenericCodecTest::RunTest(args);
109       break;
110     case 4:
111       ret = CodecDataBaseTest::RunTest(args);
112       break;
113     case 5:
114       // 0- normal, 1-Release test(50 runs) 2- from file
115       ret = MediaOptTest::RunTest(0, args);
116       break;
117     case 7:
118       ret = RtpPlay(args);
119       break;
120     case 8:
121       ret = RtpPlayMT(args);
122       break;
123     case 9:
124       qualityModeTest(args);
125       break;
126     default:
127       ret = -1;
128       break;
129   }
130   return ret;
131 }
132