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 |
(...skipping 26 matching lines...) Expand all Loading... |
37 RegisterFlagValidator(&FLAGS_bit_rate_kbps, &ValidateBitRate); | 37 RegisterFlagValidator(&FLAGS_bit_rate_kbps, &ValidateBitRate); |
38 | 38 |
39 } // namespace | 39 } // namespace |
40 | 40 |
41 class NetEqIsacQualityTest : public NetEqQualityTest { | 41 class NetEqIsacQualityTest : public NetEqQualityTest { |
42 protected: | 42 protected: |
43 NetEqIsacQualityTest(); | 43 NetEqIsacQualityTest(); |
44 void SetUp() override; | 44 void SetUp() override; |
45 void TearDown() override; | 45 void TearDown() override; |
46 virtual int EncodeBlock(int16_t* in_data, size_t block_size_samples, | 46 virtual int EncodeBlock(int16_t* in_data, size_t block_size_samples, |
47 uint8_t* payload, size_t max_bytes); | 47 rtc::Buffer* payload, size_t max_bytes); |
48 private: | 48 private: |
49 ISACFIX_MainStruct* isac_encoder_; | 49 ISACFIX_MainStruct* isac_encoder_; |
50 int bit_rate_kbps_; | 50 int bit_rate_kbps_; |
51 }; | 51 }; |
52 | 52 |
53 NetEqIsacQualityTest::NetEqIsacQualityTest() | 53 NetEqIsacQualityTest::NetEqIsacQualityTest() |
54 : NetEqQualityTest(kIsacBlockDurationMs, | 54 : NetEqQualityTest(kIsacBlockDurationMs, |
55 kIsacInputSamplingKhz, | 55 kIsacInputSamplingKhz, |
56 kIsacOutputSamplingKhz, | 56 kIsacOutputSamplingKhz, |
57 NetEqDecoder::kDecoderISAC), | 57 NetEqDecoder::kDecoderISAC), |
(...skipping 13 matching lines...) Expand all Loading... |
71 } | 71 } |
72 | 72 |
73 void NetEqIsacQualityTest::TearDown() { | 73 void NetEqIsacQualityTest::TearDown() { |
74 // Free memory. | 74 // Free memory. |
75 EXPECT_EQ(0, WebRtcIsacfix_Free(isac_encoder_)); | 75 EXPECT_EQ(0, WebRtcIsacfix_Free(isac_encoder_)); |
76 NetEqQualityTest::TearDown(); | 76 NetEqQualityTest::TearDown(); |
77 } | 77 } |
78 | 78 |
79 int NetEqIsacQualityTest::EncodeBlock(int16_t* in_data, | 79 int NetEqIsacQualityTest::EncodeBlock(int16_t* in_data, |
80 size_t block_size_samples, | 80 size_t block_size_samples, |
81 uint8_t* payload, size_t max_bytes) { | 81 rtc::Buffer* payload, size_t max_bytes) { |
82 // ISAC takes 10 ms for every call. | 82 // ISAC takes 10 ms for every call. |
83 const int subblocks = kIsacBlockDurationMs / 10; | 83 const int subblocks = kIsacBlockDurationMs / 10; |
84 const int subblock_length = 10 * kIsacInputSamplingKhz; | 84 const int subblock_length = 10 * kIsacInputSamplingKhz; |
85 int value = 0; | 85 int value = 0; |
86 | 86 |
87 int pointer = 0; | 87 int pointer = 0; |
88 for (int idx = 0; idx < subblocks; idx++, pointer += subblock_length) { | 88 for (int idx = 0; idx < subblocks; idx++, pointer += subblock_length) { |
89 // The Isac encoder does not perform encoding (and returns 0) until it | 89 // The Isac encoder does not perform encoding (and returns 0) until it |
90 // receives a sequence of sub-blocks that amount to the frame duration. | 90 // receives a sequence of sub-blocks that amount to the frame duration. |
91 EXPECT_EQ(0, value); | 91 EXPECT_EQ(0, value); |
92 value = WebRtcIsacfix_Encode(isac_encoder_, &in_data[pointer], payload); | 92 payload->AppendData(max_bytes, [&] (rtc::ArrayView<uint8_t> payload) { |
| 93 value = WebRtcIsacfix_Encode(isac_encoder_, &in_data[pointer], |
| 94 payload.data()); |
| 95 return (value >= 0) ? static_cast<size_t>(value) : 0; |
| 96 }); |
93 } | 97 } |
94 EXPECT_GT(value, 0); | 98 EXPECT_GT(value, 0); |
95 return value; | 99 return value; |
96 } | 100 } |
97 | 101 |
98 TEST_F(NetEqIsacQualityTest, Test) { | 102 TEST_F(NetEqIsacQualityTest, Test) { |
99 Simulate(); | 103 Simulate(); |
100 } | 104 } |
101 | 105 |
102 } // namespace test | 106 } // namespace test |
103 } // namespace webrtc | 107 } // namespace webrtc |
OLD | NEW |