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