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 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 for (uint8_t i = 0; i <= 3; ++i) { | 303 for (uint8_t i = 0; i <= 3; ++i) { |
304 // Create packet with payload type |i|, payload length 10 bytes, all 0. | 304 // Create packet with payload type |i|, payload length 10 bytes, all 0. |
305 Packet* packet = CreatePacket(i, 10, 0); | 305 Packet* packet = CreatePacket(i, 10, 0); |
306 packet_list.push_back(packet); | 306 packet_list.push_back(packet); |
307 } | 307 } |
308 | 308 |
309 // Use a real DecoderDatabase object here instead of a mock, since it is | 309 // Use a real DecoderDatabase object here instead of a mock, since it is |
310 // easier to just register the payload types and let the actual implementation | 310 // easier to just register the payload types and let the actual implementation |
311 // do its job. | 311 // do its job. |
312 DecoderDatabase decoder_database; | 312 DecoderDatabase decoder_database; |
313 decoder_database.RegisterPayload(0, NetEqDecoder::kDecoderCNGnb); | 313 decoder_database.RegisterPayload(0, NetEqDecoder::kDecoderCNGnb, "cng-nb"); |
314 decoder_database.RegisterPayload(1, NetEqDecoder::kDecoderPCMu); | 314 decoder_database.RegisterPayload(1, NetEqDecoder::kDecoderPCMu, "pcmu"); |
315 decoder_database.RegisterPayload(2, NetEqDecoder::kDecoderAVT); | 315 decoder_database.RegisterPayload(2, NetEqDecoder::kDecoderAVT, "avt"); |
316 decoder_database.RegisterPayload(3, NetEqDecoder::kDecoderILBC); | 316 decoder_database.RegisterPayload(3, NetEqDecoder::kDecoderILBC, "ilbc"); |
317 | 317 |
318 PayloadSplitter splitter; | 318 PayloadSplitter splitter; |
319 splitter.CheckRedPayloads(&packet_list, decoder_database); | 319 splitter.CheckRedPayloads(&packet_list, decoder_database); |
320 | 320 |
321 ASSERT_EQ(3u, packet_list.size()); // Should have dropped the last packet. | 321 ASSERT_EQ(3u, packet_list.size()); // Should have dropped the last packet. |
322 // Verify packets. The loop verifies that payload types 0, 1, and 2 are in the | 322 // Verify packets. The loop verifies that payload types 0, 1, and 2 are in the |
323 // list. | 323 // list. |
324 for (int i = 0; i <= 2; ++i) { | 324 for (int i = 0; i <= 2; ++i) { |
325 Packet* packet = packet_list.front(); | 325 Packet* packet = packet_list.front(); |
326 VerifyPacket(packet, 10, i, kSequenceNumber, kBaseTimestamp, 0, true); | 326 VerifyPacket(packet, 10, i, kSequenceNumber, kBaseTimestamp, 0, true); |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 } | 738 } |
739 | 739 |
740 // The destructor is called when decoder_database goes out of scope. | 740 // The destructor is called when decoder_database goes out of scope. |
741 EXPECT_CALL(decoder_database, Die()); | 741 EXPECT_CALL(decoder_database, Die()); |
742 } | 742 } |
743 | 743 |
744 TEST(FecPayloadSplitter, MixedPayload) { | 744 TEST(FecPayloadSplitter, MixedPayload) { |
745 PacketList packet_list; | 745 PacketList packet_list; |
746 DecoderDatabase decoder_database; | 746 DecoderDatabase decoder_database; |
747 | 747 |
748 decoder_database.RegisterPayload(0, NetEqDecoder::kDecoderOpus); | 748 decoder_database.RegisterPayload(0, NetEqDecoder::kDecoderOpus, "opus"); |
749 decoder_database.RegisterPayload(1, NetEqDecoder::kDecoderPCMu); | 749 decoder_database.RegisterPayload(1, NetEqDecoder::kDecoderPCMu, "pcmu"); |
750 | 750 |
751 Packet* packet = CreatePacket(0, 10, 0xFF, true); | 751 Packet* packet = CreatePacket(0, 10, 0xFF, true); |
752 packet_list.push_back(packet); | 752 packet_list.push_back(packet); |
753 | 753 |
754 packet = CreatePacket(0, 10, 0); // Non-FEC Opus payload. | 754 packet = CreatePacket(0, 10, 0); // Non-FEC Opus payload. |
755 packet_list.push_back(packet); | 755 packet_list.push_back(packet); |
756 | 756 |
757 packet = CreatePacket(1, 10, 0); // Non-Opus payload. | 757 packet = CreatePacket(1, 10, 0); // Non-Opus payload. |
758 packet_list.push_back(packet); | 758 packet_list.push_back(packet); |
759 | 759 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
795 delete [] packet->payload; | 795 delete [] packet->payload; |
796 delete packet; | 796 delete packet; |
797 } | 797 } |
798 | 798 |
799 TEST(FecPayloadSplitter, EmbedFecInRed) { | 799 TEST(FecPayloadSplitter, EmbedFecInRed) { |
800 PacketList packet_list; | 800 PacketList packet_list; |
801 DecoderDatabase decoder_database; | 801 DecoderDatabase decoder_database; |
802 | 802 |
803 const int kTimestampOffset = 20 * 48; // 20 ms * 48 kHz. | 803 const int kTimestampOffset = 20 * 48; // 20 ms * 48 kHz. |
804 uint8_t payload_types[] = {0, 0}; | 804 uint8_t payload_types[] = {0, 0}; |
805 decoder_database.RegisterPayload(0, NetEqDecoder::kDecoderOpus); | 805 decoder_database.RegisterPayload(0, NetEqDecoder::kDecoderOpus, "opus"); |
806 Packet* packet = CreateRedPayload(2, payload_types, kTimestampOffset, true); | 806 Packet* packet = CreateRedPayload(2, payload_types, kTimestampOffset, true); |
807 packet_list.push_back(packet); | 807 packet_list.push_back(packet); |
808 | 808 |
809 PayloadSplitter splitter; | 809 PayloadSplitter splitter; |
810 EXPECT_EQ(PayloadSplitter::kOK, | 810 EXPECT_EQ(PayloadSplitter::kOK, |
811 splitter.SplitRed(&packet_list)); | 811 splitter.SplitRed(&packet_list)); |
812 EXPECT_EQ(PayloadSplitter::kOK, | 812 EXPECT_EQ(PayloadSplitter::kOK, |
813 splitter.SplitFec(&packet_list, &decoder_database)); | 813 splitter.SplitFec(&packet_list, &decoder_database)); |
814 | 814 |
815 EXPECT_EQ(4u, packet_list.size()); | 815 EXPECT_EQ(4u, packet_list.size()); |
(...skipping 37 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 |