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