OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 | 94 |
95 // Verify NoEncoding. | 95 // Verify NoEncoding. |
96 expected_timestamp += 2 * kDataLengthSamples; | 96 expected_timestamp += 2 * kDataLengthSamples; |
97 { | 97 { |
98 SCOPED_TRACE("Fourth encoding"); | 98 SCOPED_TRACE("Fourth encoding"); |
99 EncodeAndVerify(0, expected_timestamp, kCngPt, 1); | 99 EncodeAndVerify(0, expected_timestamp, kCngPt, 1); |
100 } | 100 } |
101 } | 101 } |
102 | 102 |
103 TEST(RentACodecTest, ExternalEncoder) { | 103 TEST(RentACodecTest, ExternalEncoder) { |
| 104 const int kSampleRateHz = 8000; |
104 MockAudioEncoder external_encoder; | 105 MockAudioEncoder external_encoder; |
| 106 EXPECT_CALL(external_encoder, SampleRateHz()) |
| 107 .WillRepeatedly(Return(kSampleRateHz)); |
| 108 EXPECT_CALL(external_encoder, NumChannels()).WillRepeatedly(Return(1)); |
| 109 EXPECT_CALL(external_encoder, SetFec(false)).WillRepeatedly(Return(true)); |
| 110 |
105 RentACodec rac; | 111 RentACodec rac; |
106 RentACodec::StackParameters param; | 112 RentACodec::StackParameters param; |
107 EXPECT_EQ(&external_encoder, rac.RentEncoderStack(&external_encoder, ¶m)); | 113 EXPECT_EQ(&external_encoder, rac.RentEncoderStack(&external_encoder, ¶m)); |
108 const int kSampleRateHz = 8000; | |
109 const int kPacketSizeSamples = kSampleRateHz / 100; | 114 const int kPacketSizeSamples = kSampleRateHz / 100; |
110 int16_t audio[kPacketSizeSamples] = {0}; | 115 int16_t audio[kPacketSizeSamples] = {0}; |
111 uint8_t encoded[kPacketSizeSamples]; | 116 uint8_t encoded[kPacketSizeSamples]; |
112 AudioEncoder::EncodedInfo info; | 117 AudioEncoder::EncodedInfo info; |
113 EXPECT_CALL(external_encoder, SampleRateHz()) | |
114 .WillRepeatedly(Return(kSampleRateHz)); | |
115 EXPECT_CALL(external_encoder, NumChannels()).WillRepeatedly(Return(1)); | |
116 | 118 |
117 { | 119 { |
118 ::testing::InSequence s; | 120 ::testing::InSequence s; |
119 info.encoded_timestamp = 0; | 121 info.encoded_timestamp = 0; |
120 EXPECT_CALL(external_encoder, | 122 EXPECT_CALL(external_encoder, |
121 EncodeInternal(0, rtc::ArrayView<const int16_t>(audio), | 123 EncodeInternal(0, rtc::ArrayView<const int16_t>(audio), |
122 arraysize(encoded), encoded)) | 124 arraysize(encoded), encoded)) |
123 .WillOnce(Return(info)); | 125 .WillOnce(Return(info)); |
124 EXPECT_CALL(external_encoder, Mark("A")); | 126 EXPECT_CALL(external_encoder, Mark("A")); |
125 EXPECT_CALL(external_encoder, Mark("B")); | 127 EXPECT_CALL(external_encoder, Mark("B")); |
(...skipping 27 matching lines...) Expand all Loading... |
153 } | 155 } |
154 | 156 |
155 // Verify that the speech encoder's Reset method is called when CNG or RED | 157 // Verify that the speech encoder's Reset method is called when CNG or RED |
156 // (or both) are switched on, but not when they're switched off. | 158 // (or both) are switched on, but not when they're switched off. |
157 void TestCngAndRedResetSpeechEncoder(bool use_cng, bool use_red) { | 159 void TestCngAndRedResetSpeechEncoder(bool use_cng, bool use_red) { |
158 MockAudioEncoder speech_encoder; | 160 MockAudioEncoder speech_encoder; |
159 EXPECT_CALL(speech_encoder, NumChannels()).WillRepeatedly(Return(1)); | 161 EXPECT_CALL(speech_encoder, NumChannels()).WillRepeatedly(Return(1)); |
160 EXPECT_CALL(speech_encoder, Max10MsFramesInAPacket()) | 162 EXPECT_CALL(speech_encoder, Max10MsFramesInAPacket()) |
161 .WillRepeatedly(Return(2)); | 163 .WillRepeatedly(Return(2)); |
162 EXPECT_CALL(speech_encoder, SampleRateHz()).WillRepeatedly(Return(8000)); | 164 EXPECT_CALL(speech_encoder, SampleRateHz()).WillRepeatedly(Return(8000)); |
| 165 EXPECT_CALL(speech_encoder, SetFec(false)).WillRepeatedly(Return(true)); |
163 { | 166 { |
164 ::testing::InSequence s; | 167 ::testing::InSequence s; |
165 EXPECT_CALL(speech_encoder, Mark("disabled")); | 168 EXPECT_CALL(speech_encoder, Mark("disabled")); |
166 EXPECT_CALL(speech_encoder, Mark("enabled")); | 169 EXPECT_CALL(speech_encoder, Mark("enabled")); |
167 if (use_cng || use_red) | 170 if (use_cng || use_red) |
168 EXPECT_CALL(speech_encoder, Reset()); | 171 EXPECT_CALL(speech_encoder, Reset()); |
169 EXPECT_CALL(speech_encoder, Die()); | 172 EXPECT_CALL(speech_encoder, Die()); |
170 } | 173 } |
171 | 174 |
172 RentACodec::StackParameters param1, param2; | 175 RentACodec::StackParameters param1, param2; |
(...skipping 24 matching lines...) Expand all Loading... |
197 | 200 |
198 TEST(RentACodecTest, RentEncoderError) { | 201 TEST(RentACodecTest, RentEncoderError) { |
199 const CodecInst codec_inst = { | 202 const CodecInst codec_inst = { |
200 0, "Robert'); DROP TABLE Students;", 8000, 160, 1, 64000}; | 203 0, "Robert'); DROP TABLE Students;", 8000, 160, 1, 64000}; |
201 RentACodec rent_a_codec; | 204 RentACodec rent_a_codec; |
202 EXPECT_FALSE(rent_a_codec.RentEncoder(codec_inst)); | 205 EXPECT_FALSE(rent_a_codec.RentEncoder(codec_inst)); |
203 } | 206 } |
204 | 207 |
205 } // namespace acm2 | 208 } // namespace acm2 |
206 } // namespace webrtc | 209 } // namespace webrtc |
OLD | NEW |