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