TestAllCodecs.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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,
  26. int64_t absolute_capture_timestamp_ms) override;
  27. size_t payload_size();
  28. uint32_t timestamp_diff();
  29. void reset_payload_size();
  30. private:
  31. AudioCodingModule* receiver_acm_;
  32. uint16_t sequence_number_;
  33. uint8_t payload_data_[60 * 32 * 2 * 2];
  34. uint32_t timestamp_diff_;
  35. uint32_t last_in_timestamp_;
  36. uint64_t total_bytes_;
  37. size_t payload_size_;
  38. };
  39. class TestAllCodecs {
  40. public:
  41. TestAllCodecs();
  42. ~TestAllCodecs();
  43. void Perform();
  44. private:
  45. // The default value of '-1' indicates that the registration is based only on
  46. // codec name, and a sampling frequency matching is not required.
  47. // This is useful for codecs which support several sampling frequency.
  48. // Note! Only mono mode is tested in this test.
  49. void RegisterSendCodec(char side,
  50. char* codec_name,
  51. int32_t sampling_freq_hz,
  52. int rate,
  53. int packet_size,
  54. size_t extra_byte);
  55. void Run(TestPack* channel);
  56. void OpenOutFile(int test_number);
  57. std::unique_ptr<AudioCodingModule> acm_a_;
  58. std::unique_ptr<AudioCodingModule> acm_b_;
  59. TestPack* channel_a_to_b_;
  60. PCMFile infile_a_;
  61. PCMFile outfile_b_;
  62. int test_count_;
  63. int packet_size_samples_;
  64. size_t packet_size_bytes_;
  65. };
  66. } // namespace webrtc
  67. #endif // MODULES_AUDIO_CODING_TEST_TESTALLCODECS_H_