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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 for (uint8_t i = 0; i < 6; ++i) { | 368 for (uint8_t i = 0; i < 6; ++i) { |
369 // Let the payload type be |i|, and the payload value 10 * |i|. | 369 // Let the payload type be |i|, and the payload value 10 * |i|. |
370 packet_list.push_back(CreatePacket(i, kPayloadLength, 10 * i)); | 370 packet_list.push_back(CreatePacket(i, kPayloadLength, 10 * i)); |
371 } | 371 } |
372 | 372 |
373 MockDecoderDatabase decoder_database; | 373 MockDecoderDatabase decoder_database; |
374 // Tell the mock decoder database to return DecoderInfo structs with different | 374 // Tell the mock decoder database to return DecoderInfo structs with different |
375 // codec types. | 375 // codec types. |
376 // Use scoped pointers to avoid having to delete them later. | 376 // Use scoped pointers to avoid having to delete them later. |
377 std::unique_ptr<DecoderDatabase::DecoderInfo> info0( | 377 std::unique_ptr<DecoderDatabase::DecoderInfo> info0( |
378 new DecoderDatabase::DecoderInfo(NetEqDecoder::kDecoderISAC, "", 16000, | 378 new DecoderDatabase::DecoderInfo(NetEqDecoder::kDecoderISAC, "")); |
379 nullptr)); | |
380 EXPECT_CALL(decoder_database, GetDecoderInfo(0)) | 379 EXPECT_CALL(decoder_database, GetDecoderInfo(0)) |
381 .WillRepeatedly(Return(info0.get())); | 380 .WillRepeatedly(Return(info0.get())); |
382 std::unique_ptr<DecoderDatabase::DecoderInfo> info1( | 381 std::unique_ptr<DecoderDatabase::DecoderInfo> info1( |
383 new DecoderDatabase::DecoderInfo(NetEqDecoder::kDecoderISACswb, "", 32000, | 382 new DecoderDatabase::DecoderInfo(NetEqDecoder::kDecoderISACswb, "")); |
384 nullptr)); | |
385 EXPECT_CALL(decoder_database, GetDecoderInfo(1)) | 383 EXPECT_CALL(decoder_database, GetDecoderInfo(1)) |
386 .WillRepeatedly(Return(info1.get())); | 384 .WillRepeatedly(Return(info1.get())); |
387 std::unique_ptr<DecoderDatabase::DecoderInfo> info2( | 385 std::unique_ptr<DecoderDatabase::DecoderInfo> info2( |
388 new DecoderDatabase::DecoderInfo(NetEqDecoder::kDecoderRED, "", 8000, | 386 new DecoderDatabase::DecoderInfo(NetEqDecoder::kDecoderRED, "")); |
389 nullptr)); | |
390 EXPECT_CALL(decoder_database, GetDecoderInfo(2)) | 387 EXPECT_CALL(decoder_database, GetDecoderInfo(2)) |
391 .WillRepeatedly(Return(info2.get())); | 388 .WillRepeatedly(Return(info2.get())); |
392 std::unique_ptr<DecoderDatabase::DecoderInfo> info3( | 389 std::unique_ptr<DecoderDatabase::DecoderInfo> info3( |
393 new DecoderDatabase::DecoderInfo(NetEqDecoder::kDecoderAVT, "", 8000, | 390 new DecoderDatabase::DecoderInfo(NetEqDecoder::kDecoderAVT, "")); |
394 nullptr)); | |
395 EXPECT_CALL(decoder_database, GetDecoderInfo(3)) | 391 EXPECT_CALL(decoder_database, GetDecoderInfo(3)) |
396 .WillRepeatedly(Return(info3.get())); | 392 .WillRepeatedly(Return(info3.get())); |
397 std::unique_ptr<DecoderDatabase::DecoderInfo> info4( | 393 std::unique_ptr<DecoderDatabase::DecoderInfo> info4( |
398 new DecoderDatabase::DecoderInfo(NetEqDecoder::kDecoderCNGnb, "", 8000, | 394 new DecoderDatabase::DecoderInfo(NetEqDecoder::kDecoderCNGnb, "")); |
399 nullptr)); | |
400 EXPECT_CALL(decoder_database, GetDecoderInfo(4)) | 395 EXPECT_CALL(decoder_database, GetDecoderInfo(4)) |
401 .WillRepeatedly(Return(info4.get())); | 396 .WillRepeatedly(Return(info4.get())); |
402 std::unique_ptr<DecoderDatabase::DecoderInfo> info5( | 397 std::unique_ptr<DecoderDatabase::DecoderInfo> info5( |
403 new DecoderDatabase::DecoderInfo(NetEqDecoder::kDecoderArbitrary, "", | 398 new DecoderDatabase::DecoderInfo(NetEqDecoder::kDecoderArbitrary, "")); |
404 8000, nullptr)); | |
405 EXPECT_CALL(decoder_database, GetDecoderInfo(5)) | 399 EXPECT_CALL(decoder_database, GetDecoderInfo(5)) |
406 .WillRepeatedly(Return(info5.get())); | 400 .WillRepeatedly(Return(info5.get())); |
407 | 401 |
408 PayloadSplitter splitter; | 402 PayloadSplitter splitter; |
409 EXPECT_EQ(0, splitter.SplitAudio(&packet_list, decoder_database)); | 403 EXPECT_EQ(0, splitter.SplitAudio(&packet_list, decoder_database)); |
410 EXPECT_EQ(6u, packet_list.size()); | 404 EXPECT_EQ(6u, packet_list.size()); |
411 | 405 |
412 // Check that all payloads are intact. | 406 // Check that all payloads are intact. |
413 uint8_t payload_type = 0; | 407 uint8_t payload_type = 0; |
414 PacketList::iterator it = packet_list.begin(); | 408 PacketList::iterator it = packet_list.begin(); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 packet_list.push_back(CreatePacket(kPayloadType, payload_size_bytes, | 526 packet_list.push_back(CreatePacket(kPayloadType, payload_size_bytes, |
533 payload_size_ms)); | 527 payload_size_ms)); |
534 } | 528 } |
535 | 529 |
536 MockDecoderDatabase decoder_database; | 530 MockDecoderDatabase decoder_database; |
537 // Tell the mock decoder database to return DecoderInfo structs with different | 531 // Tell the mock decoder database to return DecoderInfo structs with different |
538 // codec types. | 532 // codec types. |
539 // Use scoped pointers to avoid having to delete them later. | 533 // Use scoped pointers to avoid having to delete them later. |
540 // (Sample rate is set to 8000 Hz, but does not matter.) | 534 // (Sample rate is set to 8000 Hz, but does not matter.) |
541 std::unique_ptr<DecoderDatabase::DecoderInfo> info( | 535 std::unique_ptr<DecoderDatabase::DecoderInfo> info( |
542 new DecoderDatabase::DecoderInfo(decoder_type_, "", 8000, nullptr)); | 536 new DecoderDatabase::DecoderInfo(decoder_type_, "")); |
543 EXPECT_CALL(decoder_database, GetDecoderInfo(kPayloadType)) | 537 EXPECT_CALL(decoder_database, GetDecoderInfo(kPayloadType)) |
544 .WillRepeatedly(Return(info.get())); | 538 .WillRepeatedly(Return(info.get())); |
545 | 539 |
546 PayloadSplitter splitter; | 540 PayloadSplitter splitter; |
547 EXPECT_EQ(0, splitter.SplitAudio(&packet_list, decoder_database)); | 541 EXPECT_EQ(0, splitter.SplitAudio(&packet_list, decoder_database)); |
548 // The payloads are expected to be split as follows: | 542 // The payloads are expected to be split as follows: |
549 // 10 ms -> 10 ms | 543 // 10 ms -> 10 ms |
550 // 20 ms -> 20 ms | 544 // 20 ms -> 20 ms |
551 // 30 ms -> 30 ms | 545 // 30 ms -> 30 ms |
552 // 40 ms -> 20 + 20 ms | 546 // 40 ms -> 20 + 20 ms |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 for (size_t i = 0; i < packet->payload_length; ++i) { | 613 for (size_t i = 0; i < packet->payload_length; ++i) { |
620 packet->payload[i] = static_cast<uint8_t>(i); | 614 packet->payload[i] = static_cast<uint8_t>(i); |
621 } | 615 } |
622 packet_list.push_back(packet); | 616 packet_list.push_back(packet); |
623 | 617 |
624 MockDecoderDatabase decoder_database; | 618 MockDecoderDatabase decoder_database; |
625 // Tell the mock decoder database to return DecoderInfo structs with different | 619 // Tell the mock decoder database to return DecoderInfo structs with different |
626 // codec types. | 620 // codec types. |
627 // Use scoped pointers to avoid having to delete them later. | 621 // Use scoped pointers to avoid having to delete them later. |
628 std::unique_ptr<DecoderDatabase::DecoderInfo> info( | 622 std::unique_ptr<DecoderDatabase::DecoderInfo> info( |
629 new DecoderDatabase::DecoderInfo(NetEqDecoder::kDecoderILBC, "", 8000, | 623 new DecoderDatabase::DecoderInfo(NetEqDecoder::kDecoderILBC, "")); |
630 nullptr)); | |
631 EXPECT_CALL(decoder_database, GetDecoderInfo(kPayloadType)) | 624 EXPECT_CALL(decoder_database, GetDecoderInfo(kPayloadType)) |
632 .WillRepeatedly(Return(info.get())); | 625 .WillRepeatedly(Return(info.get())); |
633 | 626 |
634 PayloadSplitter splitter; | 627 PayloadSplitter splitter; |
635 EXPECT_EQ(0, splitter.SplitAudio(&packet_list, decoder_database)); | 628 EXPECT_EQ(0, splitter.SplitAudio(&packet_list, decoder_database)); |
636 EXPECT_EQ(num_frames_, packet_list.size()); | 629 EXPECT_EQ(num_frames_, packet_list.size()); |
637 | 630 |
638 PacketList::iterator it = packet_list.begin(); | 631 PacketList::iterator it = packet_list.begin(); |
639 int frame_num = 0; | 632 int frame_num = 0; |
640 uint8_t payload_value = 0; | 633 uint8_t payload_value = 0; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 // Test too large payload size. | 676 // Test too large payload size. |
684 TEST(IlbcPayloadSplitter, TooLargePayload) { | 677 TEST(IlbcPayloadSplitter, TooLargePayload) { |
685 PacketList packet_list; | 678 PacketList packet_list; |
686 static const uint8_t kPayloadType = 17; // Just a random number. | 679 static const uint8_t kPayloadType = 17; // Just a random number. |
687 size_t kPayloadLengthBytes = 950; | 680 size_t kPayloadLengthBytes = 950; |
688 Packet* packet = CreatePacket(kPayloadType, kPayloadLengthBytes, 0); | 681 Packet* packet = CreatePacket(kPayloadType, kPayloadLengthBytes, 0); |
689 packet_list.push_back(packet); | 682 packet_list.push_back(packet); |
690 | 683 |
691 MockDecoderDatabase decoder_database; | 684 MockDecoderDatabase decoder_database; |
692 std::unique_ptr<DecoderDatabase::DecoderInfo> info( | 685 std::unique_ptr<DecoderDatabase::DecoderInfo> info( |
693 new DecoderDatabase::DecoderInfo(NetEqDecoder::kDecoderILBC, "", 8000, | 686 new DecoderDatabase::DecoderInfo(NetEqDecoder::kDecoderILBC, "")); |
694 nullptr)); | |
695 EXPECT_CALL(decoder_database, GetDecoderInfo(kPayloadType)) | 687 EXPECT_CALL(decoder_database, GetDecoderInfo(kPayloadType)) |
696 .WillRepeatedly(Return(info.get())); | 688 .WillRepeatedly(Return(info.get())); |
697 | 689 |
698 PayloadSplitter splitter; | 690 PayloadSplitter splitter; |
699 EXPECT_EQ(PayloadSplitter::kTooLargePayload, | 691 EXPECT_EQ(PayloadSplitter::kTooLargePayload, |
700 splitter.SplitAudio(&packet_list, decoder_database)); | 692 splitter.SplitAudio(&packet_list, decoder_database)); |
701 EXPECT_EQ(1u, packet_list.size()); | 693 EXPECT_EQ(1u, packet_list.size()); |
702 | 694 |
703 // Delete the packets and payloads to avoid having the test leak memory. | 695 // Delete the packets and payloads to avoid having the test leak memory. |
704 PacketList::iterator it = packet_list.begin(); | 696 PacketList::iterator it = packet_list.begin(); |
(...skipping 10 matching lines...) Expand all Loading... |
715 // Payload not an integer number of frames. | 707 // Payload not an integer number of frames. |
716 TEST(IlbcPayloadSplitter, UnevenPayload) { | 708 TEST(IlbcPayloadSplitter, UnevenPayload) { |
717 PacketList packet_list; | 709 PacketList packet_list; |
718 static const uint8_t kPayloadType = 17; // Just a random number. | 710 static const uint8_t kPayloadType = 17; // Just a random number. |
719 size_t kPayloadLengthBytes = 39; // Not an even number of frames. | 711 size_t kPayloadLengthBytes = 39; // Not an even number of frames. |
720 Packet* packet = CreatePacket(kPayloadType, kPayloadLengthBytes, 0); | 712 Packet* packet = CreatePacket(kPayloadType, kPayloadLengthBytes, 0); |
721 packet_list.push_back(packet); | 713 packet_list.push_back(packet); |
722 | 714 |
723 MockDecoderDatabase decoder_database; | 715 MockDecoderDatabase decoder_database; |
724 std::unique_ptr<DecoderDatabase::DecoderInfo> info( | 716 std::unique_ptr<DecoderDatabase::DecoderInfo> info( |
725 new DecoderDatabase::DecoderInfo(NetEqDecoder::kDecoderILBC, "", 8000, | 717 new DecoderDatabase::DecoderInfo(NetEqDecoder::kDecoderILBC, "")); |
726 nullptr)); | |
727 EXPECT_CALL(decoder_database, GetDecoderInfo(kPayloadType)) | 718 EXPECT_CALL(decoder_database, GetDecoderInfo(kPayloadType)) |
728 .WillRepeatedly(Return(info.get())); | 719 .WillRepeatedly(Return(info.get())); |
729 | 720 |
730 PayloadSplitter splitter; | 721 PayloadSplitter splitter; |
731 EXPECT_EQ(PayloadSplitter::kFrameSplitError, | 722 EXPECT_EQ(PayloadSplitter::kFrameSplitError, |
732 splitter.SplitAudio(&packet_list, decoder_database)); | 723 splitter.SplitAudio(&packet_list, decoder_database)); |
733 EXPECT_EQ(1u, packet_list.size()); | 724 EXPECT_EQ(1u, packet_list.size()); |
734 | 725 |
735 // Delete the packets and payloads to avoid having the test leak memory. | 726 // Delete the packets and payloads to avoid having the test leak memory. |
736 PacketList::iterator it = packet_list.begin(); | 727 PacketList::iterator it = packet_list.begin(); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
856 EXPECT_EQ(kBaseTimestamp - kTimestampOffset, packet->header.timestamp); | 847 EXPECT_EQ(kBaseTimestamp - kTimestampOffset, packet->header.timestamp); |
857 EXPECT_EQ(kPayloadLength, packet->payload_length); | 848 EXPECT_EQ(kPayloadLength, packet->payload_length); |
858 EXPECT_TRUE(packet->primary); | 849 EXPECT_TRUE(packet->primary); |
859 EXPECT_EQ(packet->payload[3], 0); | 850 EXPECT_EQ(packet->payload[3], 0); |
860 delete [] packet->payload; | 851 delete [] packet->payload; |
861 delete packet; | 852 delete packet; |
862 packet_list.pop_front(); | 853 packet_list.pop_front(); |
863 } | 854 } |
864 | 855 |
865 } // namespace webrtc | 856 } // namespace webrtc |
OLD | NEW |