OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 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 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 #include "webrtc/test/testsupport/fileutils.h" | 13 #include "webrtc/test/testsupport/fileutils.h" |
14 #include "webrtc/test/testsupport/gtest_disable.h" | |
15 #include "webrtc_cng.h" | 14 #include "webrtc_cng.h" |
16 | 15 |
17 namespace webrtc { | 16 namespace webrtc { |
18 | 17 |
19 enum { | 18 enum { |
20 kSidShortIntervalUpdate = 1, | 19 kSidShortIntervalUpdate = 1, |
21 kSidNormalIntervalUpdate = 100, | 20 kSidNormalIntervalUpdate = 100, |
22 kSidLongIntervalUpdate = 10000 | 21 kSidLongIntervalUpdate = 10000 |
23 }; | 22 }; |
24 | 23 |
(...skipping 30 matching lines...) Expand all Loading... |
55 webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"); | 54 webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"); |
56 input_file = fopen(file_name.c_str(), "rb"); | 55 input_file = fopen(file_name.c_str(), "rb"); |
57 ASSERT_TRUE(input_file != NULL); | 56 ASSERT_TRUE(input_file != NULL); |
58 ASSERT_EQ(640, static_cast<int32_t>(fread(speech_data_, sizeof(int16_t), | 57 ASSERT_EQ(640, static_cast<int32_t>(fread(speech_data_, sizeof(int16_t), |
59 640, input_file))); | 58 640, input_file))); |
60 fclose(input_file); | 59 fclose(input_file); |
61 input_file = NULL; | 60 input_file = NULL; |
62 } | 61 } |
63 | 62 |
64 // Test failing Create. | 63 // Test failing Create. |
65 TEST_F(CngTest, DISABLED_ON_IOS(CngCreateFail)) { | 64 TEST_F(CngTest, CngCreateFail) { |
66 // Test to see that an invalid pointer is caught. | 65 // Test to see that an invalid pointer is caught. |
67 EXPECT_EQ(-1, WebRtcCng_CreateEnc(NULL)); | 66 EXPECT_EQ(-1, WebRtcCng_CreateEnc(NULL)); |
68 EXPECT_EQ(-1, WebRtcCng_CreateDec(NULL)); | 67 EXPECT_EQ(-1, WebRtcCng_CreateDec(NULL)); |
69 } | 68 } |
70 | 69 |
71 // Test normal Create. | 70 // Test normal Create. |
72 TEST_F(CngTest, DISABLED_ON_IOS(CngCreate)) { | 71 TEST_F(CngTest, CngCreate) { |
73 EXPECT_EQ(0, WebRtcCng_CreateEnc(&cng_enc_inst_)); | 72 EXPECT_EQ(0, WebRtcCng_CreateEnc(&cng_enc_inst_)); |
74 EXPECT_EQ(0, WebRtcCng_CreateDec(&cng_dec_inst_)); | 73 EXPECT_EQ(0, WebRtcCng_CreateDec(&cng_dec_inst_)); |
75 EXPECT_TRUE(cng_enc_inst_ != NULL); | 74 EXPECT_TRUE(cng_enc_inst_ != NULL); |
76 EXPECT_TRUE(cng_dec_inst_ != NULL); | 75 EXPECT_TRUE(cng_dec_inst_ != NULL); |
77 // Free encoder and decoder memory. | 76 // Free encoder and decoder memory. |
78 EXPECT_EQ(0, WebRtcCng_FreeEnc(cng_enc_inst_)); | 77 EXPECT_EQ(0, WebRtcCng_FreeEnc(cng_enc_inst_)); |
79 EXPECT_EQ(0, WebRtcCng_FreeDec(cng_dec_inst_)); | 78 EXPECT_EQ(0, WebRtcCng_FreeDec(cng_dec_inst_)); |
80 } | 79 } |
81 | 80 |
82 // Create CNG encoder, init with faulty values, free CNG encoder. | 81 // Create CNG encoder, init with faulty values, free CNG encoder. |
83 TEST_F(CngTest, DISABLED_ON_IOS(CngInitFail)) { | 82 TEST_F(CngTest, CngInitFail) { |
84 // Create encoder memory. | 83 // Create encoder memory. |
85 EXPECT_EQ(0, WebRtcCng_CreateEnc(&cng_enc_inst_)); | 84 EXPECT_EQ(0, WebRtcCng_CreateEnc(&cng_enc_inst_)); |
86 | 85 |
87 // Call with too few parameters. | 86 // Call with too few parameters. |
88 EXPECT_EQ(-1, WebRtcCng_InitEnc(cng_enc_inst_, 8000, kSidNormalIntervalUpdate, | 87 EXPECT_EQ(-1, WebRtcCng_InitEnc(cng_enc_inst_, 8000, kSidNormalIntervalUpdate, |
89 kCNGNumParamsLow)); | 88 kCNGNumParamsLow)); |
90 EXPECT_EQ(6130, WebRtcCng_GetErrorCodeEnc(cng_enc_inst_)); | 89 EXPECT_EQ(6130, WebRtcCng_GetErrorCodeEnc(cng_enc_inst_)); |
91 | 90 |
92 // Call with too many parameters. | 91 // Call with too many parameters. |
93 EXPECT_EQ(-1, WebRtcCng_InitEnc(cng_enc_inst_, 8000, kSidNormalIntervalUpdate, | 92 EXPECT_EQ(-1, WebRtcCng_InitEnc(cng_enc_inst_, 8000, kSidNormalIntervalUpdate, |
94 kCNGNumParamsTooHigh)); | 93 kCNGNumParamsTooHigh)); |
95 EXPECT_EQ(6130, WebRtcCng_GetErrorCodeEnc(cng_enc_inst_)); | 94 EXPECT_EQ(6130, WebRtcCng_GetErrorCodeEnc(cng_enc_inst_)); |
96 | 95 |
97 // Free encoder memory. | 96 // Free encoder memory. |
98 EXPECT_EQ(0, WebRtcCng_FreeEnc(cng_enc_inst_)); | 97 EXPECT_EQ(0, WebRtcCng_FreeEnc(cng_enc_inst_)); |
99 } | 98 } |
100 | 99 |
101 TEST_F(CngTest, DISABLED_ON_IOS(CngEncode)) { | 100 TEST_F(CngTest, CngEncode) { |
102 uint8_t sid_data[WEBRTC_CNG_MAX_LPC_ORDER + 1]; | 101 uint8_t sid_data[WEBRTC_CNG_MAX_LPC_ORDER + 1]; |
103 int16_t number_bytes; | 102 int16_t number_bytes; |
104 | 103 |
105 // Create encoder memory. | 104 // Create encoder memory. |
106 EXPECT_EQ(0, WebRtcCng_CreateEnc(&cng_enc_inst_)); | 105 EXPECT_EQ(0, WebRtcCng_CreateEnc(&cng_enc_inst_)); |
107 | 106 |
108 // 8 kHz, Normal number of parameters | 107 // 8 kHz, Normal number of parameters |
109 EXPECT_EQ(0, WebRtcCng_InitEnc(cng_enc_inst_, 8000, kSidNormalIntervalUpdate, | 108 EXPECT_EQ(0, WebRtcCng_InitEnc(cng_enc_inst_, 8000, kSidNormalIntervalUpdate, |
110 kCNGNumParamsNormal)); | 109 kCNGNumParamsNormal)); |
111 EXPECT_EQ(0, WebRtcCng_Encode(cng_enc_inst_, speech_data_, 80, sid_data, | 110 EXPECT_EQ(0, WebRtcCng_Encode(cng_enc_inst_, speech_data_, 80, sid_data, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 EXPECT_EQ(0, WebRtcCng_Encode(cng_enc_inst_, speech_data_, 640, sid_data, | 142 EXPECT_EQ(0, WebRtcCng_Encode(cng_enc_inst_, speech_data_, 640, sid_data, |
144 &number_bytes, kNoSid)); | 143 &number_bytes, kNoSid)); |
145 EXPECT_EQ(kCNGNumParamsNormal + 1, WebRtcCng_Encode( | 144 EXPECT_EQ(kCNGNumParamsNormal + 1, WebRtcCng_Encode( |
146 cng_enc_inst_, speech_data_, 640, sid_data, &number_bytes, kForceSid)); | 145 cng_enc_inst_, speech_data_, 640, sid_data, &number_bytes, kForceSid)); |
147 | 146 |
148 // Free encoder memory. | 147 // Free encoder memory. |
149 EXPECT_EQ(0, WebRtcCng_FreeEnc(cng_enc_inst_)); | 148 EXPECT_EQ(0, WebRtcCng_FreeEnc(cng_enc_inst_)); |
150 } | 149 } |
151 | 150 |
152 // Encode Cng with too long input vector. | 151 // Encode Cng with too long input vector. |
153 TEST_F(CngTest, DISABLED_ON_IOS(CngEncodeTooLong)) { | 152 TEST_F(CngTest, CngEncodeTooLong) { |
154 uint8_t sid_data[WEBRTC_CNG_MAX_LPC_ORDER + 1]; | 153 uint8_t sid_data[WEBRTC_CNG_MAX_LPC_ORDER + 1]; |
155 int16_t number_bytes; | 154 int16_t number_bytes; |
156 | 155 |
157 // Create and init encoder memory. | 156 // Create and init encoder memory. |
158 EXPECT_EQ(0, WebRtcCng_CreateEnc(&cng_enc_inst_)); | 157 EXPECT_EQ(0, WebRtcCng_CreateEnc(&cng_enc_inst_)); |
159 EXPECT_EQ(0, WebRtcCng_InitEnc(cng_enc_inst_, 8000, kSidNormalIntervalUpdate, | 158 EXPECT_EQ(0, WebRtcCng_InitEnc(cng_enc_inst_, 8000, kSidNormalIntervalUpdate, |
160 kCNGNumParamsNormal)); | 159 kCNGNumParamsNormal)); |
161 | 160 |
162 // Run encoder with too much data. | 161 // Run encoder with too much data. |
163 EXPECT_EQ(-1, WebRtcCng_Encode(cng_enc_inst_, speech_data_, 641, sid_data, | 162 EXPECT_EQ(-1, WebRtcCng_Encode(cng_enc_inst_, speech_data_, 641, sid_data, |
164 &number_bytes, kNoSid)); | 163 &number_bytes, kNoSid)); |
165 EXPECT_EQ(6140, WebRtcCng_GetErrorCodeEnc(cng_enc_inst_)); | 164 EXPECT_EQ(6140, WebRtcCng_GetErrorCodeEnc(cng_enc_inst_)); |
166 | 165 |
167 // Free encoder memory. | 166 // Free encoder memory. |
168 EXPECT_EQ(0, WebRtcCng_FreeEnc(cng_enc_inst_)); | 167 EXPECT_EQ(0, WebRtcCng_FreeEnc(cng_enc_inst_)); |
169 } | 168 } |
170 | 169 |
171 // Call encode without calling init. | 170 // Call encode without calling init. |
172 TEST_F(CngTest, DISABLED_ON_IOS(CngEncodeNoInit)) { | 171 TEST_F(CngTest, CngEncodeNoInit) { |
173 uint8_t sid_data[WEBRTC_CNG_MAX_LPC_ORDER + 1]; | 172 uint8_t sid_data[WEBRTC_CNG_MAX_LPC_ORDER + 1]; |
174 int16_t number_bytes; | 173 int16_t number_bytes; |
175 | 174 |
176 // Create encoder memory. | 175 // Create encoder memory. |
177 EXPECT_EQ(0, WebRtcCng_CreateEnc(&cng_enc_inst_)); | 176 EXPECT_EQ(0, WebRtcCng_CreateEnc(&cng_enc_inst_)); |
178 | 177 |
179 // Run encoder without calling init. | 178 // Run encoder without calling init. |
180 EXPECT_EQ(-1, WebRtcCng_Encode(cng_enc_inst_, speech_data_, 640, sid_data, | 179 EXPECT_EQ(-1, WebRtcCng_Encode(cng_enc_inst_, speech_data_, 640, sid_data, |
181 &number_bytes, kNoSid)); | 180 &number_bytes, kNoSid)); |
182 EXPECT_EQ(6120, WebRtcCng_GetErrorCodeEnc(cng_enc_inst_)); | 181 EXPECT_EQ(6120, WebRtcCng_GetErrorCodeEnc(cng_enc_inst_)); |
183 | 182 |
184 // Free encoder memory. | 183 // Free encoder memory. |
185 EXPECT_EQ(0, WebRtcCng_FreeEnc(cng_enc_inst_)); | 184 EXPECT_EQ(0, WebRtcCng_FreeEnc(cng_enc_inst_)); |
186 } | 185 } |
187 | 186 |
188 // Update SID parameters, for both 9 and 16 parameters. | 187 // Update SID parameters, for both 9 and 16 parameters. |
189 TEST_F(CngTest, DISABLED_ON_IOS(CngUpdateSid)) { | 188 TEST_F(CngTest, CngUpdateSid) { |
190 uint8_t sid_data[WEBRTC_CNG_MAX_LPC_ORDER + 1]; | 189 uint8_t sid_data[WEBRTC_CNG_MAX_LPC_ORDER + 1]; |
191 int16_t number_bytes; | 190 int16_t number_bytes; |
192 | 191 |
193 // Create and initialize encoder and decoder memory. | 192 // Create and initialize encoder and decoder memory. |
194 EXPECT_EQ(0, WebRtcCng_CreateEnc(&cng_enc_inst_)); | 193 EXPECT_EQ(0, WebRtcCng_CreateEnc(&cng_enc_inst_)); |
195 EXPECT_EQ(0, WebRtcCng_CreateDec(&cng_dec_inst_)); | 194 EXPECT_EQ(0, WebRtcCng_CreateDec(&cng_dec_inst_)); |
196 EXPECT_EQ(0, WebRtcCng_InitEnc(cng_enc_inst_, 16000, kSidNormalIntervalUpdate, | 195 EXPECT_EQ(0, WebRtcCng_InitEnc(cng_enc_inst_, 16000, kSidNormalIntervalUpdate, |
197 kCNGNumParamsNormal)); | 196 kCNGNumParamsNormal)); |
198 EXPECT_EQ(0, WebRtcCng_InitDec(cng_dec_inst_)); | 197 EXPECT_EQ(0, WebRtcCng_InitDec(cng_dec_inst_)); |
199 | 198 |
(...skipping 16 matching lines...) Expand all Loading... |
216 kForceSid)); | 215 kForceSid)); |
217 EXPECT_EQ(0, WebRtcCng_UpdateSid(cng_dec_inst_, sid_data, | 216 EXPECT_EQ(0, WebRtcCng_UpdateSid(cng_dec_inst_, sid_data, |
218 kCNGNumParamsNormal + 1)); | 217 kCNGNumParamsNormal + 1)); |
219 | 218 |
220 // Free encoder and decoder memory. | 219 // Free encoder and decoder memory. |
221 EXPECT_EQ(0, WebRtcCng_FreeEnc(cng_enc_inst_)); | 220 EXPECT_EQ(0, WebRtcCng_FreeEnc(cng_enc_inst_)); |
222 EXPECT_EQ(0, WebRtcCng_FreeDec(cng_dec_inst_)); | 221 EXPECT_EQ(0, WebRtcCng_FreeDec(cng_dec_inst_)); |
223 } | 222 } |
224 | 223 |
225 // Update SID parameters, with wrong parameters or without calling decode. | 224 // Update SID parameters, with wrong parameters or without calling decode. |
226 TEST_F(CngTest, DISABLED_ON_IOS(CngUpdateSidErroneous)) { | 225 TEST_F(CngTest, CngUpdateSidErroneous) { |
227 uint8_t sid_data[WEBRTC_CNG_MAX_LPC_ORDER + 1]; | 226 uint8_t sid_data[WEBRTC_CNG_MAX_LPC_ORDER + 1]; |
228 int16_t number_bytes; | 227 int16_t number_bytes; |
229 | 228 |
230 // Create encoder and decoder memory. | 229 // Create encoder and decoder memory. |
231 EXPECT_EQ(0, WebRtcCng_CreateEnc(&cng_enc_inst_)); | 230 EXPECT_EQ(0, WebRtcCng_CreateEnc(&cng_enc_inst_)); |
232 EXPECT_EQ(0, WebRtcCng_CreateDec(&cng_dec_inst_)); | 231 EXPECT_EQ(0, WebRtcCng_CreateDec(&cng_dec_inst_)); |
233 | 232 |
234 // Encode. | 233 // Encode. |
235 EXPECT_EQ(0, WebRtcCng_InitEnc(cng_enc_inst_, 16000, kSidNormalIntervalUpdate, | 234 EXPECT_EQ(0, WebRtcCng_InitEnc(cng_enc_inst_, 16000, kSidNormalIntervalUpdate, |
236 kCNGNumParamsNormal)); | 235 kCNGNumParamsNormal)); |
(...skipping 15 matching lines...) Expand all Loading... |
252 kCNGNumParamsNormal + 1)); | 251 kCNGNumParamsNormal + 1)); |
253 EXPECT_EQ(0, WebRtcCng_UpdateSid(cng_dec_inst_, sid_data, | 252 EXPECT_EQ(0, WebRtcCng_UpdateSid(cng_dec_inst_, sid_data, |
254 kCNGNumParamsTooHigh + 1)); | 253 kCNGNumParamsTooHigh + 1)); |
255 | 254 |
256 // Free encoder and decoder memory. | 255 // Free encoder and decoder memory. |
257 EXPECT_EQ(0, WebRtcCng_FreeEnc(cng_enc_inst_)); | 256 EXPECT_EQ(0, WebRtcCng_FreeEnc(cng_enc_inst_)); |
258 EXPECT_EQ(0, WebRtcCng_FreeDec(cng_dec_inst_)); | 257 EXPECT_EQ(0, WebRtcCng_FreeDec(cng_dec_inst_)); |
259 } | 258 } |
260 | 259 |
261 // Test to generate cng data, by forcing SID. Both normal and faulty condition. | 260 // Test to generate cng data, by forcing SID. Both normal and faulty condition. |
262 TEST_F(CngTest, DISABLED_ON_IOS(CngGenerate)) { | 261 TEST_F(CngTest, CngGenerate) { |
263 uint8_t sid_data[WEBRTC_CNG_MAX_LPC_ORDER + 1]; | 262 uint8_t sid_data[WEBRTC_CNG_MAX_LPC_ORDER + 1]; |
264 int16_t out_data[640]; | 263 int16_t out_data[640]; |
265 int16_t number_bytes; | 264 int16_t number_bytes; |
266 | 265 |
267 // Create and initialize encoder and decoder memory. | 266 // Create and initialize encoder and decoder memory. |
268 EXPECT_EQ(0, WebRtcCng_CreateEnc(&cng_enc_inst_)); | 267 EXPECT_EQ(0, WebRtcCng_CreateEnc(&cng_enc_inst_)); |
269 EXPECT_EQ(0, WebRtcCng_CreateDec(&cng_dec_inst_)); | 268 EXPECT_EQ(0, WebRtcCng_CreateDec(&cng_dec_inst_)); |
270 EXPECT_EQ(0, WebRtcCng_InitEnc(cng_enc_inst_, 16000, kSidNormalIntervalUpdate, | 269 EXPECT_EQ(0, WebRtcCng_InitEnc(cng_enc_inst_, 16000, kSidNormalIntervalUpdate, |
271 kCNGNumParamsNormal)); | 270 kCNGNumParamsNormal)); |
272 EXPECT_EQ(0, WebRtcCng_InitDec(cng_dec_inst_)); | 271 EXPECT_EQ(0, WebRtcCng_InitDec(cng_dec_inst_)); |
(...skipping 13 matching lines...) Expand all Loading... |
286 // Call Genereate with too much data. | 285 // Call Genereate with too much data. |
287 EXPECT_EQ(-1, WebRtcCng_Generate(cng_dec_inst_, out_data, 641, 0)); | 286 EXPECT_EQ(-1, WebRtcCng_Generate(cng_dec_inst_, out_data, 641, 0)); |
288 EXPECT_EQ(6140, WebRtcCng_GetErrorCodeDec(cng_dec_inst_)); | 287 EXPECT_EQ(6140, WebRtcCng_GetErrorCodeDec(cng_dec_inst_)); |
289 | 288 |
290 // Free encoder and decoder memory. | 289 // Free encoder and decoder memory. |
291 EXPECT_EQ(0, WebRtcCng_FreeEnc(cng_enc_inst_)); | 290 EXPECT_EQ(0, WebRtcCng_FreeEnc(cng_enc_inst_)); |
292 EXPECT_EQ(0, WebRtcCng_FreeDec(cng_dec_inst_)); | 291 EXPECT_EQ(0, WebRtcCng_FreeDec(cng_dec_inst_)); |
293 } | 292 } |
294 | 293 |
295 // Test automatic SID. | 294 // Test automatic SID. |
296 TEST_F(CngTest, DISABLED_ON_IOS(CngAutoSid)) { | 295 TEST_F(CngTest, CngAutoSid) { |
297 uint8_t sid_data[WEBRTC_CNG_MAX_LPC_ORDER + 1]; | 296 uint8_t sid_data[WEBRTC_CNG_MAX_LPC_ORDER + 1]; |
298 int16_t number_bytes; | 297 int16_t number_bytes; |
299 | 298 |
300 // Create and initialize encoder and decoder memory. | 299 // Create and initialize encoder and decoder memory. |
301 EXPECT_EQ(0, WebRtcCng_CreateEnc(&cng_enc_inst_)); | 300 EXPECT_EQ(0, WebRtcCng_CreateEnc(&cng_enc_inst_)); |
302 EXPECT_EQ(0, WebRtcCng_CreateDec(&cng_dec_inst_)); | 301 EXPECT_EQ(0, WebRtcCng_CreateDec(&cng_dec_inst_)); |
303 EXPECT_EQ(0, WebRtcCng_InitEnc(cng_enc_inst_, 16000, kSidNormalIntervalUpdate, | 302 EXPECT_EQ(0, WebRtcCng_InitEnc(cng_enc_inst_, 16000, kSidNormalIntervalUpdate, |
304 kCNGNumParamsNormal)); | 303 kCNGNumParamsNormal)); |
305 EXPECT_EQ(0, WebRtcCng_InitDec(cng_dec_inst_)); | 304 EXPECT_EQ(0, WebRtcCng_InitDec(cng_dec_inst_)); |
306 | 305 |
307 // Normal Encode, 100 msec, where no SID data should be generated. | 306 // Normal Encode, 100 msec, where no SID data should be generated. |
308 for (int i = 0; i < 10; i++) { | 307 for (int i = 0; i < 10; i++) { |
309 EXPECT_EQ(0, WebRtcCng_Encode(cng_enc_inst_, speech_data_, 160, sid_data, | 308 EXPECT_EQ(0, WebRtcCng_Encode(cng_enc_inst_, speech_data_, 160, sid_data, |
310 &number_bytes, kNoSid)); | 309 &number_bytes, kNoSid)); |
311 } | 310 } |
312 | 311 |
313 // We have reached 100 msec, and SID data should be generated. | 312 // We have reached 100 msec, and SID data should be generated. |
314 EXPECT_EQ(kCNGNumParamsNormal + 1, WebRtcCng_Encode( | 313 EXPECT_EQ(kCNGNumParamsNormal + 1, WebRtcCng_Encode( |
315 cng_enc_inst_, speech_data_, 160, sid_data, &number_bytes, kNoSid)); | 314 cng_enc_inst_, speech_data_, 160, sid_data, &number_bytes, kNoSid)); |
316 | 315 |
317 // Free encoder and decoder memory. | 316 // Free encoder and decoder memory. |
318 EXPECT_EQ(0, WebRtcCng_FreeEnc(cng_enc_inst_)); | 317 EXPECT_EQ(0, WebRtcCng_FreeEnc(cng_enc_inst_)); |
319 EXPECT_EQ(0, WebRtcCng_FreeDec(cng_dec_inst_)); | 318 EXPECT_EQ(0, WebRtcCng_FreeDec(cng_dec_inst_)); |
320 } | 319 } |
321 | 320 |
322 // Test automatic SID, with very short interval. | 321 // Test automatic SID, with very short interval. |
323 TEST_F(CngTest, DISABLED_ON_IOS(CngAutoSidShort)) { | 322 TEST_F(CngTest, CngAutoSidShort) { |
324 uint8_t sid_data[WEBRTC_CNG_MAX_LPC_ORDER + 1]; | 323 uint8_t sid_data[WEBRTC_CNG_MAX_LPC_ORDER + 1]; |
325 int16_t number_bytes; | 324 int16_t number_bytes; |
326 | 325 |
327 // Create and initialize encoder and decoder memory. | 326 // Create and initialize encoder and decoder memory. |
328 EXPECT_EQ(0, WebRtcCng_CreateEnc(&cng_enc_inst_)); | 327 EXPECT_EQ(0, WebRtcCng_CreateEnc(&cng_enc_inst_)); |
329 EXPECT_EQ(0, WebRtcCng_CreateDec(&cng_dec_inst_)); | 328 EXPECT_EQ(0, WebRtcCng_CreateDec(&cng_dec_inst_)); |
330 EXPECT_EQ(0, WebRtcCng_InitEnc(cng_enc_inst_, 16000, kSidShortIntervalUpdate, | 329 EXPECT_EQ(0, WebRtcCng_InitEnc(cng_enc_inst_, 16000, kSidShortIntervalUpdate, |
331 kCNGNumParamsNormal)); | 330 kCNGNumParamsNormal)); |
332 EXPECT_EQ(0, WebRtcCng_InitDec(cng_dec_inst_)); | 331 EXPECT_EQ(0, WebRtcCng_InitDec(cng_dec_inst_)); |
333 | 332 |
334 // First call will never generate SID, unless forced to. | 333 // First call will never generate SID, unless forced to. |
335 EXPECT_EQ(0, WebRtcCng_Encode(cng_enc_inst_, speech_data_, 160, sid_data, | 334 EXPECT_EQ(0, WebRtcCng_Encode(cng_enc_inst_, speech_data_, 160, sid_data, |
336 &number_bytes, kNoSid)); | 335 &number_bytes, kNoSid)); |
337 | 336 |
338 // Normal Encode, 100 msec, SID data should be generated all the time. | 337 // Normal Encode, 100 msec, SID data should be generated all the time. |
339 for (int i = 0; i < 10; i++) { | 338 for (int i = 0; i < 10; i++) { |
340 EXPECT_EQ(kCNGNumParamsNormal + 1, WebRtcCng_Encode( | 339 EXPECT_EQ(kCNGNumParamsNormal + 1, WebRtcCng_Encode( |
341 cng_enc_inst_, speech_data_, 160, sid_data, &number_bytes, kNoSid)); | 340 cng_enc_inst_, speech_data_, 160, sid_data, &number_bytes, kNoSid)); |
342 } | 341 } |
343 | 342 |
344 // Free encoder and decoder memory. | 343 // Free encoder and decoder memory. |
345 EXPECT_EQ(0, WebRtcCng_FreeEnc(cng_enc_inst_)); | 344 EXPECT_EQ(0, WebRtcCng_FreeEnc(cng_enc_inst_)); |
346 EXPECT_EQ(0, WebRtcCng_FreeDec(cng_dec_inst_)); | 345 EXPECT_EQ(0, WebRtcCng_FreeDec(cng_dec_inst_)); |
347 } | 346 } |
348 | 347 |
349 } // namespace webrtc | 348 } // namespace webrtc |
OLD | NEW |