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

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

Issue 2404183003: Fix bug in DTMF generation where events with level > 36 would be ignored. (Closed)
Patch Set: reviewer comments Created 4 years, 2 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/dtmf_tone_generator_unittest.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) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 // Insert one more packet and make sure the buffer got flushed. That is, it 374 // Insert one more packet and make sure the buffer got flushed. That is, it
375 // should only hold one single packet. 375 // should only hold one single packet.
376 EXPECT_EQ(NetEq::kOK, 376 EXPECT_EQ(NetEq::kOK,
377 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); 377 neteq_->InsertPacket(rtp_header, payload, kReceiveTime));
378 EXPECT_EQ(1u, packet_buffer_->NumPacketsInBuffer()); 378 EXPECT_EQ(1u, packet_buffer_->NumPacketsInBuffer());
379 const RTPHeader* test_header = packet_buffer_->NextRtpHeader(); 379 const RTPHeader* test_header = packet_buffer_->NextRtpHeader();
380 EXPECT_EQ(rtp_header.header.timestamp, test_header->timestamp); 380 EXPECT_EQ(rtp_header.header.timestamp, test_header->timestamp);
381 EXPECT_EQ(rtp_header.header.sequenceNumber, test_header->sequenceNumber); 381 EXPECT_EQ(rtp_header.header.sequenceNumber, test_header->sequenceNumber);
382 } 382 }
383 383
384 TEST_F(NetEqImplTest, TestDtmfPacket) {
385 UseNoMocks();
386 CreateInstance();
387 const size_t kPayloadLength = 4;
388 const uint8_t kPayloadType = 110;
389 const uint32_t kReceiveTime = 17;
390 const int kSampleRateHz = 8000;
391 // Event: 2, E bit, Volume: 63, Length: 4176.
392 uint8_t payload[kPayloadLength] = { 0x02, 0x80 + 0x3F, 0x10, 0xF0 };
393 WebRtcRTPHeader rtp_header;
394 rtp_header.header.payloadType = kPayloadType;
395 rtp_header.header.sequenceNumber = 0x1234;
396 rtp_header.header.timestamp = 0x12345678;
397 rtp_header.header.ssrc = 0x87654321;
398
399 EXPECT_EQ(NetEq::kOK, neteq_->RegisterPayloadType(
400 NetEqDecoder::kDecoderAVT, "telephone-event", kPayloadType));
401
402 // Insert one packet.
403 EXPECT_EQ(NetEq::kOK,
404 neteq_->InsertPacket(rtp_header, payload, kReceiveTime));
405
406 // Pull audio once.
407 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000);
408 AudioFrame output;
409 bool muted;
410 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted));
411 ASSERT_FALSE(muted);
412 ASSERT_EQ(kMaxOutputSize, output.samples_per_channel_);
413 EXPECT_EQ(1u, output.num_channels_);
414 EXPECT_EQ(AudioFrame::kNormalSpeech, output.speech_type_);
415 }
416
384 // This test verifies that timestamps propagate from the incoming packets 417 // This test verifies that timestamps propagate from the incoming packets
385 // through to the sync buffer and to the playout timestamp. 418 // through to the sync buffer and to the playout timestamp.
386 TEST_F(NetEqImplTest, VerifyTimestampPropagation) { 419 TEST_F(NetEqImplTest, VerifyTimestampPropagation) {
387 UseNoMocks(); 420 UseNoMocks();
388 CreateInstance(); 421 CreateInstance();
389 422
390 const uint8_t kPayloadType = 17; // Just an arbitrary number. 423 const uint8_t kPayloadType = 17; // Just an arbitrary number.
391 const uint32_t kReceiveTime = 17; // Value doesn't matter for this test. 424 const uint32_t kReceiveTime = 17; // Value doesn't matter for this test.
392 const int kSampleRateHz = 8000; 425 const int kSampleRateHz = 8000;
393 const size_t kPayloadLengthSamples = 426 const size_t kPayloadLengthSamples =
(...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after
1425 EXPECT_CALL(*mock_delay_manager_, BufferLimits(_, _)) 1458 EXPECT_CALL(*mock_delay_manager_, BufferLimits(_, _))
1426 .Times(1) 1459 .Times(1)
1427 .WillOnce(DoAll(SetArgPointee<0>(1), SetArgPointee<1>(2))); 1460 .WillOnce(DoAll(SetArgPointee<0>(1), SetArgPointee<1>(2)));
1428 1461
1429 bool muted; 1462 bool muted;
1430 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output_, &muted)); 1463 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output_, &muted));
1431 EXPECT_EQ(kAccelerate, neteq_->last_operation_for_test()); 1464 EXPECT_EQ(kAccelerate, neteq_->last_operation_for_test());
1432 } 1465 }
1433 1466
1434 }// namespace webrtc 1467 }// namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/neteq/dtmf_tone_generator_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698