niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
tina.legrand@webrtc.org | df69775 | 2012-02-08 10:22:21 +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 | a092cbf | 2013-02-14 09:28:10 +0000 | [diff] [blame] | 11 | #include "webrtc/modules/audio_coding/main/test/TestStereo.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 12 | |
pbos@webrtc.org | 12dc1a3 | 2013-08-05 16:22:53 +0000 | [diff] [blame] | 13 | #include <assert.h> |
| 14 | |
tina.legrand@webrtc.org | a092cbf | 2013-02-14 09:28:10 +0000 | [diff] [blame] | 15 | #include <string> |
kjellander@webrtc.org | 5490c71 | 2011-12-21 13:34:18 +0000 | [diff] [blame] | 16 | |
tina.legrand@webrtc.org | 3ddc974 | 2012-06-27 09:25:50 +0000 | [diff] [blame] | 17 | #include "gtest/gtest.h" |
| 18 | |
tina.legrand@webrtc.org | a092cbf | 2013-02-14 09:28:10 +0000 | [diff] [blame] | 19 | #include "webrtc/common_types.h" |
| 20 | #include "webrtc/engine_configurations.h" |
| 21 | #include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h" |
| 22 | #include "webrtc/modules/audio_coding/main/test/utility.h" |
| 23 | #include "webrtc/system_wrappers/interface/trace.h" |
| 24 | #include "webrtc/test/testsupport/fileutils.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 25 | |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 26 | namespace webrtc { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 27 | |
| 28 | // Class for simulating packet handling |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 29 | TestPackStereo::TestPackStereo() |
| 30 | : receiver_acm_(NULL), |
| 31 | seq_no_(0), |
| 32 | timestamp_diff_(0), |
| 33 | last_in_timestamp_(0), |
| 34 | total_bytes_(0), |
| 35 | payload_size_(0), |
| 36 | codec_mode_(kNotSet), |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 37 | lost_packet_(false) { |
| 38 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 39 | |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 40 | TestPackStereo::~TestPackStereo() { |
| 41 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 42 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 43 | void TestPackStereo::RegisterReceiverACM(AudioCodingModule* acm) { |
| 44 | receiver_acm_ = acm; |
| 45 | return; |
| 46 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 47 | |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 48 | int32_t TestPackStereo::SendData(const FrameType frame_type, |
| 49 | const uint8_t payload_type, |
| 50 | const uint32_t timestamp, |
| 51 | const uint8_t* payload_data, |
| 52 | const uint16_t payload_size, |
| 53 | const RTPFragmentationHeader* fragmentation) { |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 54 | WebRtcRTPHeader rtp_info; |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 55 | int32_t status = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 56 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 57 | rtp_info.header.markerBit = false; |
| 58 | rtp_info.header.ssrc = 0; |
| 59 | rtp_info.header.sequenceNumber = seq_no_++; |
| 60 | rtp_info.header.payloadType = payload_type; |
| 61 | rtp_info.header.timestamp = timestamp; |
| 62 | if (frame_type == kFrameEmpty) { |
tina.legrand@webrtc.org | 16b6b90 | 2012-04-12 11:02:38 +0000 | [diff] [blame] | 63 | // Skip this frame |
| 64 | return 0; |
| 65 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 66 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 67 | if (lost_packet_ == false) { |
| 68 | if (frame_type != kAudioFrameCN) { |
| 69 | rtp_info.type.Audio.isCNG = false; |
tina.legrand@webrtc.org | a092cbf | 2013-02-14 09:28:10 +0000 | [diff] [blame] | 70 | rtp_info.type.Audio.channel = static_cast<int>(codec_mode_); |
tina.legrand@webrtc.org | 6b6ff55 | 2012-01-11 10:12:54 +0000 | [diff] [blame] | 71 | } else { |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 72 | rtp_info.type.Audio.isCNG = true; |
tina.legrand@webrtc.org | a092cbf | 2013-02-14 09:28:10 +0000 | [diff] [blame] | 73 | rtp_info.type.Audio.channel = static_cast<int>(kMono); |
tina.legrand@webrtc.org | 6b6ff55 | 2012-01-11 10:12:54 +0000 | [diff] [blame] | 74 | } |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 75 | status = receiver_acm_->IncomingPacket(payload_data, payload_size, |
tina.legrand@webrtc.org | 4517585 | 2012-06-01 09:27:35 +0000 | [diff] [blame] | 76 | rtp_info); |
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 | if (frame_type != kAudioFrameCN) { |
| 79 | payload_size_ = payload_size; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 80 | } else { |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 81 | payload_size_ = -1; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 82 | } |
tina.legrand@webrtc.org | 16b6b90 | 2012-04-12 11:02:38 +0000 | [diff] [blame] | 83 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 84 | timestamp_diff_ = timestamp - last_in_timestamp_; |
| 85 | last_in_timestamp_ = timestamp; |
| 86 | total_bytes_ += payload_size; |
tina.legrand@webrtc.org | 16b6b90 | 2012-04-12 11:02:38 +0000 | [diff] [blame] | 87 | } |
| 88 | return status; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 89 | } |
| 90 | |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 91 | uint16_t TestPackStereo::payload_size() { |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 92 | return payload_size_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 93 | } |
| 94 | |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 95 | uint32_t TestPackStereo::timestamp_diff() { |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 96 | return timestamp_diff_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 97 | } |
| 98 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 99 | void TestPackStereo::reset_payload_size() { |
| 100 | payload_size_ = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 101 | } |
| 102 | |
tina.legrand@webrtc.org | 16b6b90 | 2012-04-12 11:02:38 +0000 | [diff] [blame] | 103 | void TestPackStereo::set_codec_mode(enum StereoMonoMode mode) { |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 104 | codec_mode_ = mode; |
tina.legrand@webrtc.org | 16b6b90 | 2012-04-12 11:02:38 +0000 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | void TestPackStereo::set_lost_packet(bool lost) { |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 108 | lost_packet_ = lost; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 109 | } |
| 110 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 111 | TestStereo::TestStereo(int test_mode) |
| 112 | : acm_a_(NULL), |
| 113 | acm_b_(NULL), |
| 114 | channel_a2b_(NULL), |
| 115 | test_cntr_(0), |
| 116 | pack_size_samp_(0), |
| 117 | pack_size_bytes_(0), |
| 118 | counter_(0), |
| 119 | g722_pltype_(0), |
| 120 | l16_8khz_pltype_(-1), |
| 121 | l16_16khz_pltype_(-1), |
| 122 | l16_32khz_pltype_(-1), |
| 123 | pcma_pltype_(-1), |
| 124 | pcmu_pltype_(-1), |
| 125 | celt_pltype_(-1), |
tina.legrand@webrtc.org | 0ad3c1a | 2012-11-07 08:07:29 +0000 | [diff] [blame] | 126 | opus_pltype_(-1), |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 127 | cn_8khz_pltype_(-1), |
| 128 | cn_16khz_pltype_(-1), |
| 129 | cn_32khz_pltype_(-1) { |
tina.legrand@webrtc.org | 4517585 | 2012-06-01 09:27:35 +0000 | [diff] [blame] | 130 | // test_mode = 0 for silent test (auto test) |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 131 | test_mode_ = test_mode; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 132 | } |
| 133 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 134 | TestStereo::~TestStereo() { |
| 135 | if (acm_a_ != NULL) { |
| 136 | AudioCodingModule::Destroy(acm_a_); |
| 137 | acm_a_ = NULL; |
| 138 | } |
| 139 | if (acm_b_ != NULL) { |
| 140 | AudioCodingModule::Destroy(acm_b_); |
| 141 | acm_b_ = NULL; |
| 142 | } |
| 143 | if (channel_a2b_ != NULL) { |
| 144 | delete channel_a2b_; |
| 145 | channel_a2b_ = NULL; |
| 146 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 147 | } |
| 148 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 149 | void TestStereo::Perform() { |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 150 | uint16_t frequency_hz; |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 151 | int audio_channels; |
| 152 | int codec_channels; |
tina.legrand@webrtc.org | 3ddc974 | 2012-06-27 09:25:50 +0000 | [diff] [blame] | 153 | bool dtx; |
| 154 | bool vad; |
| 155 | ACMVADMode vad_mode; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 156 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 157 | if (test_mode_ == 0) { |
| 158 | printf("Running Stereo Test"); |
| 159 | WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1, |
| 160 | "---------- TestStereo ----------"); |
| 161 | } |
| 162 | |
tina.legrand@webrtc.org | 4517585 | 2012-06-01 09:27:35 +0000 | [diff] [blame] | 163 | // Open both mono and stereo test files in 32 kHz. |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 164 | const std::string file_name_stereo = webrtc::test::ResourcePath( |
| 165 | "audio_coding/teststereo32kHz", "pcm"); |
| 166 | const std::string file_name_mono = webrtc::test::ResourcePath( |
| 167 | "audio_coding/testfile32kHz", "pcm"); |
tina.legrand@webrtc.org | 4517585 | 2012-06-01 09:27:35 +0000 | [diff] [blame] | 168 | frequency_hz = 32000; |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 169 | in_file_stereo_ = new PCMFile(); |
| 170 | in_file_mono_ = new PCMFile(); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 171 | in_file_stereo_->Open(file_name_stereo, frequency_hz, "rb"); |
| 172 | in_file_stereo_->ReadStereo(true); |
| 173 | in_file_mono_->Open(file_name_mono, frequency_hz, "rb"); |
| 174 | in_file_mono_->ReadStereo(false); |
| 175 | |
tina.legrand@webrtc.org | 4517585 | 2012-06-01 09:27:35 +0000 | [diff] [blame] | 176 | // Create and initialize two ACMs, one for each side of a one-to-one call. |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 177 | acm_a_ = AudioCodingModule::Create(0); |
| 178 | acm_b_ = AudioCodingModule::Create(1); |
tina.legrand@webrtc.org | 3ddc974 | 2012-06-27 09:25:50 +0000 | [diff] [blame] | 179 | ASSERT_TRUE((acm_a_ != NULL) && (acm_b_ != NULL)); |
| 180 | EXPECT_EQ(0, acm_a_->InitializeReceiver()); |
| 181 | EXPECT_EQ(0, acm_b_->InitializeReceiver()); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 182 | |
tina.legrand@webrtc.org | 4517585 | 2012-06-01 09:27:35 +0000 | [diff] [blame] | 183 | // Register all available codes as receiving codecs. |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 184 | uint8_t num_encoders = acm_a_->NumberOfCodecs(); |
tina.legrand@webrtc.org | 4517585 | 2012-06-01 09:27:35 +0000 | [diff] [blame] | 185 | CodecInst my_codec_param; |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 186 | for (uint8_t n = 0; n < num_encoders; n++) { |
tina.legrand@webrtc.org | 7a7a008 | 2013-02-21 10:27:48 +0000 | [diff] [blame] | 187 | EXPECT_EQ(0, acm_b_->Codec(n, &my_codec_param)); |
tina.legrand@webrtc.org | 3ddc974 | 2012-06-27 09:25:50 +0000 | [diff] [blame] | 188 | EXPECT_EQ(0, acm_b_->RegisterReceiveCodec(my_codec_param)); |
tina.legrand@webrtc.org | 4517585 | 2012-06-01 09:27:35 +0000 | [diff] [blame] | 189 | } |
| 190 | |
| 191 | // Test that unregister all receive codecs works. |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 192 | for (uint8_t n = 0; n < num_encoders; n++) { |
tina.legrand@webrtc.org | 7a7a008 | 2013-02-21 10:27:48 +0000 | [diff] [blame] | 193 | EXPECT_EQ(0, acm_b_->Codec(n, &my_codec_param)); |
tina.legrand@webrtc.org | 3ddc974 | 2012-06-27 09:25:50 +0000 | [diff] [blame] | 194 | EXPECT_EQ(0, acm_b_->UnregisterReceiveCodec(my_codec_param.pltype)); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 195 | } |
tina.legrand@webrtc.org | ae1c454 | 2012-03-12 08:41:30 +0000 | [diff] [blame] | 196 | |
tina.legrand@webrtc.org | 4517585 | 2012-06-01 09:27:35 +0000 | [diff] [blame] | 197 | // Register all available codes as receiving codecs once more. |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 198 | for (uint8_t n = 0; n < num_encoders; n++) { |
tina.legrand@webrtc.org | 7a7a008 | 2013-02-21 10:27:48 +0000 | [diff] [blame] | 199 | EXPECT_EQ(0, acm_b_->Codec(n, &my_codec_param)); |
tina.legrand@webrtc.org | 3ddc974 | 2012-06-27 09:25:50 +0000 | [diff] [blame] | 200 | EXPECT_EQ(0, acm_b_->RegisterReceiveCodec(my_codec_param)); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 201 | } |
tina.legrand@webrtc.org | ae1c454 | 2012-03-12 08:41:30 +0000 | [diff] [blame] | 202 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 203 | // TODO(tlegrand): Take care of return values of all function calls. |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 204 | |
tina.legrand@webrtc.org | 4517585 | 2012-06-01 09:27:35 +0000 | [diff] [blame] | 205 | // TODO(tlegrand): Re-register all stereo codecs needed in the test, |
| 206 | // with new payload numbers. |
| 207 | // g722_pltype_ = 117; |
| 208 | // l16_8khz_pltype_ = 120; |
| 209 | // l16_16khz_pltype_ = 121; |
| 210 | // l16_32khz_pltype_ = 122; |
| 211 | // pcma_pltype_ = 110; |
| 212 | // pcmu_pltype_ = 118; |
| 213 | // celt_pltype_ = 119; |
| 214 | // cn_8khz_pltype_ = 123; |
| 215 | // cn_16khz_pltype_ = 124; |
| 216 | // cn_32khz_pltype_ = 125; |
tina.legrand@webrtc.org | ae1c454 | 2012-03-12 08:41:30 +0000 | [diff] [blame] | 217 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 218 | // Create and connect the channel. |
| 219 | channel_a2b_ = new TestPackStereo; |
tina.legrand@webrtc.org | 3ddc974 | 2012-06-27 09:25:50 +0000 | [diff] [blame] | 220 | EXPECT_EQ(0, acm_a_->RegisterTransportCallback(channel_a2b_)); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 221 | channel_a2b_->RegisterReceiverACM(acm_b_); |
tina.legrand@webrtc.org | df69775 | 2012-02-08 10:22:21 +0000 | [diff] [blame] | 222 | |
tina.legrand@webrtc.org | 3ddc974 | 2012-06-27 09:25:50 +0000 | [diff] [blame] | 223 | // Start with setting VAD/DTX, before we know we will send stereo. |
| 224 | // Continue with setting a stereo codec as send codec and verify that |
| 225 | // VAD/DTX gets turned off. |
| 226 | EXPECT_EQ(0, acm_a_->SetVAD(true, true, VADNormal)); |
tina.legrand@webrtc.org | 7a7a008 | 2013-02-21 10:27:48 +0000 | [diff] [blame] | 227 | EXPECT_EQ(0, acm_a_->VAD(&dtx, &vad, &vad_mode)); |
tina.legrand@webrtc.org | 3ddc974 | 2012-06-27 09:25:50 +0000 | [diff] [blame] | 228 | EXPECT_TRUE(dtx); |
| 229 | EXPECT_TRUE(vad); |
| 230 | char codec_pcma_temp[] = "PCMA"; |
| 231 | RegisterSendCodec('A', codec_pcma_temp, 8000, 64000, 80, 2, pcma_pltype_); |
tina.legrand@webrtc.org | 7a7a008 | 2013-02-21 10:27:48 +0000 | [diff] [blame] | 232 | EXPECT_EQ(0, acm_a_->VAD(&dtx, &vad, &vad_mode)); |
tina.legrand@webrtc.org | 3ddc974 | 2012-06-27 09:25:50 +0000 | [diff] [blame] | 233 | EXPECT_FALSE(dtx); |
| 234 | EXPECT_FALSE(vad); |
tina.legrand@webrtc.org | 46d90dc | 2013-02-01 14:20:06 +0000 | [diff] [blame] | 235 | if (test_mode_ != 0) { |
tina.legrand@webrtc.org | 3ddc974 | 2012-06-27 09:25:50 +0000 | [diff] [blame] | 236 | printf("\n"); |
| 237 | } |
| 238 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 239 | // |
| 240 | // Test Stereo-To-Stereo for all codecs. |
| 241 | // |
| 242 | audio_channels = 2; |
| 243 | codec_channels = 2; |
tina.legrand@webrtc.org | 6b6ff55 | 2012-01-11 10:12:54 +0000 | [diff] [blame] | 244 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 245 | // All codecs are tested for all allowed sampling frequencies, rates and |
| 246 | // packet sizes. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 247 | #ifdef WEBRTC_CODEC_G722 |
tina.legrand@webrtc.org | 46d90dc | 2013-02-01 14:20:06 +0000 | [diff] [blame] | 248 | if (test_mode_ != 0) { |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 249 | printf("===========================================================\n"); |
tina.legrand@webrtc.org | a092cbf | 2013-02-14 09:28:10 +0000 | [diff] [blame] | 250 | printf("Test number: %d\n", test_cntr_ + 1); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 251 | printf("Test type: Stereo-to-stereo\n"); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 252 | } |
| 253 | channel_a2b_->set_codec_mode(kStereo); |
| 254 | test_cntr_++; |
| 255 | OpenOutFile(test_cntr_); |
| 256 | char codec_g722[] = "G722"; |
| 257 | RegisterSendCodec('A', codec_g722, 16000, 64000, 160, codec_channels, |
| 258 | g722_pltype_); |
| 259 | Run(channel_a2b_, audio_channels, codec_channels); |
| 260 | RegisterSendCodec('A', codec_g722, 16000, 64000, 320, codec_channels, |
| 261 | g722_pltype_); |
| 262 | Run(channel_a2b_, audio_channels, codec_channels); |
| 263 | RegisterSendCodec('A', codec_g722, 16000, 64000, 480, codec_channels, |
| 264 | g722_pltype_); |
| 265 | Run(channel_a2b_, audio_channels, codec_channels); |
| 266 | RegisterSendCodec('A', codec_g722, 16000, 64000, 640, codec_channels, |
| 267 | g722_pltype_); |
| 268 | Run(channel_a2b_, audio_channels, codec_channels); |
| 269 | RegisterSendCodec('A', codec_g722, 16000, 64000, 800, codec_channels, |
| 270 | g722_pltype_); |
| 271 | Run(channel_a2b_, audio_channels, codec_channels); |
| 272 | RegisterSendCodec('A', codec_g722, 16000, 64000, 960, codec_channels, |
| 273 | g722_pltype_); |
| 274 | Run(channel_a2b_, audio_channels, codec_channels); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 275 | out_file_.Close(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 276 | #endif |
| 277 | #ifdef WEBRTC_CODEC_PCM16 |
tina.legrand@webrtc.org | 46d90dc | 2013-02-01 14:20:06 +0000 | [diff] [blame] | 278 | if (test_mode_ != 0) { |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 279 | printf("===========================================================\n"); |
tina.legrand@webrtc.org | a092cbf | 2013-02-14 09:28:10 +0000 | [diff] [blame] | 280 | printf("Test number: %d\n", test_cntr_ + 1); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 281 | printf("Test type: Stereo-to-stereo\n"); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 282 | } |
| 283 | channel_a2b_->set_codec_mode(kStereo); |
| 284 | test_cntr_++; |
| 285 | OpenOutFile(test_cntr_); |
| 286 | char codec_l16[] = "L16"; |
| 287 | RegisterSendCodec('A', codec_l16, 8000, 128000, 80, codec_channels, |
| 288 | l16_8khz_pltype_); |
| 289 | Run(channel_a2b_, audio_channels, codec_channels); |
| 290 | RegisterSendCodec('A', codec_l16, 8000, 128000, 160, codec_channels, |
| 291 | l16_8khz_pltype_); |
| 292 | Run(channel_a2b_, audio_channels, codec_channels); |
| 293 | RegisterSendCodec('A', codec_l16, 8000, 128000, 240, codec_channels, |
| 294 | l16_8khz_pltype_); |
| 295 | Run(channel_a2b_, audio_channels, codec_channels); |
| 296 | RegisterSendCodec('A', codec_l16, 8000, 128000, 320, codec_channels, |
| 297 | l16_8khz_pltype_); |
| 298 | Run(channel_a2b_, audio_channels, codec_channels); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 299 | out_file_.Close(); |
tina.legrand@webrtc.org | 6b6ff55 | 2012-01-11 10:12:54 +0000 | [diff] [blame] | 300 | |
tina.legrand@webrtc.org | 46d90dc | 2013-02-01 14:20:06 +0000 | [diff] [blame] | 301 | if (test_mode_ != 0) { |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 302 | printf("===========================================================\n"); |
tina.legrand@webrtc.org | a092cbf | 2013-02-14 09:28:10 +0000 | [diff] [blame] | 303 | printf("Test number: %d\n", test_cntr_ + 1); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 304 | printf("Test type: Stereo-to-stereo\n"); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 305 | } |
| 306 | test_cntr_++; |
| 307 | OpenOutFile(test_cntr_); |
| 308 | RegisterSendCodec('A', codec_l16, 16000, 256000, 160, codec_channels, |
| 309 | l16_16khz_pltype_); |
| 310 | Run(channel_a2b_, audio_channels, codec_channels); |
| 311 | RegisterSendCodec('A', codec_l16, 16000, 256000, 320, codec_channels, |
| 312 | l16_16khz_pltype_); |
| 313 | Run(channel_a2b_, audio_channels, codec_channels); |
| 314 | RegisterSendCodec('A', codec_l16, 16000, 256000, 480, codec_channels, |
| 315 | l16_16khz_pltype_); |
| 316 | Run(channel_a2b_, audio_channels, codec_channels); |
| 317 | RegisterSendCodec('A', codec_l16, 16000, 256000, 640, codec_channels, |
| 318 | l16_16khz_pltype_); |
| 319 | Run(channel_a2b_, audio_channels, codec_channels); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 320 | out_file_.Close(); |
tina.legrand@webrtc.org | 6b6ff55 | 2012-01-11 10:12:54 +0000 | [diff] [blame] | 321 | |
tina.legrand@webrtc.org | 46d90dc | 2013-02-01 14:20:06 +0000 | [diff] [blame] | 322 | if (test_mode_ != 0) { |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 323 | printf("===========================================================\n"); |
tina.legrand@webrtc.org | a092cbf | 2013-02-14 09:28:10 +0000 | [diff] [blame] | 324 | printf("Test number: %d\n", test_cntr_ + 1); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 325 | printf("Test type: Stereo-to-stereo\n"); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 326 | } |
| 327 | test_cntr_++; |
| 328 | OpenOutFile(test_cntr_); |
| 329 | RegisterSendCodec('A', codec_l16, 32000, 512000, 320, codec_channels, |
| 330 | l16_32khz_pltype_); |
| 331 | Run(channel_a2b_, audio_channels, codec_channels); |
| 332 | RegisterSendCodec('A', codec_l16, 32000, 512000, 640, codec_channels, |
| 333 | l16_32khz_pltype_); |
| 334 | Run(channel_a2b_, audio_channels, codec_channels); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 335 | out_file_.Close(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 336 | #endif |
| 337 | #define PCMA_AND_PCMU |
| 338 | #ifdef PCMA_AND_PCMU |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 339 | if (test_mode_ != 0) { |
| 340 | printf("===========================================================\n"); |
| 341 | printf("Test number: %d\n", test_cntr_ + 1); |
| 342 | printf("Test type: Stereo-to-stereo\n"); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 343 | } |
| 344 | channel_a2b_->set_codec_mode(kStereo); |
| 345 | audio_channels = 2; |
| 346 | codec_channels = 2; |
| 347 | test_cntr_++; |
| 348 | OpenOutFile(test_cntr_); |
| 349 | char codec_pcma[] = "PCMA"; |
| 350 | RegisterSendCodec('A', codec_pcma, 8000, 64000, 80, codec_channels, |
| 351 | pcma_pltype_); |
| 352 | Run(channel_a2b_, audio_channels, codec_channels); |
| 353 | RegisterSendCodec('A', codec_pcma, 8000, 64000, 160, codec_channels, |
| 354 | pcma_pltype_); |
| 355 | Run(channel_a2b_, audio_channels, codec_channels); |
| 356 | RegisterSendCodec('A', codec_pcma, 8000, 64000, 240, codec_channels, |
| 357 | pcma_pltype_); |
| 358 | Run(channel_a2b_, audio_channels, codec_channels); |
| 359 | RegisterSendCodec('A', codec_pcma, 8000, 64000, 320, codec_channels, |
| 360 | pcma_pltype_); |
| 361 | Run(channel_a2b_, audio_channels, codec_channels); |
| 362 | RegisterSendCodec('A', codec_pcma, 8000, 64000, 400, codec_channels, |
| 363 | pcma_pltype_); |
| 364 | Run(channel_a2b_, audio_channels, codec_channels); |
| 365 | RegisterSendCodec('A', codec_pcma, 8000, 64000, 480, codec_channels, |
| 366 | pcma_pltype_); |
| 367 | Run(channel_a2b_, audio_channels, codec_channels); |
tina.legrand@webrtc.org | 3ddc974 | 2012-06-27 09:25:50 +0000 | [diff] [blame] | 368 | |
| 369 | // Test that VAD/DTX cannot be turned on while sending stereo. |
| 370 | EXPECT_EQ(-1, acm_a_->SetVAD(true, true, VADNormal)); |
tina.legrand@webrtc.org | 7a7a008 | 2013-02-21 10:27:48 +0000 | [diff] [blame] | 371 | EXPECT_EQ(0, acm_a_->VAD(&dtx, &vad, &vad_mode)); |
tina.legrand@webrtc.org | 3ddc974 | 2012-06-27 09:25:50 +0000 | [diff] [blame] | 372 | EXPECT_FALSE(dtx); |
| 373 | EXPECT_FALSE(vad); |
| 374 | EXPECT_EQ(-1, acm_a_->SetVAD(true, false, VADNormal)); |
tina.legrand@webrtc.org | 7a7a008 | 2013-02-21 10:27:48 +0000 | [diff] [blame] | 375 | EXPECT_EQ(0, acm_a_->VAD(&dtx, &vad, &vad_mode)); |
tina.legrand@webrtc.org | 3ddc974 | 2012-06-27 09:25:50 +0000 | [diff] [blame] | 376 | EXPECT_FALSE(dtx); |
| 377 | EXPECT_FALSE(vad); |
| 378 | EXPECT_EQ(-1, acm_a_->SetVAD(false, true, VADNormal)); |
tina.legrand@webrtc.org | 7a7a008 | 2013-02-21 10:27:48 +0000 | [diff] [blame] | 379 | EXPECT_EQ(0, acm_a_->VAD(&dtx, &vad, &vad_mode)); |
tina.legrand@webrtc.org | 3ddc974 | 2012-06-27 09:25:50 +0000 | [diff] [blame] | 380 | EXPECT_FALSE(dtx); |
| 381 | EXPECT_FALSE(vad); |
| 382 | EXPECT_EQ(0, acm_a_->SetVAD(false, false, VADNormal)); |
tina.legrand@webrtc.org | 7a7a008 | 2013-02-21 10:27:48 +0000 | [diff] [blame] | 383 | EXPECT_EQ(0, acm_a_->VAD(&dtx, &vad, &vad_mode)); |
tina.legrand@webrtc.org | 3ddc974 | 2012-06-27 09:25:50 +0000 | [diff] [blame] | 384 | EXPECT_FALSE(dtx); |
| 385 | EXPECT_FALSE(vad); |
| 386 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 387 | out_file_.Close(); |
| 388 | if (test_mode_ != 0) { |
| 389 | printf("===========================================================\n"); |
| 390 | printf("Test number: %d\n", test_cntr_ + 1); |
| 391 | printf("Test type: Stereo-to-stereo\n"); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 392 | } |
| 393 | test_cntr_++; |
| 394 | OpenOutFile(test_cntr_); |
| 395 | char codec_pcmu[] = "PCMU"; |
| 396 | RegisterSendCodec('A', codec_pcmu, 8000, 64000, 80, codec_channels, |
| 397 | pcmu_pltype_); |
| 398 | Run(channel_a2b_, audio_channels, codec_channels); |
| 399 | RegisterSendCodec('A', codec_pcmu, 8000, 64000, 160, codec_channels, |
| 400 | pcmu_pltype_); |
| 401 | Run(channel_a2b_, audio_channels, codec_channels); |
| 402 | RegisterSendCodec('A', codec_pcmu, 8000, 64000, 240, codec_channels, |
| 403 | pcmu_pltype_); |
| 404 | Run(channel_a2b_, audio_channels, codec_channels); |
| 405 | RegisterSendCodec('A', codec_pcmu, 8000, 64000, 320, codec_channels, |
| 406 | pcmu_pltype_); |
| 407 | Run(channel_a2b_, audio_channels, codec_channels); |
| 408 | RegisterSendCodec('A', codec_pcmu, 8000, 64000, 400, codec_channels, |
| 409 | pcmu_pltype_); |
| 410 | Run(channel_a2b_, audio_channels, codec_channels); |
| 411 | RegisterSendCodec('A', codec_pcmu, 8000, 64000, 480, codec_channels, |
| 412 | pcmu_pltype_); |
| 413 | Run(channel_a2b_, audio_channels, codec_channels); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 414 | out_file_.Close(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 415 | #endif |
tina.legrand@webrtc.org | df69775 | 2012-02-08 10:22:21 +0000 | [diff] [blame] | 416 | #ifdef WEBRTC_CODEC_CELT |
tina.legrand@webrtc.org | 46d90dc | 2013-02-01 14:20:06 +0000 | [diff] [blame] | 417 | if (test_mode_ != 0) { |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 418 | printf("===========================================================\n"); |
tina.legrand@webrtc.org | a092cbf | 2013-02-14 09:28:10 +0000 | [diff] [blame] | 419 | printf("Test number: %d\n", test_cntr_ + 1); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 420 | printf("Test type: Stereo-to-stereo\n"); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 421 | } |
| 422 | channel_a2b_->set_codec_mode(kStereo); |
| 423 | audio_channels = 2; |
| 424 | codec_channels = 2; |
| 425 | test_cntr_++; |
| 426 | OpenOutFile(test_cntr_); |
| 427 | char codec_celt[] = "CELT"; |
tina.legrand@webrtc.org | 90af7f8 | 2012-06-07 08:57:27 +0000 | [diff] [blame] | 428 | RegisterSendCodec('A', codec_celt, 32000, 48000, 640, codec_channels, |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 429 | celt_pltype_); |
| 430 | Run(channel_a2b_, audio_channels, codec_channels); |
tina.legrand@webrtc.org | 90af7f8 | 2012-06-07 08:57:27 +0000 | [diff] [blame] | 431 | RegisterSendCodec('A', codec_celt, 32000, 64000, 640, codec_channels, |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 432 | celt_pltype_); |
| 433 | Run(channel_a2b_, audio_channels, codec_channels); |
tina.legrand@webrtc.org | 90af7f8 | 2012-06-07 08:57:27 +0000 | [diff] [blame] | 434 | RegisterSendCodec('A', codec_celt, 32000, 128000, 640, codec_channels, |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 435 | celt_pltype_); |
| 436 | Run(channel_a2b_, audio_channels, codec_channels); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 437 | out_file_.Close(); |
tina.legrand@webrtc.org | df69775 | 2012-02-08 10:22:21 +0000 | [diff] [blame] | 438 | #endif |
tina.legrand@webrtc.org | 0ad3c1a | 2012-11-07 08:07:29 +0000 | [diff] [blame] | 439 | #ifdef WEBRTC_CODEC_OPUS |
tina.legrand@webrtc.org | 46d90dc | 2013-02-01 14:20:06 +0000 | [diff] [blame] | 440 | if (test_mode_ != 0) { |
tina.legrand@webrtc.org | 0ad3c1a | 2012-11-07 08:07:29 +0000 | [diff] [blame] | 441 | printf("===========================================================\n"); |
tina.legrand@webrtc.org | a092cbf | 2013-02-14 09:28:10 +0000 | [diff] [blame] | 442 | printf("Test number: %d\n", test_cntr_ + 1); |
tina.legrand@webrtc.org | 0ad3c1a | 2012-11-07 08:07:29 +0000 | [diff] [blame] | 443 | printf("Test type: Stereo-to-stereo\n"); |
| 444 | } |
| 445 | channel_a2b_->set_codec_mode(kStereo); |
| 446 | audio_channels = 2; |
| 447 | codec_channels = 2; |
| 448 | test_cntr_++; |
| 449 | OpenOutFile(test_cntr_); |
tina.legrand@webrtc.org | 46d90dc | 2013-02-01 14:20:06 +0000 | [diff] [blame] | 450 | |
tina.legrand@webrtc.org | 0ad3c1a | 2012-11-07 08:07:29 +0000 | [diff] [blame] | 451 | char codec_opus[] = "opus"; |
tina.legrand@webrtc.org | 46d90dc | 2013-02-01 14:20:06 +0000 | [diff] [blame] | 452 | // Run Opus with 10 ms frame size. |
| 453 | RegisterSendCodec('A', codec_opus, 48000, 64000, 480, codec_channels, |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 454 | opus_pltype_); |
tina.legrand@webrtc.org | 0ad3c1a | 2012-11-07 08:07:29 +0000 | [diff] [blame] | 455 | Run(channel_a2b_, audio_channels, codec_channels); |
tina.legrand@webrtc.org | 46d90dc | 2013-02-01 14:20:06 +0000 | [diff] [blame] | 456 | // Run Opus with 20 ms frame size. |
| 457 | RegisterSendCodec('A', codec_opus, 48000, 64000, 480*2, codec_channels, |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 458 | opus_pltype_); |
tina.legrand@webrtc.org | 46d90dc | 2013-02-01 14:20:06 +0000 | [diff] [blame] | 459 | Run(channel_a2b_, audio_channels, codec_channels); |
| 460 | // Run Opus with 40 ms frame size. |
| 461 | RegisterSendCodec('A', codec_opus, 48000, 64000, 480*4, codec_channels, |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 462 | opus_pltype_); |
tina.legrand@webrtc.org | 46d90dc | 2013-02-01 14:20:06 +0000 | [diff] [blame] | 463 | Run(channel_a2b_, audio_channels, codec_channels); |
| 464 | // Run Opus with 60 ms frame size. |
| 465 | RegisterSendCodec('A', codec_opus, 48000, 64000, 480*6, codec_channels, |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 466 | opus_pltype_); |
tina.legrand@webrtc.org | 46d90dc | 2013-02-01 14:20:06 +0000 | [diff] [blame] | 467 | Run(channel_a2b_, audio_channels, codec_channels); |
| 468 | // Run Opus with 20 ms frame size and different bitrates. |
| 469 | RegisterSendCodec('A', codec_opus, 48000, 40000, 960, codec_channels, |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 470 | opus_pltype_); |
tina.legrand@webrtc.org | 0ad3c1a | 2012-11-07 08:07:29 +0000 | [diff] [blame] | 471 | Run(channel_a2b_, audio_channels, codec_channels); |
| 472 | RegisterSendCodec('A', codec_opus, 48000, 510000, 960, codec_channels, |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 473 | opus_pltype_); |
tina.legrand@webrtc.org | 0ad3c1a | 2012-11-07 08:07:29 +0000 | [diff] [blame] | 474 | Run(channel_a2b_, audio_channels, codec_channels); |
| 475 | out_file_.Close(); |
| 476 | #endif |
tina.legrand@webrtc.org | 6b6ff55 | 2012-01-11 10:12:54 +0000 | [diff] [blame] | 477 | // |
| 478 | // Test Mono-To-Stereo for all codecs. |
| 479 | // |
| 480 | audio_channels = 1; |
| 481 | codec_channels = 2; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 482 | |
tina.legrand@webrtc.org | 6b6ff55 | 2012-01-11 10:12:54 +0000 | [diff] [blame] | 483 | #ifdef WEBRTC_CODEC_G722 |
tina.legrand@webrtc.org | 46d90dc | 2013-02-01 14:20:06 +0000 | [diff] [blame] | 484 | if (test_mode_ != 0) { |
tina.legrand@webrtc.org | 6b6ff55 | 2012-01-11 10:12:54 +0000 | [diff] [blame] | 485 | printf("===============================================================\n"); |
tina.legrand@webrtc.org | a092cbf | 2013-02-14 09:28:10 +0000 | [diff] [blame] | 486 | printf("Test number: %d\n", test_cntr_ + 1); |
tina.legrand@webrtc.org | 6b6ff55 | 2012-01-11 10:12:54 +0000 | [diff] [blame] | 487 | printf("Test type: Mono-to-stereo\n"); |
| 488 | } |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 489 | test_cntr_++; |
| 490 | channel_a2b_->set_codec_mode(kStereo); |
| 491 | OpenOutFile(test_cntr_); |
| 492 | RegisterSendCodec('A', codec_g722, 16000, 64000, 160, codec_channels, |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 493 | g722_pltype_); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 494 | Run(channel_a2b_, audio_channels, codec_channels); |
| 495 | out_file_.Close(); |
tina.legrand@webrtc.org | 6b6ff55 | 2012-01-11 10:12:54 +0000 | [diff] [blame] | 496 | #endif |
| 497 | #ifdef WEBRTC_CODEC_PCM16 |
tina.legrand@webrtc.org | 46d90dc | 2013-02-01 14:20:06 +0000 | [diff] [blame] | 498 | if (test_mode_ != 0) { |
tina.legrand@webrtc.org | 6b6ff55 | 2012-01-11 10:12:54 +0000 | [diff] [blame] | 499 | printf("===============================================================\n"); |
tina.legrand@webrtc.org | a092cbf | 2013-02-14 09:28:10 +0000 | [diff] [blame] | 500 | printf("Test number: %d\n", test_cntr_ + 1); |
tina.legrand@webrtc.org | 6b6ff55 | 2012-01-11 10:12:54 +0000 | [diff] [blame] | 501 | printf("Test type: Mono-to-stereo\n"); |
| 502 | } |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 503 | test_cntr_++; |
| 504 | channel_a2b_->set_codec_mode(kStereo); |
| 505 | OpenOutFile(test_cntr_); |
| 506 | RegisterSendCodec('A', codec_l16, 8000, 128000, 80, codec_channels, |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 507 | l16_8khz_pltype_); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 508 | Run(channel_a2b_, audio_channels, codec_channels); |
| 509 | out_file_.Close(); |
tina.legrand@webrtc.org | 46d90dc | 2013-02-01 14:20:06 +0000 | [diff] [blame] | 510 | if (test_mode_ != 0) { |
tina.legrand@webrtc.org | 6b6ff55 | 2012-01-11 10:12:54 +0000 | [diff] [blame] | 511 | printf("===============================================================\n"); |
tina.legrand@webrtc.org | a092cbf | 2013-02-14 09:28:10 +0000 | [diff] [blame] | 512 | printf("Test number: %d\n", test_cntr_ + 1); |
tina.legrand@webrtc.org | 6b6ff55 | 2012-01-11 10:12:54 +0000 | [diff] [blame] | 513 | printf("Test type: Mono-to-stereo\n"); |
| 514 | } |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 515 | test_cntr_++; |
| 516 | OpenOutFile(test_cntr_); |
| 517 | RegisterSendCodec('A', codec_l16, 16000, 256000, 160, codec_channels, |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 518 | l16_16khz_pltype_); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 519 | Run(channel_a2b_, audio_channels, codec_channels); |
| 520 | out_file_.Close(); |
tina.legrand@webrtc.org | 46d90dc | 2013-02-01 14:20:06 +0000 | [diff] [blame] | 521 | if (test_mode_ != 0) { |
tina.legrand@webrtc.org | 6b6ff55 | 2012-01-11 10:12:54 +0000 | [diff] [blame] | 522 | printf("===============================================================\n"); |
tina.legrand@webrtc.org | a092cbf | 2013-02-14 09:28:10 +0000 | [diff] [blame] | 523 | printf("Test number: %d\n", test_cntr_ + 1); |
tina.legrand@webrtc.org | 6b6ff55 | 2012-01-11 10:12:54 +0000 | [diff] [blame] | 524 | printf("Test type: Mono-to-stereo\n"); |
| 525 | } |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 526 | test_cntr_++; |
| 527 | OpenOutFile(test_cntr_); |
| 528 | RegisterSendCodec('A', codec_l16, 32000, 512000, 320, codec_channels, |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 529 | l16_32khz_pltype_); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 530 | Run(channel_a2b_, audio_channels, codec_channels); |
| 531 | out_file_.Close(); |
tina.legrand@webrtc.org | 6b6ff55 | 2012-01-11 10:12:54 +0000 | [diff] [blame] | 532 | #endif |
| 533 | #ifdef PCMA_AND_PCMU |
tina.legrand@webrtc.org | 46d90dc | 2013-02-01 14:20:06 +0000 | [diff] [blame] | 534 | if (test_mode_ != 0) { |
tina.legrand@webrtc.org | 6b6ff55 | 2012-01-11 10:12:54 +0000 | [diff] [blame] | 535 | printf("===============================================================\n"); |
tina.legrand@webrtc.org | a092cbf | 2013-02-14 09:28:10 +0000 | [diff] [blame] | 536 | printf("Test number: %d\n", test_cntr_ + 1); |
tina.legrand@webrtc.org | 6b6ff55 | 2012-01-11 10:12:54 +0000 | [diff] [blame] | 537 | printf("Test type: Mono-to-stereo\n"); |
| 538 | } |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 539 | test_cntr_++; |
| 540 | channel_a2b_->set_codec_mode(kStereo); |
| 541 | OpenOutFile(test_cntr_); |
| 542 | RegisterSendCodec('A', codec_pcmu, 8000, 64000, 80, codec_channels, |
tina.legrand@webrtc.org | ae1c454 | 2012-03-12 08:41:30 +0000 | [diff] [blame] | 543 | pcmu_pltype_); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 544 | Run(channel_a2b_, audio_channels, codec_channels); |
| 545 | RegisterSendCodec('A', codec_pcma, 8000, 64000, 80, codec_channels, |
tina.legrand@webrtc.org | ae1c454 | 2012-03-12 08:41:30 +0000 | [diff] [blame] | 546 | pcma_pltype_); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 547 | Run(channel_a2b_, audio_channels, codec_channels); |
| 548 | out_file_.Close(); |
tina.legrand@webrtc.org | 6b6ff55 | 2012-01-11 10:12:54 +0000 | [diff] [blame] | 549 | #endif |
tina.legrand@webrtc.org | df69775 | 2012-02-08 10:22:21 +0000 | [diff] [blame] | 550 | #ifdef WEBRTC_CODEC_CELT |
tina.legrand@webrtc.org | 46d90dc | 2013-02-01 14:20:06 +0000 | [diff] [blame] | 551 | if (test_mode_ != 0) { |
tina.legrand@webrtc.org | df69775 | 2012-02-08 10:22:21 +0000 | [diff] [blame] | 552 | printf("===============================================================\n"); |
tina.legrand@webrtc.org | a092cbf | 2013-02-14 09:28:10 +0000 | [diff] [blame] | 553 | printf("Test number: %d\n", test_cntr_ + 1); |
tina.legrand@webrtc.org | df69775 | 2012-02-08 10:22:21 +0000 | [diff] [blame] | 554 | printf("Test type: Mono-to-stereo\n"); |
| 555 | } |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 556 | test_cntr_++; |
| 557 | channel_a2b_->set_codec_mode(kStereo); |
| 558 | OpenOutFile(test_cntr_); |
tina.legrand@webrtc.org | 90af7f8 | 2012-06-07 08:57:27 +0000 | [diff] [blame] | 559 | RegisterSendCodec('A', codec_celt, 32000, 64000, 640, codec_channels, |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 560 | celt_pltype_); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 561 | Run(channel_a2b_, audio_channels, codec_channels); |
| 562 | out_file_.Close(); |
tina.legrand@webrtc.org | df69775 | 2012-02-08 10:22:21 +0000 | [diff] [blame] | 563 | #endif |
tina.legrand@webrtc.org | 0ad3c1a | 2012-11-07 08:07:29 +0000 | [diff] [blame] | 564 | #ifdef WEBRTC_CODEC_OPUS |
tina.legrand@webrtc.org | 46d90dc | 2013-02-01 14:20:06 +0000 | [diff] [blame] | 565 | if (test_mode_ != 0) { |
tina.legrand@webrtc.org | 0ad3c1a | 2012-11-07 08:07:29 +0000 | [diff] [blame] | 566 | printf("===============================================================\n"); |
tina.legrand@webrtc.org | a092cbf | 2013-02-14 09:28:10 +0000 | [diff] [blame] | 567 | printf("Test number: %d\n", test_cntr_ + 1); |
tina.legrand@webrtc.org | 0ad3c1a | 2012-11-07 08:07:29 +0000 | [diff] [blame] | 568 | printf("Test type: Mono-to-stereo\n"); |
| 569 | } |
tina.legrand@webrtc.org | c459058 | 2012-11-28 12:23:29 +0000 | [diff] [blame] | 570 | |
| 571 | // Keep encode and decode in stereo. |
tina.legrand@webrtc.org | 0ad3c1a | 2012-11-07 08:07:29 +0000 | [diff] [blame] | 572 | test_cntr_++; |
| 573 | channel_a2b_->set_codec_mode(kStereo); |
| 574 | OpenOutFile(test_cntr_); |
| 575 | RegisterSendCodec('A', codec_opus, 48000, 64000, 960, codec_channels, |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 576 | opus_pltype_); |
tina.legrand@webrtc.org | 0ad3c1a | 2012-11-07 08:07:29 +0000 | [diff] [blame] | 577 | Run(channel_a2b_, audio_channels, codec_channels); |
tina.legrand@webrtc.org | c459058 | 2012-11-28 12:23:29 +0000 | [diff] [blame] | 578 | |
| 579 | // Encode in mono, decode in stereo mode. |
| 580 | RegisterSendCodec('A', codec_opus, 48000, 64000, 960, 1, opus_pltype_); |
| 581 | Run(channel_a2b_, audio_channels, codec_channels); |
tina.legrand@webrtc.org | 0ad3c1a | 2012-11-07 08:07:29 +0000 | [diff] [blame] | 582 | out_file_.Close(); |
| 583 | #endif |
tina.legrand@webrtc.org | 6b6ff55 | 2012-01-11 10:12:54 +0000 | [diff] [blame] | 584 | |
| 585 | // |
| 586 | // Test Stereo-To-Mono for all codecs. |
| 587 | // |
| 588 | audio_channels = 2; |
| 589 | codec_channels = 1; |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 590 | channel_a2b_->set_codec_mode(kMono); |
tina.legrand@webrtc.org | 6b6ff55 | 2012-01-11 10:12:54 +0000 | [diff] [blame] | 591 | |
tina.legrand@webrtc.org | 6b6ff55 | 2012-01-11 10:12:54 +0000 | [diff] [blame] | 592 | #ifdef WEBRTC_CODEC_G722 |
| 593 | // Run stereo audio and mono codec. |
tina.legrand@webrtc.org | 46d90dc | 2013-02-01 14:20:06 +0000 | [diff] [blame] | 594 | if (test_mode_ != 0) { |
tina.legrand@webrtc.org | 6b6ff55 | 2012-01-11 10:12:54 +0000 | [diff] [blame] | 595 | printf("===============================================================\n"); |
tina.legrand@webrtc.org | a092cbf | 2013-02-14 09:28:10 +0000 | [diff] [blame] | 596 | printf("Test number: %d\n", test_cntr_ + 1); |
tina.legrand@webrtc.org | 6b6ff55 | 2012-01-11 10:12:54 +0000 | [diff] [blame] | 597 | printf("Test type: Stereo-to-mono\n"); |
| 598 | } |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 599 | test_cntr_++; |
| 600 | OpenOutFile(test_cntr_); |
| 601 | RegisterSendCodec('A', codec_g722, 16000, 64000, 160, codec_channels, |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 602 | g722_pltype_); |
tina.legrand@webrtc.org | 3ddc974 | 2012-06-27 09:25:50 +0000 | [diff] [blame] | 603 | |
| 604 | // Make sure it is possible to set VAD/CNG, now that we are sending mono |
| 605 | // again. |
| 606 | EXPECT_EQ(0, acm_a_->SetVAD(true, true, VADNormal)); |
tina.legrand@webrtc.org | 7a7a008 | 2013-02-21 10:27:48 +0000 | [diff] [blame] | 607 | EXPECT_EQ(0, acm_a_->VAD(&dtx, &vad, &vad_mode)); |
tina.legrand@webrtc.org | 3ddc974 | 2012-06-27 09:25:50 +0000 | [diff] [blame] | 608 | EXPECT_TRUE(dtx); |
| 609 | EXPECT_TRUE(vad); |
| 610 | EXPECT_EQ(0, acm_a_->SetVAD(false, false, VADNormal)); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 611 | Run(channel_a2b_, audio_channels, codec_channels); |
| 612 | out_file_.Close(); |
tina.legrand@webrtc.org | 6b6ff55 | 2012-01-11 10:12:54 +0000 | [diff] [blame] | 613 | #endif |
| 614 | #ifdef WEBRTC_CODEC_PCM16 |
tina.legrand@webrtc.org | 46d90dc | 2013-02-01 14:20:06 +0000 | [diff] [blame] | 615 | if (test_mode_ != 0) { |
tina.legrand@webrtc.org | 6b6ff55 | 2012-01-11 10:12:54 +0000 | [diff] [blame] | 616 | printf("===============================================================\n"); |
tina.legrand@webrtc.org | a092cbf | 2013-02-14 09:28:10 +0000 | [diff] [blame] | 617 | printf("Test number: %d\n", test_cntr_ + 1); |
tina.legrand@webrtc.org | 6b6ff55 | 2012-01-11 10:12:54 +0000 | [diff] [blame] | 618 | printf("Test type: Stereo-to-mono\n"); |
| 619 | } |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 620 | test_cntr_++; |
| 621 | OpenOutFile(test_cntr_); |
| 622 | RegisterSendCodec('A', codec_l16, 8000, 128000, 80, codec_channels, |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 623 | l16_8khz_pltype_); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 624 | Run(channel_a2b_, audio_channels, codec_channels); |
| 625 | out_file_.Close(); |
tina.legrand@webrtc.org | 46d90dc | 2013-02-01 14:20:06 +0000 | [diff] [blame] | 626 | if (test_mode_ != 0) { |
tina.legrand@webrtc.org | 6b6ff55 | 2012-01-11 10:12:54 +0000 | [diff] [blame] | 627 | printf("===============================================================\n"); |
tina.legrand@webrtc.org | a092cbf | 2013-02-14 09:28:10 +0000 | [diff] [blame] | 628 | printf("Test number: %d\n", test_cntr_ + 1); |
tina.legrand@webrtc.org | 6b6ff55 | 2012-01-11 10:12:54 +0000 | [diff] [blame] | 629 | printf("Test type: Stereo-to-mono\n"); |
tina.legrand@webrtc.org | a092cbf | 2013-02-14 09:28:10 +0000 | [diff] [blame] | 630 | } |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 631 | test_cntr_++; |
| 632 | OpenOutFile(test_cntr_); |
| 633 | RegisterSendCodec('A', codec_l16, 16000, 256000, 160, codec_channels, |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 634 | l16_16khz_pltype_); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 635 | Run(channel_a2b_, audio_channels, codec_channels); |
| 636 | out_file_.Close(); |
tina.legrand@webrtc.org | 46d90dc | 2013-02-01 14:20:06 +0000 | [diff] [blame] | 637 | if (test_mode_ != 0) { |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 638 | printf("==============================================================\n"); |
| 639 | printf("Test number: %d\n", test_cntr_ + 1); |
| 640 | printf("Test type: Stereo-to-mono\n"); |
tina.legrand@webrtc.org | a092cbf | 2013-02-14 09:28:10 +0000 | [diff] [blame] | 641 | } |
| 642 | test_cntr_++; |
| 643 | OpenOutFile(test_cntr_); |
| 644 | RegisterSendCodec('A', codec_l16, 32000, 512000, 320, codec_channels, |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 645 | l16_32khz_pltype_); |
tina.legrand@webrtc.org | a092cbf | 2013-02-14 09:28:10 +0000 | [diff] [blame] | 646 | Run(channel_a2b_, audio_channels, codec_channels); |
| 647 | out_file_.Close(); |
tina.legrand@webrtc.org | 6b6ff55 | 2012-01-11 10:12:54 +0000 | [diff] [blame] | 648 | #endif |
| 649 | #ifdef PCMA_AND_PCMU |
tina.legrand@webrtc.org | 46d90dc | 2013-02-01 14:20:06 +0000 | [diff] [blame] | 650 | if (test_mode_ != 0) { |
tina.legrand@webrtc.org | 6b6ff55 | 2012-01-11 10:12:54 +0000 | [diff] [blame] | 651 | printf("===============================================================\n"); |
tina.legrand@webrtc.org | a092cbf | 2013-02-14 09:28:10 +0000 | [diff] [blame] | 652 | printf("Test number: %d\n", test_cntr_ + 1); |
tina.legrand@webrtc.org | df69775 | 2012-02-08 10:22:21 +0000 | [diff] [blame] | 653 | printf("Test type: Stereo-to-mono\n"); |
tina.legrand@webrtc.org | 6b6ff55 | 2012-01-11 10:12:54 +0000 | [diff] [blame] | 654 | } |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 655 | test_cntr_++; |
| 656 | OpenOutFile(test_cntr_); |
| 657 | RegisterSendCodec('A', codec_pcmu, 8000, 64000, 80, codec_channels, |
tina.legrand@webrtc.org | ae1c454 | 2012-03-12 08:41:30 +0000 | [diff] [blame] | 658 | pcmu_pltype_); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 659 | Run(channel_a2b_, audio_channels, codec_channels); |
| 660 | RegisterSendCodec('A', codec_pcma, 8000, 64000, 80, codec_channels, |
tina.legrand@webrtc.org | ae1c454 | 2012-03-12 08:41:30 +0000 | [diff] [blame] | 661 | pcma_pltype_); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 662 | Run(channel_a2b_, audio_channels, codec_channels); |
| 663 | out_file_.Close(); |
tina.legrand@webrtc.org | 6b6ff55 | 2012-01-11 10:12:54 +0000 | [diff] [blame] | 664 | #endif |
tina.legrand@webrtc.org | df69775 | 2012-02-08 10:22:21 +0000 | [diff] [blame] | 665 | #ifdef WEBRTC_CODEC_CELT |
tina.legrand@webrtc.org | 46d90dc | 2013-02-01 14:20:06 +0000 | [diff] [blame] | 666 | if (test_mode_ != 0) { |
tina.legrand@webrtc.org | df69775 | 2012-02-08 10:22:21 +0000 | [diff] [blame] | 667 | printf("===============================================================\n"); |
tina.legrand@webrtc.org | a092cbf | 2013-02-14 09:28:10 +0000 | [diff] [blame] | 668 | printf("Test number: %d\n", test_cntr_ + 1); |
tina.legrand@webrtc.org | df69775 | 2012-02-08 10:22:21 +0000 | [diff] [blame] | 669 | printf("Test type: Stereo-to-mono\n"); |
| 670 | } |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 671 | test_cntr_++; |
| 672 | OpenOutFile(test_cntr_); |
tina.legrand@webrtc.org | 90af7f8 | 2012-06-07 08:57:27 +0000 | [diff] [blame] | 673 | RegisterSendCodec('A', codec_celt, 32000, 64000, 640, codec_channels, |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 674 | celt_pltype_); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 675 | Run(channel_a2b_, audio_channels, codec_channels); |
| 676 | out_file_.Close(); |
tina.legrand@webrtc.org | df69775 | 2012-02-08 10:22:21 +0000 | [diff] [blame] | 677 | #endif |
tina.legrand@webrtc.org | 0ad3c1a | 2012-11-07 08:07:29 +0000 | [diff] [blame] | 678 | #ifdef WEBRTC_CODEC_OPUS |
tina.legrand@webrtc.org | 46d90dc | 2013-02-01 14:20:06 +0000 | [diff] [blame] | 679 | if (test_mode_ != 0) { |
tina.legrand@webrtc.org | 0ad3c1a | 2012-11-07 08:07:29 +0000 | [diff] [blame] | 680 | printf("===============================================================\n"); |
tina.legrand@webrtc.org | a092cbf | 2013-02-14 09:28:10 +0000 | [diff] [blame] | 681 | printf("Test number: %d\n", test_cntr_ + 1); |
tina.legrand@webrtc.org | 0ad3c1a | 2012-11-07 08:07:29 +0000 | [diff] [blame] | 682 | printf("Test type: Stereo-to-mono\n"); |
| 683 | } |
| 684 | test_cntr_++; |
| 685 | OpenOutFile(test_cntr_); |
tina.legrand@webrtc.org | c459058 | 2012-11-28 12:23:29 +0000 | [diff] [blame] | 686 | // Encode and decode in mono. |
tina.legrand@webrtc.org | 0ad3c1a | 2012-11-07 08:07:29 +0000 | [diff] [blame] | 687 | RegisterSendCodec('A', codec_opus, 48000, 32000, 960, codec_channels, |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 688 | opus_pltype_); |
tina.legrand@webrtc.org | c459058 | 2012-11-28 12:23:29 +0000 | [diff] [blame] | 689 | CodecInst opus_codec_param; |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 690 | for (uint8_t n = 0; n < num_encoders; n++) { |
tina.legrand@webrtc.org | 7a7a008 | 2013-02-21 10:27:48 +0000 | [diff] [blame] | 691 | EXPECT_EQ(0, acm_b_->Codec(n, &opus_codec_param)); |
tina.legrand@webrtc.org | c459058 | 2012-11-28 12:23:29 +0000 | [diff] [blame] | 692 | if (!strcmp(opus_codec_param.plname, "opus")) { |
| 693 | opus_codec_param.channels = 1; |
| 694 | EXPECT_EQ(0, acm_b_->RegisterReceiveCodec(opus_codec_param)); |
| 695 | break; |
| 696 | } |
| 697 | } |
| 698 | Run(channel_a2b_, audio_channels, codec_channels); |
| 699 | |
| 700 | // Encode in stereo, decode in mono. |
| 701 | RegisterSendCodec('A', codec_opus, 48000, 32000, 960, 2, opus_pltype_); |
| 702 | Run(channel_a2b_, audio_channels, codec_channels); |
| 703 | |
| 704 | out_file_.Close(); |
| 705 | |
| 706 | // Test switching between decoding mono and stereo for Opus. |
| 707 | |
| 708 | // Decode in mono. |
| 709 | test_cntr_++; |
| 710 | OpenOutFile(test_cntr_); |
| 711 | if (test_mode_ != 0) { |
| 712 | // Print out codec and settings |
| 713 | printf("Test number: %d\nCodec: Opus Freq: 48000 Rate :32000 PackSize: 960" |
| 714 | " Decode: mono\n", test_cntr_); |
| 715 | } |
tina.legrand@webrtc.org | 0ad3c1a | 2012-11-07 08:07:29 +0000 | [diff] [blame] | 716 | Run(channel_a2b_, audio_channels, codec_channels); |
| 717 | out_file_.Close(); |
tina.legrand@webrtc.org | c459058 | 2012-11-28 12:23:29 +0000 | [diff] [blame] | 718 | // Decode in stereo. |
| 719 | test_cntr_++; |
| 720 | OpenOutFile(test_cntr_); |
| 721 | if (test_mode_ != 0) { |
| 722 | // Print out codec and settings |
| 723 | printf("Test number: %d\nCodec: Opus Freq: 48000 Rate :32000 PackSize: 960" |
| 724 | " Decode: stereo\n", test_cntr_); |
| 725 | } |
| 726 | opus_codec_param.channels = 2; |
| 727 | EXPECT_EQ(0, acm_b_->RegisterReceiveCodec(opus_codec_param)); |
| 728 | Run(channel_a2b_, audio_channels, 2); |
| 729 | out_file_.Close(); |
| 730 | // Decode in mono. |
| 731 | test_cntr_++; |
| 732 | OpenOutFile(test_cntr_); |
| 733 | if (test_mode_ != 0) { |
| 734 | // Print out codec and settings |
| 735 | printf("Test number: %d\nCodec: Opus Freq: 48000 Rate :32000 PackSize: 960" |
| 736 | " Decode: mono\n", test_cntr_); |
| 737 | } |
| 738 | opus_codec_param.channels = 1; |
| 739 | EXPECT_EQ(0, acm_b_->RegisterReceiveCodec(opus_codec_param)); |
| 740 | Run(channel_a2b_, audio_channels, codec_channels); |
| 741 | out_file_.Close(); |
| 742 | |
tina.legrand@webrtc.org | 0ad3c1a | 2012-11-07 08:07:29 +0000 | [diff] [blame] | 743 | #endif |
tina.legrand@webrtc.org | 6b6ff55 | 2012-01-11 10:12:54 +0000 | [diff] [blame] | 744 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 745 | // Print out which codecs were tested, and which were not, in the run. |
| 746 | if (test_mode_ != 0) { |
| 747 | printf("\nThe following codecs was INCLUDED in the test:\n"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 748 | #ifdef WEBRTC_CODEC_G722 |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 749 | printf(" G.722\n"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 750 | #endif |
| 751 | #ifdef WEBRTC_CODEC_PCM16 |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 752 | printf(" PCM16\n"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 753 | #endif |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 754 | printf(" G.711\n"); |
tina.legrand@webrtc.org | 3ddc974 | 2012-06-27 09:25:50 +0000 | [diff] [blame] | 755 | #ifdef WEBRTC_CODEC_CELT |
| 756 | printf(" CELT\n"); |
| 757 | #endif |
tina.legrand@webrtc.org | c459058 | 2012-11-28 12:23:29 +0000 | [diff] [blame] | 758 | #ifdef WEBRTC_CODEC_OPUS |
| 759 | printf(" Opus\n"); |
| 760 | #endif |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 761 | printf("\nTo complete the test, listen to the %d number of output " |
| 762 | "files.\n", |
| 763 | test_cntr_); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 764 | } |
| 765 | |
| 766 | // Delete the file pointers. |
| 767 | delete in_file_stereo_; |
| 768 | delete in_file_mono_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 769 | } |
| 770 | |
| 771 | // Register Codec to use in the test |
| 772 | // |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 773 | // Input: side - which ACM to use, 'A' or 'B' |
| 774 | // codec_name - name to use when register the codec |
| 775 | // sampling_freq_hz - sampling frequency in Herz |
| 776 | // rate - bitrate in bytes |
| 777 | // pack_size - packet size in samples |
| 778 | // channels - number of channels; 1 for mono, 2 for stereo |
| 779 | // payload_type - payload type for the codec |
tina.legrand@webrtc.org | 3ddc974 | 2012-06-27 09:25:50 +0000 | [diff] [blame] | 780 | void TestStereo::RegisterSendCodec(char side, char* codec_name, |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 781 | int32_t sampling_freq_hz, int rate, |
tina.legrand@webrtc.org | 3ddc974 | 2012-06-27 09:25:50 +0000 | [diff] [blame] | 782 | int pack_size, int channels, |
| 783 | int payload_type) { |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 784 | if (test_mode_ != 0) { |
| 785 | // Print out codec and settings |
tina.legrand@webrtc.org | ba46804 | 2012-08-17 10:38:28 +0000 | [diff] [blame] | 786 | printf("Codec: %s Freq: %d Rate: %d PackSize: %d\n", codec_name, |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 787 | sampling_freq_hz, rate, pack_size); |
| 788 | } |
| 789 | |
| 790 | // Store packet size in samples, used to validate the received packet |
| 791 | pack_size_samp_ = pack_size; |
| 792 | |
| 793 | // Store the expected packet size in bytes, used to validate the received |
| 794 | // packet. Add 0.875 to always round up to a whole byte. |
| 795 | // For Celt the packet size in bytes is already counting the stereo part. |
| 796 | if (!strcmp(codec_name, "CELT")) { |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 797 | pack_size_bytes_ = (uint16_t)( |
tina.legrand@webrtc.org | a092cbf | 2013-02-14 09:28:10 +0000 | [diff] [blame] | 798 | static_cast<float>(pack_size * rate) / |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 799 | static_cast<float>(sampling_freq_hz * 8) + 0.875) / channels; |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 800 | } else { |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 801 | pack_size_bytes_ = (uint16_t)( |
tina.legrand@webrtc.org | a092cbf | 2013-02-14 09:28:10 +0000 | [diff] [blame] | 802 | static_cast<float>(pack_size * rate) / |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 803 | static_cast<float>(sampling_freq_hz * 8) + 0.875); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 804 | } |
| 805 | |
| 806 | // Set pointer to the ACM where to register the codec |
tina.legrand@webrtc.org | 3ddc974 | 2012-06-27 09:25:50 +0000 | [diff] [blame] | 807 | AudioCodingModule* my_acm = NULL; |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 808 | switch (side) { |
| 809 | case 'A': { |
| 810 | my_acm = acm_a_; |
| 811 | break; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 812 | } |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 813 | case 'B': { |
| 814 | my_acm = acm_b_; |
| 815 | break; |
tina.legrand@webrtc.org | 16b6b90 | 2012-04-12 11:02:38 +0000 | [diff] [blame] | 816 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 817 | default: |
tina.legrand@webrtc.org | 3ddc974 | 2012-06-27 09:25:50 +0000 | [diff] [blame] | 818 | break; |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 819 | } |
tina.legrand@webrtc.org | 3ddc974 | 2012-06-27 09:25:50 +0000 | [diff] [blame] | 820 | ASSERT_TRUE(my_acm != NULL); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 821 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 822 | CodecInst my_codec_param; |
| 823 | // Get all codec parameters before registering |
tina.legrand@webrtc.org | 7a7a008 | 2013-02-21 10:27:48 +0000 | [diff] [blame] | 824 | CHECK_ERROR(AudioCodingModule::Codec(codec_name, &my_codec_param, |
tina.legrand@webrtc.org | 4517585 | 2012-06-01 09:27:35 +0000 | [diff] [blame] | 825 | sampling_freq_hz, channels)); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 826 | my_codec_param.rate = rate; |
| 827 | my_codec_param.pacsize = pack_size; |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 828 | CHECK_ERROR(my_acm->RegisterSendCodec(my_codec_param)); |
tina.legrand@webrtc.org | 0ad3c1a | 2012-11-07 08:07:29 +0000 | [diff] [blame] | 829 | |
| 830 | send_codec_name_ = codec_name; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 831 | } |
| 832 | |
tina.legrand@webrtc.org | 16b6b90 | 2012-04-12 11:02:38 +0000 | [diff] [blame] | 833 | void TestStereo::Run(TestPackStereo* channel, int in_channels, int out_channels, |
| 834 | int percent_loss) { |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 835 | AudioFrame audio_frame; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 836 | |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 837 | int32_t out_freq_hz_b = out_file_.SamplingFrequency(); |
| 838 | uint16_t rec_size; |
| 839 | uint32_t time_stamp_diff; |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 840 | channel->reset_payload_size(); |
| 841 | int error_count = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 842 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 843 | while (1) { |
| 844 | // Simulate packet loss by setting |packet_loss_| to "true" in |
| 845 | // |percent_loss| percent of the loops. |
| 846 | if (percent_loss > 0) { |
| 847 | if (counter_ == floor((100 / percent_loss) + 0.5)) { |
| 848 | counter_ = 0; |
| 849 | channel->set_lost_packet(true); |
| 850 | } else { |
| 851 | channel->set_lost_packet(false); |
| 852 | } |
| 853 | counter_++; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 854 | } |
| 855 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 856 | // Add 10 msec to ACM |
| 857 | if (in_channels == 1) { |
| 858 | if (in_file_mono_->EndOfFile()) { |
| 859 | break; |
| 860 | } |
| 861 | in_file_mono_->Read10MsData(audio_frame); |
| 862 | } else { |
| 863 | if (in_file_stereo_->EndOfFile()) { |
| 864 | break; |
| 865 | } |
| 866 | in_file_stereo_->Read10MsData(audio_frame); |
| 867 | } |
| 868 | CHECK_ERROR(acm_a_->Add10MsData(audio_frame)); |
| 869 | |
| 870 | // Run sender side of ACM |
| 871 | CHECK_ERROR(acm_a_->Process()); |
| 872 | |
| 873 | // Verify that the received packet size matches the settings |
| 874 | rec_size = channel->payload_size(); |
| 875 | if ((0 < rec_size) & (rec_size < 65535)) { |
tina.legrand@webrtc.org | 0ad3c1a | 2012-11-07 08:07:29 +0000 | [diff] [blame] | 876 | // Opus is variable rate, skip this test. |
| 877 | if (strcmp(send_codec_name_, "opus")) { |
| 878 | if ((rec_size != pack_size_bytes_ * out_channels) |
| 879 | && (pack_size_bytes_ < 65535)) { |
| 880 | error_count++; |
| 881 | } |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 882 | } |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 883 | // Verify that the timestamp is updated with expected length |
| 884 | time_stamp_diff = channel->timestamp_diff(); |
| 885 | if ((counter_ > 10) && (time_stamp_diff != pack_size_samp_)) { |
| 886 | error_count++; |
| 887 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 888 | } |
| 889 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 890 | // Run received side of ACM |
tina.legrand@webrtc.org | 7a7a008 | 2013-02-21 10:27:48 +0000 | [diff] [blame] | 891 | CHECK_ERROR(acm_b_->PlayoutData10Ms(out_freq_hz_b, &audio_frame)); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 892 | |
| 893 | // Write output speech to file |
| 894 | out_file_.Write10MsData( |
andrew@webrtc.org | 63a5098 | 2012-05-02 23:56:37 +0000 | [diff] [blame] | 895 | audio_frame.data_, |
| 896 | audio_frame.samples_per_channel_ * audio_frame.num_channels_); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 897 | } |
| 898 | |
tina.legrand@webrtc.org | 3ddc974 | 2012-06-27 09:25:50 +0000 | [diff] [blame] | 899 | EXPECT_EQ(0, error_count); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 900 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 901 | if (in_file_mono_->EndOfFile()) { |
| 902 | in_file_mono_->Rewind(); |
| 903 | } |
| 904 | if (in_file_stereo_->EndOfFile()) { |
| 905 | in_file_stereo_->Rewind(); |
| 906 | } |
| 907 | // Reset in case we ended with a lost packet |
| 908 | channel->set_lost_packet(false); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 909 | } |
| 910 | |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 911 | void TestStereo::OpenOutFile(int16_t test_number) { |
tina.legrand@webrtc.org | ba46804 | 2012-08-17 10:38:28 +0000 | [diff] [blame] | 912 | std::string file_name; |
| 913 | std::stringstream file_stream; |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 914 | file_stream << webrtc::test::OutputPath() << "teststereo_out_" << test_number |
| 915 | << ".pcm"; |
tina.legrand@webrtc.org | ba46804 | 2012-08-17 10:38:28 +0000 | [diff] [blame] | 916 | file_name = file_stream.str(); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 917 | out_file_.Open(file_name, 32000, "wb"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 918 | } |
| 919 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 920 | void TestStereo::DisplaySendReceiveCodec() { |
| 921 | CodecInst my_codec_param; |
tina.legrand@webrtc.org | 7a7a008 | 2013-02-21 10:27:48 +0000 | [diff] [blame] | 922 | acm_a_->SendCodec(&my_codec_param); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 923 | if (test_mode_ != 0) { |
| 924 | printf("%s -> ", my_codec_param.plname); |
| 925 | } |
tina.legrand@webrtc.org | 7a7a008 | 2013-02-21 10:27:48 +0000 | [diff] [blame] | 926 | acm_b_->ReceiveCodec(&my_codec_param); |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 927 | if (test_mode_ != 0) { |
| 928 | printf("%s\n", my_codec_param.plname); |
| 929 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 930 | } |
| 931 | |
tina.legrand@webrtc.org | a6ecd1e | 2012-04-26 07:54:30 +0000 | [diff] [blame] | 932 | } // namespace webrtc |