| 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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 // TODO(hlundin): Move to separate file? | 232 // TODO(hlundin): Move to separate file? |
| 233 TEST(NetEq, CreateAndDestroy) { | 233 TEST(NetEq, CreateAndDestroy) { |
| 234 NetEq::Config config; | 234 NetEq::Config config; |
| 235 NetEq* neteq = NetEq::Create(config); | 235 NetEq* neteq = NetEq::Create(config); |
| 236 delete neteq; | 236 delete neteq; |
| 237 } | 237 } |
| 238 | 238 |
| 239 TEST_F(NetEqImplTest, RegisterPayloadType) { | 239 TEST_F(NetEqImplTest, RegisterPayloadType) { |
| 240 CreateInstance(); | 240 CreateInstance(); |
| 241 uint8_t rtp_payload_type = 0; | 241 uint8_t rtp_payload_type = 0; |
| 242 NetEqDecoder codec_type = kDecoderPCMu; | 242 NetEqDecoder codec_type = NetEqDecoder::kDecoderPCMu; |
| 243 EXPECT_CALL(*mock_decoder_database_, | 243 EXPECT_CALL(*mock_decoder_database_, |
| 244 RegisterPayload(rtp_payload_type, codec_type)); | 244 RegisterPayload(rtp_payload_type, codec_type)); |
| 245 neteq_->RegisterPayloadType(codec_type, rtp_payload_type); | 245 neteq_->RegisterPayloadType(codec_type, rtp_payload_type); |
| 246 } | 246 } |
| 247 | 247 |
| 248 TEST_F(NetEqImplTest, RemovePayloadType) { | 248 TEST_F(NetEqImplTest, RemovePayloadType) { |
| 249 CreateInstance(); | 249 CreateInstance(); |
| 250 uint8_t rtp_payload_type = 0; | 250 uint8_t rtp_payload_type = 0; |
| 251 EXPECT_CALL(*mock_decoder_database_, Remove(rtp_payload_type)) | 251 EXPECT_CALL(*mock_decoder_database_, Remove(rtp_payload_type)) |
| 252 .WillOnce(Return(DecoderDatabase::kDecoderNotFound)); | 252 .WillOnce(Return(DecoderDatabase::kDecoderNotFound)); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 .Times(2) | 293 .Times(2) |
| 294 .WillRepeatedly(Return(DecoderDatabase::kOK)); // Payload type is valid. | 294 .WillRepeatedly(Return(DecoderDatabase::kOK)); // Payload type is valid. |
| 295 EXPECT_CALL(*mock_decoder_database_, IsDtmf(kPayloadType)) | 295 EXPECT_CALL(*mock_decoder_database_, IsDtmf(kPayloadType)) |
| 296 .WillRepeatedly(Return(false)); // This is not DTMF. | 296 .WillRepeatedly(Return(false)); // This is not DTMF. |
| 297 EXPECT_CALL(*mock_decoder_database_, GetDecoder(kPayloadType)) | 297 EXPECT_CALL(*mock_decoder_database_, GetDecoder(kPayloadType)) |
| 298 .Times(3) | 298 .Times(3) |
| 299 .WillRepeatedly(Return(&mock_decoder)); | 299 .WillRepeatedly(Return(&mock_decoder)); |
| 300 EXPECT_CALL(*mock_decoder_database_, IsComfortNoise(kPayloadType)) | 300 EXPECT_CALL(*mock_decoder_database_, IsComfortNoise(kPayloadType)) |
| 301 .WillRepeatedly(Return(false)); // This is not CNG. | 301 .WillRepeatedly(Return(false)); // This is not CNG. |
| 302 DecoderDatabase::DecoderInfo info; | 302 DecoderDatabase::DecoderInfo info; |
| 303 info.codec_type = kDecoderPCMu; | 303 info.codec_type = NetEqDecoder::kDecoderPCMu; |
| 304 EXPECT_CALL(*mock_decoder_database_, GetDecoderInfo(kPayloadType)) | 304 EXPECT_CALL(*mock_decoder_database_, GetDecoderInfo(kPayloadType)) |
| 305 .WillRepeatedly(Return(&info)); | 305 .WillRepeatedly(Return(&info)); |
| 306 | 306 |
| 307 // Expectations for packet buffer. | 307 // Expectations for packet buffer. |
| 308 EXPECT_CALL(*mock_packet_buffer_, NumPacketsInBuffer()) | 308 EXPECT_CALL(*mock_packet_buffer_, NumPacketsInBuffer()) |
| 309 .WillOnce(Return(0)) // First packet. | 309 .WillOnce(Return(0)) // First packet. |
| 310 .WillOnce(Return(1)) // Second packet. | 310 .WillOnce(Return(1)) // Second packet. |
| 311 .WillOnce(Return(2)); // Second packet, checking after it was inserted. | 311 .WillOnce(Return(2)); // Second packet, checking after it was inserted. |
| 312 EXPECT_CALL(*mock_packet_buffer_, Empty()) | 312 EXPECT_CALL(*mock_packet_buffer_, Empty()) |
| 313 .WillOnce(Return(false)); // Called once after first packet is inserted. | 313 .WillOnce(Return(false)); // Called once after first packet is inserted. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 327 | 327 |
| 328 // Expectations for DTMF buffer. | 328 // Expectations for DTMF buffer. |
| 329 EXPECT_CALL(*mock_dtmf_buffer_, Flush()) | 329 EXPECT_CALL(*mock_dtmf_buffer_, Flush()) |
| 330 .Times(1); | 330 .Times(1); |
| 331 | 331 |
| 332 // Expectations for delay manager. | 332 // Expectations for delay manager. |
| 333 { | 333 { |
| 334 // All expectations within this block must be called in this specific order. | 334 // All expectations within this block must be called in this specific order. |
| 335 InSequence sequence; // Dummy variable. | 335 InSequence sequence; // Dummy variable. |
| 336 // Expectations when the first packet is inserted. | 336 // Expectations when the first packet is inserted. |
| 337 EXPECT_CALL(*mock_delay_manager_, LastDecoderType(kDecoderPCMu)) | 337 EXPECT_CALL(*mock_delay_manager_, |
| 338 LastDecoderType(NetEqDecoder::kDecoderPCMu)) |
| 338 .Times(1); | 339 .Times(1); |
| 339 EXPECT_CALL(*mock_delay_manager_, last_pack_cng_or_dtmf()) | 340 EXPECT_CALL(*mock_delay_manager_, last_pack_cng_or_dtmf()) |
| 340 .Times(2) | 341 .Times(2) |
| 341 .WillRepeatedly(Return(-1)); | 342 .WillRepeatedly(Return(-1)); |
| 342 EXPECT_CALL(*mock_delay_manager_, set_last_pack_cng_or_dtmf(0)) | 343 EXPECT_CALL(*mock_delay_manager_, set_last_pack_cng_or_dtmf(0)) |
| 343 .Times(1); | 344 .Times(1); |
| 344 EXPECT_CALL(*mock_delay_manager_, ResetPacketIatCount()).Times(1); | 345 EXPECT_CALL(*mock_delay_manager_, ResetPacketIatCount()).Times(1); |
| 345 // Expectations when the second packet is inserted. Slightly different. | 346 // Expectations when the second packet is inserted. Slightly different. |
| 346 EXPECT_CALL(*mock_delay_manager_, LastDecoderType(kDecoderPCMu)) | 347 EXPECT_CALL(*mock_delay_manager_, |
| 348 LastDecoderType(NetEqDecoder::kDecoderPCMu)) |
| 347 .Times(1); | 349 .Times(1); |
| 348 EXPECT_CALL(*mock_delay_manager_, last_pack_cng_or_dtmf()) | 350 EXPECT_CALL(*mock_delay_manager_, last_pack_cng_or_dtmf()) |
| 349 .WillOnce(Return(0)); | 351 .WillOnce(Return(0)); |
| 350 EXPECT_CALL(*mock_delay_manager_, SetPacketAudioLength(30)) | 352 EXPECT_CALL(*mock_delay_manager_, SetPacketAudioLength(30)) |
| 351 .WillOnce(Return(0)); | 353 .WillOnce(Return(0)); |
| 352 } | 354 } |
| 353 | 355 |
| 354 // Expectations for payload splitter. | 356 // Expectations for payload splitter. |
| 355 EXPECT_CALL(*mock_payload_splitter_, SplitAudio(_, _)) | 357 EXPECT_CALL(*mock_payload_splitter_, SplitAudio(_, _)) |
| 356 .Times(2) | 358 .Times(2) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 374 const size_t kPayloadLengthBytes = 2 * kPayloadLengthSamples; // PCM 16-bit. | 376 const size_t kPayloadLengthBytes = 2 * kPayloadLengthSamples; // PCM 16-bit. |
| 375 const uint8_t kPayloadType = 17; // Just an arbitrary number. | 377 const uint8_t kPayloadType = 17; // Just an arbitrary number. |
| 376 const uint32_t kReceiveTime = 17; // Value doesn't matter for this test. | 378 const uint32_t kReceiveTime = 17; // Value doesn't matter for this test. |
| 377 uint8_t payload[kPayloadLengthBytes] = {0}; | 379 uint8_t payload[kPayloadLengthBytes] = {0}; |
| 378 WebRtcRTPHeader rtp_header; | 380 WebRtcRTPHeader rtp_header; |
| 379 rtp_header.header.payloadType = kPayloadType; | 381 rtp_header.header.payloadType = kPayloadType; |
| 380 rtp_header.header.sequenceNumber = 0x1234; | 382 rtp_header.header.sequenceNumber = 0x1234; |
| 381 rtp_header.header.timestamp = 0x12345678; | 383 rtp_header.header.timestamp = 0x12345678; |
| 382 rtp_header.header.ssrc = 0x87654321; | 384 rtp_header.header.ssrc = 0x87654321; |
| 383 | 385 |
| 384 EXPECT_EQ(NetEq::kOK, | 386 EXPECT_EQ(NetEq::kOK, neteq_->RegisterPayloadType( |
| 385 neteq_->RegisterPayloadType(kDecoderPCM16B, kPayloadType)); | 387 NetEqDecoder::kDecoderPCM16B, kPayloadType)); |
| 386 | 388 |
| 387 // Insert packets. The buffer should not flush. | 389 // Insert packets. The buffer should not flush. |
| 388 for (size_t i = 1; i <= config_.max_packets_in_buffer; ++i) { | 390 for (size_t i = 1; i <= config_.max_packets_in_buffer; ++i) { |
| 389 EXPECT_EQ(NetEq::kOK, | 391 EXPECT_EQ(NetEq::kOK, |
| 390 neteq_->InsertPacket( | 392 neteq_->InsertPacket( |
| 391 rtp_header, payload, kPayloadLengthBytes, kReceiveTime)); | 393 rtp_header, payload, kPayloadLengthBytes, kReceiveTime)); |
| 392 rtp_header.header.timestamp += kPayloadLengthSamples; | 394 rtp_header.header.timestamp += kPayloadLengthSamples; |
| 393 rtp_header.header.sequenceNumber += 1; | 395 rtp_header.header.sequenceNumber += 1; |
| 394 EXPECT_EQ(i, packet_buffer_->NumPacketsInBuffer()); | 396 EXPECT_EQ(i, packet_buffer_->NumPacketsInBuffer()); |
| 395 } | 397 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 void Reset() override { next_value_ = 1; } | 450 void Reset() override { next_value_ = 1; } |
| 449 | 451 |
| 450 size_t Channels() const override { return 1; } | 452 size_t Channels() const override { return 1; } |
| 451 | 453 |
| 452 uint16_t next_value() const { return next_value_; } | 454 uint16_t next_value() const { return next_value_; } |
| 453 | 455 |
| 454 private: | 456 private: |
| 455 int16_t next_value_; | 457 int16_t next_value_; |
| 456 } decoder_; | 458 } decoder_; |
| 457 | 459 |
| 458 EXPECT_EQ(NetEq::kOK, | 460 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( |
| 459 neteq_->RegisterExternalDecoder(&decoder_, kDecoderPCM16B, | 461 &decoder_, NetEqDecoder::kDecoderPCM16B, |
| 460 kPayloadType, kSampleRateHz)); | 462 kPayloadType, kSampleRateHz)); |
| 461 | 463 |
| 462 // Insert one packet. | 464 // Insert one packet. |
| 463 EXPECT_EQ(NetEq::kOK, | 465 EXPECT_EQ(NetEq::kOK, |
| 464 neteq_->InsertPacket( | 466 neteq_->InsertPacket( |
| 465 rtp_header, payload, kPayloadLengthBytes, kReceiveTime)); | 467 rtp_header, payload, kPayloadLengthBytes, kReceiveTime)); |
| 466 | 468 |
| 467 // Pull audio once. | 469 // Pull audio once. |
| 468 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); | 470 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); |
| 469 int16_t output[kMaxOutputSize]; | 471 int16_t output[kMaxOutputSize]; |
| 470 size_t samples_per_channel; | 472 size_t samples_per_channel; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 .WillRepeatedly(Return(0)); | 530 .WillRepeatedly(Return(0)); |
| 529 int16_t dummy_output[kPayloadLengthSamples] = {0}; | 531 int16_t dummy_output[kPayloadLengthSamples] = {0}; |
| 530 // The below expectation will make the mock decoder write | 532 // The below expectation will make the mock decoder write |
| 531 // |kPayloadLengthSamples| zeros to the output array, and mark it as speech. | 533 // |kPayloadLengthSamples| zeros to the output array, and mark it as speech. |
| 532 EXPECT_CALL(mock_decoder, | 534 EXPECT_CALL(mock_decoder, |
| 533 Decode(Pointee(0), kPayloadLengthBytes, kSampleRateHz, _, _, _)) | 535 Decode(Pointee(0), kPayloadLengthBytes, kSampleRateHz, _, _, _)) |
| 534 .WillOnce(DoAll(SetArrayArgument<4>(dummy_output, | 536 .WillOnce(DoAll(SetArrayArgument<4>(dummy_output, |
| 535 dummy_output + kPayloadLengthSamples), | 537 dummy_output + kPayloadLengthSamples), |
| 536 SetArgPointee<5>(AudioDecoder::kSpeech), | 538 SetArgPointee<5>(AudioDecoder::kSpeech), |
| 537 Return(kPayloadLengthSamples))); | 539 Return(kPayloadLengthSamples))); |
| 538 EXPECT_EQ(NetEq::kOK, | 540 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( |
| 539 neteq_->RegisterExternalDecoder(&mock_decoder, kDecoderPCM16B, | 541 &mock_decoder, NetEqDecoder::kDecoderPCM16B, |
| 540 kPayloadType, kSampleRateHz)); | 542 kPayloadType, kSampleRateHz)); |
| 541 | 543 |
| 542 // Insert one packet. | 544 // Insert one packet. |
| 543 EXPECT_EQ(NetEq::kOK, | 545 EXPECT_EQ(NetEq::kOK, |
| 544 neteq_->InsertPacket( | 546 neteq_->InsertPacket( |
| 545 rtp_header, payload, kPayloadLengthBytes, kReceiveTime)); | 547 rtp_header, payload, kPayloadLengthBytes, kReceiveTime)); |
| 546 | 548 |
| 547 // Pull audio once. | 549 // Pull audio once. |
| 548 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); | 550 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); |
| 549 int16_t output[kMaxOutputSize]; | 551 int16_t output[kMaxOutputSize]; |
| 550 size_t samples_per_channel; | 552 size_t samples_per_channel; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 NetEqOutputType type; | 634 NetEqOutputType type; |
| 633 EXPECT_EQ(NetEq::kOK, | 635 EXPECT_EQ(NetEq::kOK, |
| 634 neteq_->GetAudio(kMaxOutputSize, output, &samples_per_channel, | 636 neteq_->GetAudio(kMaxOutputSize, output, &samples_per_channel, |
| 635 &num_channels, &type)); | 637 &num_channels, &type)); |
| 636 ASSERT_LE(samples_per_channel, kMaxOutputSize); | 638 ASSERT_LE(samples_per_channel, kMaxOutputSize); |
| 637 EXPECT_EQ(kMaxOutputSize, samples_per_channel); | 639 EXPECT_EQ(kMaxOutputSize, samples_per_channel); |
| 638 EXPECT_EQ(1, num_channels); | 640 EXPECT_EQ(1, num_channels); |
| 639 EXPECT_EQ(kOutputPLC, type); | 641 EXPECT_EQ(kOutputPLC, type); |
| 640 | 642 |
| 641 // Register the payload type. | 643 // Register the payload type. |
| 642 EXPECT_EQ(NetEq::kOK, | 644 EXPECT_EQ(NetEq::kOK, neteq_->RegisterPayloadType( |
| 643 neteq_->RegisterPayloadType(kDecoderPCM16B, kPayloadType)); | 645 NetEqDecoder::kDecoderPCM16B, kPayloadType)); |
| 644 | 646 |
| 645 // Insert 10 packets. | 647 // Insert 10 packets. |
| 646 for (size_t i = 0; i < 10; ++i) { | 648 for (size_t i = 0; i < 10; ++i) { |
| 647 rtp_header.header.sequenceNumber++; | 649 rtp_header.header.sequenceNumber++; |
| 648 rtp_header.header.timestamp += kPayloadLengthSamples; | 650 rtp_header.header.timestamp += kPayloadLengthSamples; |
| 649 EXPECT_EQ(NetEq::kOK, | 651 EXPECT_EQ(NetEq::kOK, |
| 650 neteq_->InsertPacket(rtp_header, payload, kPayloadLengthBytes, | 652 neteq_->InsertPacket(rtp_header, payload, kPayloadLengthBytes, |
| 651 kReceiveTime)); | 653 kReceiveTime)); |
| 652 EXPECT_EQ(i + 1, packet_buffer_->NumPacketsInBuffer()); | 654 EXPECT_EQ(i + 1, packet_buffer_->NumPacketsInBuffer()); |
| 653 } | 655 } |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 Return(kPayloadLengthSamples))); | 718 Return(kPayloadLengthSamples))); |
| 717 | 719 |
| 718 EXPECT_CALL(mock_decoder, Decode(Pointee(2), kPayloadLengthBytes, | 720 EXPECT_CALL(mock_decoder, Decode(Pointee(2), kPayloadLengthBytes, |
| 719 kSampleRateKhz * 1000, _, _, _)) | 721 kSampleRateKhz * 1000, _, _, _)) |
| 720 .WillOnce(DoAll(SetArrayArgument<4>(dummy_output, | 722 .WillOnce(DoAll(SetArrayArgument<4>(dummy_output, |
| 721 dummy_output + kPayloadLengthSamples), | 723 dummy_output + kPayloadLengthSamples), |
| 722 SetArgPointee<5>(AudioDecoder::kSpeech), | 724 SetArgPointee<5>(AudioDecoder::kSpeech), |
| 723 Return(kPayloadLengthSamples))); | 725 Return(kPayloadLengthSamples))); |
| 724 | 726 |
| 725 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( | 727 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( |
| 726 &mock_decoder, kDecoderOpus, kPayloadType, | 728 &mock_decoder, NetEqDecoder::kDecoderOpus, |
| 727 kSampleRateKhz * 1000)); | 729 kPayloadType, kSampleRateKhz * 1000)); |
| 728 | 730 |
| 729 // Insert one packet (decoder will return speech). | 731 // Insert one packet (decoder will return speech). |
| 730 EXPECT_EQ(NetEq::kOK, | 732 EXPECT_EQ(NetEq::kOK, |
| 731 neteq_->InsertPacket( | 733 neteq_->InsertPacket( |
| 732 rtp_header, payload, kPayloadLengthBytes, kReceiveTime)); | 734 rtp_header, payload, kPayloadLengthBytes, kReceiveTime)); |
| 733 | 735 |
| 734 // Insert second packet (decoder will return CNG). | 736 // Insert second packet (decoder will return CNG). |
| 735 payload[0] = 1; | 737 payload[0] = 1; |
| 736 rtp_header.header.sequenceNumber++; | 738 rtp_header.header.sequenceNumber++; |
| 737 rtp_header.header.timestamp += kPayloadLengthSamples; | 739 rtp_header.header.timestamp += kPayloadLengthSamples; |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 855 kPayloadLengthSamples * kChannels), | 857 kPayloadLengthSamples * kChannels), |
| 856 SetArgPointee<4>(AudioDecoder::kSpeech), | 858 SetArgPointee<4>(AudioDecoder::kSpeech), |
| 857 Return(static_cast<int>( | 859 Return(static_cast<int>( |
| 858 kPayloadLengthSamples * kChannels)))); | 860 kPayloadLengthSamples * kChannels)))); |
| 859 | 861 |
| 860 EXPECT_CALL(decoder_, PacketDuration(Pointee(kSecondPayloadValue), | 862 EXPECT_CALL(decoder_, PacketDuration(Pointee(kSecondPayloadValue), |
| 861 kPayloadLengthBytes)) | 863 kPayloadLengthBytes)) |
| 862 .Times(AtLeast(1)) | 864 .Times(AtLeast(1)) |
| 863 .WillRepeatedly(Return(kNetEqMaxFrameSize)); | 865 .WillRepeatedly(Return(kNetEqMaxFrameSize)); |
| 864 | 866 |
| 865 EXPECT_EQ(NetEq::kOK, | 867 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( |
| 866 neteq_->RegisterExternalDecoder(&decoder_, kDecoderPCM16B, | 868 &decoder_, NetEqDecoder::kDecoderPCM16B, |
| 867 kPayloadType, kSampleRateHz)); | 869 kPayloadType, kSampleRateHz)); |
| 868 | 870 |
| 869 // Insert one packet. | 871 // Insert one packet. |
| 870 payload[0] = kFirstPayloadValue; // This will make Decode() fail. | 872 payload[0] = kFirstPayloadValue; // This will make Decode() fail. |
| 871 EXPECT_EQ(NetEq::kOK, | 873 EXPECT_EQ(NetEq::kOK, |
| 872 neteq_->InsertPacket( | 874 neteq_->InsertPacket( |
| 873 rtp_header, payload, kPayloadLengthBytes, kReceiveTime)); | 875 rtp_header, payload, kPayloadLengthBytes, kReceiveTime)); |
| 874 | 876 |
| 875 // Insert another packet. | 877 // Insert another packet. |
| 876 payload[0] = kSecondPayloadValue; // This will make Decode() successful. | 878 payload[0] = kSecondPayloadValue; // This will make Decode() successful. |
| 877 rtp_header.header.sequenceNumber++; | 879 rtp_header.header.sequenceNumber++; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 916 const size_t kPayloadLengthBytes = 2 * kPayloadLengthSamples; // PCM 16-bit. | 918 const size_t kPayloadLengthBytes = 2 * kPayloadLengthSamples; // PCM 16-bit. |
| 917 const uint8_t kPayloadType = 17; // Just an arbitrary number. | 919 const uint8_t kPayloadType = 17; // Just an arbitrary number. |
| 918 const uint32_t kReceiveTime = 17; // Value doesn't matter for this test. | 920 const uint32_t kReceiveTime = 17; // Value doesn't matter for this test. |
| 919 uint8_t payload[kPayloadLengthBytes] = {0}; | 921 uint8_t payload[kPayloadLengthBytes] = {0}; |
| 920 WebRtcRTPHeader rtp_header; | 922 WebRtcRTPHeader rtp_header; |
| 921 rtp_header.header.payloadType = kPayloadType; | 923 rtp_header.header.payloadType = kPayloadType; |
| 922 rtp_header.header.sequenceNumber = 0x1234; | 924 rtp_header.header.sequenceNumber = 0x1234; |
| 923 rtp_header.header.timestamp = 0x12345678; | 925 rtp_header.header.timestamp = 0x12345678; |
| 924 rtp_header.header.ssrc = 0x87654321; | 926 rtp_header.header.ssrc = 0x87654321; |
| 925 | 927 |
| 926 EXPECT_EQ(NetEq::kOK, | 928 EXPECT_EQ(NetEq::kOK, neteq_->RegisterPayloadType( |
| 927 neteq_->RegisterPayloadType(kDecoderPCM16B, kPayloadType)); | 929 NetEqDecoder::kDecoderPCM16B, kPayloadType)); |
| 928 | 930 |
| 929 // Insert packets until the buffer flushes. | 931 // Insert packets until the buffer flushes. |
| 930 for (size_t i = 0; i <= config_.max_packets_in_buffer; ++i) { | 932 for (size_t i = 0; i <= config_.max_packets_in_buffer; ++i) { |
| 931 EXPECT_EQ(i, packet_buffer_->NumPacketsInBuffer()); | 933 EXPECT_EQ(i, packet_buffer_->NumPacketsInBuffer()); |
| 932 EXPECT_EQ(NetEq::kOK, | 934 EXPECT_EQ(NetEq::kOK, |
| 933 neteq_->InsertPacket(rtp_header, payload, kPayloadLengthBytes, | 935 neteq_->InsertPacket(rtp_header, payload, kPayloadLengthBytes, |
| 934 kReceiveTime)); | 936 kReceiveTime)); |
| 935 rtp_header.header.timestamp += | 937 rtp_header.header.timestamp += |
| 936 rtc::checked_cast<uint32_t>(kPayloadLengthSamples); | 938 rtc::checked_cast<uint32_t>(kPayloadLengthSamples); |
| 937 ++rtp_header.header.sequenceNumber; | 939 ++rtp_header.header.sequenceNumber; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 972 // The below expectation will make the mock decoder write | 974 // The below expectation will make the mock decoder write |
| 973 // |kPayloadLengthSamples| - 5 zeros to the output array, and mark it as | 975 // |kPayloadLengthSamples| - 5 zeros to the output array, and mark it as |
| 974 // speech. That is, the decoded length is 5 samples shorter than the expected. | 976 // speech. That is, the decoded length is 5 samples shorter than the expected. |
| 975 EXPECT_CALL(mock_decoder, | 977 EXPECT_CALL(mock_decoder, |
| 976 Decode(_, kPayloadLengthBytes, kSampleRateHz, _, _, _)) | 978 Decode(_, kPayloadLengthBytes, kSampleRateHz, _, _, _)) |
| 977 .WillOnce( | 979 .WillOnce( |
| 978 DoAll(SetArrayArgument<4>(dummy_output, | 980 DoAll(SetArrayArgument<4>(dummy_output, |
| 979 dummy_output + kPayloadLengthSamples - 5), | 981 dummy_output + kPayloadLengthSamples - 5), |
| 980 SetArgPointee<5>(AudioDecoder::kSpeech), | 982 SetArgPointee<5>(AudioDecoder::kSpeech), |
| 981 Return(kPayloadLengthSamples - 5))); | 983 Return(kPayloadLengthSamples - 5))); |
| 982 EXPECT_EQ(NetEq::kOK, | 984 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( |
| 983 neteq_->RegisterExternalDecoder(&mock_decoder, kDecoderPCM16B, | 985 &mock_decoder, NetEqDecoder::kDecoderPCM16B, |
| 984 kPayloadType, kSampleRateHz)); | 986 kPayloadType, kSampleRateHz)); |
| 985 | 987 |
| 986 // Insert one packet. | 988 // Insert one packet. |
| 987 EXPECT_EQ(NetEq::kOK, | 989 EXPECT_EQ(NetEq::kOK, |
| 988 neteq_->InsertPacket(rtp_header, payload, kPayloadLengthBytes, | 990 neteq_->InsertPacket(rtp_header, payload, kPayloadLengthBytes, |
| 989 kReceiveTime)); | 991 kReceiveTime)); |
| 990 | 992 |
| 991 EXPECT_EQ(5u, neteq_->sync_buffer_for_test()->FutureLength()); | 993 EXPECT_EQ(5u, neteq_->sync_buffer_for_test()->FutureLength()); |
| 992 | 994 |
| 993 // Pull audio once. | 995 // Pull audio once. |
| 994 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); | 996 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1068 EXPECT_CALL(mock_decoder, | 1070 EXPECT_CALL(mock_decoder, |
| 1069 Decode(_, kPayloadLengthBytes, kSampleRateHz, _, _, _)) | 1071 Decode(_, kPayloadLengthBytes, kSampleRateHz, _, _, _)) |
| 1070 .Times(2) | 1072 .Times(2) |
| 1071 .WillRepeatedly( | 1073 .WillRepeatedly( |
| 1072 DoAll(SetArrayArgument<4>(dummy_output, | 1074 DoAll(SetArrayArgument<4>(dummy_output, |
| 1073 dummy_output + kFrameLengthSamples), | 1075 dummy_output + kFrameLengthSamples), |
| 1074 SetArgPointee<5>(AudioDecoder::kSpeech), | 1076 SetArgPointee<5>(AudioDecoder::kSpeech), |
| 1075 Return(kFrameLengthSamples))); | 1077 Return(kFrameLengthSamples))); |
| 1076 } | 1078 } |
| 1077 | 1079 |
| 1078 EXPECT_EQ(NetEq::kOK, | 1080 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( |
| 1079 neteq_->RegisterExternalDecoder(&mock_decoder, kDecoderPCM16B, | 1081 &mock_decoder, NetEqDecoder::kDecoderPCM16B, |
| 1080 kPayloadType, kSampleRateHz)); | 1082 kPayloadType, kSampleRateHz)); |
| 1081 | 1083 |
| 1082 // Insert packets. | 1084 // Insert packets. |
| 1083 for (int i = 0; i < 6; ++i) { | 1085 for (int i = 0; i < 6; ++i) { |
| 1084 rtp_header.header.sequenceNumber += 1; | 1086 rtp_header.header.sequenceNumber += 1; |
| 1085 rtp_header.header.timestamp += kFrameLengthSamples; | 1087 rtp_header.header.timestamp += kFrameLengthSamples; |
| 1086 EXPECT_EQ(NetEq::kOK, | 1088 EXPECT_EQ(NetEq::kOK, |
| 1087 neteq_->InsertPacket(rtp_header, payload, kPayloadLengthBytes, | 1089 neteq_->InsertPacket(rtp_header, payload, kPayloadLengthBytes, |
| 1088 kReceiveTime)); | 1090 kReceiveTime)); |
| 1089 } | 1091 } |
| 1090 | 1092 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1190 // Mock decoder finally returns to normal. | 1192 // Mock decoder finally returns to normal. |
| 1191 EXPECT_CALL(mock_decoder, Decode(nullptr, 0, kSampleRateHz, _, _, _)) | 1193 EXPECT_CALL(mock_decoder, Decode(nullptr, 0, kSampleRateHz, _, _, _)) |
| 1192 .Times(2) | 1194 .Times(2) |
| 1193 .WillRepeatedly( | 1195 .WillRepeatedly( |
| 1194 DoAll(SetArrayArgument<4>(dummy_output, | 1196 DoAll(SetArrayArgument<4>(dummy_output, |
| 1195 dummy_output + kFrameLengthSamples), | 1197 dummy_output + kFrameLengthSamples), |
| 1196 SetArgPointee<5>(AudioDecoder::kComfortNoise), | 1198 SetArgPointee<5>(AudioDecoder::kComfortNoise), |
| 1197 Return(kFrameLengthSamples))); | 1199 Return(kFrameLengthSamples))); |
| 1198 } | 1200 } |
| 1199 | 1201 |
| 1200 EXPECT_EQ(NetEq::kOK, | 1202 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( |
| 1201 neteq_->RegisterExternalDecoder(&mock_decoder, kDecoderPCM16B, | 1203 &mock_decoder, NetEqDecoder::kDecoderPCM16B, |
| 1202 kPayloadType, kSampleRateHz)); | 1204 kPayloadType, kSampleRateHz)); |
| 1203 | 1205 |
| 1204 // Insert 2 packets. This will make netEq into codec internal CNG mode. | 1206 // Insert 2 packets. This will make netEq into codec internal CNG mode. |
| 1205 for (int i = 0; i < 2; ++i) { | 1207 for (int i = 0; i < 2; ++i) { |
| 1206 rtp_header.header.sequenceNumber += 1; | 1208 rtp_header.header.sequenceNumber += 1; |
| 1207 rtp_header.header.timestamp += kFrameLengthSamples; | 1209 rtp_header.header.timestamp += kFrameLengthSamples; |
| 1208 EXPECT_EQ(NetEq::kOK, | 1210 EXPECT_EQ(NetEq::kOK, |
| 1209 neteq_->InsertPacket(rtp_header, payload, kPayloadLengthBytes, | 1211 neteq_->InsertPacket(rtp_header, payload, kPayloadLengthBytes, |
| 1210 kReceiveTime)); | 1212 kReceiveTime)); |
| 1211 } | 1213 } |
| 1212 | 1214 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1240 neteq_->GetAudio(kMaxOutputSize, output, &samples_per_channel, | 1242 neteq_->GetAudio(kMaxOutputSize, output, &samples_per_channel, |
| 1241 &num_channels, &type)); | 1243 &num_channels, &type)); |
| 1242 EXPECT_EQ(kMaxOutputSize, samples_per_channel); | 1244 EXPECT_EQ(kMaxOutputSize, samples_per_channel); |
| 1243 EXPECT_EQ(1, num_channels); | 1245 EXPECT_EQ(1, num_channels); |
| 1244 EXPECT_EQ(kOutputCNG, type); | 1246 EXPECT_EQ(kOutputCNG, type); |
| 1245 | 1247 |
| 1246 EXPECT_CALL(mock_decoder, Die()); | 1248 EXPECT_CALL(mock_decoder, Die()); |
| 1247 } | 1249 } |
| 1248 | 1250 |
| 1249 }// namespace webrtc | 1251 }// namespace webrtc |
| OLD | NEW |