You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

109 lines
2.8 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * Copyright (c) 2012 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_ENCODEDECODETEST_H_
  11. #define MODULES_AUDIO_CODING_TEST_ENCODEDECODETEST_H_
  12. #include <stdio.h>
  13. #include <string.h>
  14. #include "modules/audio_coding/include/audio_coding_module.h"
  15. #include "modules/audio_coding/test/PCMFile.h"
  16. #include "modules/audio_coding/test/RTPFile.h"
  17. #include "modules/include/module_common_types.h"
  18. namespace webrtc {
  19. #define MAX_INCOMING_PAYLOAD 8096
  20. // TestPacketization callback which writes the encoded payloads to file
  21. class TestPacketization : public AudioPacketizationCallback {
  22. public:
  23. TestPacketization(RTPStream* rtpStream, uint16_t frequency);
  24. ~TestPacketization();
  25. int32_t SendData(const AudioFrameType frameType,
  26. const uint8_t payloadType,
  27. const uint32_t timeStamp,
  28. const uint8_t* payloadData,
  29. const size_t payloadSize) override;
  30. private:
  31. static void MakeRTPheader(uint8_t* rtpHeader,
  32. uint8_t payloadType,
  33. int16_t seqNo,
  34. uint32_t timeStamp,
  35. uint32_t ssrc);
  36. RTPStream* _rtpStream;
  37. int32_t _frequency;
  38. int16_t _seqNo;
  39. };
  40. class Sender {
  41. public:
  42. Sender();
  43. void Setup(AudioCodingModule* acm,
  44. RTPStream* rtpStream,
  45. std::string in_file_name,
  46. int in_sample_rate,
  47. int payload_type,
  48. SdpAudioFormat format);
  49. void Teardown();
  50. void Run();
  51. bool Add10MsData();
  52. protected:
  53. AudioCodingModule* _acm;
  54. private:
  55. PCMFile _pcmFile;
  56. AudioFrame _audioFrame;
  57. TestPacketization* _packetization;
  58. };
  59. class Receiver {
  60. public:
  61. Receiver();
  62. virtual ~Receiver() {}
  63. void Setup(AudioCodingModule* acm,
  64. RTPStream* rtpStream,
  65. std::string out_file_name,
  66. size_t channels,
  67. int file_num);
  68. void Teardown();
  69. void Run();
  70. virtual bool IncomingPacket();
  71. bool PlayoutData();
  72. private:
  73. PCMFile _pcmFile;
  74. int16_t* _playoutBuffer;
  75. uint16_t _playoutLengthSmpls;
  76. int32_t _frequency;
  77. bool _firstTime;
  78. protected:
  79. AudioCodingModule* _acm;
  80. uint8_t _incomingPayload[MAX_INCOMING_PAYLOAD];
  81. RTPStream* _rtpStream;
  82. RTPHeader _rtpHeader;
  83. size_t _realPayloadSizeBytes;
  84. size_t _payloadSizeBytes;
  85. uint32_t _nextTime;
  86. };
  87. class EncodeDecodeTest {
  88. public:
  89. EncodeDecodeTest();
  90. void Perform();
  91. };
  92. } // namespace webrtc
  93. #endif // MODULES_AUDIO_CODING_TEST_ENCODEDECODETEST_H_