niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
tina.legrand@webrtc.org | ae1c454 | 2012-03-12 08:41:30 +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 | |
kjellander | 3e6db23 | 2015-11-26 04:44:54 -0800 | [diff] [blame] | 11 | #ifndef WEBRTC_MODULES_AUDIO_CODING_TEST_TESTSTEREO_H_ |
| 12 | #define WEBRTC_MODULES_AUDIO_CODING_TEST_TESTSTEREO_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 13 | |
tina.legrand@webrtc.org | 16b6b90 | 2012-04-12 11:02:38 +0000 | [diff] [blame] | 14 | #include <math.h> |
| 15 | |
kwiberg@webrtc.org | 00b8f6b | 2015-02-26 14:34:55 +0000 | [diff] [blame] | 16 | #include "webrtc/base/scoped_ptr.h" |
kjellander | 3e6db23 | 2015-11-26 04:44:54 -0800 | [diff] [blame] | 17 | #include "webrtc/modules/audio_coding/test/ACMTest.h" |
| 18 | #include "webrtc/modules/audio_coding/test/Channel.h" |
| 19 | #include "webrtc/modules/audio_coding/test/PCMFile.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 20 | |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 21 | #define PCMA_AND_PCMU |
| 22 | |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 23 | namespace webrtc { |
| 24 | |
tina.legrand@webrtc.org | 16b6b90 | 2012-04-12 11:02:38 +0000 | [diff] [blame] | 25 | enum StereoMonoMode { |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 26 | kNotSet, |
| 27 | kMono, |
| 28 | kStereo |
tina.legrand@webrtc.org | 16b6b90 | 2012-04-12 11:02:38 +0000 | [diff] [blame] | 29 | }; |
| 30 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 31 | class TestPackStereo : public AudioPacketizationCallback { |
| 32 | public: |
| 33 | TestPackStereo(); |
| 34 | ~TestPackStereo(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 35 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 36 | void RegisterReceiverACM(AudioCodingModule* acm); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 37 | |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 38 | int32_t SendData(const FrameType frame_type, |
| 39 | const uint8_t payload_type, |
| 40 | const uint32_t timestamp, |
| 41 | const uint8_t* payload_data, |
| 42 | const size_t payload_size, |
| 43 | const RTPFragmentationHeader* fragmentation) override; |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 44 | |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 45 | uint16_t payload_size(); |
| 46 | uint32_t timestamp_diff(); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 47 | void reset_payload_size(); |
| 48 | void set_codec_mode(StereoMonoMode mode); |
| 49 | void set_lost_packet(bool lost); |
| 50 | |
| 51 | private: |
| 52 | AudioCodingModule* receiver_acm_; |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 53 | int16_t seq_no_; |
| 54 | uint32_t timestamp_diff_; |
| 55 | uint32_t last_in_timestamp_; |
| 56 | uint64_t total_bytes_; |
henrike@webrtc.org | 6ac22e6 | 2014-08-11 21:06:30 +0000 | [diff] [blame] | 57 | int payload_size_; |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 58 | StereoMonoMode codec_mode_; |
| 59 | // Simulate packet losses |
| 60 | bool lost_packet_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 61 | }; |
| 62 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 63 | class TestStereo : public ACMTest { |
| 64 | public: |
henrik.lundin@webrtc.org | adaf809 | 2014-04-17 08:29:10 +0000 | [diff] [blame] | 65 | explicit TestStereo(int test_mode); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 66 | ~TestStereo(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 67 | |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 68 | void Perform() override; |
| 69 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 70 | private: |
| 71 | // The default value of '-1' indicates that the registration is based only on |
| 72 | // codec name and a sampling frequncy matching is not required. This is useful |
| 73 | // for codecs which support several sampling frequency. |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 74 | void RegisterSendCodec(char side, char* codec_name, int32_t samp_freq_hz, |
| 75 | int rate, int pack_size, int channels, |
| 76 | int payload_type); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 77 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 78 | void Run(TestPackStereo* channel, int in_channels, int out_channels, |
| 79 | int percent_loss = 0); |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 80 | void OpenOutFile(int16_t test_number); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 81 | void DisplaySendReceiveCodec(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 82 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 83 | int test_mode_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 84 | |
kwiberg@webrtc.org | 00b8f6b | 2015-02-26 14:34:55 +0000 | [diff] [blame] | 85 | rtc::scoped_ptr<AudioCodingModule> acm_a_; |
| 86 | rtc::scoped_ptr<AudioCodingModule> acm_b_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 87 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 88 | TestPackStereo* channel_a2b_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 89 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 90 | PCMFile* in_file_stereo_; |
| 91 | PCMFile* in_file_mono_; |
| 92 | PCMFile out_file_; |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 93 | int16_t test_cntr_; |
| 94 | uint16_t pack_size_samp_; |
| 95 | uint16_t pack_size_bytes_; |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 96 | int counter_; |
tina.legrand@webrtc.org | 0ad3c1a | 2012-11-07 08:07:29 +0000 | [diff] [blame] | 97 | char* send_codec_name_; |
tina.legrand@webrtc.org | ae1c454 | 2012-03-12 08:41:30 +0000 | [diff] [blame] | 98 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 99 | // Payload types for stereo codecs and CNG |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 100 | #ifdef WEBRTC_CODEC_G722 |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 101 | int g722_pltype_; |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 102 | #endif |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 103 | int l16_8khz_pltype_; |
| 104 | int l16_16khz_pltype_; |
| 105 | int l16_32khz_pltype_; |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 106 | #ifdef PCMA_AND_PCMU |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 107 | int pcma_pltype_; |
| 108 | int pcmu_pltype_; |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 109 | #endif |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 110 | #ifdef WEBRTC_CODEC_OPUS |
tina.legrand@webrtc.org | 0ad3c1a | 2012-11-07 08:07:29 +0000 | [diff] [blame] | 111 | int opus_pltype_; |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 112 | #endif |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 113 | }; |
| 114 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 115 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 116 | |
kjellander | 3e6db23 | 2015-11-26 04:44:54 -0800 | [diff] [blame] | 117 | #endif // WEBRTC_MODULES_AUDIO_CODING_TEST_TESTSTEREO_H_ |