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 | 10 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 WebRtcOpusDecInst* opus_decoder_; | 64 WebRtcOpusDecInst* opus_decoder_; |
65 | 65 |
66 AudioLoop speech_data_; | 66 AudioLoop speech_data_; |
67 uint8_t bitstream_[kMaxBytes]; | 67 uint8_t bitstream_[kMaxBytes]; |
68 size_t encoded_bytes_; | 68 size_t encoded_bytes_; |
69 size_t channels_; | 69 size_t channels_; |
70 int application_; | 70 int application_; |
71 }; | 71 }; |
72 | 72 |
73 OpusTest::OpusTest() | 73 OpusTest::OpusTest() |
74 : opus_encoder_(NULL), | 74 : opus_encoder_(nullptr), |
75 opus_decoder_(NULL), | 75 opus_decoder_(nullptr), |
76 encoded_bytes_(0), | 76 encoded_bytes_(0), |
77 channels_(static_cast<size_t>(::testing::get<0>(GetParam()))), | 77 channels_(static_cast<size_t>(::testing::get<0>(GetParam()))), |
78 application_(::testing::get<1>(GetParam())) { | 78 application_(::testing::get<1>(GetParam())) {} |
79 } | |
80 | 79 |
81 void OpusTest::PrepareSpeechData(size_t channel, int block_length_ms, | 80 void OpusTest::PrepareSpeechData(size_t channel, int block_length_ms, |
82 int loop_length_ms) { | 81 int loop_length_ms) { |
83 const std::string file_name = | 82 const std::string file_name = |
84 webrtc::test::ResourcePath((channel == 1) ? | 83 webrtc::test::ResourcePath((channel == 1) ? |
85 "audio_coding/testfile32kHz" : | 84 "audio_coding/testfile32kHz" : |
86 "audio_coding/teststereo32kHz", "pcm"); | 85 "audio_coding/teststereo32kHz", "pcm"); |
87 if (loop_length_ms < block_length_ms) { | 86 if (loop_length_ms < block_length_ms) { |
88 loop_length_ms = block_length_ms; | 87 loop_length_ms = block_length_ms; |
89 } | 88 } |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); | 298 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); |
300 EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_decoder_)); | 299 EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_decoder_)); |
301 } | 300 } |
302 | 301 |
303 // Test failing Create. | 302 // Test failing Create. |
304 TEST(OpusTest, OpusCreateFail) { | 303 TEST(OpusTest, OpusCreateFail) { |
305 WebRtcOpusEncInst* opus_encoder; | 304 WebRtcOpusEncInst* opus_encoder; |
306 WebRtcOpusDecInst* opus_decoder; | 305 WebRtcOpusDecInst* opus_decoder; |
307 | 306 |
308 // Test to see that an invalid pointer is caught. | 307 // Test to see that an invalid pointer is caught. |
309 EXPECT_EQ(-1, WebRtcOpus_EncoderCreate(NULL, 1, 0)); | 308 EXPECT_EQ(-1, WebRtcOpus_EncoderCreate(nullptr, 1, 0)); |
310 // Invalid channel number. | 309 // Invalid channel number. |
311 EXPECT_EQ(-1, WebRtcOpus_EncoderCreate(&opus_encoder, 3, 0)); | 310 EXPECT_EQ(-1, WebRtcOpus_EncoderCreate(&opus_encoder, 3, 0)); |
312 // Invalid applciation mode. | 311 // Invalid applciation mode. |
313 EXPECT_EQ(-1, WebRtcOpus_EncoderCreate(&opus_encoder, 1, 2)); | 312 EXPECT_EQ(-1, WebRtcOpus_EncoderCreate(&opus_encoder, 1, 2)); |
314 | 313 |
315 EXPECT_EQ(-1, WebRtcOpus_DecoderCreate(NULL, 1)); | 314 EXPECT_EQ(-1, WebRtcOpus_DecoderCreate(nullptr, 1)); |
316 // Invalid channel number. | 315 // Invalid channel number. |
317 EXPECT_EQ(-1, WebRtcOpus_DecoderCreate(&opus_decoder, 3)); | 316 EXPECT_EQ(-1, WebRtcOpus_DecoderCreate(&opus_decoder, 3)); |
318 } | 317 } |
319 | 318 |
320 // Test failing Free. | 319 // Test failing Free. |
321 TEST(OpusTest, OpusFreeFail) { | 320 TEST(OpusTest, OpusFreeFail) { |
322 // Test to see that an invalid pointer is caught. | 321 // Test to see that an invalid pointer is caught. |
323 EXPECT_EQ(-1, WebRtcOpus_EncoderFree(NULL)); | 322 EXPECT_EQ(-1, WebRtcOpus_EncoderFree(nullptr)); |
324 EXPECT_EQ(-1, WebRtcOpus_DecoderFree(NULL)); | 323 EXPECT_EQ(-1, WebRtcOpus_DecoderFree(nullptr)); |
325 } | 324 } |
326 | 325 |
327 // Test normal Create and Free. | 326 // Test normal Create and Free. |
328 TEST_P(OpusTest, OpusCreateFree) { | 327 TEST_P(OpusTest, OpusCreateFree) { |
329 EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, | 328 EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, |
330 channels_, | 329 channels_, |
331 application_)); | 330 application_)); |
332 EXPECT_EQ(0, WebRtcOpus_DecoderCreate(&opus_decoder_, channels_)); | 331 EXPECT_EQ(0, WebRtcOpus_DecoderCreate(&opus_decoder_, channels_)); |
333 EXPECT_TRUE(opus_encoder_ != NULL); | 332 EXPECT_TRUE(opus_encoder_ != nullptr); |
334 EXPECT_TRUE(opus_decoder_ != NULL); | 333 EXPECT_TRUE(opus_decoder_ != nullptr); |
335 // Free encoder and decoder memory. | 334 // Free encoder and decoder memory. |
336 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); | 335 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); |
337 EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_decoder_)); | 336 EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_decoder_)); |
338 } | 337 } |
339 | 338 |
340 TEST_P(OpusTest, OpusEncodeDecode) { | 339 TEST_P(OpusTest, OpusEncodeDecode) { |
341 PrepareSpeechData(channels_, 20, 20); | 340 PrepareSpeechData(channels_, 20, 20); |
342 | 341 |
343 // Create encoder memory. | 342 // Create encoder memory. |
344 EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, | 343 EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_, |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); | 692 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); |
694 EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_decoder_)); | 693 EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_decoder_)); |
695 } | 694 } |
696 | 695 |
697 INSTANTIATE_TEST_CASE_P(VariousMode, | 696 INSTANTIATE_TEST_CASE_P(VariousMode, |
698 OpusTest, | 697 OpusTest, |
699 Combine(Values(1, 2), Values(0, 1))); | 698 Combine(Values(1, 2), Values(0, 1))); |
700 | 699 |
701 | 700 |
702 } // namespace webrtc | 701 } // namespace webrtc |
OLD | NEW |