OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 "webrtc/modules/audio_coding/codecs/isac/fix/include/isacfix.h" | 11 #include "webrtc/modules/audio_coding/codecs/isac/fix/include/isacfix.h" |
12 #include "webrtc/modules/audio_coding/neteq/tools/neteq_quality_test.h" | 12 #include "webrtc/modules/audio_coding/neteq/tools/neteq_quality_test.h" |
| 13 #include "webrtc/rtc_base/flags.h" |
13 | 14 |
14 using google::RegisterFlagValidator; | |
15 using google::ParseCommandLineFlags; | |
16 using testing::InitGoogleTest; | 15 using testing::InitGoogleTest; |
17 | 16 |
18 namespace webrtc { | 17 namespace webrtc { |
19 namespace test { | 18 namespace test { |
20 namespace { | 19 namespace { |
21 static const int kIsacBlockDurationMs = 30; | 20 static const int kIsacBlockDurationMs = 30; |
22 static const int kIsacInputSamplingKhz = 16; | 21 static const int kIsacInputSamplingKhz = 16; |
23 static const int kIsacOutputSamplingKhz = 16; | 22 static const int kIsacOutputSamplingKhz = 16; |
24 | 23 |
25 // Define switch for bit rate. | 24 DEFINE_int(bit_rate_kbps, 32, "Target bit rate (kbps)."); |
26 static bool ValidateBitRate(const char* flagname, int32_t value) { | |
27 if (value >= 10 && value <= 32) | |
28 return true; | |
29 printf("Invalid bit rate, should be between 10 and 32 kbps."); | |
30 return false; | |
31 } | |
32 | |
33 DEFINE_int32(bit_rate_kbps, 32, "Target bit rate (kbps)."); | |
34 | |
35 static const bool bit_rate_dummy = | |
36 RegisterFlagValidator(&FLAGS_bit_rate_kbps, &ValidateBitRate); | |
37 | 25 |
38 } // namespace | 26 } // namespace |
39 | 27 |
40 class NetEqIsacQualityTest : public NetEqQualityTest { | 28 class NetEqIsacQualityTest : public NetEqQualityTest { |
41 protected: | 29 protected: |
42 NetEqIsacQualityTest(); | 30 NetEqIsacQualityTest(); |
43 void SetUp() override; | 31 void SetUp() override; |
44 void TearDown() override; | 32 void TearDown() override; |
45 int EncodeBlock(int16_t* in_data, size_t block_size_samples, | 33 int EncodeBlock(int16_t* in_data, size_t block_size_samples, |
46 rtc::Buffer* payload, size_t max_bytes) override; | 34 rtc::Buffer* payload, size_t max_bytes) override; |
47 private: | 35 private: |
48 ISACFIX_MainStruct* isac_encoder_; | 36 ISACFIX_MainStruct* isac_encoder_; |
49 int bit_rate_kbps_; | 37 int bit_rate_kbps_; |
50 }; | 38 }; |
51 | 39 |
52 NetEqIsacQualityTest::NetEqIsacQualityTest() | 40 NetEqIsacQualityTest::NetEqIsacQualityTest() |
53 : NetEqQualityTest(kIsacBlockDurationMs, | 41 : NetEqQualityTest(kIsacBlockDurationMs, |
54 kIsacInputSamplingKhz, | 42 kIsacInputSamplingKhz, |
55 kIsacOutputSamplingKhz, | 43 kIsacOutputSamplingKhz, |
56 NetEqDecoder::kDecoderISAC), | 44 NetEqDecoder::kDecoderISAC), |
57 isac_encoder_(NULL), | 45 isac_encoder_(NULL), |
58 bit_rate_kbps_(FLAGS_bit_rate_kbps) {} | 46 bit_rate_kbps_(FLAG_bit_rate_kbps) { |
| 47 // Flag validation |
| 48 RTC_CHECK(FLAG_bit_rate_kbps >= 10 && FLAG_bit_rate_kbps <= 32) |
| 49 << "Invalid bit rate, should be between 10 and 32 kbps."; |
| 50 } |
59 | 51 |
60 void NetEqIsacQualityTest::SetUp() { | 52 void NetEqIsacQualityTest::SetUp() { |
61 ASSERT_EQ(1u, channels_) << "iSAC supports only mono audio."; | 53 ASSERT_EQ(1u, channels_) << "iSAC supports only mono audio."; |
62 // Create encoder memory. | 54 // Create encoder memory. |
63 WebRtcIsacfix_Create(&isac_encoder_); | 55 WebRtcIsacfix_Create(&isac_encoder_); |
64 ASSERT_TRUE(isac_encoder_ != NULL); | 56 ASSERT_TRUE(isac_encoder_ != NULL); |
65 EXPECT_EQ(0, WebRtcIsacfix_EncoderInit(isac_encoder_, 1)); | 57 EXPECT_EQ(0, WebRtcIsacfix_EncoderInit(isac_encoder_, 1)); |
66 // Set bitrate and block length. | 58 // Set bitrate and block length. |
67 EXPECT_EQ(0, WebRtcIsacfix_Control(isac_encoder_, bit_rate_kbps_ * 1000, | 59 EXPECT_EQ(0, WebRtcIsacfix_Control(isac_encoder_, bit_rate_kbps_ * 1000, |
68 kIsacBlockDurationMs)); | 60 kIsacBlockDurationMs)); |
(...skipping 28 matching lines...) Expand all Loading... |
97 EXPECT_GT(value, 0); | 89 EXPECT_GT(value, 0); |
98 return value; | 90 return value; |
99 } | 91 } |
100 | 92 |
101 TEST_F(NetEqIsacQualityTest, Test) { | 93 TEST_F(NetEqIsacQualityTest, Test) { |
102 Simulate(); | 94 Simulate(); |
103 } | 95 } |
104 | 96 |
105 } // namespace test | 97 } // namespace test |
106 } // namespace webrtc | 98 } // namespace webrtc |
OLD | NEW |