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