minyue@webrtc.org | aa5ea1c | 2014-05-23 15:16:51 +0000 | [diff] [blame] | 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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef MODULES_AUDIO_CODING_TEST_PACKETLOSSTEST_H_ |
| 12 | #define MODULES_AUDIO_CODING_TEST_PACKETLOSSTEST_H_ |
minyue@webrtc.org | aa5ea1c | 2014-05-23 15:16:51 +0000 | [diff] [blame] | 13 | |
kwiberg | 3747838 | 2016-02-14 20:40:57 -0800 | [diff] [blame] | 14 | #include <memory> |
minyue@webrtc.org | aa5ea1c | 2014-05-23 15:16:51 +0000 | [diff] [blame] | 15 | #include <string> |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 16 | #include "modules/audio_coding/test/EncodeDecodeTest.h" |
minyue@webrtc.org | aa5ea1c | 2014-05-23 15:16:51 +0000 | [diff] [blame] | 17 | |
| 18 | namespace webrtc { |
| 19 | |
| 20 | class ReceiverWithPacketLoss : public Receiver { |
| 21 | public: |
| 22 | ReceiverWithPacketLoss(); |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 23 | void Setup(AudioCodingModule* acm, |
| 24 | RTPStream* rtpStream, |
| 25 | std::string out_file_name, |
| 26 | int channels, |
| 27 | int loss_rate, |
minyue@webrtc.org | aa5ea1c | 2014-05-23 15:16:51 +0000 | [diff] [blame] | 28 | int burst_length); |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 29 | bool IncomingPacket() override; |
| 30 | |
minyue@webrtc.org | aa5ea1c | 2014-05-23 15:16:51 +0000 | [diff] [blame] | 31 | protected: |
| 32 | bool PacketLost(); |
| 33 | int loss_rate_; |
| 34 | int burst_length_; |
| 35 | int packet_counter_; |
| 36 | int lost_packet_counter_; |
| 37 | int burst_lost_counter_; |
| 38 | }; |
| 39 | |
| 40 | class SenderWithFEC : public Sender { |
| 41 | public: |
| 42 | SenderWithFEC(); |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 43 | void Setup(AudioCodingModule* acm, |
| 44 | RTPStream* rtpStream, |
| 45 | std::string in_file_name, |
| 46 | int sample_rate, |
| 47 | int channels, |
minyue@webrtc.org | aa5ea1c | 2014-05-23 15:16:51 +0000 | [diff] [blame] | 48 | int expected_loss_rate); |
| 49 | bool SetPacketLossRate(int expected_loss_rate); |
| 50 | bool SetFEC(bool enable_fec); |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 51 | |
minyue@webrtc.org | aa5ea1c | 2014-05-23 15:16:51 +0000 | [diff] [blame] | 52 | protected: |
| 53 | int expected_loss_rate_; |
| 54 | }; |
| 55 | |
| 56 | class PacketLossTest : public ACMTest { |
| 57 | public: |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 58 | PacketLossTest(int channels, |
| 59 | int expected_loss_rate_, |
| 60 | int actual_loss_rate, |
minyue@webrtc.org | aa5ea1c | 2014-05-23 15:16:51 +0000 | [diff] [blame] | 61 | int burst_length); |
| 62 | void Perform(); |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 63 | |
minyue@webrtc.org | aa5ea1c | 2014-05-23 15:16:51 +0000 | [diff] [blame] | 64 | protected: |
| 65 | int channels_; |
| 66 | std::string in_file_name_; |
| 67 | int sample_rate_hz_; |
kwiberg | 3747838 | 2016-02-14 20:40:57 -0800 | [diff] [blame] | 68 | std::unique_ptr<SenderWithFEC> sender_; |
| 69 | std::unique_ptr<ReceiverWithPacketLoss> receiver_; |
minyue@webrtc.org | aa5ea1c | 2014-05-23 15:16:51 +0000 | [diff] [blame] | 70 | int expected_loss_rate_; |
| 71 | int actual_loss_rate_; |
| 72 | int burst_length_; |
| 73 | }; |
| 74 | |
| 75 | } // namespace webrtc |
| 76 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 77 | #endif // MODULES_AUDIO_CODING_TEST_PACKETLOSSTEST_H_ |