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/TestAllCodecs.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 12 | |
tina.legrand@webrtc.org | 5e7ca60 | 2012-06-12 07:16:24 +0000 | [diff] [blame] | 13 | #include <stdio.h> |
tina.legrand@webrtc.org | 5e7ca60 | 2012-06-12 07:16:24 +0000 | [diff] [blame] | 14 | #include <string> |
kjellander@webrtc.org | 5490c71 | 2011-12-21 13:34:18 +0000 | [diff] [blame] | 15 | |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 16 | #include "gtest/gtest.h" |
| 17 | |
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.h" |
| 21 | #include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h" |
| 22 | #include "webrtc/modules/audio_coding/main/test/utility.h" |
| 23 | #include "webrtc/system_wrappers/interface/trace.h" |
| 24 | #include "webrtc/test/testsupport/fileutils.h" |
| 25 | #include "webrtc/typedefs.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 26 | |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 27 | // Description of the test: |
| 28 | // In this test we set up a one-way communication channel from a participant |
| 29 | // called "a" to a participant called "b". |
| 30 | // a -> channel_a_to_b -> b |
| 31 | // |
| 32 | // The test loops through all available mono codecs, encode at "a" sends over |
| 33 | // the channel, and decodes at "b". |
| 34 | |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 35 | namespace webrtc { |
| 36 | |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 37 | // Class for simulating packet handling. |
| 38 | TestPack::TestPack() |
| 39 | : receiver_acm_(NULL), |
| 40 | sequence_number_(0), |
| 41 | timestamp_diff_(0), |
| 42 | last_in_timestamp_(0), |
| 43 | total_bytes_(0), |
| 44 | payload_size_(0) { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 45 | } |
| 46 | |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 47 | TestPack::~TestPack() { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 48 | } |
| 49 | |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 50 | void TestPack::RegisterReceiverACM(AudioCodingModule* acm) { |
| 51 | receiver_acm_ = acm; |
| 52 | return; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 53 | } |
| 54 | |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 55 | int32_t TestPack::SendData(FrameType frame_type, uint8_t payload_type, |
| 56 | uint32_t timestamp, const uint8_t* payload_data, |
| 57 | uint16_t payload_size, |
| 58 | const RTPFragmentationHeader* fragmentation) { |
| 59 | WebRtcRTPHeader rtp_info; |
| 60 | int32_t status; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 61 | |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 62 | rtp_info.header.markerBit = false; |
| 63 | rtp_info.header.ssrc = 0; |
| 64 | rtp_info.header.sequenceNumber = sequence_number_++; |
| 65 | rtp_info.header.payloadType = payload_type; |
| 66 | rtp_info.header.timestamp = timestamp; |
| 67 | if (frame_type == kAudioFrameCN) { |
| 68 | rtp_info.type.Audio.isCNG = true; |
| 69 | } else { |
| 70 | rtp_info.type.Audio.isCNG = false; |
| 71 | } |
| 72 | if (frame_type == kFrameEmpty) { |
| 73 | // Skip this frame. |
| 74 | return 0; |
| 75 | } |
| 76 | |
| 77 | // Only run mono for all test cases. |
| 78 | rtp_info.type.Audio.channel = 1; |
| 79 | memcpy(payload_data_, payload_data, payload_size); |
| 80 | |
| 81 | status = receiver_acm_->IncomingPacket(payload_data_, payload_size, |
| 82 | rtp_info); |
| 83 | |
| 84 | payload_size_ = payload_size; |
| 85 | timestamp_diff_ = timestamp - last_in_timestamp_; |
| 86 | last_in_timestamp_ = timestamp; |
| 87 | total_bytes_ += payload_size; |
| 88 | return status; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 89 | } |
| 90 | |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 91 | uint16_t TestPack::payload_size() { |
| 92 | return payload_size_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 93 | } |
| 94 | |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 95 | uint32_t TestPack::timestamp_diff() { |
| 96 | return timestamp_diff_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 97 | } |
| 98 | |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 99 | void TestPack::reset_payload_size() { |
| 100 | payload_size_ = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 101 | } |
| 102 | |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 103 | TestAllCodecs::TestAllCodecs(int test_mode) |
| 104 | : acm_a_(NULL), |
| 105 | acm_b_(NULL), |
| 106 | channel_a_to_b_(NULL), |
| 107 | test_count_(0), |
| 108 | packet_size_samples_(0), |
| 109 | packet_size_bytes_(0) { |
| 110 | // test_mode = 0 for silent test (auto test) |
| 111 | test_mode_ = test_mode; |
| 112 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 113 | |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 114 | TestAllCodecs::~TestAllCodecs() { |
| 115 | if (acm_a_ != NULL) { |
| 116 | AudioCodingModule::Destroy(acm_a_); |
| 117 | acm_a_ = NULL; |
| 118 | } |
| 119 | if (acm_b_ != NULL) { |
| 120 | AudioCodingModule::Destroy(acm_b_); |
| 121 | acm_b_ = NULL; |
| 122 | } |
| 123 | if (channel_a_to_b_ != NULL) { |
| 124 | delete channel_a_to_b_; |
| 125 | channel_a_to_b_ = NULL; |
| 126 | } |
| 127 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 128 | |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 129 | void TestAllCodecs::Perform() { |
tina.legrand@webrtc.org | ba46804 | 2012-08-17 10:38:28 +0000 | [diff] [blame] | 130 | const std::string file_name = |
| 131 | webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"); |
| 132 | infile_a_.Open(file_name, 32000, "rb"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 133 | |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 134 | if (test_mode_ == 0) { |
| 135 | WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1, |
| 136 | "---------- TestAllCodecs ----------"); |
| 137 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 138 | |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 139 | acm_a_ = AudioCodingModule::Create(0); |
| 140 | acm_b_ = AudioCodingModule::Create(1); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 141 | |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 142 | acm_a_->InitializeReceiver(); |
| 143 | acm_b_->InitializeReceiver(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 144 | |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 145 | uint8_t num_encoders = acm_a_->NumberOfCodecs(); |
| 146 | CodecInst my_codec_param; |
| 147 | for (uint8_t n = 0; n < num_encoders; n++) { |
| 148 | acm_b_->Codec(n, my_codec_param); |
tina.legrand@webrtc.org | c459058 | 2012-11-28 12:23:29 +0000 | [diff] [blame] | 149 | if (!strcmp(my_codec_param.plname, "opus")) { |
| 150 | my_codec_param.channels = 1; |
| 151 | } |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 152 | acm_b_->RegisterReceiveCodec(my_codec_param); |
| 153 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 154 | |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 155 | // Create and connect the channel |
| 156 | channel_a_to_b_ = new TestPack; |
| 157 | acm_a_->RegisterTransportCallback(channel_a_to_b_); |
| 158 | channel_a_to_b_->RegisterReceiverACM(acm_b_); |
| 159 | |
| 160 | // All codecs are tested for all allowed sampling frequencies, rates and |
| 161 | // packet sizes. |
| 162 | #ifdef WEBRTC_CODEC_AMR |
| 163 | if (test_mode_ != 0) { |
| 164 | printf("===============================================================\n"); |
| 165 | } |
| 166 | test_count_++; |
| 167 | OpenOutFile(test_count_); |
| 168 | char codec_amr[] = "AMR"; |
| 169 | RegisterSendCodec('A', codec_amr, 8000, 4750, 160, 2); |
| 170 | Run(channel_a_to_b_); |
| 171 | RegisterSendCodec('A', codec_amr, 8000, 4750, 320, 2); |
| 172 | Run(channel_a_to_b_); |
| 173 | RegisterSendCodec('A', codec_amr, 8000, 4750, 480, 3); |
| 174 | Run(channel_a_to_b_); |
| 175 | RegisterSendCodec('A', codec_amr, 8000, 5150, 160, 2); |
| 176 | Run(channel_a_to_b_); |
| 177 | RegisterSendCodec('A', codec_amr, 8000, 5150, 320, 2); |
| 178 | Run(channel_a_to_b_); |
| 179 | RegisterSendCodec('A', codec_amr, 8000, 5150, 480, 3); |
| 180 | Run(channel_a_to_b_); |
| 181 | RegisterSendCodec('A', codec_amr, 8000, 5900, 160, 1); |
| 182 | Run(channel_a_to_b_); |
| 183 | RegisterSendCodec('A', codec_amr, 8000, 5900, 320, 2); |
| 184 | Run(channel_a_to_b_); |
| 185 | RegisterSendCodec('A', codec_amr, 8000, 5900, 480, 2); |
| 186 | Run(channel_a_to_b_); |
| 187 | RegisterSendCodec('A', codec_amr, 8000, 6700, 160, 1); |
| 188 | Run(channel_a_to_b_); |
| 189 | RegisterSendCodec('A', codec_amr, 8000, 6700, 320, 2); |
| 190 | Run(channel_a_to_b_); |
| 191 | RegisterSendCodec('A', codec_amr, 8000, 6700, 480, 2); |
| 192 | Run(channel_a_to_b_); |
| 193 | RegisterSendCodec('A', codec_amr, 8000, 7400, 160, 1); |
| 194 | Run(channel_a_to_b_); |
| 195 | RegisterSendCodec('A', codec_amr, 8000, 7400, 320, 2); |
| 196 | Run(channel_a_to_b_); |
| 197 | RegisterSendCodec('A', codec_amr, 8000, 7400, 480, 3); |
| 198 | Run(channel_a_to_b_); |
| 199 | RegisterSendCodec('A', codec_amr, 8000, 7950, 160, 2); |
| 200 | Run(channel_a_to_b_); |
| 201 | RegisterSendCodec('A', codec_amr, 8000, 7950, 320, 2); |
| 202 | Run(channel_a_to_b_); |
| 203 | RegisterSendCodec('A', codec_amr, 8000, 7950, 480, 3); |
| 204 | Run(channel_a_to_b_); |
| 205 | RegisterSendCodec('A', codec_amr, 8000, 10200, 160, 1); |
| 206 | Run(channel_a_to_b_); |
| 207 | RegisterSendCodec('A', codec_amr, 8000, 10200, 320, 2); |
| 208 | Run(channel_a_to_b_); |
| 209 | RegisterSendCodec('A', codec_amr, 8000, 10200, 480, 3); |
| 210 | Run(channel_a_to_b_); |
| 211 | RegisterSendCodec('A', codec_amr, 8000, 12200, 160, 1); |
| 212 | Run(channel_a_to_b_); |
| 213 | RegisterSendCodec('A', codec_amr, 8000, 12200, 320, 2); |
| 214 | Run(channel_a_to_b_); |
| 215 | RegisterSendCodec('A', codec_amr, 8000, 12200, 480, 3); |
| 216 | Run(channel_a_to_b_); |
| 217 | outfile_b_.Close(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 218 | #endif |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 219 | #ifdef WEBRTC_CODEC_AMRWB |
| 220 | if (test_mode_ != 0) { |
| 221 | printf("===============================================================\n"); |
| 222 | } |
| 223 | test_count_++; |
| 224 | char codec_amrwb[] = "AMR-WB"; |
| 225 | OpenOutFile(test_count_); |
| 226 | RegisterSendCodec('A', codec_amrwb, 16000, 7000, 320, 0); |
| 227 | Run(channel_a_to_b_); |
| 228 | RegisterSendCodec('A', codec_amrwb, 16000, 7000, 640, 0); |
| 229 | Run(channel_a_to_b_); |
| 230 | RegisterSendCodec('A', codec_amrwb, 16000, 7000, 960, 0); |
| 231 | Run(channel_a_to_b_); |
| 232 | RegisterSendCodec('A', codec_amrwb, 16000, 9000, 320, 1); |
| 233 | Run(channel_a_to_b_); |
| 234 | RegisterSendCodec('A', codec_amrwb, 16000, 9000, 640, 2); |
| 235 | Run(channel_a_to_b_); |
| 236 | RegisterSendCodec('A', codec_amrwb, 16000, 9000, 960, 2); |
| 237 | Run(channel_a_to_b_); |
| 238 | RegisterSendCodec('A', codec_amrwb, 16000, 12000, 320, 3); |
| 239 | Run(channel_a_to_b_); |
| 240 | RegisterSendCodec('A', codec_amrwb, 16000, 12000, 640, 6); |
| 241 | Run(channel_a_to_b_); |
| 242 | RegisterSendCodec('A', codec_amrwb, 16000, 12000, 960, 8); |
| 243 | Run(channel_a_to_b_); |
| 244 | RegisterSendCodec('A', codec_amrwb, 16000, 14000, 320, 2); |
| 245 | Run(channel_a_to_b_); |
| 246 | RegisterSendCodec('A', codec_amrwb, 16000, 14000, 640, 4); |
| 247 | Run(channel_a_to_b_); |
| 248 | RegisterSendCodec('A', codec_amrwb, 16000, 14000, 960, 5); |
| 249 | Run(channel_a_to_b_); |
| 250 | RegisterSendCodec('A', codec_amrwb, 16000, 16000, 320, 1); |
| 251 | Run(channel_a_to_b_); |
| 252 | RegisterSendCodec('A', codec_amrwb, 16000, 16000, 640, 2); |
| 253 | Run(channel_a_to_b_); |
| 254 | RegisterSendCodec('A', codec_amrwb, 16000, 16000, 960, 2); |
| 255 | Run(channel_a_to_b_); |
| 256 | RegisterSendCodec('A', codec_amrwb, 16000, 18000, 320, 2); |
| 257 | Run(channel_a_to_b_); |
| 258 | RegisterSendCodec('A', codec_amrwb, 16000, 18000, 640, 4); |
| 259 | Run(channel_a_to_b_); |
| 260 | RegisterSendCodec('A', codec_amrwb, 16000, 18000, 960, 5); |
| 261 | Run(channel_a_to_b_); |
| 262 | RegisterSendCodec('A', codec_amrwb, 16000, 20000, 320, 1); |
| 263 | Run(channel_a_to_b_); |
| 264 | RegisterSendCodec('A', codec_amrwb, 16000, 20000, 640, 2); |
| 265 | Run(channel_a_to_b_); |
| 266 | RegisterSendCodec('A', codec_amrwb, 16000, 20000, 960, 2); |
| 267 | Run(channel_a_to_b_); |
| 268 | RegisterSendCodec('A', codec_amrwb, 16000, 23000, 320, 1); |
| 269 | Run(channel_a_to_b_); |
| 270 | RegisterSendCodec('A', codec_amrwb, 16000, 23000, 640, 3); |
| 271 | Run(channel_a_to_b_); |
| 272 | RegisterSendCodec('A', codec_amrwb, 16000, 23000, 960, 3); |
| 273 | Run(channel_a_to_b_); |
| 274 | RegisterSendCodec('A', codec_amrwb, 16000, 24000, 320, 1); |
| 275 | Run(channel_a_to_b_); |
| 276 | RegisterSendCodec('A', codec_amrwb, 16000, 24000, 640, 2); |
| 277 | Run(channel_a_to_b_); |
| 278 | RegisterSendCodec('A', codec_amrwb, 16000, 24000, 960, 2); |
| 279 | Run(channel_a_to_b_); |
| 280 | outfile_b_.Close(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 281 | #endif |
| 282 | #ifdef WEBRTC_CODEC_G722 |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 283 | if (test_mode_ != 0) { |
| 284 | printf("===============================================================\n"); |
| 285 | } |
| 286 | test_count_++; |
| 287 | OpenOutFile(test_count_); |
| 288 | char codec_g722[] = "G722"; |
| 289 | RegisterSendCodec('A', codec_g722, 16000, 64000, 160, 0); |
| 290 | Run(channel_a_to_b_); |
| 291 | RegisterSendCodec('A', codec_g722, 16000, 64000, 320, 0); |
| 292 | Run(channel_a_to_b_); |
| 293 | RegisterSendCodec('A', codec_g722, 16000, 64000, 480, 0); |
| 294 | Run(channel_a_to_b_); |
| 295 | RegisterSendCodec('A', codec_g722, 16000, 64000, 640, 0); |
| 296 | Run(channel_a_to_b_); |
| 297 | RegisterSendCodec('A', codec_g722, 16000, 64000, 800, 0); |
| 298 | Run(channel_a_to_b_); |
| 299 | RegisterSendCodec('A', codec_g722, 16000, 64000, 960, 0); |
| 300 | Run(channel_a_to_b_); |
| 301 | outfile_b_.Close(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 302 | #endif |
| 303 | #ifdef WEBRTC_CODEC_G722_1 |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 304 | if (test_mode_ != 0) { |
| 305 | printf("===============================================================\n"); |
| 306 | } |
| 307 | test_count_++; |
| 308 | OpenOutFile(test_count_); |
| 309 | char codec_g722_1[] = "G7221"; |
| 310 | RegisterSendCodec('A', codec_g722_1, 16000, 32000, 320, 0); |
| 311 | Run(channel_a_to_b_); |
| 312 | RegisterSendCodec('A', codec_g722_1, 16000, 24000, 320, 0); |
| 313 | Run(channel_a_to_b_); |
| 314 | RegisterSendCodec('A', codec_g722_1, 16000, 16000, 320, 0); |
| 315 | Run(channel_a_to_b_); |
| 316 | outfile_b_.Close(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 317 | #endif |
| 318 | #ifdef WEBRTC_CODEC_G722_1C |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 319 | if (test_mode_ != 0) { |
| 320 | printf("===============================================================\n"); |
| 321 | } |
| 322 | test_count_++; |
| 323 | OpenOutFile(test_count_); |
| 324 | char codec_g722_1c[] = "G7221"; |
| 325 | RegisterSendCodec('A', codec_g722_1c, 32000, 48000, 640, 0); |
| 326 | Run(channel_a_to_b_); |
| 327 | RegisterSendCodec('A', codec_g722_1c, 32000, 32000, 640, 0); |
| 328 | Run(channel_a_to_b_); |
| 329 | RegisterSendCodec('A', codec_g722_1c, 32000, 24000, 640, 0); |
| 330 | Run(channel_a_to_b_); |
| 331 | outfile_b_.Close(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 332 | #endif |
| 333 | #ifdef WEBRTC_CODEC_G729 |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 334 | if (test_mode_ != 0) { |
| 335 | printf("===============================================================\n"); |
| 336 | } |
| 337 | test_count_++; |
| 338 | OpenOutFile(test_count_); |
| 339 | char codec_g729[] = "G729"; |
| 340 | RegisterSendCodec('A', codec_g729, 8000, 8000, 80, 0); |
| 341 | Run(channel_a_to_b_); |
| 342 | RegisterSendCodec('A', codec_g729, 8000, 8000, 160, 0); |
| 343 | Run(channel_a_to_b_); |
| 344 | RegisterSendCodec('A', codec_g729, 8000, 8000, 240, 0); |
| 345 | Run(channel_a_to_b_); |
| 346 | RegisterSendCodec('A', codec_g729, 8000, 8000, 320, 0); |
| 347 | Run(channel_a_to_b_); |
| 348 | RegisterSendCodec('A', codec_g729, 8000, 8000, 400, 0); |
| 349 | Run(channel_a_to_b_); |
| 350 | RegisterSendCodec('A', codec_g729, 8000, 8000, 480, 0); |
| 351 | Run(channel_a_to_b_); |
| 352 | outfile_b_.Close(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 353 | #endif |
| 354 | #ifdef WEBRTC_CODEC_G729_1 |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 355 | if (test_mode_ != 0) { |
| 356 | printf("===============================================================\n"); |
| 357 | } |
| 358 | test_count_++; |
| 359 | OpenOutFile(test_count_); |
| 360 | char codec_g729_1[] = "G7291"; |
| 361 | RegisterSendCodec('A', codec_g729_1, 16000, 8000, 320, 1); |
| 362 | Run(channel_a_to_b_); |
| 363 | RegisterSendCodec('A', codec_g729_1, 16000, 8000, 640, 1); |
| 364 | Run(channel_a_to_b_); |
| 365 | RegisterSendCodec('A', codec_g729_1, 16000, 8000, 960, 1); |
| 366 | Run(channel_a_to_b_); |
| 367 | RegisterSendCodec('A', codec_g729_1, 16000, 12000, 320, 1); |
| 368 | Run(channel_a_to_b_); |
| 369 | RegisterSendCodec('A', codec_g729_1, 16000, 12000, 640, 1); |
| 370 | Run(channel_a_to_b_); |
| 371 | RegisterSendCodec('A', codec_g729_1, 16000, 12000, 960, 1); |
| 372 | Run(channel_a_to_b_); |
| 373 | RegisterSendCodec('A', codec_g729_1, 16000, 14000, 320, 1); |
| 374 | Run(channel_a_to_b_); |
| 375 | RegisterSendCodec('A', codec_g729_1, 16000, 14000, 640, 1); |
| 376 | Run(channel_a_to_b_); |
| 377 | RegisterSendCodec('A', codec_g729_1, 16000, 14000, 960, 1); |
| 378 | Run(channel_a_to_b_); |
| 379 | RegisterSendCodec('A', codec_g729_1, 16000, 16000, 320, 1); |
| 380 | Run(channel_a_to_b_); |
| 381 | RegisterSendCodec('A', codec_g729_1, 16000, 16000, 640, 1); |
| 382 | Run(channel_a_to_b_); |
| 383 | RegisterSendCodec('A', codec_g729_1, 16000, 16000, 960, 1); |
| 384 | Run(channel_a_to_b_); |
| 385 | RegisterSendCodec('A', codec_g729_1, 16000, 18000, 320, 1); |
| 386 | Run(channel_a_to_b_); |
| 387 | RegisterSendCodec('A', codec_g729_1, 16000, 18000, 640, 1); |
| 388 | Run(channel_a_to_b_); |
| 389 | RegisterSendCodec('A', codec_g729_1, 16000, 18000, 960, 1); |
| 390 | Run(channel_a_to_b_); |
| 391 | RegisterSendCodec('A', codec_g729_1, 16000, 20000, 320, 1); |
| 392 | Run(channel_a_to_b_); |
| 393 | RegisterSendCodec('A', codec_g729_1, 16000, 20000, 640, 1); |
| 394 | Run(channel_a_to_b_); |
| 395 | RegisterSendCodec('A', codec_g729_1, 16000, 20000, 960, 1); |
| 396 | Run(channel_a_to_b_); |
| 397 | RegisterSendCodec('A', codec_g729_1, 16000, 22000, 320, 1); |
| 398 | Run(channel_a_to_b_); |
| 399 | RegisterSendCodec('A', codec_g729_1, 16000, 22000, 640, 1); |
| 400 | Run(channel_a_to_b_); |
| 401 | RegisterSendCodec('A', codec_g729_1, 16000, 22000, 960, 1); |
| 402 | Run(channel_a_to_b_); |
| 403 | RegisterSendCodec('A', codec_g729_1, 16000, 24000, 320, 1); |
| 404 | Run(channel_a_to_b_); |
| 405 | RegisterSendCodec('A', codec_g729_1, 16000, 24000, 640, 1); |
| 406 | Run(channel_a_to_b_); |
| 407 | RegisterSendCodec('A', codec_g729_1, 16000, 24000, 960, 1); |
| 408 | Run(channel_a_to_b_); |
| 409 | RegisterSendCodec('A', codec_g729_1, 16000, 26000, 320, 1); |
| 410 | Run(channel_a_to_b_); |
| 411 | RegisterSendCodec('A', codec_g729_1, 16000, 26000, 640, 1); |
| 412 | Run(channel_a_to_b_); |
| 413 | RegisterSendCodec('A', codec_g729_1, 16000, 26000, 960, 1); |
| 414 | Run(channel_a_to_b_); |
| 415 | RegisterSendCodec('A', codec_g729_1, 16000, 28000, 320, 1); |
| 416 | Run(channel_a_to_b_); |
| 417 | RegisterSendCodec('A', codec_g729_1, 16000, 28000, 640, 1); |
| 418 | Run(channel_a_to_b_); |
| 419 | RegisterSendCodec('A', codec_g729_1, 16000, 28000, 960, 1); |
| 420 | Run(channel_a_to_b_); |
| 421 | RegisterSendCodec('A', codec_g729_1, 16000, 30000, 320, 1); |
| 422 | Run(channel_a_to_b_); |
| 423 | RegisterSendCodec('A', codec_g729_1, 16000, 30000, 640, 1); |
| 424 | Run(channel_a_to_b_); |
| 425 | RegisterSendCodec('A', codec_g729_1, 16000, 30000, 960, 1); |
| 426 | Run(channel_a_to_b_); |
| 427 | RegisterSendCodec('A', codec_g729_1, 16000, 32000, 320, 1); |
| 428 | Run(channel_a_to_b_); |
| 429 | RegisterSendCodec('A', codec_g729_1, 16000, 32000, 640, 1); |
| 430 | Run(channel_a_to_b_); |
| 431 | RegisterSendCodec('A', codec_g729_1, 16000, 32000, 960, 1); |
| 432 | Run(channel_a_to_b_); |
| 433 | outfile_b_.Close(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 434 | #endif |
| 435 | #ifdef WEBRTC_CODEC_GSMFR |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 436 | if (test_mode_ != 0) { |
| 437 | printf("===============================================================\n"); |
| 438 | } |
| 439 | test_count_++; |
| 440 | OpenOutFile(test_count_); |
| 441 | char codec_gsmfr[] = "GSM"; |
| 442 | RegisterSendCodec('A', codec_gsmfr, 8000, 13200, 160, 0); |
| 443 | Run(channel_a_to_b_); |
| 444 | RegisterSendCodec('A', codec_gsmfr, 8000, 13200, 320, 0); |
| 445 | Run(channel_a_to_b_); |
| 446 | RegisterSendCodec('A', codec_gsmfr, 8000, 13200, 480, 0); |
| 447 | Run(channel_a_to_b_); |
| 448 | outfile_b_.Close(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 449 | #endif |
| 450 | #ifdef WEBRTC_CODEC_ILBC |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 451 | if (test_mode_ != 0) { |
| 452 | printf("===============================================================\n"); |
| 453 | } |
| 454 | test_count_++; |
| 455 | OpenOutFile(test_count_); |
| 456 | char codec_ilbc[] = "ILBC"; |
| 457 | RegisterSendCodec('A', codec_ilbc, 8000, 13300, 240, 0); |
| 458 | Run(channel_a_to_b_); |
| 459 | RegisterSendCodec('A', codec_ilbc, 8000, 13300, 480, 0); |
| 460 | Run(channel_a_to_b_); |
| 461 | RegisterSendCodec('A', codec_ilbc, 8000, 15200, 160, 0); |
| 462 | Run(channel_a_to_b_); |
| 463 | RegisterSendCodec('A', codec_ilbc, 8000, 15200, 320, 0); |
| 464 | Run(channel_a_to_b_); |
| 465 | outfile_b_.Close(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 466 | #endif |
| 467 | #if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)) |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 468 | if (test_mode_ != 0) { |
| 469 | printf("===============================================================\n"); |
| 470 | } |
| 471 | test_count_++; |
| 472 | OpenOutFile(test_count_); |
| 473 | char codec_isac[] = "ISAC"; |
| 474 | RegisterSendCodec('A', codec_isac, 16000, -1, 480, -1); |
| 475 | Run(channel_a_to_b_); |
| 476 | RegisterSendCodec('A', codec_isac, 16000, -1, 960, -1); |
| 477 | Run(channel_a_to_b_); |
| 478 | RegisterSendCodec('A', codec_isac, 16000, 15000, 480, -1); |
| 479 | Run(channel_a_to_b_); |
| 480 | RegisterSendCodec('A', codec_isac, 16000, 32000, 960, -1); |
| 481 | Run(channel_a_to_b_); |
| 482 | outfile_b_.Close(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 483 | #endif |
| 484 | #ifdef WEBRTC_CODEC_ISAC |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 485 | if (test_mode_ != 0) { |
| 486 | printf("===============================================================\n"); |
| 487 | } |
| 488 | test_count_++; |
| 489 | OpenOutFile(test_count_); |
| 490 | RegisterSendCodec('A', codec_isac, 32000, -1, 960, -1); |
| 491 | Run(channel_a_to_b_); |
| 492 | RegisterSendCodec('A', codec_isac, 32000, 56000, 960, -1); |
| 493 | Run(channel_a_to_b_); |
| 494 | RegisterSendCodec('A', codec_isac, 32000, 37000, 960, -1); |
| 495 | Run(channel_a_to_b_); |
| 496 | RegisterSendCodec('A', codec_isac, 32000, 32000, 960, -1); |
| 497 | Run(channel_a_to_b_); |
| 498 | outfile_b_.Close(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 499 | #endif |
| 500 | #ifdef WEBRTC_CODEC_PCM16 |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 501 | if (test_mode_ != 0) { |
| 502 | printf("===============================================================\n"); |
| 503 | } |
| 504 | test_count_++; |
| 505 | OpenOutFile(test_count_); |
| 506 | char codec_l16[] = "L16"; |
| 507 | RegisterSendCodec('A', codec_l16, 8000, 128000, 80, 0); |
| 508 | Run(channel_a_to_b_); |
| 509 | RegisterSendCodec('A', codec_l16, 8000, 128000, 160, 0); |
| 510 | Run(channel_a_to_b_); |
| 511 | RegisterSendCodec('A', codec_l16, 8000, 128000, 240, 0); |
| 512 | Run(channel_a_to_b_); |
| 513 | RegisterSendCodec('A', codec_l16, 8000, 128000, 320, 0); |
| 514 | Run(channel_a_to_b_); |
| 515 | outfile_b_.Close(); |
| 516 | if (test_mode_ != 0) { |
| 517 | printf("===============================================================\n"); |
| 518 | } |
| 519 | test_count_++; |
| 520 | OpenOutFile(test_count_); |
| 521 | RegisterSendCodec('A', codec_l16, 16000, 256000, 160, 0); |
| 522 | Run(channel_a_to_b_); |
| 523 | RegisterSendCodec('A', codec_l16, 16000, 256000, 320, 0); |
| 524 | Run(channel_a_to_b_); |
| 525 | RegisterSendCodec('A', codec_l16, 16000, 256000, 480, 0); |
| 526 | Run(channel_a_to_b_); |
| 527 | RegisterSendCodec('A', codec_l16, 16000, 256000, 640, 0); |
| 528 | Run(channel_a_to_b_); |
| 529 | outfile_b_.Close(); |
| 530 | if (test_mode_ != 0) { |
| 531 | printf("===============================================================\n"); |
| 532 | } |
| 533 | test_count_++; |
| 534 | OpenOutFile(test_count_); |
| 535 | RegisterSendCodec('A', codec_l16, 32000, 512000, 320, 0); |
| 536 | Run(channel_a_to_b_); |
| 537 | RegisterSendCodec('A', codec_l16, 32000, 512000, 640, 0); |
| 538 | Run(channel_a_to_b_); |
| 539 | outfile_b_.Close(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 540 | #endif |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 541 | if (test_mode_ != 0) { |
| 542 | printf("===============================================================\n"); |
| 543 | } |
| 544 | test_count_++; |
| 545 | OpenOutFile(test_count_); |
| 546 | char codec_pcma[] = "PCMA"; |
| 547 | RegisterSendCodec('A', codec_pcma, 8000, 64000, 80, 0); |
| 548 | Run(channel_a_to_b_); |
| 549 | RegisterSendCodec('A', codec_pcma, 8000, 64000, 160, 0); |
| 550 | Run(channel_a_to_b_); |
| 551 | RegisterSendCodec('A', codec_pcma, 8000, 64000, 240, 0); |
| 552 | Run(channel_a_to_b_); |
| 553 | RegisterSendCodec('A', codec_pcma, 8000, 64000, 320, 0); |
| 554 | Run(channel_a_to_b_); |
| 555 | RegisterSendCodec('A', codec_pcma, 8000, 64000, 400, 0); |
| 556 | Run(channel_a_to_b_); |
| 557 | RegisterSendCodec('A', codec_pcma, 8000, 64000, 480, 0); |
| 558 | Run(channel_a_to_b_); |
| 559 | if (test_mode_ != 0) { |
| 560 | printf("===============================================================\n"); |
| 561 | } |
| 562 | char codec_pcmu[] = "PCMU"; |
| 563 | RegisterSendCodec('A', codec_pcmu, 8000, 64000, 80, 0); |
| 564 | Run(channel_a_to_b_); |
| 565 | RegisterSendCodec('A', codec_pcmu, 8000, 64000, 160, 0); |
| 566 | Run(channel_a_to_b_); |
| 567 | RegisterSendCodec('A', codec_pcmu, 8000, 64000, 240, 0); |
| 568 | Run(channel_a_to_b_); |
| 569 | RegisterSendCodec('A', codec_pcmu, 8000, 64000, 320, 0); |
| 570 | Run(channel_a_to_b_); |
| 571 | RegisterSendCodec('A', codec_pcmu, 8000, 64000, 400, 0); |
| 572 | Run(channel_a_to_b_); |
| 573 | RegisterSendCodec('A', codec_pcmu, 8000, 64000, 480, 0); |
| 574 | Run(channel_a_to_b_); |
| 575 | outfile_b_.Close(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 576 | #ifdef WEBRTC_CODEC_SPEEX |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 577 | if (test_mode_ != 0) { |
| 578 | printf("===============================================================\n"); |
| 579 | } |
| 580 | test_count_++; |
| 581 | OpenOutFile(test_count_); |
| 582 | char codec_speex[] = "SPEEX"; |
| 583 | RegisterSendCodec('A', codec_speex, 8000, 2400, 160, 0); |
| 584 | Run(channel_a_to_b_); |
| 585 | RegisterSendCodec('A', codec_speex, 8000, 8000, 320, 0); |
| 586 | Run(channel_a_to_b_); |
| 587 | RegisterSendCodec('A', codec_speex, 8000, 18200, 480, 0); |
| 588 | Run(channel_a_to_b_); |
| 589 | outfile_b_.Close(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 590 | |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 591 | if (test_mode_ != 0) { |
| 592 | printf("===============================================================\n"); |
| 593 | } |
| 594 | test_count_++; |
| 595 | OpenOutFile(test_count_); |
| 596 | RegisterSendCodec('A', codec_speex, 16000, 4000, 320, 0); |
| 597 | Run(channel_a_to_b_); |
| 598 | RegisterSendCodec('A', codec_speex, 16000, 12800, 640, 0); |
| 599 | Run(channel_a_to_b_); |
| 600 | RegisterSendCodec('A', codec_speex, 16000, 34200, 960, 0); |
| 601 | Run(channel_a_to_b_); |
| 602 | outfile_b_.Close(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 603 | #endif |
tina.legrand@webrtc.org | df69775 | 2012-02-08 10:22:21 +0000 | [diff] [blame] | 604 | #ifdef WEBRTC_CODEC_CELT |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 605 | if (test_mode_ != 0) { |
| 606 | printf("===============================================================\n"); |
| 607 | } |
| 608 | test_count_++; |
| 609 | OpenOutFile(test_count_); |
| 610 | char codec_celt[] = "CELT"; |
| 611 | RegisterSendCodec('A', codec_celt, 32000, 48000, 640, 0); |
| 612 | Run(channel_a_to_b_); |
| 613 | RegisterSendCodec('A', codec_celt, 32000, 64000, 640, 0); |
| 614 | Run(channel_a_to_b_); |
| 615 | RegisterSendCodec('A', codec_celt, 32000, 128000, 640, 0); |
| 616 | Run(channel_a_to_b_); |
| 617 | outfile_b_.Close(); |
tina.legrand@webrtc.org | df69775 | 2012-02-08 10:22:21 +0000 | [diff] [blame] | 618 | #endif |
tina.legrand@webrtc.org | a7d8387 | 2012-10-18 10:00:52 +0000 | [diff] [blame] | 619 | #ifdef WEBRTC_CODEC_OPUS |
| 620 | if (test_mode_ != 0) { |
| 621 | printf("===============================================================\n"); |
| 622 | } |
| 623 | test_count_++; |
| 624 | OpenOutFile(test_count_); |
| 625 | char codec_opus[] = "OPUS"; |
tina.legrand@webrtc.org | 46d90dc | 2013-02-01 14:20:06 +0000 | [diff] [blame] | 626 | RegisterSendCodec('A', codec_opus, 48000, 6000, 480, -1); |
tina.legrand@webrtc.org | a7d8387 | 2012-10-18 10:00:52 +0000 | [diff] [blame] | 627 | Run(channel_a_to_b_); |
tina.legrand@webrtc.org | 46d90dc | 2013-02-01 14:20:06 +0000 | [diff] [blame] | 628 | RegisterSendCodec('A', codec_opus, 48000, 20000, 480*2, -1); |
tina.legrand@webrtc.org | a7d8387 | 2012-10-18 10:00:52 +0000 | [diff] [blame] | 629 | Run(channel_a_to_b_); |
tina.legrand@webrtc.org | 46d90dc | 2013-02-01 14:20:06 +0000 | [diff] [blame] | 630 | RegisterSendCodec('A', codec_opus, 48000, 32000, 480*4, -1); |
tina.legrand@webrtc.org | a7d8387 | 2012-10-18 10:00:52 +0000 | [diff] [blame] | 631 | Run(channel_a_to_b_); |
tina.legrand@webrtc.org | 46d90dc | 2013-02-01 14:20:06 +0000 | [diff] [blame] | 632 | RegisterSendCodec('A', codec_opus, 48000, 48000, 480, -1); |
tina.legrand@webrtc.org | a7d8387 | 2012-10-18 10:00:52 +0000 | [diff] [blame] | 633 | Run(channel_a_to_b_); |
tina.legrand@webrtc.org | 46d90dc | 2013-02-01 14:20:06 +0000 | [diff] [blame] | 634 | RegisterSendCodec('A', codec_opus, 48000, 64000, 480*4, -1); |
tina.legrand@webrtc.org | a7d8387 | 2012-10-18 10:00:52 +0000 | [diff] [blame] | 635 | Run(channel_a_to_b_); |
tina.legrand@webrtc.org | 46d90dc | 2013-02-01 14:20:06 +0000 | [diff] [blame] | 636 | RegisterSendCodec('A', codec_opus, 48000, 96000, 480*6, -1); |
tina.legrand@webrtc.org | a7d8387 | 2012-10-18 10:00:52 +0000 | [diff] [blame] | 637 | Run(channel_a_to_b_); |
tina.legrand@webrtc.org | 46d90dc | 2013-02-01 14:20:06 +0000 | [diff] [blame] | 638 | RegisterSendCodec('A', codec_opus, 48000, 500000, 480*2, -1); |
tina.legrand@webrtc.org | a7d8387 | 2012-10-18 10:00:52 +0000 | [diff] [blame] | 639 | Run(channel_a_to_b_); |
tina.legrand@webrtc.org | c459058 | 2012-11-28 12:23:29 +0000 | [diff] [blame] | 640 | outfile_b_.Close(); |
tina.legrand@webrtc.org | a7d8387 | 2012-10-18 10:00:52 +0000 | [diff] [blame] | 641 | #endif |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 642 | if (test_mode_ != 0) { |
| 643 | printf("===============================================================\n"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 644 | |
| 645 | /* Print out all codecs that were not tested in the run */ |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 646 | printf("The following codecs was not included in the test:\n"); |
| 647 | #ifndef WEBRTC_CODEC_AMR |
| 648 | printf(" GSMAMR\n"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 649 | #endif |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 650 | #ifndef WEBRTC_CODEC_AMRWB |
| 651 | printf(" GSMAMR-wb\n"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 652 | #endif |
| 653 | #ifndef WEBRTC_CODEC_G722 |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 654 | printf(" G.722\n"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 655 | #endif |
| 656 | #ifndef WEBRTC_CODEC_G722_1 |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 657 | printf(" G.722.1\n"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 658 | #endif |
| 659 | #ifndef WEBRTC_CODEC_G722_1C |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 660 | printf(" G.722.1C\n"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 661 | #endif |
| 662 | #ifndef WEBRTC_CODEC_G729 |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 663 | printf(" G.729\n"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 664 | #endif |
| 665 | #ifndef WEBRTC_CODEC_G729_1 |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 666 | printf(" G.729.1\n"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 667 | #endif |
| 668 | #ifndef WEBRTC_CODEC_GSMFR |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 669 | printf(" GSMFR\n"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 670 | #endif |
| 671 | #ifndef WEBRTC_CODEC_ILBC |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 672 | printf(" iLBC\n"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 673 | #endif |
| 674 | #ifndef WEBRTC_CODEC_ISAC |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 675 | printf(" ISAC float\n"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 676 | #endif |
| 677 | #ifndef WEBRTC_CODEC_ISACFX |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 678 | printf(" ISAC fix\n"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 679 | #endif |
| 680 | #ifndef WEBRTC_CODEC_PCM16 |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 681 | printf(" PCM16\n"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 682 | #endif |
| 683 | #ifndef WEBRTC_CODEC_SPEEX |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 684 | printf(" Speex\n"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 685 | #endif |
| 686 | |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 687 | printf("\nTo complete the test, listen to the %d number of output files.\n", |
| 688 | test_count_); |
| 689 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 690 | } |
| 691 | |
| 692 | // Register Codec to use in the test |
| 693 | // |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 694 | // Input: side - which ACM to use, 'A' or 'B' |
| 695 | // codec_name - name to use when register the codec |
| 696 | // sampling_freq_hz - sampling frequency in Herz |
| 697 | // rate - bitrate in bytes |
| 698 | // packet_size - packet size in samples |
| 699 | // extra_byte - if extra bytes needed compared to the bitrate |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 700 | // used when registering, can be an internal header |
| 701 | // set to -1 if the codec is a variable rate codec |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 702 | void TestAllCodecs::RegisterSendCodec(char side, char* codec_name, |
| 703 | int32_t sampling_freq_hz, int rate, |
| 704 | int packet_size, int extra_byte) { |
| 705 | if (test_mode_ != 0) { |
| 706 | // Print out codec and settings. |
| 707 | printf("codec: %s Freq: %d Rate: %d PackSize: %d\n", codec_name, |
| 708 | sampling_freq_hz, rate, packet_size); |
| 709 | } |
| 710 | |
| 711 | // Store packet-size in samples, used to validate the received packet. |
| 712 | // If G.722, store half the size to compensate for the timestamp bug in the |
| 713 | // RFC for G.722. |
| 714 | // If iSAC runs in adaptive mode, packet size in samples can change on the |
| 715 | // fly, so we exclude this test by setting |packet_size_samples_| to -1. |
| 716 | if (!strcmp(codec_name, "G722")) { |
| 717 | packet_size_samples_ = packet_size / 2; |
| 718 | } else if (!strcmp(codec_name, "ISAC") && (rate == -1)) { |
| 719 | packet_size_samples_ = -1; |
| 720 | } else { |
| 721 | packet_size_samples_ = packet_size; |
| 722 | } |
| 723 | |
| 724 | // Store the expected packet size in bytes, used to validate the received |
| 725 | // packet. If variable rate codec (extra_byte == -1), set to -1 (65535). |
| 726 | if (extra_byte != -1) { |
| 727 | // Add 0.875 to always round up to a whole byte |
| 728 | packet_size_bytes_ = |
| 729 | static_cast<uint16_t>(static_cast<float>(packet_size * rate) / |
| 730 | static_cast<float>(sampling_freq_hz * 8) + 0.875) + extra_byte; |
| 731 | } else { |
| 732 | // Packets will have a variable size. |
| 733 | packet_size_bytes_ = -1; |
| 734 | } |
| 735 | |
| 736 | // Set pointer to the ACM where to register the codec. |
| 737 | AudioCodingModule* my_acm = NULL; |
| 738 | switch (side) { |
| 739 | case 'A': { |
| 740 | my_acm = acm_a_; |
| 741 | break; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 742 | } |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 743 | case 'B': { |
| 744 | my_acm = acm_b_; |
| 745 | break; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 746 | } |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 747 | default: { |
| 748 | break; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 749 | } |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 750 | } |
| 751 | ASSERT_TRUE(my_acm != NULL); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 752 | |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 753 | // Get all codec parameters before registering |
| 754 | CodecInst my_codec_param; |
| 755 | CHECK_ERROR(AudioCodingModule::Codec(codec_name, my_codec_param, |
| 756 | sampling_freq_hz, 1)); |
| 757 | my_codec_param.rate = rate; |
| 758 | my_codec_param.pacsize = packet_size; |
| 759 | CHECK_ERROR(my_acm->RegisterSendCodec(my_codec_param)); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 760 | } |
| 761 | |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 762 | void TestAllCodecs::Run(TestPack* channel) { |
| 763 | AudioFrame audio_frame; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 764 | |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 765 | int32_t out_freq_hz = outfile_b_.SamplingFrequency(); |
| 766 | uint16_t receive_size; |
| 767 | uint32_t timestamp_diff; |
| 768 | channel->reset_payload_size(); |
| 769 | int error_count = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 770 | |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 771 | int counter = 0; |
| 772 | while (!infile_a_.EndOfFile()) { |
| 773 | // Add 10 msec to ACM. |
| 774 | infile_a_.Read10MsData(audio_frame); |
| 775 | CHECK_ERROR(acm_a_->Add10MsData(audio_frame)); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 776 | |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 777 | // Run sender side of ACM. |
| 778 | CHECK_ERROR(acm_a_->Process()); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 779 | |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 780 | // Verify that the received packet size matches the settings. |
| 781 | receive_size = channel->payload_size(); |
| 782 | if (receive_size) { |
| 783 | if ((receive_size != packet_size_bytes_) && |
| 784 | (packet_size_bytes_ < 65535)) { |
| 785 | error_count++; |
| 786 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 787 | |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 788 | // Verify that the timestamp is updated with expected length. The counter |
| 789 | // is used to avoid problems when switching codec or frame size in the |
| 790 | // test. |
| 791 | timestamp_diff = channel->timestamp_diff(); |
| 792 | if ((counter > 10) && (timestamp_diff != packet_size_samples_) && |
| 793 | (packet_size_samples_ < 65535)) |
| 794 | error_count++; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 795 | } |
| 796 | |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 797 | // Run received side of ACM. |
| 798 | CHECK_ERROR(acm_b_->PlayoutData10Ms(out_freq_hz, audio_frame)); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 799 | |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 800 | // Write output speech to file. |
| 801 | outfile_b_.Write10MsData(audio_frame.data_, |
| 802 | audio_frame.samples_per_channel_); |
| 803 | |
| 804 | // Update loop counter |
| 805 | counter++; |
| 806 | } |
| 807 | |
| 808 | EXPECT_EQ(0, error_count); |
| 809 | |
| 810 | if (infile_a_.EndOfFile()) { |
| 811 | infile_a_.Rewind(); |
| 812 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 813 | } |
| 814 | |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 815 | void TestAllCodecs::OpenOutFile(int test_number) { |
| 816 | std::string filename = webrtc::test::OutputPath(); |
| 817 | std::ostringstream test_number_str; |
| 818 | test_number_str << test_number; |
| 819 | filename += "testallcodecs_out_"; |
| 820 | filename += test_number_str.str(); |
| 821 | filename += ".pcm"; |
tina.legrand@webrtc.org | ba46804 | 2012-08-17 10:38:28 +0000 | [diff] [blame] | 822 | outfile_b_.Open(filename, 32000, "wb"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 823 | } |
| 824 | |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 825 | void TestAllCodecs::DisplaySendReceiveCodec() { |
| 826 | CodecInst my_codec_param; |
| 827 | acm_a_->SendCodec(my_codec_param); |
| 828 | printf("%s -> ", my_codec_param.plname); |
| 829 | acm_b_->ReceiveCodec(my_codec_param); |
| 830 | printf("%s\n", my_codec_param.plname); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 831 | } |
| 832 | |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 833 | } // namespace webrtc |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 834 | |