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 | |
kjellander | 3e6db23 | 2015-11-26 04:44:54 -0800 | [diff] [blame] | 11 | #ifndef WEBRTC_MODULES_AUDIO_CODING_TEST_PACKETLOSSTEST_H_ |
| 12 | #define WEBRTC_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> |
kjellander | 3e6db23 | 2015-11-26 04:44:54 -0800 | [diff] [blame] | 16 | #include "webrtc/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(); |
| 23 | void Setup(AudioCodingModule *acm, RTPStream *rtpStream, |
| 24 | std::string out_file_name, int channels, int loss_rate, |
| 25 | int burst_length); |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 26 | bool IncomingPacket() override; |
| 27 | |
minyue@webrtc.org | aa5ea1c | 2014-05-23 15:16:51 +0000 | [diff] [blame] | 28 | protected: |
| 29 | bool PacketLost(); |
| 30 | int loss_rate_; |
| 31 | int burst_length_; |
| 32 | int packet_counter_; |
| 33 | int lost_packet_counter_; |
| 34 | int burst_lost_counter_; |
| 35 | }; |
| 36 | |
| 37 | class SenderWithFEC : public Sender { |
| 38 | public: |
| 39 | SenderWithFEC(); |
| 40 | void Setup(AudioCodingModule *acm, RTPStream *rtpStream, |
| 41 | std::string in_file_name, int sample_rate, int channels, |
| 42 | int expected_loss_rate); |
| 43 | bool SetPacketLossRate(int expected_loss_rate); |
| 44 | bool SetFEC(bool enable_fec); |
| 45 | protected: |
| 46 | int expected_loss_rate_; |
| 47 | }; |
| 48 | |
| 49 | class PacketLossTest : public ACMTest { |
| 50 | public: |
| 51 | PacketLossTest(int channels, int expected_loss_rate_, int actual_loss_rate, |
| 52 | int burst_length); |
| 53 | void Perform(); |
| 54 | protected: |
| 55 | int channels_; |
| 56 | std::string in_file_name_; |
| 57 | int sample_rate_hz_; |
kwiberg | 3747838 | 2016-02-14 20:40:57 -0800 | [diff] [blame^] | 58 | std::unique_ptr<SenderWithFEC> sender_; |
| 59 | std::unique_ptr<ReceiverWithPacketLoss> receiver_; |
minyue@webrtc.org | aa5ea1c | 2014-05-23 15:16:51 +0000 | [diff] [blame] | 60 | int expected_loss_rate_; |
| 61 | int actual_loss_rate_; |
| 62 | int burst_length_; |
| 63 | }; |
| 64 | |
| 65 | } // namespace webrtc |
| 66 | |
kjellander | 3e6db23 | 2015-11-26 04:44:54 -0800 | [diff] [blame] | 67 | #endif // WEBRTC_MODULES_AUDIO_CODING_TEST_PACKETLOSSTEST_H_ |