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 | |
| 14 | #include <string> |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame^] | 15 | |
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, |
Fredrik Solenberg | 657b296 | 2018-12-05 10:30:25 +0100 | [diff] [blame] | 27 | int file_num, |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 28 | int loss_rate, |
minyue@webrtc.org | aa5ea1c | 2014-05-23 15:16:51 +0000 | [diff] [blame] | 29 | int burst_length); |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 30 | bool IncomingPacket() override; |
| 31 | |
minyue@webrtc.org | aa5ea1c | 2014-05-23 15:16:51 +0000 | [diff] [blame] | 32 | protected: |
| 33 | bool PacketLost(); |
| 34 | int loss_rate_; |
| 35 | int burst_length_; |
| 36 | int packet_counter_; |
| 37 | int lost_packet_counter_; |
| 38 | int burst_lost_counter_; |
| 39 | }; |
| 40 | |
| 41 | class SenderWithFEC : public Sender { |
| 42 | public: |
| 43 | SenderWithFEC(); |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 44 | void Setup(AudioCodingModule* acm, |
| 45 | RTPStream* rtpStream, |
| 46 | std::string in_file_name, |
Fredrik Solenberg | 657b296 | 2018-12-05 10:30:25 +0100 | [diff] [blame] | 47 | int payload_type, |
| 48 | SdpAudioFormat format, |
minyue@webrtc.org | aa5ea1c | 2014-05-23 15:16:51 +0000 | [diff] [blame] | 49 | int expected_loss_rate); |
| 50 | bool SetPacketLossRate(int expected_loss_rate); |
| 51 | bool SetFEC(bool enable_fec); |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 52 | |
minyue@webrtc.org | aa5ea1c | 2014-05-23 15:16:51 +0000 | [diff] [blame] | 53 | protected: |
| 54 | int expected_loss_rate_; |
| 55 | }; |
| 56 | |
Karl Wiberg | 3ff52ff | 2018-10-01 12:31:22 +0200 | [diff] [blame] | 57 | class PacketLossTest { |
minyue@webrtc.org | aa5ea1c | 2014-05-23 15:16:51 +0000 | [diff] [blame] | 58 | public: |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 59 | PacketLossTest(int channels, |
| 60 | int expected_loss_rate_, |
| 61 | int actual_loss_rate, |
minyue@webrtc.org | aa5ea1c | 2014-05-23 15:16:51 +0000 | [diff] [blame] | 62 | int burst_length); |
| 63 | void Perform(); |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 64 | |
minyue@webrtc.org | aa5ea1c | 2014-05-23 15:16:51 +0000 | [diff] [blame] | 65 | protected: |
| 66 | int channels_; |
| 67 | std::string in_file_name_; |
| 68 | int sample_rate_hz_; |
minyue@webrtc.org | aa5ea1c | 2014-05-23 15:16:51 +0000 | [diff] [blame] | 69 | int expected_loss_rate_; |
| 70 | int actual_loss_rate_; |
| 71 | int burst_length_; |
| 72 | }; |
| 73 | |
| 74 | } // namespace webrtc |
| 75 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 76 | #endif // MODULES_AUDIO_CODING_TEST_PACKETLOSSTEST_H_ |