Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(268)

Side by Side Diff: webrtc/modules/audio_coding/neteq/neteq_unittest.cc

Issue 2965203002: Let NetEq reset the AudioFrame during muted state (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/modules/audio_coding/neteq/neteq_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2011 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 1318 matching lines...) Expand 10 before | Expand all | Expand 10 after
1329 }; 1329 };
1330 1330
1331 // Verifies that NetEq goes in and out of muted state as expected. 1331 // Verifies that NetEq goes in and out of muted state as expected.
1332 TEST_F(NetEqDecodingTestWithMutedState, MutedState) { 1332 TEST_F(NetEqDecodingTestWithMutedState, MutedState) {
1333 // Insert one speech packet. 1333 // Insert one speech packet.
1334 InsertPacket(0); 1334 InsertPacket(0);
1335 // Pull out audio once and expect it not to be muted. 1335 // Pull out audio once and expect it not to be muted.
1336 EXPECT_FALSE(GetAudioReturnMuted()); 1336 EXPECT_FALSE(GetAudioReturnMuted());
1337 // Pull data until faded out. 1337 // Pull data until faded out.
1338 GetAudioUntilMuted(); 1338 GetAudioUntilMuted();
1339 EXPECT_TRUE(out_frame_.muted());
1339 1340
1340 // Verify that output audio is not written during muted mode. Other parameters 1341 // Verify that output audio is not written during muted mode. Other parameters
1341 // should be correct, though. 1342 // should be correct, though.
1342 AudioFrame new_frame; 1343 AudioFrame new_frame;
1343 int16_t* frame_data = new_frame.mutable_data(); 1344 int16_t* frame_data = new_frame.mutable_data();
1344 for (size_t i = 0; i < AudioFrame::kMaxDataSizeSamples; i++) { 1345 for (size_t i = 0; i < AudioFrame::kMaxDataSizeSamples; i++) {
1345 frame_data[i] = 17; 1346 frame_data[i] = 17;
1346 } 1347 }
1347 bool muted; 1348 bool muted;
1348 EXPECT_EQ(0, neteq_->GetAudio(&new_frame, &muted)); 1349 EXPECT_EQ(0, neteq_->GetAudio(&new_frame, &muted));
1349 EXPECT_TRUE(muted); 1350 EXPECT_TRUE(muted);
1351 EXPECT_TRUE(out_frame_.muted());
1350 for (size_t i = 0; i < AudioFrame::kMaxDataSizeSamples; i++) { 1352 for (size_t i = 0; i < AudioFrame::kMaxDataSizeSamples; i++) {
1351 EXPECT_EQ(17, frame_data[i]); 1353 EXPECT_EQ(17, frame_data[i]);
1352 } 1354 }
1353 EXPECT_EQ(out_frame_.timestamp_ + out_frame_.samples_per_channel_, 1355 EXPECT_EQ(out_frame_.timestamp_ + out_frame_.samples_per_channel_,
1354 new_frame.timestamp_); 1356 new_frame.timestamp_);
1355 EXPECT_EQ(out_frame_.samples_per_channel_, new_frame.samples_per_channel_); 1357 EXPECT_EQ(out_frame_.samples_per_channel_, new_frame.samples_per_channel_);
1356 EXPECT_EQ(out_frame_.sample_rate_hz_, new_frame.sample_rate_hz_); 1358 EXPECT_EQ(out_frame_.sample_rate_hz_, new_frame.sample_rate_hz_);
1357 EXPECT_EQ(out_frame_.num_channels_, new_frame.num_channels_); 1359 EXPECT_EQ(out_frame_.num_channels_, new_frame.num_channels_);
1358 EXPECT_EQ(out_frame_.speech_type_, new_frame.speech_type_); 1360 EXPECT_EQ(out_frame_.speech_type_, new_frame.speech_type_);
1359 EXPECT_EQ(out_frame_.vad_activity_, new_frame.vad_activity_); 1361 EXPECT_EQ(out_frame_.vad_activity_, new_frame.vad_activity_);
1360 1362
1361 // Insert new data. Timestamp is corrected for the time elapsed since the last 1363 // Insert new data. Timestamp is corrected for the time elapsed since the last
1362 // packet. Verify that normal operation resumes. 1364 // packet. Verify that normal operation resumes.
1363 InsertPacket(kSamples * counter_); 1365 InsertPacket(kSamples * counter_);
1364 GetAudioUntilNormal(); 1366 GetAudioUntilNormal();
1367 EXPECT_FALSE(out_frame_.muted());
1365 1368
1366 NetEqNetworkStatistics stats; 1369 NetEqNetworkStatistics stats;
1367 EXPECT_EQ(0, neteq_->NetworkStatistics(&stats)); 1370 EXPECT_EQ(0, neteq_->NetworkStatistics(&stats));
1368 // NetEqNetworkStatistics::expand_rate tells the fraction of samples that were 1371 // NetEqNetworkStatistics::expand_rate tells the fraction of samples that were
1369 // concealment samples, in Q14 (16384 = 100%) .The vast majority should be 1372 // concealment samples, in Q14 (16384 = 100%) .The vast majority should be
1370 // concealment samples in this test. 1373 // concealment samples in this test.
1371 EXPECT_GT(stats.expand_rate, 14000); 1374 EXPECT_GT(stats.expand_rate, 14000);
1372 // And, it should be greater than the speech_expand_rate. 1375 // And, it should be greater than the speech_expand_rate.
1373 EXPECT_GT(stats.expand_rate, stats.speech_expand_rate); 1376 EXPECT_GT(stats.expand_rate, stats.speech_expand_rate);
1374 } 1377 }
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
1626 // Pull out data once. 1629 // Pull out data once.
1627 AudioFrame output; 1630 AudioFrame output;
1628 bool muted; 1631 bool muted;
1629 ASSERT_EQ(0, neteq_->GetAudio(&output, &muted)); 1632 ASSERT_EQ(0, neteq_->GetAudio(&output, &muted));
1630 1633
1631 EXPECT_EQ(std::vector<uint32_t>({kRtpTimestamp1, kRtpTimestamp2}), 1634 EXPECT_EQ(std::vector<uint32_t>({kRtpTimestamp1, kRtpTimestamp2}),
1632 neteq_->LastDecodedTimestamps()); 1635 neteq_->LastDecodedTimestamps());
1633 } 1636 }
1634 1637
1635 } // namespace webrtc 1638 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/neteq/neteq_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698