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

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

Issue 2337473002: Multi frequency DTMF support - receiver side (Closed)
Patch Set: rebase Created 4 years, 1 month 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
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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 EXPECT_CALL(*mock_dtmf_buffer_, Die()).Times(1); 166 EXPECT_CALL(*mock_dtmf_buffer_, Die()).Times(1);
167 } 167 }
168 if (use_mock_dtmf_tone_generator_) { 168 if (use_mock_dtmf_tone_generator_) {
169 EXPECT_CALL(*mock_dtmf_tone_generator_, Die()).Times(1); 169 EXPECT_CALL(*mock_dtmf_tone_generator_, Die()).Times(1);
170 } 170 }
171 if (use_mock_packet_buffer_) { 171 if (use_mock_packet_buffer_) {
172 EXPECT_CALL(*mock_packet_buffer_, Die()).Times(1); 172 EXPECT_CALL(*mock_packet_buffer_, Die()).Times(1);
173 } 173 }
174 } 174 }
175 175
176 void TestDtmfPacket(NetEqDecoder decoder_type) {
177 const size_t kPayloadLength = 4;
178 const uint8_t kPayloadType = 110;
179 const uint32_t kReceiveTime = 17;
180 const int kSampleRateHz = 16000;
181 config_.sample_rate_hz = kSampleRateHz;
182 UseNoMocks();
183 CreateInstance();
184 // Event: 2, E bit, Volume: 17, Length: 4336.
185 uint8_t payload[kPayloadLength] = { 0x02, 0x80 + 0x11, 0x10, 0xF0 };
186 WebRtcRTPHeader rtp_header;
187 rtp_header.header.payloadType = kPayloadType;
188 rtp_header.header.sequenceNumber = 0x1234;
189 rtp_header.header.timestamp = 0x12345678;
190 rtp_header.header.ssrc = 0x87654321;
191
192 EXPECT_EQ(NetEq::kOK, neteq_->RegisterPayloadType(
193 decoder_type, "telephone-event", kPayloadType));
194
195 // Insert first packet.
196 EXPECT_EQ(NetEq::kOK,
197 neteq_->InsertPacket(rtp_header, payload, kReceiveTime));
198
199 // Pull audio once.
200 const size_t kMaxOutputSize =
201 static_cast<size_t>(10 * kSampleRateHz / 1000);
202 AudioFrame output;
203 bool muted;
204 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted));
205 ASSERT_FALSE(muted);
206 ASSERT_EQ(kMaxOutputSize, output.samples_per_channel_);
207 EXPECT_EQ(1u, output.num_channels_);
208 EXPECT_EQ(AudioFrame::kNormalSpeech, output.speech_type_);
209
210 // Verify first 64 samples of actual output.
211 const std::vector<int16_t> kOutput({
212 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1578, -2816, -3460, -3403, -2709, -1594,
213 -363, 671, 1269, 1328, 908, 202, -513, -964, -955, -431, 504, 1617,
214 2602, 3164, 3101, 2364, 1073, -511, -2047, -3198, -3721, -3525, -2688,
215 -1440, -99, 1015, 1663, 1744, 1319, 588, -171, -680, -747, -315, 515,
216 1512, 2378, 2828, 2674, 1877, 568, -986, -2446, -3482, -3864, -3516,
217 -2534, -1163 });
218 ASSERT_GE(kMaxOutputSize, kOutput.size());
219 EXPECT_TRUE(std::equal(kOutput.begin(), kOutput.end(), output.data_));
220 }
221
176 std::unique_ptr<NetEqImpl> neteq_; 222 std::unique_ptr<NetEqImpl> neteq_;
177 NetEq::Config config_; 223 NetEq::Config config_;
178 TickTimer* tick_timer_ = nullptr; 224 TickTimer* tick_timer_ = nullptr;
179 MockBufferLevelFilter* mock_buffer_level_filter_ = nullptr; 225 MockBufferLevelFilter* mock_buffer_level_filter_ = nullptr;
180 BufferLevelFilter* buffer_level_filter_ = nullptr; 226 BufferLevelFilter* buffer_level_filter_ = nullptr;
181 bool use_mock_buffer_level_filter_ = true; 227 bool use_mock_buffer_level_filter_ = true;
182 MockDecoderDatabase* mock_decoder_database_ = nullptr; 228 MockDecoderDatabase* mock_decoder_database_ = nullptr;
183 DecoderDatabase* decoder_database_ = nullptr; 229 DecoderDatabase* decoder_database_ = nullptr;
184 bool use_mock_decoder_database_ = true; 230 bool use_mock_decoder_database_ = true;
185 MockDelayPeakDetector* mock_delay_peak_detector_ = nullptr; 231 MockDelayPeakDetector* mock_delay_peak_detector_ = nullptr;
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 // Insert one more packet and make sure the buffer got flushed. That is, it 424 // Insert one more packet and make sure the buffer got flushed. That is, it
379 // should only hold one single packet. 425 // should only hold one single packet.
380 EXPECT_EQ(NetEq::kOK, 426 EXPECT_EQ(NetEq::kOK,
381 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); 427 neteq_->InsertPacket(rtp_header, payload, kReceiveTime));
382 EXPECT_EQ(1u, packet_buffer_->NumPacketsInBuffer()); 428 EXPECT_EQ(1u, packet_buffer_->NumPacketsInBuffer());
383 const Packet* test_packet = packet_buffer_->PeekNextPacket(); 429 const Packet* test_packet = packet_buffer_->PeekNextPacket();
384 EXPECT_EQ(rtp_header.header.timestamp, test_packet->timestamp); 430 EXPECT_EQ(rtp_header.header.timestamp, test_packet->timestamp);
385 EXPECT_EQ(rtp_header.header.sequenceNumber, test_packet->sequence_number); 431 EXPECT_EQ(rtp_header.header.sequenceNumber, test_packet->sequence_number);
386 } 432 }
387 433
388 TEST_F(NetEqImplTest, TestDtmfPacket) { 434 TEST_F(NetEqImplTest, TestDtmfPacketAVT) {
389 UseNoMocks(); 435 TestDtmfPacket(NetEqDecoder::kDecoderAVT);
390 CreateInstance(); 436 }
391 const size_t kPayloadLength = 4;
392 const uint8_t kPayloadType = 110;
393 const uint32_t kReceiveTime = 17;
394 const int kSampleRateHz = 8000;
395 // Event: 2, E bit, Volume: 63, Length: 4176.
396 uint8_t payload[kPayloadLength] = { 0x02, 0x80 + 0x3F, 0x10, 0xF0 };
397 WebRtcRTPHeader rtp_header;
398 rtp_header.header.payloadType = kPayloadType;
399 rtp_header.header.sequenceNumber = 0x1234;
400 rtp_header.header.timestamp = 0x12345678;
401 rtp_header.header.ssrc = 0x87654321;
402 437
403 EXPECT_EQ(NetEq::kOK, neteq_->RegisterPayloadType( 438 TEST_F(NetEqImplTest, TestDtmfPacketAVT16kHz) {
404 NetEqDecoder::kDecoderAVT, "telephone-event", kPayloadType)); 439 TestDtmfPacket(NetEqDecoder::kDecoderAVT16kHz);
440 }
405 441
406 // Insert one packet. 442 TEST_F(NetEqImplTest, TestDtmfPacketAVT32kHz) {
407 EXPECT_EQ(NetEq::kOK, 443 TestDtmfPacket(NetEqDecoder::kDecoderAVT32kHz);
408 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); 444 }
409 445
410 // Pull audio once. 446 TEST_F(NetEqImplTest, TestDtmfPacketAVT48kHz) {
411 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); 447 TestDtmfPacket(NetEqDecoder::kDecoderAVT48kHz);
412 AudioFrame output;
413 bool muted;
414 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted));
415 ASSERT_FALSE(muted);
416 ASSERT_EQ(kMaxOutputSize, output.samples_per_channel_);
417 EXPECT_EQ(1u, output.num_channels_);
418 EXPECT_EQ(AudioFrame::kNormalSpeech, output.speech_type_);
419 } 448 }
420 449
421 // This test verifies that timestamps propagate from the incoming packets 450 // This test verifies that timestamps propagate from the incoming packets
422 // through to the sync buffer and to the playout timestamp. 451 // through to the sync buffer and to the playout timestamp.
423 TEST_F(NetEqImplTest, VerifyTimestampPropagation) { 452 TEST_F(NetEqImplTest, VerifyTimestampPropagation) {
424 UseNoMocks(); 453 UseNoMocks();
425 CreateInstance(); 454 CreateInstance();
426 455
427 const uint8_t kPayloadType = 17; // Just an arbitrary number. 456 const uint8_t kPayloadType = 17; // Just an arbitrary number.
428 const uint32_t kReceiveTime = 17; // Value doesn't matter for this test. 457 const uint32_t kReceiveTime = 17; // Value doesn't matter for this test.
(...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after
1462 EXPECT_CALL(*mock_delay_manager_, BufferLimits(_, _)) 1491 EXPECT_CALL(*mock_delay_manager_, BufferLimits(_, _))
1463 .Times(1) 1492 .Times(1)
1464 .WillOnce(DoAll(SetArgPointee<0>(1), SetArgPointee<1>(2))); 1493 .WillOnce(DoAll(SetArgPointee<0>(1), SetArgPointee<1>(2)));
1465 1494
1466 bool muted; 1495 bool muted;
1467 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output_, &muted)); 1496 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output_, &muted));
1468 EXPECT_EQ(kAccelerate, neteq_->last_operation_for_test()); 1497 EXPECT_EQ(kAccelerate, neteq_->last_operation_for_test());
1469 } 1498 }
1470 1499
1471 }// namespace webrtc 1500 }// namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/neteq/neteq_impl.cc ('k') | webrtc/modules/audio_coding/neteq/tools/neteq_rtpplay.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698