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