Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 UseNoMocks(); | |
| 178 CreateInstance(); | |
| 179 const size_t kPayloadLength = 4; | |
| 180 const uint8_t kPayloadType = 110; | |
| 181 const uint32_t kReceiveTime = 17; | |
| 182 const int kSampleRateHz = 8000; | |
|
ossu
2016/10/11 17:56:17
So DTMF sample rate doesn't depend on clock rate,
the sun
2016/10/11 19:17:17
The sample rate is set when NetEq is constructed a
| |
| 183 // Event: 2, E bit, Volume: 0x3F, Length: 0x10F0. | |
| 184 uint8_t payload[kPayloadLength] = { 0x02, 0x80 + 0x3F, 0x10, 0xF0 }; | |
| 185 WebRtcRTPHeader rtp_header; | |
| 186 rtp_header.header.payloadType = kPayloadType; | |
| 187 rtp_header.header.sequenceNumber = 0x1234; | |
| 188 rtp_header.header.timestamp = 0x12345678; | |
| 189 rtp_header.header.ssrc = 0x87654321; | |
| 190 | |
| 191 EXPECT_EQ(NetEq::kOK, neteq_->RegisterPayloadType( | |
| 192 decoder_type, "telephone-event", kPayloadType)); | |
| 193 | |
| 194 // Insert first packet. | |
| 195 EXPECT_EQ(NetEq::kOK, | |
| 196 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | |
| 197 | |
| 198 // Pull audio once. | |
| 199 const size_t kMaxOutputSize = | |
| 200 static_cast<size_t>(10 * kSampleRateHz / 1000); | |
| 201 AudioFrame output; | |
| 202 bool muted; | |
| 203 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted)); | |
| 204 ASSERT_FALSE(muted); | |
| 205 ASSERT_EQ(kMaxOutputSize, output.samples_per_channel_); | |
| 206 EXPECT_EQ(1u, output.num_channels_); | |
| 207 EXPECT_EQ(AudioFrame::kNormalSpeech, output.speech_type_); | |
|
ossu
2016/10/11 17:56:18
Do you want to check that there is actually audio
the sun
2016/10/11 19:17:17
Done.
| |
| 208 } | |
| 209 | |
| 176 std::unique_ptr<NetEqImpl> neteq_; | 210 std::unique_ptr<NetEqImpl> neteq_; |
| 177 NetEq::Config config_; | 211 NetEq::Config config_; |
| 178 TickTimer* tick_timer_ = nullptr; | 212 TickTimer* tick_timer_ = nullptr; |
| 179 MockBufferLevelFilter* mock_buffer_level_filter_ = nullptr; | 213 MockBufferLevelFilter* mock_buffer_level_filter_ = nullptr; |
| 180 BufferLevelFilter* buffer_level_filter_ = nullptr; | 214 BufferLevelFilter* buffer_level_filter_ = nullptr; |
| 181 bool use_mock_buffer_level_filter_ = true; | 215 bool use_mock_buffer_level_filter_ = true; |
| 182 MockDecoderDatabase* mock_decoder_database_ = nullptr; | 216 MockDecoderDatabase* mock_decoder_database_ = nullptr; |
| 183 DecoderDatabase* decoder_database_ = nullptr; | 217 DecoderDatabase* decoder_database_ = nullptr; |
| 184 bool use_mock_decoder_database_ = true; | 218 bool use_mock_decoder_database_ = true; |
| 185 MockDelayPeakDetector* mock_delay_peak_detector_ = nullptr; | 219 MockDelayPeakDetector* mock_delay_peak_detector_ = nullptr; |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 374 // Insert one more packet and make sure the buffer got flushed. That is, it | 408 // Insert one more packet and make sure the buffer got flushed. That is, it |
| 375 // should only hold one single packet. | 409 // should only hold one single packet. |
| 376 EXPECT_EQ(NetEq::kOK, | 410 EXPECT_EQ(NetEq::kOK, |
| 377 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 411 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
| 378 EXPECT_EQ(1u, packet_buffer_->NumPacketsInBuffer()); | 412 EXPECT_EQ(1u, packet_buffer_->NumPacketsInBuffer()); |
| 379 const RTPHeader* test_header = packet_buffer_->NextRtpHeader(); | 413 const RTPHeader* test_header = packet_buffer_->NextRtpHeader(); |
| 380 EXPECT_EQ(rtp_header.header.timestamp, test_header->timestamp); | 414 EXPECT_EQ(rtp_header.header.timestamp, test_header->timestamp); |
| 381 EXPECT_EQ(rtp_header.header.sequenceNumber, test_header->sequenceNumber); | 415 EXPECT_EQ(rtp_header.header.sequenceNumber, test_header->sequenceNumber); |
| 382 } | 416 } |
| 383 | 417 |
| 418 TEST_F(NetEqImplTest, TestDtmfPacketAVT) { | |
| 419 TestDtmfPacket(NetEqDecoder::kDecoderAVT); | |
| 420 } | |
| 421 | |
| 422 TEST_F(NetEqImplTest, TestDtmfPacketAVT16kHz) { | |
| 423 TestDtmfPacket(NetEqDecoder::kDecoderAVT16kHz); | |
| 424 } | |
| 425 | |
| 426 TEST_F(NetEqImplTest, TestDtmfPacketAVT32kHz) { | |
| 427 TestDtmfPacket(NetEqDecoder::kDecoderAVT32kHz); | |
| 428 } | |
| 429 | |
| 430 TEST_F(NetEqImplTest, TestDtmfPacketAVT48kHz) { | |
| 431 TestDtmfPacket(NetEqDecoder::kDecoderAVT48kHz); | |
| 432 } | |
| 433 | |
| 384 // This test verifies that timestamps propagate from the incoming packets | 434 // This test verifies that timestamps propagate from the incoming packets |
| 385 // through to the sync buffer and to the playout timestamp. | 435 // through to the sync buffer and to the playout timestamp. |
| 386 TEST_F(NetEqImplTest, VerifyTimestampPropagation) { | 436 TEST_F(NetEqImplTest, VerifyTimestampPropagation) { |
| 387 UseNoMocks(); | 437 UseNoMocks(); |
| 388 CreateInstance(); | 438 CreateInstance(); |
| 389 | 439 |
| 390 const uint8_t kPayloadType = 17; // Just an arbitrary number. | 440 const uint8_t kPayloadType = 17; // Just an arbitrary number. |
| 391 const uint32_t kReceiveTime = 17; // Value doesn't matter for this test. | 441 const uint32_t kReceiveTime = 17; // Value doesn't matter for this test. |
| 392 const int kSampleRateHz = 8000; | 442 const int kSampleRateHz = 8000; |
| 393 const size_t kPayloadLengthSamples = | 443 const size_t kPayloadLengthSamples = |
| (...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1425 EXPECT_CALL(*mock_delay_manager_, BufferLimits(_, _)) | 1475 EXPECT_CALL(*mock_delay_manager_, BufferLimits(_, _)) |
| 1426 .Times(1) | 1476 .Times(1) |
| 1427 .WillOnce(DoAll(SetArgPointee<0>(1), SetArgPointee<1>(2))); | 1477 .WillOnce(DoAll(SetArgPointee<0>(1), SetArgPointee<1>(2))); |
| 1428 | 1478 |
| 1429 bool muted; | 1479 bool muted; |
| 1430 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output_, &muted)); | 1480 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output_, &muted)); |
| 1431 EXPECT_EQ(kAccelerate, neteq_->last_operation_for_test()); | 1481 EXPECT_EQ(kAccelerate, neteq_->last_operation_for_test()); |
| 1432 } | 1482 } |
| 1433 | 1483 |
| 1434 }// namespace webrtc | 1484 }// namespace webrtc |
| OLD | NEW |