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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
52 cng_.reset(); | 52 cng_.reset(); |
53 // Don't expect the cng_ object to delete the AudioEncoder object. But it | 53 // Don't expect the cng_ object to delete the AudioEncoder object. But it |
54 // will be deleted with the test fixture. This is why we explicitly delete | 54 // will be deleted with the test fixture. This is why we explicitly delete |
55 // the cng_ object above, and set expectations on mock_encoder_ afterwards. | 55 // the cng_ object above, and set expectations on mock_encoder_ afterwards. |
56 EXPECT_CALL(mock_encoder_, Die()).Times(1); | 56 EXPECT_CALL(mock_encoder_, Die()).Times(1); |
57 } | 57 } |
58 | 58 |
59 void CreateCng() { | 59 void CreateCng() { |
60 // The config_ parameters may be changed by the TEST_Fs up until CreateCng() | 60 // The config_ parameters may be changed by the TEST_Fs up until CreateCng() |
61 // is called, thus we cannot use the values until now. | 61 // is called, thus we cannot use the values until now. |
62 num_audio_samples_10ms_ = 10 * sample_rate_hz_ / 1000; | 62 num_audio_samples_10ms_ = static_cast<size_t>(10 * sample_rate_hz_ / 1000); |
63 ASSERT_LE(num_audio_samples_10ms_, kMaxNumSamples); | 63 ASSERT_LE(num_audio_samples_10ms_, kMaxNumSamples); |
64 EXPECT_CALL(mock_encoder_, SampleRateHz()) | 64 EXPECT_CALL(mock_encoder_, SampleRateHz()) |
65 .WillRepeatedly(Return(sample_rate_hz_)); | 65 .WillRepeatedly(Return(sample_rate_hz_)); |
66 // Max10MsFramesInAPacket() is just used to verify that the SID frame period | 66 // Max10MsFramesInAPacket() is just used to verify that the SID frame period |
67 // is not too small. The return value does not matter that much, as long as | 67 // is not too small. The return value does not matter that much, as long as |
68 // it is smaller than 10. | 68 // it is smaller than 10. |
69 EXPECT_CALL(mock_encoder_, Max10MsFramesInAPacket()).WillOnce(Return(1)); | 69 EXPECT_CALL(mock_encoder_, Max10MsFramesInAPacket()).WillOnce(Return(1U)); |
kwiberg-webrtc
2015/08/06 09:14:25
1u is a tiny bit easier to read.
Peter Kasting
2015/08/06 18:38:50
OK
| |
70 EXPECT_CALL(mock_encoder_, MaxEncodedBytes()) | 70 EXPECT_CALL(mock_encoder_, MaxEncodedBytes()) |
71 .WillRepeatedly(Return(kMockMaxEncodedBytes)); | 71 .WillRepeatedly(Return(kMockMaxEncodedBytes)); |
72 cng_.reset(new AudioEncoderCng(config_)); | 72 cng_.reset(new AudioEncoderCng(config_)); |
73 encoded_.resize(cng_->MaxEncodedBytes(), 0); | 73 encoded_.resize(cng_->MaxEncodedBytes(), 0); |
74 } | 74 } |
75 | 75 |
76 void Encode() { | 76 void Encode() { |
77 ASSERT_TRUE(cng_) << "Must call CreateCng() first."; | 77 ASSERT_TRUE(cng_) << "Must call CreateCng() first."; |
78 encoded_info_ = cng_->Encode(timestamp_, audio_, num_audio_samples_10ms_, | 78 encoded_info_ = cng_->Encode(timestamp_, audio_, num_audio_samples_10ms_, |
79 encoded_.size(), &encoded_[0]); | 79 encoded_.size(), &encoded_[0]); |
80 timestamp_ += static_cast<uint32_t>(num_audio_samples_10ms_); | 80 timestamp_ += static_cast<uint32_t>(num_audio_samples_10ms_); |
81 } | 81 } |
82 | 82 |
83 // Expect |num_calls| calls to the encoder, all successful. The last call | 83 // Expect |num_calls| calls to the encoder, all successful. The last call |
84 // claims to have encoded |kMockMaxEncodedBytes| bytes, and all the preceding | 84 // claims to have encoded |kMockMaxEncodedBytes| bytes, and all the preceding |
85 // ones 0 bytes. | 85 // ones 0 bytes. |
86 void ExpectEncodeCalls(int num_calls) { | 86 void ExpectEncodeCalls(size_t num_calls) { |
87 InSequence s; | 87 InSequence s; |
88 AudioEncoder::EncodedInfo info; | 88 AudioEncoder::EncodedInfo info; |
89 for (int j = 0; j < num_calls - 1; ++j) { | 89 for (size_t j = 0; j < num_calls - 1; ++j) { |
90 EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _)) | 90 EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _)) |
91 .WillOnce(Return(info)); | 91 .WillOnce(Return(info)); |
92 } | 92 } |
93 info.encoded_bytes = kMockReturnEncodedBytes; | 93 info.encoded_bytes = kMockReturnEncodedBytes; |
94 EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _)) | 94 EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _)) |
95 .WillOnce(Return(info)); | 95 .WillOnce(Return(info)); |
96 } | 96 } |
97 | 97 |
98 // Verifies that the cng_ object waits until it has collected | 98 // Verifies that the cng_ object waits until it has collected |
99 // |blocks_per_frame| blocks of audio, and then dispatches all of them to | 99 // |blocks_per_frame| blocks of audio, and then dispatches all of them to |
100 // the underlying codec (speech or cng). | 100 // the underlying codec (speech or cng). |
101 void CheckBlockGrouping(int blocks_per_frame, bool active_speech) { | 101 void CheckBlockGrouping(size_t blocks_per_frame, bool active_speech) { |
102 EXPECT_CALL(mock_encoder_, Num10MsFramesInNextPacket()) | 102 EXPECT_CALL(mock_encoder_, Num10MsFramesInNextPacket()) |
103 .WillRepeatedly(Return(blocks_per_frame)); | 103 .WillRepeatedly(Return(blocks_per_frame)); |
104 CreateCng(); | 104 CreateCng(); |
105 EXPECT_CALL(*mock_vad_, VoiceActivity(_, _, _)) | 105 EXPECT_CALL(*mock_vad_, VoiceActivity(_, _, _)) |
106 .WillRepeatedly(Return(active_speech ? Vad::kActive : Vad::kPassive)); | 106 .WillRepeatedly(Return(active_speech ? Vad::kActive : Vad::kPassive)); |
107 | 107 |
108 // Don't expect any calls to the encoder yet. | 108 // Don't expect any calls to the encoder yet. |
109 EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _)).Times(0); | 109 EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _)).Times(0); |
110 for (int i = 0; i < blocks_per_frame - 1; ++i) { | 110 for (size_t i = 0; i < blocks_per_frame - 1; ++i) { |
111 Encode(); | 111 Encode(); |
112 EXPECT_EQ(0u, encoded_info_.encoded_bytes); | 112 EXPECT_EQ(0u, encoded_info_.encoded_bytes); |
113 } | 113 } |
114 if (active_speech) | 114 if (active_speech) |
115 ExpectEncodeCalls(blocks_per_frame); | 115 ExpectEncodeCalls(blocks_per_frame); |
116 Encode(); | 116 Encode(); |
117 if (active_speech) { | 117 if (active_speech) { |
118 EXPECT_EQ(kMockReturnEncodedBytes, encoded_info_.encoded_bytes); | 118 EXPECT_EQ(kMockReturnEncodedBytes, encoded_info_.encoded_bytes); |
119 } else { | 119 } else { |
120 EXPECT_EQ(static_cast<size_t>(config_.num_cng_coefficients + 1), | 120 EXPECT_EQ(static_cast<size_t>(config_.num_cng_coefficients + 1), |
121 encoded_info_.encoded_bytes); | 121 encoded_info_.encoded_bytes); |
122 } | 122 } |
123 } | 123 } |
124 | 124 |
125 // Verifies that the audio is partitioned into larger blocks before calling | 125 // Verifies that the audio is partitioned into larger blocks before calling |
126 // the VAD. | 126 // the VAD. |
127 void CheckVadInputSize(int input_frame_size_ms, | 127 void CheckVadInputSize(int input_frame_size_ms, |
128 int expected_first_block_size_ms, | 128 int expected_first_block_size_ms, |
129 int expected_second_block_size_ms) { | 129 int expected_second_block_size_ms) { |
130 const int blocks_per_frame = input_frame_size_ms / 10; | 130 const size_t blocks_per_frame = |
131 static_cast<size_t>(input_frame_size_ms / 10); | |
131 | 132 |
132 EXPECT_CALL(mock_encoder_, Num10MsFramesInNextPacket()) | 133 EXPECT_CALL(mock_encoder_, Num10MsFramesInNextPacket()) |
133 .WillRepeatedly(Return(blocks_per_frame)); | 134 .WillRepeatedly(Return(blocks_per_frame)); |
134 | 135 |
135 // Expect nothing to happen before the last block is sent to cng_. | 136 // Expect nothing to happen before the last block is sent to cng_. |
136 EXPECT_CALL(*mock_vad_, VoiceActivity(_, _, _)).Times(0); | 137 EXPECT_CALL(*mock_vad_, VoiceActivity(_, _, _)).Times(0); |
137 for (int i = 0; i < blocks_per_frame - 1; ++i) { | 138 for (size_t i = 0; i < blocks_per_frame - 1; ++i) { |
138 Encode(); | 139 Encode(); |
139 } | 140 } |
140 | 141 |
141 // Let the VAD decision be passive, since an active decision may lead to | 142 // Let the VAD decision be passive, since an active decision may lead to |
142 // early termination of the decision loop. | 143 // early termination of the decision loop. |
143 InSequence s; | 144 InSequence s; |
144 EXPECT_CALL( | 145 EXPECT_CALL( |
145 *mock_vad_, | 146 *mock_vad_, |
146 VoiceActivity(_, expected_first_block_size_ms * sample_rate_hz_ / 1000, | 147 VoiceActivity(_, expected_first_block_size_ms * sample_rate_hz_ / 1000, |
147 sample_rate_hz_)).WillOnce(Return(Vad::kPassive)); | 148 sample_rate_hz_)).WillOnce(Return(Vad::kPassive)); |
148 if (expected_second_block_size_ms > 0) { | 149 if (expected_second_block_size_ms > 0) { |
149 EXPECT_CALL(*mock_vad_, | 150 EXPECT_CALL(*mock_vad_, |
150 VoiceActivity( | 151 VoiceActivity( |
151 _, expected_second_block_size_ms * sample_rate_hz_ / 1000, | 152 _, expected_second_block_size_ms * sample_rate_hz_ / 1000, |
152 sample_rate_hz_)).WillOnce(Return(Vad::kPassive)); | 153 sample_rate_hz_)).WillOnce(Return(Vad::kPassive)); |
153 } | 154 } |
154 | 155 |
155 // With this call to Encode(), |mock_vad_| should be called according to the | 156 // With this call to Encode(), |mock_vad_| should be called according to the |
156 // above expectations. | 157 // above expectations. |
157 Encode(); | 158 Encode(); |
158 } | 159 } |
159 | 160 |
160 // Tests a frame with both active and passive speech. Returns true if the | 161 // Tests a frame with both active and passive speech. Returns true if the |
161 // decision was active speech, false if it was passive. | 162 // decision was active speech, false if it was passive. |
162 bool CheckMixedActivePassive(Vad::Activity first_type, | 163 bool CheckMixedActivePassive(Vad::Activity first_type, |
163 Vad::Activity second_type) { | 164 Vad::Activity second_type) { |
164 // Set the speech encoder frame size to 60 ms, to ensure that the VAD will | 165 // Set the speech encoder frame size to 60 ms, to ensure that the VAD will |
165 // be called twice. | 166 // be called twice. |
166 const int blocks_per_frame = 6; | 167 const size_t blocks_per_frame = 6; |
167 EXPECT_CALL(mock_encoder_, Num10MsFramesInNextPacket()) | 168 EXPECT_CALL(mock_encoder_, Num10MsFramesInNextPacket()) |
168 .WillRepeatedly(Return(blocks_per_frame)); | 169 .WillRepeatedly(Return(blocks_per_frame)); |
169 InSequence s; | 170 InSequence s; |
170 EXPECT_CALL(*mock_vad_, VoiceActivity(_, _, _)) | 171 EXPECT_CALL(*mock_vad_, VoiceActivity(_, _, _)) |
171 .WillOnce(Return(first_type)); | 172 .WillOnce(Return(first_type)); |
172 if (first_type == Vad::kPassive) { | 173 if (first_type == Vad::kPassive) { |
173 // Expect a second call to the VAD only if the first frame was passive. | 174 // Expect a second call to the VAD only if the first frame was passive. |
174 EXPECT_CALL(*mock_vad_, VoiceActivity(_, _, _)) | 175 EXPECT_CALL(*mock_vad_, VoiceActivity(_, _, _)) |
175 .WillOnce(Return(second_type)); | 176 .WillOnce(Return(second_type)); |
176 } | 177 } |
177 encoded_info_.payload_type = 0; | 178 encoded_info_.payload_type = 0; |
178 for (int i = 0; i < blocks_per_frame; ++i) { | 179 for (size_t i = 0; i < blocks_per_frame; ++i) { |
179 Encode(); | 180 Encode(); |
180 } | 181 } |
181 return encoded_info_.payload_type != kCngPayloadType; | 182 return encoded_info_.payload_type != kCngPayloadType; |
182 } | 183 } |
183 | 184 |
184 AudioEncoderCng::Config config_; | 185 AudioEncoderCng::Config config_; |
185 rtc::scoped_ptr<AudioEncoderCng> cng_; | 186 rtc::scoped_ptr<AudioEncoderCng> cng_; |
186 MockAudioEncoder mock_encoder_; | 187 MockAudioEncoder mock_encoder_; |
187 MockVad* mock_vad_; // Ownership is transferred to |cng_|. | 188 MockVad* mock_vad_; // Ownership is transferred to |cng_|. |
188 uint32_t timestamp_; | 189 uint32_t timestamp_; |
189 int16_t audio_[kMaxNumSamples]; | 190 int16_t audio_[kMaxNumSamples]; |
190 size_t num_audio_samples_10ms_; | 191 size_t num_audio_samples_10ms_; |
191 std::vector<uint8_t> encoded_; | 192 std::vector<uint8_t> encoded_; |
192 AudioEncoder::EncodedInfo encoded_info_; | 193 AudioEncoder::EncodedInfo encoded_info_; |
193 int sample_rate_hz_; | 194 int sample_rate_hz_; |
194 }; | 195 }; |
195 | 196 |
196 TEST_F(AudioEncoderCngTest, CreateAndDestroy) { | 197 TEST_F(AudioEncoderCngTest, CreateAndDestroy) { |
197 CreateCng(); | 198 CreateCng(); |
198 } | 199 } |
199 | 200 |
200 TEST_F(AudioEncoderCngTest, CheckFrameSizePropagation) { | 201 TEST_F(AudioEncoderCngTest, CheckFrameSizePropagation) { |
201 CreateCng(); | 202 CreateCng(); |
202 EXPECT_CALL(mock_encoder_, Num10MsFramesInNextPacket()).WillOnce(Return(17)); | 203 EXPECT_CALL(mock_encoder_, Num10MsFramesInNextPacket()).WillOnce(Return(17U)); |
203 EXPECT_EQ(17, cng_->Num10MsFramesInNextPacket()); | 204 EXPECT_EQ(17U, cng_->Num10MsFramesInNextPacket()); |
204 } | 205 } |
205 | 206 |
206 TEST_F(AudioEncoderCngTest, CheckChangeBitratePropagation) { | 207 TEST_F(AudioEncoderCngTest, CheckChangeBitratePropagation) { |
207 CreateCng(); | 208 CreateCng(); |
208 EXPECT_CALL(mock_encoder_, SetTargetBitrate(4711)); | 209 EXPECT_CALL(mock_encoder_, SetTargetBitrate(4711)); |
209 cng_->SetTargetBitrate(4711); | 210 cng_->SetTargetBitrate(4711); |
210 } | 211 } |
211 | 212 |
212 TEST_F(AudioEncoderCngTest, CheckProjectedPacketLossRatePropagation) { | 213 TEST_F(AudioEncoderCngTest, CheckProjectedPacketLossRatePropagation) { |
213 CreateCng(); | 214 CreateCng(); |
214 EXPECT_CALL(mock_encoder_, SetProjectedPacketLossRate(0.5)); | 215 EXPECT_CALL(mock_encoder_, SetProjectedPacketLossRate(0.5)); |
215 cng_->SetProjectedPacketLossRate(0.5); | 216 cng_->SetProjectedPacketLossRate(0.5); |
216 } | 217 } |
217 | 218 |
218 TEST_F(AudioEncoderCngTest, EncodeCallsVad) { | 219 TEST_F(AudioEncoderCngTest, EncodeCallsVad) { |
219 EXPECT_CALL(mock_encoder_, Num10MsFramesInNextPacket()) | 220 EXPECT_CALL(mock_encoder_, Num10MsFramesInNextPacket()) |
220 .WillRepeatedly(Return(1)); | 221 .WillRepeatedly(Return(1U)); |
221 CreateCng(); | 222 CreateCng(); |
222 EXPECT_CALL(*mock_vad_, VoiceActivity(_, _, _)) | 223 EXPECT_CALL(*mock_vad_, VoiceActivity(_, _, _)) |
223 .WillOnce(Return(Vad::kPassive)); | 224 .WillOnce(Return(Vad::kPassive)); |
224 Encode(); | 225 Encode(); |
225 } | 226 } |
226 | 227 |
227 TEST_F(AudioEncoderCngTest, EncodeCollects1BlockPassiveSpeech) { | 228 TEST_F(AudioEncoderCngTest, EncodeCollects1BlockPassiveSpeech) { |
228 CheckBlockGrouping(1, false); | 229 CheckBlockGrouping(1, false); |
229 } | 230 } |
230 | 231 |
(...skipping 11 matching lines...) Expand all Loading... | |
242 | 243 |
243 TEST_F(AudioEncoderCngTest, EncodeCollects2BlocksActiveSpeech) { | 244 TEST_F(AudioEncoderCngTest, EncodeCollects2BlocksActiveSpeech) { |
244 CheckBlockGrouping(2, true); | 245 CheckBlockGrouping(2, true); |
245 } | 246 } |
246 | 247 |
247 TEST_F(AudioEncoderCngTest, EncodeCollects3BlocksActiveSpeech) { | 248 TEST_F(AudioEncoderCngTest, EncodeCollects3BlocksActiveSpeech) { |
248 CheckBlockGrouping(3, true); | 249 CheckBlockGrouping(3, true); |
249 } | 250 } |
250 | 251 |
251 TEST_F(AudioEncoderCngTest, EncodePassive) { | 252 TEST_F(AudioEncoderCngTest, EncodePassive) { |
252 const int kBlocksPerFrame = 3; | 253 const size_t kBlocksPerFrame = 3; |
253 EXPECT_CALL(mock_encoder_, Num10MsFramesInNextPacket()) | 254 EXPECT_CALL(mock_encoder_, Num10MsFramesInNextPacket()) |
254 .WillRepeatedly(Return(kBlocksPerFrame)); | 255 .WillRepeatedly(Return(kBlocksPerFrame)); |
255 CreateCng(); | 256 CreateCng(); |
256 EXPECT_CALL(*mock_vad_, VoiceActivity(_, _, _)) | 257 EXPECT_CALL(*mock_vad_, VoiceActivity(_, _, _)) |
257 .WillRepeatedly(Return(Vad::kPassive)); | 258 .WillRepeatedly(Return(Vad::kPassive)); |
258 // Expect no calls at all to the speech encoder mock. | 259 // Expect no calls at all to the speech encoder mock. |
259 EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _)).Times(0); | 260 EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _)).Times(0); |
260 uint32_t expected_timestamp = timestamp_; | 261 uint32_t expected_timestamp = timestamp_; |
261 for (int i = 0; i < 100; ++i) { | 262 for (size_t i = 0; i < 100; ++i) { |
262 Encode(); | 263 Encode(); |
263 // Check if it was time to call the cng encoder. This is done once every | 264 // Check if it was time to call the cng encoder. This is done once every |
264 // |kBlocksPerFrame| calls. | 265 // |kBlocksPerFrame| calls. |
265 if ((i + 1) % kBlocksPerFrame == 0) { | 266 if ((i + 1) % kBlocksPerFrame == 0) { |
266 // Now check if a SID interval has elapsed. | 267 // Now check if a SID interval has elapsed. |
267 if ((i % (config_.sid_frame_interval_ms / 10)) < kBlocksPerFrame) { | 268 if ((i % (config_.sid_frame_interval_ms / 10)) < kBlocksPerFrame) { |
268 // If so, verify that we got a CNG encoding. | 269 // If so, verify that we got a CNG encoding. |
269 EXPECT_EQ(kCngPayloadType, encoded_info_.payload_type); | 270 EXPECT_EQ(kCngPayloadType, encoded_info_.payload_type); |
270 EXPECT_FALSE(encoded_info_.speech); | 271 EXPECT_FALSE(encoded_info_.speech); |
271 EXPECT_EQ(static_cast<size_t>(config_.num_cng_coefficients) + 1, | 272 EXPECT_EQ(static_cast<size_t>(config_.num_cng_coefficients) + 1, |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
332 } | 333 } |
333 TEST_F(AudioEncoderCngTest, VadInputSize60Ms) { | 334 TEST_F(AudioEncoderCngTest, VadInputSize60Ms) { |
334 CreateCng(); | 335 CreateCng(); |
335 CheckVadInputSize(60, 30, 30); | 336 CheckVadInputSize(60, 30, 30); |
336 } | 337 } |
337 | 338 |
338 // Verifies that the correct payload type is set when CNG is encoded. | 339 // Verifies that the correct payload type is set when CNG is encoded. |
339 TEST_F(AudioEncoderCngTest, VerifyCngPayloadType) { | 340 TEST_F(AudioEncoderCngTest, VerifyCngPayloadType) { |
340 CreateCng(); | 341 CreateCng(); |
341 EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _)).Times(0); | 342 EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _)).Times(0); |
342 EXPECT_CALL(mock_encoder_, Num10MsFramesInNextPacket()).WillOnce(Return(1)); | 343 EXPECT_CALL(mock_encoder_, Num10MsFramesInNextPacket()).WillOnce(Return(1U)); |
343 EXPECT_CALL(*mock_vad_, VoiceActivity(_, _, _)) | 344 EXPECT_CALL(*mock_vad_, VoiceActivity(_, _, _)) |
344 .WillOnce(Return(Vad::kPassive)); | 345 .WillOnce(Return(Vad::kPassive)); |
345 encoded_info_.payload_type = 0; | 346 encoded_info_.payload_type = 0; |
346 Encode(); | 347 Encode(); |
347 EXPECT_EQ(kCngPayloadType, encoded_info_.payload_type); | 348 EXPECT_EQ(kCngPayloadType, encoded_info_.payload_type); |
348 } | 349 } |
349 | 350 |
350 // Verifies that a SID frame is encoded immediately as the signal changes from | 351 // Verifies that a SID frame is encoded immediately as the signal changes from |
351 // active speech to passive. | 352 // active speech to passive. |
352 TEST_F(AudioEncoderCngTest, VerifySidFrameAfterSpeech) { | 353 TEST_F(AudioEncoderCngTest, VerifySidFrameAfterSpeech) { |
353 CreateCng(); | 354 CreateCng(); |
354 EXPECT_CALL(mock_encoder_, Num10MsFramesInNextPacket()) | 355 EXPECT_CALL(mock_encoder_, Num10MsFramesInNextPacket()) |
355 .WillRepeatedly(Return(1)); | 356 .WillRepeatedly(Return(1U)); |
356 // Start with encoding noise. | 357 // Start with encoding noise. |
357 EXPECT_CALL(*mock_vad_, VoiceActivity(_, _, _)) | 358 EXPECT_CALL(*mock_vad_, VoiceActivity(_, _, _)) |
358 .Times(2) | 359 .Times(2) |
359 .WillRepeatedly(Return(Vad::kPassive)); | 360 .WillRepeatedly(Return(Vad::kPassive)); |
360 Encode(); | 361 Encode(); |
361 EXPECT_EQ(kCngPayloadType, encoded_info_.payload_type); | 362 EXPECT_EQ(kCngPayloadType, encoded_info_.payload_type); |
362 EXPECT_EQ(static_cast<size_t>(config_.num_cng_coefficients) + 1, | 363 EXPECT_EQ(static_cast<size_t>(config_.num_cng_coefficients) + 1, |
363 encoded_info_.encoded_bytes); | 364 encoded_info_.encoded_bytes); |
364 // Encode again, and make sure we got no frame at all (since the SID frame | 365 // Encode again, and make sure we got no frame at all (since the SID frame |
365 // period is 100 ms by default). | 366 // period is 100 ms by default). |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
436 TEST_F(AudioEncoderCngDeathTest, Stereo) { | 437 TEST_F(AudioEncoderCngDeathTest, Stereo) { |
437 EXPECT_CALL(mock_encoder_, NumChannels()).WillRepeatedly(Return(2)); | 438 EXPECT_CALL(mock_encoder_, NumChannels()).WillRepeatedly(Return(2)); |
438 EXPECT_DEATH(CreateCng(), "Invalid configuration"); | 439 EXPECT_DEATH(CreateCng(), "Invalid configuration"); |
439 config_.num_channels = 2; | 440 config_.num_channels = 2; |
440 EXPECT_DEATH(CreateCng(), "Invalid configuration"); | 441 EXPECT_DEATH(CreateCng(), "Invalid configuration"); |
441 } | 442 } |
442 | 443 |
443 TEST_F(AudioEncoderCngDeathTest, EncoderFrameSizeTooLarge) { | 444 TEST_F(AudioEncoderCngDeathTest, EncoderFrameSizeTooLarge) { |
444 CreateCng(); | 445 CreateCng(); |
445 EXPECT_CALL(mock_encoder_, Num10MsFramesInNextPacket()) | 446 EXPECT_CALL(mock_encoder_, Num10MsFramesInNextPacket()) |
446 .WillRepeatedly(Return(7)); | 447 .WillRepeatedly(Return(7U)); |
447 for (int i = 0; i < 6; ++i) | 448 for (int i = 0; i < 6; ++i) |
448 Encode(); | 449 Encode(); |
449 EXPECT_DEATH(Encode(), | 450 EXPECT_DEATH(Encode(), |
450 "Frame size cannot be larger than 60 ms when using VAD/CNG."); | 451 "Frame size cannot be larger than 60 ms when using VAD/CNG."); |
451 } | 452 } |
452 | 453 |
453 #endif // GTEST_HAS_DEATH_TEST | 454 #endif // GTEST_HAS_DEATH_TEST |
454 | 455 |
455 } // namespace webrtc | 456 } // namespace webrtc |
OLD | NEW |