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_CODECS_TEST_FRAWEWORK_TEST_H_ 12 #define WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_FRAWEWORK_TEST_H_ 13 14 #include <stdlib.h> 15 16 #include <fstream> 17 #include <string> 18 19 #include "webrtc/modules/interface/module_common_types.h" 20 #include "webrtc/modules/video_coding/codecs/interface/video_codec_interface.h" 21 22 class CodecTest 23 { 24 public: 25 CodecTest(std::string name, std::string description); 26 CodecTest(std::string name, std::string description, 27 uint32_t bitRate); ~CodecTest()28 virtual ~CodecTest() {}; 29 virtual void Setup(); 30 virtual void Perform()=0; 31 virtual void Print(); 32 void SetEncoder(webrtc::VideoEncoder *encoder); 33 void SetDecoder(webrtc::VideoDecoder *decoder); 34 void SetLog(std::fstream* log); 35 36 protected: 37 virtual void CodecSettings(int width, 38 int height, 39 uint32_t frameRate=30, 40 uint32_t bitRate=0); 41 virtual void Teardown(); 42 double ActualBitRate(int nFrames); 43 virtual bool PacketLoss(double lossRate, int /*thrown*/); RandUniform()44 static double RandUniform() { return (rand() + 1.0)/(RAND_MAX + 1.0); } 45 static void VideoEncodedBufferToEncodedImage( 46 webrtc::VideoFrame& videoBuffer, 47 webrtc::EncodedImage &image); 48 49 webrtc::VideoEncoder* _encoder; 50 webrtc::VideoDecoder* _decoder; 51 uint32_t _bitRate; 52 unsigned int _lengthSourceFrame; 53 unsigned char* _sourceBuffer; 54 webrtc::I420VideoFrame _inputVideoBuffer; 55 // TODO(mikhal): For now using VideoFrame for encodedBuffer, should use a 56 // designated class. 57 webrtc::VideoFrame _encodedVideoBuffer; 58 webrtc::I420VideoFrame _decodedVideoBuffer; 59 webrtc::VideoCodec _inst; 60 std::fstream* _log; 61 std::string _inname; 62 std::string _outname; 63 std::string _encodedName; 64 int _sumEncBytes; 65 int _width; 66 int _halfWidth; 67 int _height; 68 int _halfHeight; 69 int _sizeY; 70 int _sizeUv; 71 private: 72 std::string _name; 73 std::string _description; 74 75 }; 76 77 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_FRAWEWORK_TEST_H_ 78