niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame^] | 11 | #ifndef MODULES_AUDIO_CODING_TEST_TESTALLCODECS_H_ |
| 12 | #define MODULES_AUDIO_CODING_TEST_TESTALLCODECS_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 13 | |
kwiberg | 3747838 | 2016-02-14 20:40:57 -0800 | [diff] [blame] | 14 | #include <memory> |
| 15 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame^] | 16 | #include "modules/audio_coding/test/ACMTest.h" |
| 17 | #include "modules/audio_coding/test/Channel.h" |
| 18 | #include "modules/audio_coding/test/PCMFile.h" |
| 19 | #include "typedefs.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 20 | |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 21 | namespace webrtc { |
| 22 | |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 23 | class TestPack : public AudioPacketizationCallback { |
| 24 | public: |
| 25 | TestPack(); |
| 26 | ~TestPack(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 27 | |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 28 | void RegisterReceiverACM(AudioCodingModule* acm); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 29 | |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 30 | int32_t SendData(FrameType frame_type, |
| 31 | uint8_t payload_type, |
| 32 | uint32_t timestamp, |
| 33 | const uint8_t* payload_data, |
| 34 | size_t payload_size, |
| 35 | const RTPFragmentationHeader* fragmentation) override; |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 36 | |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 37 | size_t payload_size(); |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 38 | uint32_t timestamp_diff(); |
| 39 | void reset_payload_size(); |
| 40 | |
| 41 | private: |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 42 | AudioCodingModule* receiver_acm_; |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 43 | uint16_t sequence_number_; |
| 44 | uint8_t payload_data_[60 * 32 * 2 * 2]; |
| 45 | uint32_t timestamp_diff_; |
| 46 | uint32_t last_in_timestamp_; |
| 47 | uint64_t total_bytes_; |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 48 | size_t payload_size_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 49 | }; |
| 50 | |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 51 | class TestAllCodecs : public ACMTest { |
| 52 | public: |
henrik.lundin@webrtc.org | adaf809 | 2014-04-17 08:29:10 +0000 | [diff] [blame] | 53 | explicit TestAllCodecs(int test_mode); |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 54 | ~TestAllCodecs(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 55 | |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 56 | void Perform() override; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 57 | |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 58 | private: |
| 59 | // The default value of '-1' indicates that the registration is based only on |
| 60 | // codec name, and a sampling frequency matching is not required. |
| 61 | // This is useful for codecs which support several sampling frequency. |
| 62 | // Note! Only mono mode is tested in this test. |
| 63 | void RegisterSendCodec(char side, char* codec_name, int32_t sampling_freq_hz, |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 64 | int rate, int packet_size, size_t extra_byte); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 65 | |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 66 | void Run(TestPack* channel); |
| 67 | void OpenOutFile(int test_number); |
| 68 | void DisplaySendReceiveCodec(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 69 | |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 70 | int test_mode_; |
kwiberg | 3747838 | 2016-02-14 20:40:57 -0800 | [diff] [blame] | 71 | std::unique_ptr<AudioCodingModule> acm_a_; |
| 72 | std::unique_ptr<AudioCodingModule> acm_b_; |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 73 | TestPack* channel_a_to_b_; |
| 74 | PCMFile infile_a_; |
| 75 | PCMFile outfile_b_; |
| 76 | int test_count_; |
henrike@webrtc.org | 6ac22e6 | 2014-08-11 21:06:30 +0000 | [diff] [blame] | 77 | int packet_size_samples_; |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 78 | size_t packet_size_bytes_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 79 | }; |
| 80 | |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 81 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 82 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame^] | 83 | #endif // MODULES_AUDIO_CODING_TEST_TESTALLCODECS_H_ |