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_FRAMEWORK_PACKET_LOSS_TEST_H_ 12 #define WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_FRAMEWORK_PACKET_LOSS_TEST_H_ 13 14 #include <list> 15 16 #include "webrtc/modules/video_coding/codecs/test_framework/normal_async_test.h" 17 18 class PacketLossTest : public NormalAsyncTest 19 { 20 public: 21 PacketLossTest(); 22 virtual ~PacketLossTest() {if(_lastFrame) {delete [] _lastFrame; _lastFrame = NULL;}} 23 virtual void Encoded(const webrtc::EncodedImage& encodedImage); 24 virtual void Decoded(const webrtc::I420VideoFrame& decodedImage); 25 protected: 26 PacketLossTest(std::string name, std::string description); 27 PacketLossTest(std::string name, 28 std::string description, 29 double lossRate, 30 bool useNack, 31 unsigned int rttFrames = 0); 32 33 virtual void Setup(); 34 virtual void Teardown(); 35 virtual void CodecSpecific_InitBitrate(); 36 virtual int DoPacketLoss(); 37 virtual int NextPacket(int size, unsigned char **pkg); 38 virtual int ByteLoss(int size, unsigned char *pkg, int bytesToLose); 39 virtual void InsertPacket(webrtc::VideoFrame *buf, unsigned char *pkg, 40 int size); 41 int _inBufIdx; 42 int _outBufIdx; 43 44 // When NACK is being simulated _lossProbabilty is zero, 45 // otherwise it is set equal to _lossRate. 46 // Desired channel loss rate. 47 double _lossRate; 48 // Probability used to simulate packet drops. 49 double _lossProbability; 50 51 int _totalKept; 52 int _totalThrown; 53 int _sumChannelBytes; 54 std::list<uint32_t> _frameQueue; 55 uint8_t* _lastFrame; 56 uint32_t _lastFrameLength; 57 }; 58 59 60 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_FRAMEWORK_PACKET_LOSS_TEST_H_ 61