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