| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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/modules/audio_coding/codecs/opus/interface/opus_interface.h" | 13 #include "webrtc/modules/audio_coding/codecs/opus/interface/opus_interface.h" |
| 14 #include "webrtc/modules/audio_coding/codecs/opus/opus_inst.h" | 14 #include "webrtc/modules/audio_coding/codecs/opus/opus_inst.h" |
| 15 #include "webrtc/modules/audio_coding/neteq/tools/audio_loop.h" | 15 #include "webrtc/modules/audio_coding/neteq/tools/audio_loop.h" |
| 16 #include "webrtc/test/testsupport/fileutils.h" | 16 #include "webrtc/test/testsupport/fileutils.h" |
| 17 #include "webrtc/test/testsupport/gtest_disable.h" | |
| 18 | 17 |
| 19 namespace webrtc { | 18 namespace webrtc { |
| 20 | 19 |
| 21 using test::AudioLoop; | 20 using test::AudioLoop; |
| 22 using ::testing::TestWithParam; | 21 using ::testing::TestWithParam; |
| 23 using ::testing::Values; | 22 using ::testing::Values; |
| 24 using ::testing::Combine; | 23 using ::testing::Combine; |
| 25 | 24 |
| 26 // Maximum number of bytes in output bitstream. | 25 // Maximum number of bytes in output bitstream. |
| 27 const size_t kMaxBytes = 1000; | 26 const size_t kMaxBytes = 1000; |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 } | 240 } |
| 242 | 241 |
| 243 // Free memory. | 242 // Free memory. |
| 244 delete[] output_data_decode; | 243 delete[] output_data_decode; |
| 245 delete[] silence; | 244 delete[] silence; |
| 246 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); | 245 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); |
| 247 EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_decoder_)); | 246 EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_decoder_)); |
| 248 } | 247 } |
| 249 | 248 |
| 250 // Test failing Create. | 249 // Test failing Create. |
| 251 TEST(OpusTest, DISABLED_ON_IOS(OpusCreateFail)) { | 250 TEST(OpusTest, OpusCreateFail) { |
| 252 WebRtcOpusEncInst* opus_encoder; | 251 WebRtcOpusEncInst* opus_encoder; |
| 253 WebRtcOpusDecInst* opus_decoder; | 252 WebRtcOpusDecInst* opus_decoder; |
| 254 | 253 |
| 255 // Test to see that an invalid pointer is caught. | 254 // Test to see that an invalid pointer is caught. |
| 256 EXPECT_EQ(-1, WebRtcOpus_EncoderCreate(NULL, 1, 0)); | 255 EXPECT_EQ(-1, WebRtcOpus_EncoderCreate(NULL, 1, 0)); |
| 257 // Invalid channel number. | 256 // Invalid channel number. |
| 258 EXPECT_EQ(-1, WebRtcOpus_EncoderCreate(&opus_encoder, 3, 0)); | 257 EXPECT_EQ(-1, WebRtcOpus_EncoderCreate(&opus_encoder, 3, 0)); |
| 259 // Invalid applciation mode. | 258 // Invalid applciation mode. |
| 260 EXPECT_EQ(-1, WebRtcOpus_EncoderCreate(&opus_encoder, 1, 2)); | 259 EXPECT_EQ(-1, WebRtcOpus_EncoderCreate(&opus_encoder, 1, 2)); |
| 261 | 260 |
| 262 EXPECT_EQ(-1, WebRtcOpus_DecoderCreate(NULL, 1)); | 261 EXPECT_EQ(-1, WebRtcOpus_DecoderCreate(NULL, 1)); |
| 263 // Invalid channel number. | 262 // Invalid channel number. |
| 264 EXPECT_EQ(-1, WebRtcOpus_DecoderCreate(&opus_decoder, 3)); | 263 EXPECT_EQ(-1, WebRtcOpus_DecoderCreate(&opus_decoder, 3)); |
| 265 } | 264 } |
| 266 | 265 |
| 267 // Test failing Free. | 266 // Test failing Free. |
| 268 TEST(OpusTest, DISABLED_ON_IOS(OpusFreeFail)) { | 267 TEST(OpusTest, OpusFreeFail) { |
| 269 // Test to see that an invalid pointer is caught. | 268 // Test to see that an invalid pointer is caught. |
| 270 EXPECT_EQ(-1, WebRtcOpus_EncoderFree(NULL)); | 269 EXPECT_EQ(-1, WebRtcOpus_EncoderFree(NULL)); |
| 271 EXPECT_EQ(-1, WebRtcOpus_DecoderFree(NULL)); | 270 EXPECT_EQ(-1, WebRtcOpus_DecoderFree(NULL)); |
| 272 } | 271 } |
| 273 | 272 |
| 274 // Test normal Create and Free. | 273 // Test normal Create and Free. |
| 275 TEST_P(OpusTest, DISABLED_ON_IOS(OpusCreateFree)) { | 274 TEST_P(OpusTest, OpusCreateFree) { |
| 276 EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, | 275 EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, |
| 277 channels_, | 276 channels_, |
| 278 application_)); | 277 application_)); |
| 279 EXPECT_EQ(0, WebRtcOpus_DecoderCreate(&opus_decoder_, channels_)); | 278 EXPECT_EQ(0, WebRtcOpus_DecoderCreate(&opus_decoder_, channels_)); |
| 280 EXPECT_TRUE(opus_encoder_ != NULL); | 279 EXPECT_TRUE(opus_encoder_ != NULL); |
| 281 EXPECT_TRUE(opus_decoder_ != NULL); | 280 EXPECT_TRUE(opus_decoder_ != NULL); |
| 282 // Free encoder and decoder memory. | 281 // Free encoder and decoder memory. |
| 283 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); | 282 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); |
| 284 EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_decoder_)); | 283 EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_decoder_)); |
| 285 } | 284 } |
| 286 | 285 |
| 287 TEST_P(OpusTest, DISABLED_ON_IOS(OpusEncodeDecode)) { | 286 TEST_P(OpusTest, OpusEncodeDecode) { |
| 288 PrepareSpeechData(channels_, 20, 20); | 287 PrepareSpeechData(channels_, 20, 20); |
| 289 | 288 |
| 290 // Create encoder memory. | 289 // Create encoder memory. |
| 291 EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, | 290 EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, |
| 292 channels_, | 291 channels_, |
| 293 application_)); | 292 application_)); |
| 294 EXPECT_EQ(0, WebRtcOpus_DecoderCreate(&opus_decoder_, | 293 EXPECT_EQ(0, WebRtcOpus_DecoderCreate(&opus_decoder_, |
| 295 channels_)); | 294 channels_)); |
| 296 | 295 |
| 297 // Set bitrate. | 296 // Set bitrate. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 315 EncodeDecode(opus_encoder_, speech_data_.GetNextBlock(), | 314 EncodeDecode(opus_encoder_, speech_data_.GetNextBlock(), |
| 316 kOpus20msFrameSamples, opus_decoder_, | 315 kOpus20msFrameSamples, opus_decoder_, |
| 317 output_data_decode, &audio_type)); | 316 output_data_decode, &audio_type)); |
| 318 | 317 |
| 319 // Free memory. | 318 // Free memory. |
| 320 delete[] output_data_decode; | 319 delete[] output_data_decode; |
| 321 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); | 320 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); |
| 322 EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_decoder_)); | 321 EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_decoder_)); |
| 323 } | 322 } |
| 324 | 323 |
| 325 TEST_P(OpusTest, DISABLED_ON_IOS(OpusSetBitRate)) { | 324 TEST_P(OpusTest, OpusSetBitRate) { |
| 326 // Test without creating encoder memory. | 325 // Test without creating encoder memory. |
| 327 EXPECT_EQ(-1, WebRtcOpus_SetBitRate(opus_encoder_, 60000)); | 326 EXPECT_EQ(-1, WebRtcOpus_SetBitRate(opus_encoder_, 60000)); |
| 328 | 327 |
| 329 // Create encoder memory, try with different bitrates. | 328 // Create encoder memory, try with different bitrates. |
| 330 EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, | 329 EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, |
| 331 channels_, | 330 channels_, |
| 332 application_)); | 331 application_)); |
| 333 EXPECT_EQ(0, WebRtcOpus_SetBitRate(opus_encoder_, 30000)); | 332 EXPECT_EQ(0, WebRtcOpus_SetBitRate(opus_encoder_, 30000)); |
| 334 EXPECT_EQ(0, WebRtcOpus_SetBitRate(opus_encoder_, 60000)); | 333 EXPECT_EQ(0, WebRtcOpus_SetBitRate(opus_encoder_, 60000)); |
| 335 EXPECT_EQ(0, WebRtcOpus_SetBitRate(opus_encoder_, 300000)); | 334 EXPECT_EQ(0, WebRtcOpus_SetBitRate(opus_encoder_, 300000)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 351 EXPECT_EQ(0, WebRtcOpus_SetComplexity(opus_encoder_, 0)); | 350 EXPECT_EQ(0, WebRtcOpus_SetComplexity(opus_encoder_, 0)); |
| 352 EXPECT_EQ(0, WebRtcOpus_SetComplexity(opus_encoder_, 10)); | 351 EXPECT_EQ(0, WebRtcOpus_SetComplexity(opus_encoder_, 10)); |
| 353 EXPECT_EQ(-1, WebRtcOpus_SetComplexity(opus_encoder_, 11)); | 352 EXPECT_EQ(-1, WebRtcOpus_SetComplexity(opus_encoder_, 11)); |
| 354 | 353 |
| 355 // Free memory. | 354 // Free memory. |
| 356 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); | 355 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); |
| 357 } | 356 } |
| 358 | 357 |
| 359 // Encode and decode one frame, initialize the decoder and | 358 // Encode and decode one frame, initialize the decoder and |
| 360 // decode once more. | 359 // decode once more. |
| 361 TEST_P(OpusTest, DISABLED_ON_IOS(OpusDecodeInit)) { | 360 TEST_P(OpusTest, OpusDecodeInit) { |
| 362 PrepareSpeechData(channels_, 20, 20); | 361 PrepareSpeechData(channels_, 20, 20); |
| 363 | 362 |
| 364 // Create encoder memory. | 363 // Create encoder memory. |
| 365 EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, | 364 EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, |
| 366 channels_, | 365 channels_, |
| 367 application_)); | 366 application_)); |
| 368 EXPECT_EQ(0, WebRtcOpus_DecoderCreate(&opus_decoder_, channels_)); | 367 EXPECT_EQ(0, WebRtcOpus_DecoderCreate(&opus_decoder_, channels_)); |
| 369 | 368 |
| 370 // Encode & decode. | 369 // Encode & decode. |
| 371 int16_t audio_type; | 370 int16_t audio_type; |
| 372 int16_t* output_data_decode = new int16_t[kOpus20msFrameSamples * channels_]; | 371 int16_t* output_data_decode = new int16_t[kOpus20msFrameSamples * channels_]; |
| 373 EXPECT_EQ(kOpus20msFrameSamples, | 372 EXPECT_EQ(kOpus20msFrameSamples, |
| 374 EncodeDecode(opus_encoder_, speech_data_.GetNextBlock(), | 373 EncodeDecode(opus_encoder_, speech_data_.GetNextBlock(), |
| 375 kOpus20msFrameSamples, opus_decoder_, | 374 kOpus20msFrameSamples, opus_decoder_, |
| 376 output_data_decode, &audio_type)); | 375 output_data_decode, &audio_type)); |
| 377 | 376 |
| 378 EXPECT_EQ(0, WebRtcOpus_DecoderInit(opus_decoder_)); | 377 EXPECT_EQ(0, WebRtcOpus_DecoderInit(opus_decoder_)); |
| 379 | 378 |
| 380 EXPECT_EQ(kOpus20msFrameSamples, | 379 EXPECT_EQ(kOpus20msFrameSamples, |
| 381 WebRtcOpus_Decode(opus_decoder_, bitstream_, | 380 WebRtcOpus_Decode(opus_decoder_, bitstream_, |
| 382 encoded_bytes_, output_data_decode, | 381 encoded_bytes_, output_data_decode, |
| 383 &audio_type)); | 382 &audio_type)); |
| 384 | 383 |
| 385 // Free memory. | 384 // Free memory. |
| 386 delete[] output_data_decode; | 385 delete[] output_data_decode; |
| 387 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); | 386 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); |
| 388 EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_decoder_)); | 387 EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_decoder_)); |
| 389 } | 388 } |
| 390 | 389 |
| 391 TEST_P(OpusTest, DISABLED_ON_IOS(OpusEnableDisableFec)) { | 390 TEST_P(OpusTest, OpusEnableDisableFec) { |
| 392 // Test without creating encoder memory. | 391 // Test without creating encoder memory. |
| 393 EXPECT_EQ(-1, WebRtcOpus_EnableFec(opus_encoder_)); | 392 EXPECT_EQ(-1, WebRtcOpus_EnableFec(opus_encoder_)); |
| 394 EXPECT_EQ(-1, WebRtcOpus_DisableFec(opus_encoder_)); | 393 EXPECT_EQ(-1, WebRtcOpus_DisableFec(opus_encoder_)); |
| 395 | 394 |
| 396 // Create encoder memory. | 395 // Create encoder memory. |
| 397 EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, | 396 EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, |
| 398 channels_, | 397 channels_, |
| 399 application_)); | 398 application_)); |
| 400 | 399 |
| 401 EXPECT_EQ(0, WebRtcOpus_EnableFec(opus_encoder_)); | 400 EXPECT_EQ(0, WebRtcOpus_EnableFec(opus_encoder_)); |
| 402 EXPECT_EQ(0, WebRtcOpus_DisableFec(opus_encoder_)); | 401 EXPECT_EQ(0, WebRtcOpus_DisableFec(opus_encoder_)); |
| 403 | 402 |
| 404 // Free memory. | 403 // Free memory. |
| 405 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); | 404 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); |
| 406 } | 405 } |
| 407 | 406 |
| 408 TEST_P(OpusTest, DISABLED_ON_IOS(OpusEnableDisableDtx)) { | 407 TEST_P(OpusTest, OpusEnableDisableDtx) { |
| 409 // Test without creating encoder memory. | 408 // Test without creating encoder memory. |
| 410 EXPECT_EQ(-1, WebRtcOpus_EnableDtx(opus_encoder_)); | 409 EXPECT_EQ(-1, WebRtcOpus_EnableDtx(opus_encoder_)); |
| 411 EXPECT_EQ(-1, WebRtcOpus_DisableDtx(opus_encoder_)); | 410 EXPECT_EQ(-1, WebRtcOpus_DisableDtx(opus_encoder_)); |
| 412 | 411 |
| 413 // Create encoder memory. | 412 // Create encoder memory. |
| 414 EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, | 413 EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, |
| 415 channels_, | 414 channels_, |
| 416 application_)); | 415 application_)); |
| 417 | 416 |
| 418 opus_int32 dtx; | 417 opus_int32 dtx; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 432 EXPECT_EQ(0, WebRtcOpus_DisableDtx(opus_encoder_)); | 431 EXPECT_EQ(0, WebRtcOpus_DisableDtx(opus_encoder_)); |
| 433 opus_encoder_ctl(opus_encoder_->encoder, | 432 opus_encoder_ctl(opus_encoder_->encoder, |
| 434 OPUS_GET_DTX(&dtx)); | 433 OPUS_GET_DTX(&dtx)); |
| 435 EXPECT_EQ(0, dtx); | 434 EXPECT_EQ(0, dtx); |
| 436 | 435 |
| 437 | 436 |
| 438 // Free memory. | 437 // Free memory. |
| 439 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); | 438 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); |
| 440 } | 439 } |
| 441 | 440 |
| 442 TEST_P(OpusTest, DISABLED_ON_IOS(OpusDtxOff)) { | 441 TEST_P(OpusTest, OpusDtxOff) { |
| 443 TestDtxEffect(false); | 442 TestDtxEffect(false); |
| 444 } | 443 } |
| 445 | 444 |
| 446 TEST_P(OpusTest, DISABLED_ON_IOS(OpusDtxOn)) { | 445 TEST_P(OpusTest, OpusDtxOn) { |
| 447 TestDtxEffect(true); | 446 TestDtxEffect(true); |
| 448 } | 447 } |
| 449 | 448 |
| 450 TEST_P(OpusTest, DISABLED_ON_IOS(OpusSetPacketLossRate)) { | 449 TEST_P(OpusTest, OpusSetPacketLossRate) { |
| 451 // Test without creating encoder memory. | 450 // Test without creating encoder memory. |
| 452 EXPECT_EQ(-1, WebRtcOpus_SetPacketLossRate(opus_encoder_, 50)); | 451 EXPECT_EQ(-1, WebRtcOpus_SetPacketLossRate(opus_encoder_, 50)); |
| 453 | 452 |
| 454 // Create encoder memory. | 453 // Create encoder memory. |
| 455 EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, | 454 EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, |
| 456 channels_, | 455 channels_, |
| 457 application_)); | 456 application_)); |
| 458 | 457 |
| 459 EXPECT_EQ(0, WebRtcOpus_SetPacketLossRate(opus_encoder_, 50)); | 458 EXPECT_EQ(0, WebRtcOpus_SetPacketLossRate(opus_encoder_, 50)); |
| 460 EXPECT_EQ(-1, WebRtcOpus_SetPacketLossRate(opus_encoder_, -1)); | 459 EXPECT_EQ(-1, WebRtcOpus_SetPacketLossRate(opus_encoder_, -1)); |
| 461 EXPECT_EQ(-1, WebRtcOpus_SetPacketLossRate(opus_encoder_, 101)); | 460 EXPECT_EQ(-1, WebRtcOpus_SetPacketLossRate(opus_encoder_, 101)); |
| 462 | 461 |
| 463 // Free memory. | 462 // Free memory. |
| 464 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); | 463 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); |
| 465 } | 464 } |
| 466 | 465 |
| 467 TEST_P(OpusTest, DISABLED_ON_IOS(OpusSetMaxPlaybackRate)) { | 466 TEST_P(OpusTest, OpusSetMaxPlaybackRate) { |
| 468 // Test without creating encoder memory. | 467 // Test without creating encoder memory. |
| 469 EXPECT_EQ(-1, WebRtcOpus_SetMaxPlaybackRate(opus_encoder_, 20000)); | 468 EXPECT_EQ(-1, WebRtcOpus_SetMaxPlaybackRate(opus_encoder_, 20000)); |
| 470 | 469 |
| 471 // Create encoder memory. | 470 // Create encoder memory. |
| 472 EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, | 471 EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, |
| 473 channels_, | 472 channels_, |
| 474 application_)); | 473 application_)); |
| 475 | 474 |
| 476 SetMaxPlaybackRate(opus_encoder_, OPUS_BANDWIDTH_FULLBAND, 48000); | 475 SetMaxPlaybackRate(opus_encoder_, OPUS_BANDWIDTH_FULLBAND, 48000); |
| 477 SetMaxPlaybackRate(opus_encoder_, OPUS_BANDWIDTH_FULLBAND, 24001); | 476 SetMaxPlaybackRate(opus_encoder_, OPUS_BANDWIDTH_FULLBAND, 24001); |
| 478 SetMaxPlaybackRate(opus_encoder_, OPUS_BANDWIDTH_SUPERWIDEBAND, 24000); | 477 SetMaxPlaybackRate(opus_encoder_, OPUS_BANDWIDTH_SUPERWIDEBAND, 24000); |
| 479 SetMaxPlaybackRate(opus_encoder_, OPUS_BANDWIDTH_SUPERWIDEBAND, 16001); | 478 SetMaxPlaybackRate(opus_encoder_, OPUS_BANDWIDTH_SUPERWIDEBAND, 16001); |
| 480 SetMaxPlaybackRate(opus_encoder_, OPUS_BANDWIDTH_WIDEBAND, 16000); | 479 SetMaxPlaybackRate(opus_encoder_, OPUS_BANDWIDTH_WIDEBAND, 16000); |
| 481 SetMaxPlaybackRate(opus_encoder_, OPUS_BANDWIDTH_WIDEBAND, 12001); | 480 SetMaxPlaybackRate(opus_encoder_, OPUS_BANDWIDTH_WIDEBAND, 12001); |
| 482 SetMaxPlaybackRate(opus_encoder_, OPUS_BANDWIDTH_MEDIUMBAND, 12000); | 481 SetMaxPlaybackRate(opus_encoder_, OPUS_BANDWIDTH_MEDIUMBAND, 12000); |
| 483 SetMaxPlaybackRate(opus_encoder_, OPUS_BANDWIDTH_MEDIUMBAND, 8001); | 482 SetMaxPlaybackRate(opus_encoder_, OPUS_BANDWIDTH_MEDIUMBAND, 8001); |
| 484 SetMaxPlaybackRate(opus_encoder_, OPUS_BANDWIDTH_NARROWBAND, 8000); | 483 SetMaxPlaybackRate(opus_encoder_, OPUS_BANDWIDTH_NARROWBAND, 8000); |
| 485 SetMaxPlaybackRate(opus_encoder_, OPUS_BANDWIDTH_NARROWBAND, 4000); | 484 SetMaxPlaybackRate(opus_encoder_, OPUS_BANDWIDTH_NARROWBAND, 4000); |
| 486 | 485 |
| 487 // Free memory. | 486 // Free memory. |
| 488 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); | 487 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); |
| 489 } | 488 } |
| 490 | 489 |
| 491 // Test PLC. | 490 // Test PLC. |
| 492 TEST_P(OpusTest, DISABLED_ON_IOS(OpusDecodePlc)) { | 491 TEST_P(OpusTest, OpusDecodePlc) { |
| 493 PrepareSpeechData(channels_, 20, 20); | 492 PrepareSpeechData(channels_, 20, 20); |
| 494 | 493 |
| 495 // Create encoder memory. | 494 // Create encoder memory. |
| 496 EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, | 495 EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, |
| 497 channels_, | 496 channels_, |
| 498 application_)); | 497 application_)); |
| 499 EXPECT_EQ(0, WebRtcOpus_DecoderCreate(&opus_decoder_, channels_)); | 498 EXPECT_EQ(0, WebRtcOpus_DecoderCreate(&opus_decoder_, channels_)); |
| 500 | 499 |
| 501 // Set bitrate. | 500 // Set bitrate. |
| 502 EXPECT_EQ(0, WebRtcOpus_SetBitRate(opus_encoder_, | 501 EXPECT_EQ(0, WebRtcOpus_SetBitRate(opus_encoder_, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 519 WebRtcOpus_DecodePlc(opus_decoder_, plc_buffer, 1)); | 518 WebRtcOpus_DecodePlc(opus_decoder_, plc_buffer, 1)); |
| 520 | 519 |
| 521 // Free memory. | 520 // Free memory. |
| 522 delete[] plc_buffer; | 521 delete[] plc_buffer; |
| 523 delete[] output_data_decode; | 522 delete[] output_data_decode; |
| 524 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); | 523 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); |
| 525 EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_decoder_)); | 524 EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_decoder_)); |
| 526 } | 525 } |
| 527 | 526 |
| 528 // Duration estimation. | 527 // Duration estimation. |
| 529 TEST_P(OpusTest, DISABLED_ON_IOS(OpusDurationEstimation)) { | 528 TEST_P(OpusTest, OpusDurationEstimation) { |
| 530 PrepareSpeechData(channels_, 20, 20); | 529 PrepareSpeechData(channels_, 20, 20); |
| 531 | 530 |
| 532 // Create. | 531 // Create. |
| 533 EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, | 532 EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, |
| 534 channels_, | 533 channels_, |
| 535 application_)); | 534 application_)); |
| 536 EXPECT_EQ(0, WebRtcOpus_DecoderCreate(&opus_decoder_, channels_)); | 535 EXPECT_EQ(0, WebRtcOpus_DecoderCreate(&opus_decoder_, channels_)); |
| 537 | 536 |
| 538 // 10 ms. We use only first 10 ms of a 20 ms block. | 537 // 10 ms. We use only first 10 ms of a 20 ms block. |
| 539 encoded_bytes_ = WebRtcOpus_Encode(opus_encoder_, | 538 encoded_bytes_ = WebRtcOpus_Encode(opus_encoder_, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 553 EXPECT_GE(encoded_bytes_, 0); | 552 EXPECT_GE(encoded_bytes_, 0); |
| 554 EXPECT_EQ(kOpus20msFrameSamples, | 553 EXPECT_EQ(kOpus20msFrameSamples, |
| 555 WebRtcOpus_DurationEst(opus_decoder_, bitstream_, | 554 WebRtcOpus_DurationEst(opus_decoder_, bitstream_, |
| 556 encoded_bytes_)); | 555 encoded_bytes_)); |
| 557 | 556 |
| 558 // Free memory. | 557 // Free memory. |
| 559 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); | 558 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); |
| 560 EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_decoder_)); | 559 EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_decoder_)); |
| 561 } | 560 } |
| 562 | 561 |
| 563 TEST_P(OpusTest, DISABLED_ON_IOS(OpusDecodeRepacketized)) { | 562 TEST_P(OpusTest, OpusDecodeRepacketized) { |
| 564 const int kPackets = 6; | 563 const int kPackets = 6; |
| 565 | 564 |
| 566 PrepareSpeechData(channels_, 20, 20 * kPackets); | 565 PrepareSpeechData(channels_, 20, 20 * kPackets); |
| 567 | 566 |
| 568 // Create encoder memory. | 567 // Create encoder memory. |
| 569 ASSERT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, | 568 ASSERT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, |
| 570 channels_, | 569 channels_, |
| 571 application_)); | 570 application_)); |
| 572 ASSERT_EQ(0, WebRtcOpus_DecoderCreate(&opus_decoder_, | 571 ASSERT_EQ(0, WebRtcOpus_DecoderCreate(&opus_decoder_, |
| 573 channels_)); | 572 channels_)); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); | 606 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); |
| 608 EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_decoder_)); | 607 EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_decoder_)); |
| 609 } | 608 } |
| 610 | 609 |
| 611 INSTANTIATE_TEST_CASE_P(VariousMode, | 610 INSTANTIATE_TEST_CASE_P(VariousMode, |
| 612 OpusTest, | 611 OpusTest, |
| 613 Combine(Values(1, 2), Values(0, 1))); | 612 Combine(Values(1, 2), Values(0, 1))); |
| 614 | 613 |
| 615 | 614 |
| 616 } // namespace webrtc | 615 } // namespace webrtc |
| OLD | NEW |