OLD | NEW |
---|---|
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 1297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1308 static constexpr size_t kSamples = 10 * 16; | 1308 static constexpr size_t kSamples = 10 * 16; |
1309 static constexpr size_t kPayloadBytes = kSamples * 2; | 1309 static constexpr size_t kPayloadBytes = kSamples * 2; |
1310 | 1310 |
1311 void InsertPacket(uint32_t rtp_timestamp) { | 1311 void InsertPacket(uint32_t rtp_timestamp) { |
1312 uint8_t payload[kPayloadBytes] = {0}; | 1312 uint8_t payload[kPayloadBytes] = {0}; |
1313 WebRtcRTPHeader rtp_info; | 1313 WebRtcRTPHeader rtp_info; |
1314 PopulateRtpInfo(0, rtp_timestamp, &rtp_info); | 1314 PopulateRtpInfo(0, rtp_timestamp, &rtp_info); |
1315 EXPECT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); | 1315 EXPECT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
1316 } | 1316 } |
1317 | 1317 |
1318 void InsertCngPacket(uint32_t rtp_timestamp) { | |
1319 uint8_t payload[kPayloadBytes] = {0}; | |
1320 WebRtcRTPHeader rtp_info; | |
1321 size_t payload_len; | |
1322 PopulateCng(0, rtp_timestamp, &rtp_info, payload, &payload_len); | |
1323 EXPECT_EQ( | |
1324 NetEq::kOK, | |
1325 neteq_->InsertPacket( | |
1326 rtp_info, rtc::ArrayView<const uint8_t>(payload, payload_len), 0)); | |
1327 } | |
1328 | |
1318 bool GetAudioReturnMuted() { | 1329 bool GetAudioReturnMuted() { |
1319 bool muted; | 1330 bool muted; |
1320 EXPECT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); | 1331 EXPECT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); |
1321 return muted; | 1332 return muted; |
1322 } | 1333 } |
1323 | 1334 |
1324 void GetAudioUntilMuted() { | 1335 void GetAudioUntilMuted() { |
1325 while (!GetAudioReturnMuted()) { | 1336 while (!GetAudioReturnMuted()) { |
1326 ASSERT_LT(counter_++, 1000) << "Test timed out"; | 1337 ASSERT_LT(counter_++, 1000) << "Test timed out"; |
1327 } | 1338 } |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1422 // Pull data until faded out. | 1433 // Pull data until faded out. |
1423 GetAudioUntilMuted(); | 1434 GetAudioUntilMuted(); |
1424 | 1435 |
1425 EXPECT_NE(AudioFrame::kNormalSpeech, out_frame_.speech_type_); | 1436 EXPECT_NE(AudioFrame::kNormalSpeech, out_frame_.speech_type_); |
1426 // Insert packet which is older than the first packet. | 1437 // Insert packet which is older than the first packet. |
1427 InsertPacket(kSamples * (counter_ - 1000)); | 1438 InsertPacket(kSamples * (counter_ - 1000)); |
1428 EXPECT_FALSE(GetAudioReturnMuted()); | 1439 EXPECT_FALSE(GetAudioReturnMuted()); |
1429 EXPECT_EQ(AudioFrame::kNormalSpeech, out_frame_.speech_type_); | 1440 EXPECT_EQ(AudioFrame::kNormalSpeech, out_frame_.speech_type_); |
1430 } | 1441 } |
1431 | 1442 |
1443 // Verifies that NetEq doesn't enter muted state when CNG mode is active and the | |
1444 // packet stream is suspended for a long time. | |
1445 TEST_F(NetEqDecodingTestWithMutedState, DoNotMuteExtendedCngWithoutPackets) { | |
1446 // Insert one speech packet. | |
1447 InsertCngPacket(0); | |
1448 | |
1449 // Pull 10 seconds of audio (10 ms per lap). | |
1450 for (int i = 0; i < 1000; ++i) { | |
aleloi
2016/09/19 11:55:07
Does it take much time to do 1000 iterations? I.e.
hlundin-webrtc
2016/09/20 08:09:02
The test completes in 22 ms on my machine. It runs
| |
1451 bool muted; | |
1452 EXPECT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); | |
1453 EXPECT_EQ(AudioFrame::kCNG, out_frame_.speech_type_); | |
1454 ASSERT_FALSE(muted); | |
aleloi
2016/09/19 11:55:07
I recently read go/unit-test-practices and I think
hlundin-webrtc
2016/09/20 08:09:02
How about this?
| |
1455 } | |
1456 | |
1457 // Insert new data. Timestamp is corrected for the time elapsed since the last | |
1458 // packet. Verify that normal operation resumes. | |
1459 InsertPacket(kSamples * counter_); | |
1460 GetAudioUntilNormal(); | |
1461 } | |
1462 | |
1432 class NetEqDecodingTestTwoInstances : public NetEqDecodingTest { | 1463 class NetEqDecodingTestTwoInstances : public NetEqDecodingTest { |
1433 public: | 1464 public: |
1434 NetEqDecodingTestTwoInstances() : NetEqDecodingTest() {} | 1465 NetEqDecodingTestTwoInstances() : NetEqDecodingTest() {} |
1435 | 1466 |
1436 void SetUp() override { | 1467 void SetUp() override { |
1437 NetEqDecodingTest::SetUp(); | 1468 NetEqDecodingTest::SetUp(); |
1438 config2_ = config_; | 1469 config2_ = config_; |
1439 } | 1470 } |
1440 | 1471 |
1441 void CreateSecondInstance() { | 1472 void CreateSecondInstance() { |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1542 if (muted) { | 1573 if (muted) { |
1543 EXPECT_TRUE(AudioFramesEqualExceptData(out_frame1, out_frame2)); | 1574 EXPECT_TRUE(AudioFramesEqualExceptData(out_frame1, out_frame2)); |
1544 } else { | 1575 } else { |
1545 EXPECT_TRUE(AudioFramesEqual(out_frame1, out_frame2)); | 1576 EXPECT_TRUE(AudioFramesEqual(out_frame1, out_frame2)); |
1546 } | 1577 } |
1547 } | 1578 } |
1548 EXPECT_FALSE(muted); | 1579 EXPECT_FALSE(muted); |
1549 } | 1580 } |
1550 | 1581 |
1551 } // namespace webrtc | 1582 } // namespace webrtc |
OLD | NEW |