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.

82 lines
2.3 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_TESTALLCODECS_H_
  11. #define MODULES_AUDIO_CODING_TEST_TESTALLCODECS_H_
  12. #include <memory>
  13. #include "modules/audio_coding/include/audio_coding_module.h"
  14. #include "modules/audio_coding/test/PCMFile.h"
  15. namespace webrtc {
  16. class TestPack : public AudioPacketizationCallback {
  17. public:
  18. TestPack();
  19. ~TestPack();
  20. void RegisterReceiverACM(AudioCodingModule* acm);
  21. int32_t SendData(AudioFrameType frame_type,
  22. uint8_t payload_type,
  23. uint32_t timestamp,
  24. const uint8_t* payload_data,
  25. size_t payload_size) override;
  26. size_t payload_size();
  27. uint32_t timestamp_diff();
  28. void reset_payload_size();
  29. private:
  30. AudioCodingModule* receiver_acm_;
  31. uint16_t sequence_number_;
  32. uint8_t payload_data_[60 * 32 * 2 * 2];
  33. uint32_t timestamp_diff_;
  34. uint32_t last_in_timestamp_;
  35. uint64_t total_bytes_;
  36. size_t payload_size_;
  37. };
  38. class TestAllCodecs {
  39. public:
  40. TestAllCodecs();
  41. ~TestAllCodecs();
  42. void Perform();
  43. private:
  44. // The default value of '-1' indicates that the registration is based only on
  45. // codec name, and a sampling frequency matching is not required.
  46. // This is useful for codecs which support several sampling frequency.
  47. // Note! Only mono mode is tested in this test.
  48. void RegisterSendCodec(char side,
  49. char* codec_name,
  50. int32_t sampling_freq_hz,
  51. int rate,
  52. int packet_size,
  53. size_t extra_byte);
  54. void Run(TestPack* channel);
  55. void OpenOutFile(int test_number);
  56. std::unique_ptr<AudioCodingModule> acm_a_;
  57. std::unique_ptr<AudioCodingModule> acm_b_;
  58. TestPack* channel_a_to_b_;
  59. PCMFile infile_a_;
  60. PCMFile outfile_b_;
  61. int test_count_;
  62. int packet_size_samples_;
  63. size_t packet_size_bytes_;
  64. };
  65. } // namespace webrtc
  66. #endif // MODULES_AUDIO_CODING_TEST_TESTALLCODECS_H_