1 /* 2 * Copyright (c) 2012 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 #ifndef WEBRTC_MODULES_VIDEO_CODING_TEST_TEST_UTIL_H_ 12 #define WEBRTC_MODULES_VIDEO_CODING_TEST_TEST_UTIL_H_ 13 14 /* 15 * General declarations used through out VCM offline tests. 16 */ 17 18 #include <string> 19 20 #include "webrtc/base/constructormagic.h" 21 #include "webrtc/modules/interface/module_common_types.h" 22 #include "webrtc/modules/video_coding/main/interface/video_coding.h" 23 #include "webrtc/system_wrappers/interface/event_wrapper.h" 24 25 enum { kMaxNackListSize = 250 }; 26 enum { kMaxPacketAgeToNack = 450 }; 27 28 // Class used for passing command line arguments to tests 29 class CmdArgs { 30 public: 31 CmdArgs(); 32 33 std::string codecName; 34 webrtc::VideoCodecType codecType; 35 int width; 36 int height; 37 int bitRate; 38 int frameRate; 39 int packetLoss; 40 int rtt; 41 int protectionMode; 42 int camaEnable; 43 std::string inputFile; 44 std::string outputFile; 45 std::string fv_outputfile; 46 int testNum; 47 }; 48 49 int MTRxTxTest(CmdArgs& args); 50 double NormalDist(double mean, double stdDev); 51 52 struct RtpPacket { 53 uint8_t data[1650]; // max packet size 54 int32_t length; 55 int64_t receiveTime; 56 }; 57 58 class NullEvent : public webrtc::EventWrapper { 59 public: ~NullEvent()60 virtual ~NullEvent() {} 61 Set()62 virtual bool Set() { return true; } 63 Reset()64 virtual bool Reset() { return true; } 65 Wait(unsigned long max_time)66 virtual webrtc::EventTypeWrapper Wait(unsigned long max_time) { 67 return webrtc::kEventTimeout; 68 } 69 StartTimer(bool periodic,unsigned long time)70 virtual bool StartTimer(bool periodic, unsigned long time) { return true; } 71 StopTimer()72 virtual bool StopTimer() { return true; } 73 }; 74 75 class NullEventFactory : public webrtc::EventFactory { 76 public: ~NullEventFactory()77 virtual ~NullEventFactory() {} 78 CreateEvent()79 virtual webrtc::EventWrapper* CreateEvent() { 80 return new NullEvent; 81 } 82 }; 83 84 class FileOutputFrameReceiver : public webrtc::VCMReceiveCallback { 85 public: 86 FileOutputFrameReceiver(const std::string& base_out_filename, uint32_t ssrc); 87 virtual ~FileOutputFrameReceiver(); 88 89 // VCMReceiveCallback 90 virtual int32_t FrameToRender(webrtc::I420VideoFrame& video_frame); 91 92 private: 93 std::string out_filename_; 94 uint32_t ssrc_; 95 FILE* out_file_; 96 FILE* timing_file_; 97 int width_; 98 int height_; 99 int count_; 100 101 DISALLOW_IMPLICIT_CONSTRUCTORS(FileOutputFrameReceiver); 102 }; 103 104 // Codec type conversion 105 webrtc::RtpVideoCodecTypes ConvertCodecType(const char* plname); 106 107 #endif 108