PacketLossTest.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. #ifndef MODULES_AUDIO_CODING_TEST_PACKETLOSSTEST_H_
  11. #define MODULES_AUDIO_CODING_TEST_PACKETLOSSTEST_H_
  12. #include <string>
  13. #include "modules/audio_coding/test/EncodeDecodeTest.h"
  14. namespace webrtc {
  15. class ReceiverWithPacketLoss : public Receiver {
  16. public:
  17. ReceiverWithPacketLoss();
  18. void Setup(AudioCodingModule* acm,
  19. RTPStream* rtpStream,
  20. std::string out_file_name,
  21. int channels,
  22. int file_num,
  23. int loss_rate,
  24. int burst_length);
  25. bool IncomingPacket() override;
  26. protected:
  27. bool PacketLost();
  28. int loss_rate_;
  29. int burst_length_;
  30. int packet_counter_;
  31. int lost_packet_counter_;
  32. int burst_lost_counter_;
  33. };
  34. class SenderWithFEC : public Sender {
  35. public:
  36. SenderWithFEC();
  37. void Setup(AudioCodingModule* acm,
  38. RTPStream* rtpStream,
  39. std::string in_file_name,
  40. int payload_type,
  41. SdpAudioFormat format,
  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. class PacketLossTest {
  49. public:
  50. PacketLossTest(int channels,
  51. int expected_loss_rate_,
  52. int actual_loss_rate,
  53. int burst_length);
  54. void Perform();
  55. protected:
  56. int channels_;
  57. std::string in_file_name_;
  58. int sample_rate_hz_;
  59. int expected_loss_rate_;
  60. int actual_loss_rate_;
  61. int burst_length_;
  62. };
  63. } // namespace webrtc
  64. #endif // MODULES_AUDIO_CODING_TEST_PACKETLOSSTEST_H_