Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: webrtc/modules/audio_coding/test/TwoWayCommunication.cc

Issue 2388153004: Stop using old AudioCodingModule::RegisterReceiveCodec overloads (Closed)
Patch Set: rebase Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "TwoWayCommunication.h" 11 #include "TwoWayCommunication.h"
12 12
13 #include <ctype.h> 13 #include <ctype.h>
14 #include <stdio.h> 14 #include <stdio.h>
15 #include <string.h> 15 #include <string.h>
16 16
17 #include <memory> 17 #include <memory>
18 18
19 #ifdef WIN32 19 #ifdef WIN32
20 #include <Windows.h> 20 #include <Windows.h>
21 #endif 21 #endif
22 22
23 #include "webrtc/common_types.h" 23 #include "webrtc/common_types.h"
24 #include "webrtc/modules/audio_coding/codecs/audio_format_conversion.h"
24 #include "webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h" 25 #include "webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h"
25 #include "webrtc/modules/audio_coding/test/PCMFile.h" 26 #include "webrtc/modules/audio_coding/test/PCMFile.h"
26 #include "webrtc/modules/audio_coding/test/utility.h" 27 #include "webrtc/modules/audio_coding/test/utility.h"
27 #include "webrtc/system_wrappers/include/trace.h" 28 #include "webrtc/system_wrappers/include/trace.h"
28 #include "webrtc/test/gtest.h" 29 #include "webrtc/test/gtest.h"
29 #include "webrtc/test/testsupport/fileutils.h" 30 #include "webrtc/test/testsupport/fileutils.h"
30 #include "webrtc/voice_engine_configurations.h" 31 #include "webrtc/voice_engine_configurations.h"
31 32
32 namespace webrtc { 33 namespace webrtc {
33 34
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 ChooseCodec(&codecID_A, &codecID_B); 91 ChooseCodec(&codecID_A, &codecID_B);
91 CodecInst codecInst_A; 92 CodecInst codecInst_A;
92 CodecInst codecInst_B; 93 CodecInst codecInst_B;
93 CodecInst dummyCodec; 94 CodecInst dummyCodec;
94 EXPECT_EQ(0, _acmA->Codec(codecID_A, &codecInst_A)); 95 EXPECT_EQ(0, _acmA->Codec(codecID_A, &codecInst_A));
95 EXPECT_EQ(0, _acmB->Codec(codecID_B, &codecInst_B)); 96 EXPECT_EQ(0, _acmB->Codec(codecID_B, &codecInst_B));
96 EXPECT_EQ(0, _acmA->Codec(6, &dummyCodec)); 97 EXPECT_EQ(0, _acmA->Codec(6, &dummyCodec));
97 98
98 //--- Set A codecs 99 //--- Set A codecs
99 EXPECT_EQ(0, _acmA->RegisterSendCodec(codecInst_A)); 100 EXPECT_EQ(0, _acmA->RegisterSendCodec(codecInst_A));
100 EXPECT_EQ(0, _acmA->RegisterReceiveCodec(codecInst_B)); 101 EXPECT_EQ(true, _acmA->RegisterReceiveCodec(codecInst_B.pltype,
102 CodecInstToSdp(codecInst_B)));
101 //--- Set ref-A codecs 103 //--- Set ref-A codecs
102 EXPECT_EQ(0, _acmRefA->RegisterSendCodec(codecInst_A)); 104 EXPECT_EQ(0, _acmRefA->RegisterSendCodec(codecInst_A));
103 EXPECT_EQ(0, _acmRefA->RegisterReceiveCodec(codecInst_B)); 105 EXPECT_EQ(true, _acmRefA->RegisterReceiveCodec(codecInst_B.pltype,
106 CodecInstToSdp(codecInst_B)));
104 107
105 //--- Set B codecs 108 //--- Set B codecs
106 EXPECT_EQ(0, _acmB->RegisterSendCodec(codecInst_B)); 109 EXPECT_EQ(0, _acmB->RegisterSendCodec(codecInst_B));
107 EXPECT_EQ(0, _acmB->RegisterReceiveCodec(codecInst_A)); 110 EXPECT_EQ(true, _acmB->RegisterReceiveCodec(codecInst_A.pltype,
111 CodecInstToSdp(codecInst_A)));
108 112
109 //--- Set ref-B codecs 113 //--- Set ref-B codecs
110 EXPECT_EQ(0, _acmRefB->RegisterSendCodec(codecInst_B)); 114 EXPECT_EQ(0, _acmRefB->RegisterSendCodec(codecInst_B));
111 EXPECT_EQ(0, _acmRefB->RegisterReceiveCodec(codecInst_A)); 115 EXPECT_EQ(true, _acmRefB->RegisterReceiveCodec(codecInst_A.pltype,
116 CodecInstToSdp(codecInst_A)));
112 117
113 uint16_t frequencyHz; 118 uint16_t frequencyHz;
114 119
115 //--- Input A 120 //--- Input A
116 std::string in_file_name = webrtc::test::ResourcePath( 121 std::string in_file_name = webrtc::test::ResourcePath(
117 "audio_coding/testfile32kHz", "pcm"); 122 "audio_coding/testfile32kHz", "pcm");
118 frequencyHz = 32000; 123 frequencyHz = 32000;
119 printf("Enter input file at side A [%s]: ", in_file_name.c_str()); 124 printf("Enter input file at side A [%s]: ", in_file_name.c_str());
120 PCMFile::ChooseFile(&in_file_name, 499, &frequencyHz); 125 PCMFile::ChooseFile(&in_file_name, 499, &frequencyHz);
121 _inFileA.Open(in_file_name, frequencyHz, "rb"); 126 _inFileA.Open(in_file_name, frequencyHz, "rb");
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 CodecInst codecInst_A; 172 CodecInst codecInst_A;
168 CodecInst codecInst_B; 173 CodecInst codecInst_B;
169 CodecInst dummyCodec; 174 CodecInst dummyCodec;
170 175
171 EXPECT_EQ(0, _acmA->Codec("ISAC", &codecInst_A, 16000, 1)); 176 EXPECT_EQ(0, _acmA->Codec("ISAC", &codecInst_A, 16000, 1));
172 EXPECT_EQ(0, _acmB->Codec("L16", &codecInst_B, 8000, 1)); 177 EXPECT_EQ(0, _acmB->Codec("L16", &codecInst_B, 8000, 1));
173 EXPECT_EQ(0, _acmA->Codec(6, &dummyCodec)); 178 EXPECT_EQ(0, _acmA->Codec(6, &dummyCodec));
174 179
175 //--- Set A codecs 180 //--- Set A codecs
176 EXPECT_EQ(0, _acmA->RegisterSendCodec(codecInst_A)); 181 EXPECT_EQ(0, _acmA->RegisterSendCodec(codecInst_A));
177 EXPECT_EQ(0, _acmA->RegisterReceiveCodec(codecInst_B)); 182 EXPECT_EQ(true, _acmA->RegisterReceiveCodec(codecInst_B.pltype,
183 CodecInstToSdp(codecInst_B)));
178 184
179 //--- Set ref-A codecs 185 //--- Set ref-A codecs
180 EXPECT_GT(_acmRefA->RegisterSendCodec(codecInst_A), -1); 186 EXPECT_GT(_acmRefA->RegisterSendCodec(codecInst_A), -1);
181 EXPECT_GT(_acmRefA->RegisterReceiveCodec(codecInst_B), -1); 187 EXPECT_EQ(true, _acmRefA->RegisterReceiveCodec(codecInst_B.pltype,
188 CodecInstToSdp(codecInst_B)));
182 189
183 //--- Set B codecs 190 //--- Set B codecs
184 EXPECT_GT(_acmB->RegisterSendCodec(codecInst_B), -1); 191 EXPECT_GT(_acmB->RegisterSendCodec(codecInst_B), -1);
185 EXPECT_GT(_acmB->RegisterReceiveCodec(codecInst_A), -1); 192 EXPECT_EQ(true, _acmB->RegisterReceiveCodec(codecInst_A.pltype,
193 CodecInstToSdp(codecInst_A)));
186 194
187 //--- Set ref-B codecs 195 //--- Set ref-B codecs
188 EXPECT_EQ(0, _acmRefB->RegisterSendCodec(codecInst_B)); 196 EXPECT_EQ(0, _acmRefB->RegisterSendCodec(codecInst_B));
189 EXPECT_EQ(0, _acmRefB->RegisterReceiveCodec(codecInst_A)); 197 EXPECT_EQ(true, _acmRefB->RegisterReceiveCodec(codecInst_A.pltype,
198 CodecInstToSdp(codecInst_A)));
190 199
191 uint16_t frequencyHz; 200 uint16_t frequencyHz;
192 201
193 //--- Input A and B 202 //--- Input A and B
194 std::string in_file_name = webrtc::test::ResourcePath( 203 std::string in_file_name = webrtc::test::ResourcePath(
195 "audio_coding/testfile32kHz", "pcm"); 204 "audio_coding/testfile32kHz", "pcm");
196 frequencyHz = 16000; 205 frequencyHz = 16000;
197 _inFileA.Open(in_file_name, frequencyHz, "rb"); 206 _inFileA.Open(in_file_name, frequencyHz, "rb");
198 _inFileB.Open(in_file_name, frequencyHz, "rb"); 207 _inFileB.Open(in_file_name, frequencyHz, "rb");
199 208
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 // Re-register send codec on side B. 294 // Re-register send codec on side B.
286 if (((secPassed % 5) == 4) && (msecPassed >= 990)) { 295 if (((secPassed % 5) == 4) && (msecPassed >= 990)) {
287 EXPECT_EQ(0, _acmB->RegisterSendCodec(*codecInst_B)); 296 EXPECT_EQ(0, _acmB->RegisterSendCodec(*codecInst_B));
288 EXPECT_TRUE(_acmB->SendCodec()); 297 EXPECT_TRUE(_acmB->SendCodec());
289 } 298 }
290 // Initialize receiver on side A. 299 // Initialize receiver on side A.
291 if (((secPassed % 7) == 6) && (msecPassed == 0)) 300 if (((secPassed % 7) == 6) && (msecPassed == 0))
292 EXPECT_EQ(0, _acmA->InitializeReceiver()); 301 EXPECT_EQ(0, _acmA->InitializeReceiver());
293 // Re-register codec on side A. 302 // Re-register codec on side A.
294 if (((secPassed % 7) == 6) && (msecPassed >= 990)) { 303 if (((secPassed % 7) == 6) && (msecPassed >= 990)) {
295 EXPECT_EQ(0, _acmA->RegisterReceiveCodec(*codecInst_B)); 304 EXPECT_EQ(true, _acmA->RegisterReceiveCodec(
305 codecInst_B->pltype, CodecInstToSdp(*codecInst_B)));
296 } 306 }
297 } 307 }
298 } 308 }
299 309
300 } // namespace webrtc 310 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698