niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
andrew@webrtc.org | 9dc45da | 2012-05-23 15:39:01 +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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #include "modules/audio_coding/test/iSACTest.h" |
tina.legrand@webrtc.org | 73222cf | 2013-03-15 13:29:17 +0000 | [diff] [blame] | 12 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 13 | #include <stdio.h> |
| 14 | #include <string.h> |
| 15 | |
Niels Möller | 2edab4c | 2018-10-22 09:48:08 +0200 | [diff] [blame] | 16 | #include "absl/strings/match.h" |
Karl Wiberg | 5817d3d | 2018-04-06 10:06:42 +0200 | [diff] [blame] | 17 | #include "api/audio_codecs/builtin_audio_decoder_factory.h" |
Karl Wiberg | bf7a046 | 2018-09-25 14:48:33 +0200 | [diff] [blame] | 18 | #include "api/audio_codecs/isac/audio_encoder_isac_float.h" |
Jonas Olsson | 366a50c | 2018-09-06 13:41:30 +0200 | [diff] [blame] | 19 | #include "rtc_base/strings/string_builder.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 20 | #include "rtc_base/time_utils.h" |
Karl Wiberg | bf7a046 | 2018-09-25 14:48:33 +0200 | [diff] [blame] | 21 | #include "test/gmock.h" |
| 22 | #include "test/gtest.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 23 | #include "test/testsupport/file_utils.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 24 | |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 25 | namespace webrtc { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 26 | |
Karl Wiberg | bf7a046 | 2018-09-25 14:48:33 +0200 | [diff] [blame] | 27 | using ::testing::AnyOf; |
| 28 | using ::testing::Eq; |
| 29 | using ::testing::StrCaseEq; |
| 30 | |
| 31 | namespace { |
| 32 | |
Fredrik Solenberg | 657b296 | 2018-12-05 10:30:25 +0100 | [diff] [blame] | 33 | constexpr int kISAC16kPayloadType = 103; |
| 34 | constexpr int kISAC32kPayloadType = 104; |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 35 | const SdpAudioFormat kISAC16kFormat = {"ISAC", 16000, 1}; |
| 36 | const SdpAudioFormat kISAC32kFormat = {"ISAC", 32000, 1}; |
Karl Wiberg | bf7a046 | 2018-09-25 14:48:33 +0200 | [diff] [blame] | 37 | |
| 38 | AudioEncoderIsacFloat::Config TweakConfig( |
| 39 | AudioEncoderIsacFloat::Config config, |
| 40 | const ACMTestISACConfig& test_config) { |
| 41 | if (test_config.currentRateBitPerSec > 0) { |
| 42 | config.bit_rate = test_config.currentRateBitPerSec; |
| 43 | } |
| 44 | if (test_config.currentFrameSizeMsec != 0) { |
| 45 | config.frame_size_ms = test_config.currentFrameSizeMsec; |
| 46 | } |
| 47 | EXPECT_THAT(config.IsOk(), Eq(true)); |
| 48 | return config; |
| 49 | } |
| 50 | |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 51 | void SetISACConfigDefault(ACMTestISACConfig& isacConfig) { |
| 52 | isacConfig.currentRateBitPerSec = 0; |
| 53 | isacConfig.currentFrameSizeMsec = 0; |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 54 | isacConfig.encodingMode = -1; |
| 55 | isacConfig.initRateBitPerSec = 0; |
| 56 | isacConfig.initFrameSizeInMsec = 0; |
| 57 | isacConfig.enforceFrameSize = false; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 58 | } |
| 59 | |
Karl Wiberg | bf7a046 | 2018-09-25 14:48:33 +0200 | [diff] [blame] | 60 | } // namespace |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 61 | |
Fredrik Solenberg | 657b296 | 2018-12-05 10:30:25 +0100 | [diff] [blame] | 62 | ISACTest::ISACTest() |
Karl Wiberg | 5817d3d | 2018-04-06 10:06:42 +0200 | [diff] [blame] | 63 | : _acmA(AudioCodingModule::Create( |
| 64 | AudioCodingModule::Config(CreateBuiltinAudioDecoderFactory()))), |
| 65 | _acmB(AudioCodingModule::Create( |
Fredrik Solenberg | 657b296 | 2018-12-05 10:30:25 +0100 | [diff] [blame] | 66 | AudioCodingModule::Config(CreateBuiltinAudioDecoderFactory()))) {} |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 67 | |
turaj@webrtc.org | 55e1723 | 2013-10-29 04:40:09 +0000 | [diff] [blame] | 68 | ISACTest::~ISACTest() {} |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 69 | |
tina.legrand@webrtc.org | ee92b66 | 2013-08-27 07:33:51 +0000 | [diff] [blame] | 70 | void ISACTest::Setup() { |
tina.legrand@webrtc.org | ee92b66 | 2013-08-27 07:33:51 +0000 | [diff] [blame] | 71 | // Register both iSAC-wb & iSAC-swb in both sides as receiver codecs. |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 72 | std::map<int, SdpAudioFormat> receive_codecs = { |
| 73 | {kISAC16kPayloadType, kISAC16kFormat}, |
| 74 | {kISAC32kPayloadType, kISAC32kFormat}}; |
Fredrik Solenberg | 657b296 | 2018-12-05 10:30:25 +0100 | [diff] [blame] | 75 | _acmA->SetReceiveCodecs(receive_codecs); |
| 76 | _acmB->SetReceiveCodecs(receive_codecs); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 77 | |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 78 | //--- Set A-to-B channel |
turaj@webrtc.org | 55e1723 | 2013-10-29 04:40:09 +0000 | [diff] [blame] | 79 | _channel_A2B.reset(new Channel); |
| 80 | EXPECT_EQ(0, _acmA->RegisterTransportCallback(_channel_A2B.get())); |
| 81 | _channel_A2B->RegisterReceiverACM(_acmB.get()); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 82 | |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 83 | //--- Set B-to-A channel |
turaj@webrtc.org | 55e1723 | 2013-10-29 04:40:09 +0000 | [diff] [blame] | 84 | _channel_B2A.reset(new Channel); |
| 85 | EXPECT_EQ(0, _acmB->RegisterTransportCallback(_channel_B2A.get())); |
| 86 | _channel_B2A->RegisterReceiverACM(_acmA.get()); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 87 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 88 | file_name_swb_ = |
| 89 | webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 90 | |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 91 | _acmB->SetEncoder(AudioEncoderIsacFloat::MakeAudioEncoder( |
| 92 | *AudioEncoderIsacFloat::SdpToConfig(kISAC16kFormat), |
| 93 | kISAC16kPayloadType)); |
| 94 | _acmA->SetEncoder(AudioEncoderIsacFloat::MakeAudioEncoder( |
| 95 | *AudioEncoderIsacFloat::SdpToConfig(kISAC32kFormat), |
| 96 | kISAC32kPayloadType)); |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 97 | |
| 98 | _inFileA.Open(file_name_swb_, 32000, "rb"); |
Henrik Lundin | 4d68208 | 2015-12-10 16:24:39 +0100 | [diff] [blame] | 99 | // Set test length to 500 ms (50 blocks of 10 ms each). |
| 100 | _inFileA.SetNum10MsBlocksToRead(50); |
| 101 | // Fast-forward 1 second (100 blocks) since the files start with silence. |
| 102 | _inFileA.FastForward(100); |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 103 | std::string fileNameA = webrtc::test::OutputPath() + "testisac_a.pcm"; |
| 104 | std::string fileNameB = webrtc::test::OutputPath() + "testisac_b.pcm"; |
| 105 | _outFileA.Open(fileNameA, 32000, "wb"); |
| 106 | _outFileB.Open(fileNameB, 32000, "wb"); |
| 107 | |
| 108 | while (!_inFileA.EndOfFile()) { |
| 109 | Run10ms(); |
| 110 | } |
Fredrik Solenberg | 657b296 | 2018-12-05 10:30:25 +0100 | [diff] [blame] | 111 | |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 112 | _inFileA.Close(); |
| 113 | _outFileA.Close(); |
| 114 | _outFileB.Close(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 115 | } |
| 116 | |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 117 | void ISACTest::Perform() { |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 118 | Setup(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 119 | |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 120 | int16_t testNr = 0; |
| 121 | ACMTestISACConfig wbISACConfig; |
| 122 | ACMTestISACConfig swbISACConfig; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 123 | |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 124 | SetISACConfigDefault(wbISACConfig); |
| 125 | SetISACConfigDefault(swbISACConfig); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 126 | |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 127 | wbISACConfig.currentRateBitPerSec = -1; |
| 128 | swbISACConfig.currentRateBitPerSec = -1; |
| 129 | testNr++; |
| 130 | EncodeDecode(testNr, wbISACConfig, swbISACConfig); |
| 131 | |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 132 | SetISACConfigDefault(wbISACConfig); |
| 133 | SetISACConfigDefault(swbISACConfig); |
| 134 | testNr++; |
| 135 | EncodeDecode(testNr, wbISACConfig, swbISACConfig); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 136 | |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 137 | testNr++; |
Fredrik Solenberg | 657b296 | 2018-12-05 10:30:25 +0100 | [diff] [blame] | 138 | SwitchingSamplingRate(testNr, 4); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 139 | } |
| 140 | |
andresp@webrtc.org | d0b436a | 2014-01-13 13:15:59 +0000 | [diff] [blame] | 141 | void ISACTest::Run10ms() { |
| 142 | AudioFrame audioFrame; |
| 143 | EXPECT_GT(_inFileA.Read10MsData(audioFrame), 0); |
henrik.lundin@webrtc.org | f56c162 | 2015-03-02 12:29:30 +0000 | [diff] [blame] | 144 | EXPECT_GE(_acmA->Add10MsData(audioFrame), 0); |
| 145 | EXPECT_GE(_acmB->Add10MsData(audioFrame), 0); |
henrik.lundin | d4ccb00 | 2016-05-17 12:21:55 -0700 | [diff] [blame] | 146 | bool muted; |
| 147 | EXPECT_EQ(0, _acmA->PlayoutData10Ms(32000, &audioFrame, &muted)); |
| 148 | ASSERT_FALSE(muted); |
andresp@webrtc.org | d0b436a | 2014-01-13 13:15:59 +0000 | [diff] [blame] | 149 | _outFileA.Write10MsData(audioFrame); |
henrik.lundin | d4ccb00 | 2016-05-17 12:21:55 -0700 | [diff] [blame] | 150 | EXPECT_EQ(0, _acmB->PlayoutData10Ms(32000, &audioFrame, &muted)); |
| 151 | ASSERT_FALSE(muted); |
andresp@webrtc.org | d0b436a | 2014-01-13 13:15:59 +0000 | [diff] [blame] | 152 | _outFileB.Write10MsData(audioFrame); |
| 153 | } |
| 154 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 155 | void ISACTest::EncodeDecode(int testNr, |
| 156 | ACMTestISACConfig& wbISACConfig, |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 157 | ACMTestISACConfig& swbISACConfig) { |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 158 | // Files in Side A and B |
| 159 | _inFileA.Open(file_name_swb_, 32000, "rb", true); |
| 160 | _inFileB.Open(file_name_swb_, 32000, "rb", true); |
| 161 | |
| 162 | std::string file_name_out; |
Jonas Olsson | 366a50c | 2018-09-06 13:41:30 +0200 | [diff] [blame] | 163 | rtc::StringBuilder file_stream_a; |
| 164 | rtc::StringBuilder file_stream_b; |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 165 | file_stream_a << webrtc::test::OutputPath(); |
| 166 | file_stream_b << webrtc::test::OutputPath(); |
tina.legrand@webrtc.org | ee92b66 | 2013-08-27 07:33:51 +0000 | [diff] [blame] | 167 | file_stream_a << "out_iSACTest_A_" << testNr << ".pcm"; |
| 168 | file_stream_b << "out_iSACTest_B_" << testNr << ".pcm"; |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 169 | file_name_out = file_stream_a.str(); |
| 170 | _outFileA.Open(file_name_out, 32000, "wb"); |
| 171 | file_name_out = file_stream_b.str(); |
| 172 | _outFileB.Open(file_name_out, 32000, "wb"); |
| 173 | |
tina.legrand@webrtc.org | ee92b66 | 2013-08-27 07:33:51 +0000 | [diff] [blame] | 174 | // Side A is sending super-wideband, and side B is sending wideband. |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 175 | _acmA->SetEncoder(AudioEncoderIsacFloat::MakeAudioEncoder( |
| 176 | TweakConfig(*AudioEncoderIsacFloat::SdpToConfig(kISAC32kFormat), |
| 177 | swbISACConfig), |
| 178 | kISAC32kPayloadType)); |
| 179 | _acmB->SetEncoder(AudioEncoderIsacFloat::MakeAudioEncoder( |
| 180 | TweakConfig(*AudioEncoderIsacFloat::SdpToConfig(kISAC16kFormat), |
| 181 | wbISACConfig), |
| 182 | kISAC16kPayloadType)); |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 183 | |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 184 | _channel_A2B->ResetStats(); |
| 185 | _channel_B2A->ResetStats(); |
| 186 | |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 187 | while (!(_inFileA.EndOfFile() || _inFileA.Rewinded())) { |
| 188 | Run10ms(); |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 189 | } |
tina.legrand@webrtc.org | ba46804 | 2012-08-17 10:38:28 +0000 | [diff] [blame] | 190 | |
andresp@webrtc.org | d0b436a | 2014-01-13 13:15:59 +0000 | [diff] [blame] | 191 | _channel_A2B->ResetStats(); |
| 192 | _channel_B2A->ResetStats(); |
| 193 | |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 194 | _outFileA.Close(); |
| 195 | _outFileB.Close(); |
| 196 | _inFileA.Close(); |
| 197 | _inFileB.Close(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 198 | } |
| 199 | |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 200 | void ISACTest::SwitchingSamplingRate(int testNr, int maxSampRateChange) { |
| 201 | // Files in Side A |
| 202 | _inFileA.Open(file_name_swb_, 32000, "rb"); |
| 203 | _inFileB.Open(file_name_swb_, 32000, "rb"); |
tina.legrand@webrtc.org | ba46804 | 2012-08-17 10:38:28 +0000 | [diff] [blame] | 204 | |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 205 | std::string file_name_out; |
Jonas Olsson | 366a50c | 2018-09-06 13:41:30 +0200 | [diff] [blame] | 206 | rtc::StringBuilder file_stream_a; |
| 207 | rtc::StringBuilder file_stream_b; |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 208 | file_stream_a << webrtc::test::OutputPath(); |
| 209 | file_stream_b << webrtc::test::OutputPath(); |
tina.legrand@webrtc.org | ee92b66 | 2013-08-27 07:33:51 +0000 | [diff] [blame] | 210 | file_stream_a << "out_iSACTest_A_" << testNr << ".pcm"; |
| 211 | file_stream_b << "out_iSACTest_B_" << testNr << ".pcm"; |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 212 | file_name_out = file_stream_a.str(); |
| 213 | _outFileA.Open(file_name_out, 32000, "wb"); |
| 214 | file_name_out = file_stream_b.str(); |
| 215 | _outFileB.Open(file_name_out, 32000, "wb"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 216 | |
tina.legrand@webrtc.org | ee92b66 | 2013-08-27 07:33:51 +0000 | [diff] [blame] | 217 | // Start with side A sending super-wideband and side B seding wideband. |
| 218 | // Toggle sending wideband/super-wideband in this test. |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 219 | _acmA->SetEncoder(AudioEncoderIsacFloat::MakeAudioEncoder( |
| 220 | *AudioEncoderIsacFloat::SdpToConfig(kISAC32kFormat), |
| 221 | kISAC32kPayloadType)); |
| 222 | _acmB->SetEncoder(AudioEncoderIsacFloat::MakeAudioEncoder( |
| 223 | *AudioEncoderIsacFloat::SdpToConfig(kISAC16kFormat), |
| 224 | kISAC16kPayloadType)); |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 225 | |
| 226 | int numSendCodecChanged = 0; |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 227 | while (numSendCodecChanged < (maxSampRateChange << 1)) { |
| 228 | Run10ms(); |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 229 | if (_inFileA.EndOfFile()) { |
| 230 | if (_inFileA.SamplingFrequency() == 16000) { |
tina.legrand@webrtc.org | ee92b66 | 2013-08-27 07:33:51 +0000 | [diff] [blame] | 231 | // Switch side A to send super-wideband. |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 232 | _inFileA.Close(); |
| 233 | _inFileA.Open(file_name_swb_, 32000, "rb"); |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 234 | _acmA->SetEncoder(AudioEncoderIsacFloat::MakeAudioEncoder( |
| 235 | *AudioEncoderIsacFloat::SdpToConfig(kISAC32kFormat), |
| 236 | kISAC32kPayloadType)); |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 237 | } else { |
tina.legrand@webrtc.org | ee92b66 | 2013-08-27 07:33:51 +0000 | [diff] [blame] | 238 | // Switch side A to send wideband. |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 239 | _inFileA.Close(); |
| 240 | _inFileA.Open(file_name_swb_, 32000, "rb"); |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 241 | _acmA->SetEncoder(AudioEncoderIsacFloat::MakeAudioEncoder( |
| 242 | *AudioEncoderIsacFloat::SdpToConfig(kISAC16kFormat), |
| 243 | kISAC16kPayloadType)); |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 244 | } |
| 245 | numSendCodecChanged++; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 246 | } |
| 247 | |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 248 | if (_inFileB.EndOfFile()) { |
| 249 | if (_inFileB.SamplingFrequency() == 16000) { |
tina.legrand@webrtc.org | ee92b66 | 2013-08-27 07:33:51 +0000 | [diff] [blame] | 250 | // Switch side B to send super-wideband. |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 251 | _inFileB.Close(); |
| 252 | _inFileB.Open(file_name_swb_, 32000, "rb"); |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 253 | _acmB->SetEncoder(AudioEncoderIsacFloat::MakeAudioEncoder( |
| 254 | *AudioEncoderIsacFloat::SdpToConfig(kISAC32kFormat), |
| 255 | kISAC32kPayloadType)); |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 256 | } else { |
tina.legrand@webrtc.org | ee92b66 | 2013-08-27 07:33:51 +0000 | [diff] [blame] | 257 | // Switch side B to send wideband. |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 258 | _inFileB.Close(); |
| 259 | _inFileB.Open(file_name_swb_, 32000, "rb"); |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 260 | _acmB->SetEncoder(AudioEncoderIsacFloat::MakeAudioEncoder( |
| 261 | *AudioEncoderIsacFloat::SdpToConfig(kISAC16kFormat), |
| 262 | kISAC16kPayloadType)); |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 263 | } |
| 264 | numSendCodecChanged++; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 265 | } |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 266 | } |
| 267 | _outFileA.Close(); |
| 268 | _outFileB.Close(); |
| 269 | _inFileA.Close(); |
| 270 | _inFileB.Close(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 271 | } |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 272 | |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 273 | } // namespace webrtc |