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