PacketLossTest.h (2259B)
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 11 #ifndef MODULES_AUDIO_CODING_TEST_PACKETLOSSTEST_H_ 12 #define MODULES_AUDIO_CODING_TEST_PACKETLOSSTEST_H_ 13 14 #include <string> 15 16 #include "absl/strings/string_view.h" 17 #include "api/audio_codecs/audio_format.h" 18 #include "api/environment/environment.h" 19 #include "api/neteq/neteq.h" 20 #include "modules/audio_coding/include/audio_coding_module.h" 21 #include "modules/audio_coding/test/EncodeDecodeTest.h" 22 #include "modules/audio_coding/test/RTPFile.h" 23 24 namespace webrtc { 25 26 class ReceiverWithPacketLoss : public Receiver { 27 public: 28 ReceiverWithPacketLoss(); 29 void Setup(NetEq* neteq, 30 RTPStream* rtpStream, 31 absl::string_view out_file_name, 32 int channels, 33 int file_num, 34 int loss_rate, 35 int burst_length); 36 bool IncomingPacket() override; 37 38 protected: 39 bool PacketLost(); 40 int loss_rate_; 41 int burst_length_; 42 int packet_counter_; 43 int lost_packet_counter_; 44 int burst_lost_counter_; 45 }; 46 47 class SenderWithFEC : public Sender { 48 public: 49 SenderWithFEC(); 50 void Setup(const Environment& env, 51 AudioCodingModule* acm, 52 RTPStream* rtpStream, 53 absl::string_view in_file_name, 54 int payload_type, 55 SdpAudioFormat format, 56 int expected_loss_rate); 57 bool SetPacketLossRate(int expected_loss_rate); 58 bool SetFEC(bool enable_fec); 59 60 protected: 61 int expected_loss_rate_; 62 }; 63 64 class PacketLossTest { 65 public: 66 PacketLossTest(int channels, 67 int expected_loss_rate_, 68 int actual_loss_rate, 69 int burst_length); 70 void Perform(); 71 72 protected: 73 int channels_; 74 std::string in_file_name_; 75 int sample_rate_hz_; 76 int expected_loss_rate_; 77 int actual_loss_rate_; 78 int burst_length_; 79 }; 80 81 } // namespace webrtc 82 83 #endif // MODULES_AUDIO_CODING_TEST_PACKETLOSSTEST_H_