blob: d841d65a1b77031043f9a3fc626eea6cb874ae91 [file] [log] [blame]
minyue@webrtc.orgaa5ea1c2014-05-23 15:16:51 +00001/*
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 Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_AUDIO_CODING_TEST_PACKETLOSSTEST_H_
12#define MODULES_AUDIO_CODING_TEST_PACKETLOSSTEST_H_
minyue@webrtc.orgaa5ea1c2014-05-23 15:16:51 +000013
14#include <string>
Jonas Olssona4d87372019-07-05 19:08:33 +020015
Ali Tofigh714e3cb2022-07-20 12:53:07 +020016#include "absl/strings/string_view.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020017#include "modules/audio_coding/test/EncodeDecodeTest.h"
minyue@webrtc.orgaa5ea1c2014-05-23 15:16:51 +000018
19namespace webrtc {
20
21class ReceiverWithPacketLoss : public Receiver {
22 public:
23 ReceiverWithPacketLoss();
Yves Gerey665174f2018-06-19 15:03:05 +020024 void Setup(AudioCodingModule* acm,
25 RTPStream* rtpStream,
Ali Tofigh714e3cb2022-07-20 12:53:07 +020026 absl::string_view out_file_name,
Yves Gerey665174f2018-06-19 15:03:05 +020027 int channels,
Fredrik Solenberg657b2962018-12-05 10:30:25 +010028 int file_num,
Yves Gerey665174f2018-06-19 15:03:05 +020029 int loss_rate,
minyue@webrtc.orgaa5ea1c2014-05-23 15:16:51 +000030 int burst_length);
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +000031 bool IncomingPacket() override;
32
minyue@webrtc.orgaa5ea1c2014-05-23 15:16:51 +000033 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
42class SenderWithFEC : public Sender {
43 public:
44 SenderWithFEC();
Yves Gerey665174f2018-06-19 15:03:05 +020045 void Setup(AudioCodingModule* acm,
46 RTPStream* rtpStream,
Ali Tofigh714e3cb2022-07-20 12:53:07 +020047 absl::string_view in_file_name,
Fredrik Solenberg657b2962018-12-05 10:30:25 +010048 int payload_type,
49 SdpAudioFormat format,
minyue@webrtc.orgaa5ea1c2014-05-23 15:16:51 +000050 int expected_loss_rate);
51 bool SetPacketLossRate(int expected_loss_rate);
52 bool SetFEC(bool enable_fec);
Yves Gerey665174f2018-06-19 15:03:05 +020053
minyue@webrtc.orgaa5ea1c2014-05-23 15:16:51 +000054 protected:
55 int expected_loss_rate_;
56};
57
Karl Wiberg3ff52ff2018-10-01 12:31:22 +020058class PacketLossTest {
minyue@webrtc.orgaa5ea1c2014-05-23 15:16:51 +000059 public:
Yves Gerey665174f2018-06-19 15:03:05 +020060 PacketLossTest(int channels,
61 int expected_loss_rate_,
62 int actual_loss_rate,
minyue@webrtc.orgaa5ea1c2014-05-23 15:16:51 +000063 int burst_length);
64 void Perform();
Yves Gerey665174f2018-06-19 15:03:05 +020065
minyue@webrtc.orgaa5ea1c2014-05-23 15:16:51 +000066 protected:
67 int channels_;
68 std::string in_file_name_;
69 int sample_rate_hz_;
minyue@webrtc.orgaa5ea1c2014-05-23 15:16:51 +000070 int expected_loss_rate_;
71 int actual_loss_rate_;
72 int burst_length_;
73};
74
75} // namespace webrtc
76
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020077#endif // MODULES_AUDIO_CODING_TEST_PACKETLOSSTEST_H_