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