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