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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 void PacketGenerator::Reset(uint16_t seq_no, uint32_t ts, uint8_t pt, | 46 void PacketGenerator::Reset(uint16_t seq_no, uint32_t ts, uint8_t pt, |
47 int frame_size) { | 47 int frame_size) { |
48 seq_no_ = seq_no; | 48 seq_no_ = seq_no; |
49 ts_ = ts; | 49 ts_ = ts; |
50 pt_ = pt; | 50 pt_ = pt; |
51 frame_size_ = frame_size; | 51 frame_size_ = frame_size; |
52 } | 52 } |
53 | 53 |
54 Packet* PacketGenerator::NextPacket(int payload_size_bytes) { | 54 Packet* PacketGenerator::NextPacket(int payload_size_bytes) { |
55 Packet* packet = new Packet; | 55 Packet* packet = new Packet; |
56 packet->header.sequenceNumber = seq_no_; | 56 packet->sequence_number = seq_no_; |
57 packet->header.timestamp = ts_; | 57 packet->timestamp = ts_; |
58 packet->header.payloadType = pt_; | 58 packet->payload_type = pt_; |
59 packet->header.markerBit = false; | |
60 packet->header.ssrc = 0x12345678; | |
61 packet->header.numCSRCs = 0; | |
62 packet->header.paddingLength = 0; | |
63 packet->payload.SetSize(payload_size_bytes); | 59 packet->payload.SetSize(payload_size_bytes); |
64 ++seq_no_; | 60 ++seq_no_; |
65 ts_ += frame_size_; | 61 ts_ += frame_size_; |
66 return packet; | 62 return packet; |
67 } | 63 } |
68 | 64 |
69 struct PacketsToInsert { | 65 struct PacketsToInsert { |
70 uint16_t sequence_number; | 66 uint16_t sequence_number; |
71 uint32_t timestamp; | 67 uint32_t timestamp; |
72 uint8_t payload_type; | 68 uint8_t payload_type; |
(...skipping 20 matching lines...) Expand all Loading... |
93 | 89 |
94 const int payload_len = 100; | 90 const int payload_len = 100; |
95 Packet* packet = gen.NextPacket(payload_len); | 91 Packet* packet = gen.NextPacket(payload_len); |
96 | 92 |
97 EXPECT_EQ(0, buffer.InsertPacket(packet)); | 93 EXPECT_EQ(0, buffer.InsertPacket(packet)); |
98 uint32_t next_ts; | 94 uint32_t next_ts; |
99 EXPECT_EQ(PacketBuffer::kOK, buffer.NextTimestamp(&next_ts)); | 95 EXPECT_EQ(PacketBuffer::kOK, buffer.NextTimestamp(&next_ts)); |
100 EXPECT_EQ(4711u, next_ts); | 96 EXPECT_EQ(4711u, next_ts); |
101 EXPECT_FALSE(buffer.Empty()); | 97 EXPECT_FALSE(buffer.Empty()); |
102 EXPECT_EQ(1u, buffer.NumPacketsInBuffer()); | 98 EXPECT_EQ(1u, buffer.NumPacketsInBuffer()); |
103 const RTPHeader* hdr = buffer.NextRtpHeader(); | 99 const Packet* next_packet = buffer.PeekNextPacket(); |
104 EXPECT_EQ(&(packet->header), hdr); // Compare pointer addresses. | 100 EXPECT_EQ(packet, next_packet); // Compare pointer addresses. |
105 | 101 |
106 // Do not explicitly flush buffer or delete packet to test that it is deleted | 102 // Do not explicitly flush buffer or delete packet to test that it is deleted |
107 // with the buffer. (Tested with Valgrind or similar tool.) | 103 // with the buffer. (Tested with Valgrind or similar tool.) |
108 } | 104 } |
109 | 105 |
110 // Test to flush buffer. | 106 // Test to flush buffer. |
111 TEST(PacketBuffer, FlushBuffer) { | 107 TEST(PacketBuffer, FlushBuffer) { |
112 TickTimer tick_timer; | 108 TickTimer tick_timer; |
113 PacketBuffer buffer(10, &tick_timer); // 10 packets. | 109 PacketBuffer buffer(10, &tick_timer); // 10 packets. |
114 PacketGenerator gen(0, 0, 0, 10); | 110 PacketGenerator gen(0, 0, 0, 10); |
(...skipping 30 matching lines...) Expand all Loading... |
145 uint32_t next_ts; | 141 uint32_t next_ts; |
146 EXPECT_EQ(PacketBuffer::kOK, buffer.NextTimestamp(&next_ts)); | 142 EXPECT_EQ(PacketBuffer::kOK, buffer.NextTimestamp(&next_ts)); |
147 EXPECT_EQ(0u, next_ts); // Expect first inserted packet to be first in line. | 143 EXPECT_EQ(0u, next_ts); // Expect first inserted packet to be first in line. |
148 | 144 |
149 // Insert 11th packet; should flush the buffer and insert it after flushing. | 145 // Insert 11th packet; should flush the buffer and insert it after flushing. |
150 Packet* packet = gen.NextPacket(payload_len); | 146 Packet* packet = gen.NextPacket(payload_len); |
151 EXPECT_EQ(PacketBuffer::kFlushed, buffer.InsertPacket(packet)); | 147 EXPECT_EQ(PacketBuffer::kFlushed, buffer.InsertPacket(packet)); |
152 EXPECT_EQ(1u, buffer.NumPacketsInBuffer()); | 148 EXPECT_EQ(1u, buffer.NumPacketsInBuffer()); |
153 EXPECT_EQ(PacketBuffer::kOK, buffer.NextTimestamp(&next_ts)); | 149 EXPECT_EQ(PacketBuffer::kOK, buffer.NextTimestamp(&next_ts)); |
154 // Expect last inserted packet to be first in line. | 150 // Expect last inserted packet to be first in line. |
155 EXPECT_EQ(packet->header.timestamp, next_ts); | 151 EXPECT_EQ(packet->timestamp, next_ts); |
156 | 152 |
157 // Flush buffer to delete all packets. | 153 // Flush buffer to delete all packets. |
158 buffer.Flush(); | 154 buffer.Flush(); |
159 } | 155 } |
160 | 156 |
161 // Test inserting a list of packets. | 157 // Test inserting a list of packets. |
162 TEST(PacketBuffer, InsertPacketList) { | 158 TEST(PacketBuffer, InsertPacketList) { |
163 TickTimer tick_timer; | 159 TickTimer tick_timer; |
164 PacketBuffer buffer(10, &tick_timer); // 10 packets. | 160 PacketBuffer buffer(10, &tick_timer); // 10 packets. |
165 PacketGenerator gen(0, 0, 0, 10); | 161 PacketGenerator gen(0, 0, 0, 10); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 PacketList list; | 200 PacketList list; |
205 const int payload_len = 10; | 201 const int payload_len = 10; |
206 | 202 |
207 // Insert 10 small packets. | 203 // Insert 10 small packets. |
208 for (int i = 0; i < 10; ++i) { | 204 for (int i = 0; i < 10; ++i) { |
209 Packet* packet = gen.NextPacket(payload_len); | 205 Packet* packet = gen.NextPacket(payload_len); |
210 list.push_back(packet); | 206 list.push_back(packet); |
211 } | 207 } |
212 // Insert 11th packet of another payload type (not CNG). | 208 // Insert 11th packet of another payload type (not CNG). |
213 Packet* packet = gen.NextPacket(payload_len); | 209 Packet* packet = gen.NextPacket(payload_len); |
214 packet->header.payloadType = 1; | 210 packet->payload_type = 1; |
215 list.push_back(packet); | 211 list.push_back(packet); |
216 | 212 |
217 | 213 |
218 MockDecoderDatabase decoder_database; | 214 MockDecoderDatabase decoder_database; |
219 auto factory = CreateBuiltinAudioDecoderFactory(); | 215 auto factory = CreateBuiltinAudioDecoderFactory(); |
220 const DecoderDatabase::DecoderInfo info0(NetEqDecoder::kDecoderPCMu, factory); | 216 const DecoderDatabase::DecoderInfo info0(NetEqDecoder::kDecoderPCMu, factory); |
221 EXPECT_CALL(decoder_database, GetDecoderInfo(0)) | 217 EXPECT_CALL(decoder_database, GetDecoderInfo(0)) |
222 .WillRepeatedly(Return(&info0)); | 218 .WillRepeatedly(Return(&info0)); |
223 const DecoderDatabase::DecoderInfo info1(NetEqDecoder::kDecoderPCMa, factory); | 219 const DecoderDatabase::DecoderInfo info1(NetEqDecoder::kDecoderPCMa, factory); |
224 EXPECT_CALL(decoder_database, GetDecoderInfo(1)) | 220 EXPECT_CALL(decoder_database, GetDecoderInfo(1)) |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 decoder_database, | 359 decoder_database, |
364 ¤t_pt, | 360 ¤t_pt, |
365 ¤t_cng_pt)); | 361 ¤t_cng_pt)); |
366 EXPECT_EQ(10u, buffer.NumPacketsInBuffer()); | 362 EXPECT_EQ(10u, buffer.NumPacketsInBuffer()); |
367 | 363 |
368 // Extract them and make sure that come out in the right order. | 364 // Extract them and make sure that come out in the right order. |
369 uint32_t current_ts = start_ts; | 365 uint32_t current_ts = start_ts; |
370 for (int i = 0; i < 10; ++i) { | 366 for (int i = 0; i < 10; ++i) { |
371 Packet* packet = buffer.GetNextPacket(NULL); | 367 Packet* packet = buffer.GetNextPacket(NULL); |
372 ASSERT_FALSE(packet == NULL); | 368 ASSERT_FALSE(packet == NULL); |
373 EXPECT_EQ(current_ts, packet->header.timestamp); | 369 EXPECT_EQ(current_ts, packet->timestamp); |
374 current_ts += ts_increment; | 370 current_ts += ts_increment; |
375 delete packet; | 371 delete packet; |
376 } | 372 } |
377 EXPECT_TRUE(buffer.Empty()); | 373 EXPECT_TRUE(buffer.Empty()); |
378 | 374 |
379 EXPECT_CALL(decoder_database, Die()); // Called when object is deleted. | 375 EXPECT_CALL(decoder_database, Die()); // Called when object is deleted. |
380 } | 376 } |
381 | 377 |
382 // The test first inserts a packet with narrow-band CNG, then a packet with | 378 // The test first inserts a packet with narrow-band CNG, then a packet with |
383 // wide-band speech. The expected behavior of the packet buffer is to detect a | 379 // wide-band speech. The expected behavior of the packet buffer is to detect a |
(...skipping 21 matching lines...) Expand all Loading... |
405 PacketGenerator gen(0, 0, kCngPt, 10); | 401 PacketGenerator gen(0, 0, kCngPt, 10); |
406 PacketList list; | 402 PacketList list; |
407 list.push_back(gen.NextPacket(kPayloadLen)); | 403 list.push_back(gen.NextPacket(kPayloadLen)); |
408 rtc::Optional<uint8_t> current_pt; | 404 rtc::Optional<uint8_t> current_pt; |
409 rtc::Optional<uint8_t> current_cng_pt; | 405 rtc::Optional<uint8_t> current_cng_pt; |
410 EXPECT_EQ(PacketBuffer::kOK, | 406 EXPECT_EQ(PacketBuffer::kOK, |
411 buffer.InsertPacketList(&list, decoder_database, ¤t_pt, | 407 buffer.InsertPacketList(&list, decoder_database, ¤t_pt, |
412 ¤t_cng_pt)); | 408 ¤t_cng_pt)); |
413 EXPECT_TRUE(list.empty()); | 409 EXPECT_TRUE(list.empty()); |
414 EXPECT_EQ(1u, buffer.NumPacketsInBuffer()); | 410 EXPECT_EQ(1u, buffer.NumPacketsInBuffer()); |
415 ASSERT_TRUE(buffer.NextRtpHeader()); | 411 ASSERT_TRUE(buffer.PeekNextPacket()); |
416 EXPECT_EQ(kCngPt, buffer.NextRtpHeader()->payloadType); | 412 EXPECT_EQ(kCngPt, buffer.PeekNextPacket()->payload_type); |
417 EXPECT_FALSE(current_pt); // Current payload type not set. | 413 EXPECT_FALSE(current_pt); // Current payload type not set. |
418 EXPECT_EQ(rtc::Optional<uint8_t>(kCngPt), | 414 EXPECT_EQ(rtc::Optional<uint8_t>(kCngPt), |
419 current_cng_pt); // CNG payload type set. | 415 current_cng_pt); // CNG payload type set. |
420 | 416 |
421 // Insert second packet, which is wide-band speech. | 417 // Insert second packet, which is wide-band speech. |
422 Packet* packet = gen.NextPacket(kPayloadLen); | 418 Packet* packet = gen.NextPacket(kPayloadLen); |
423 packet->header.payloadType = kSpeechPt; | 419 packet->payload_type = kSpeechPt; |
424 list.push_back(packet); | 420 list.push_back(packet); |
425 // Expect the buffer to flush out the CNG packet, since it does not match the | 421 // Expect the buffer to flush out the CNG packet, since it does not match the |
426 // new speech sample rate. | 422 // new speech sample rate. |
427 EXPECT_EQ(PacketBuffer::kFlushed, | 423 EXPECT_EQ(PacketBuffer::kFlushed, |
428 buffer.InsertPacketList(&list, decoder_database, ¤t_pt, | 424 buffer.InsertPacketList(&list, decoder_database, ¤t_pt, |
429 ¤t_cng_pt)); | 425 ¤t_cng_pt)); |
430 EXPECT_TRUE(list.empty()); | 426 EXPECT_TRUE(list.empty()); |
431 EXPECT_EQ(1u, buffer.NumPacketsInBuffer()); | 427 EXPECT_EQ(1u, buffer.NumPacketsInBuffer()); |
432 ASSERT_TRUE(buffer.NextRtpHeader()); | 428 ASSERT_TRUE(buffer.PeekNextPacket()); |
433 EXPECT_EQ(kSpeechPt, buffer.NextRtpHeader()->payloadType); | 429 EXPECT_EQ(kSpeechPt, buffer.PeekNextPacket()->payload_type); |
434 | 430 |
435 EXPECT_EQ(rtc::Optional<uint8_t>(kSpeechPt), | 431 EXPECT_EQ(rtc::Optional<uint8_t>(kSpeechPt), |
436 current_pt); // Current payload type set. | 432 current_pt); // Current payload type set. |
437 EXPECT_FALSE(current_cng_pt); // CNG payload type reset. | 433 EXPECT_FALSE(current_cng_pt); // CNG payload type reset. |
438 | 434 |
439 buffer.Flush(); // Clean up. | 435 buffer.Flush(); // Clean up. |
440 EXPECT_CALL(decoder_database, Die()); // Called when object is deleted. | 436 EXPECT_CALL(decoder_database, Die()); // Called when object is deleted. |
441 } | 437 } |
442 | 438 |
443 TEST(PacketBuffer, Failures) { | 439 TEST(PacketBuffer, Failures) { |
(...skipping 10 matching lines...) Expand all Loading... |
454 packet = gen.NextPacket(payload_len); | 450 packet = gen.NextPacket(payload_len); |
455 packet->payload.Clear(); | 451 packet->payload.Clear(); |
456 EXPECT_EQ(PacketBuffer::kInvalidPacket, buffer->InsertPacket(packet)); | 452 EXPECT_EQ(PacketBuffer::kInvalidPacket, buffer->InsertPacket(packet)); |
457 // Packet is deleted by the PacketBuffer. | 453 // Packet is deleted by the PacketBuffer. |
458 | 454 |
459 // Buffer should still be empty. Test all empty-checks. | 455 // Buffer should still be empty. Test all empty-checks. |
460 uint32_t temp_ts; | 456 uint32_t temp_ts; |
461 EXPECT_EQ(PacketBuffer::kBufferEmpty, buffer->NextTimestamp(&temp_ts)); | 457 EXPECT_EQ(PacketBuffer::kBufferEmpty, buffer->NextTimestamp(&temp_ts)); |
462 EXPECT_EQ(PacketBuffer::kBufferEmpty, | 458 EXPECT_EQ(PacketBuffer::kBufferEmpty, |
463 buffer->NextHigherTimestamp(0, &temp_ts)); | 459 buffer->NextHigherTimestamp(0, &temp_ts)); |
464 EXPECT_EQ(NULL, buffer->NextRtpHeader()); | 460 EXPECT_EQ(NULL, buffer->PeekNextPacket()); |
465 EXPECT_EQ(NULL, buffer->GetNextPacket(NULL)); | 461 EXPECT_EQ(NULL, buffer->GetNextPacket(NULL)); |
466 EXPECT_EQ(PacketBuffer::kBufferEmpty, buffer->DiscardNextPacket()); | 462 EXPECT_EQ(PacketBuffer::kBufferEmpty, buffer->DiscardNextPacket()); |
467 EXPECT_EQ(0, buffer->DiscardAllOldPackets(0)); // 0 packets discarded. | 463 EXPECT_EQ(0, buffer->DiscardAllOldPackets(0)); // 0 packets discarded. |
468 | 464 |
469 // Insert one packet to make the buffer non-empty. | 465 // Insert one packet to make the buffer non-empty. |
470 packet = gen.NextPacket(payload_len); | 466 packet = gen.NextPacket(payload_len); |
471 EXPECT_EQ(PacketBuffer::kOK, buffer->InsertPacket(packet)); | 467 EXPECT_EQ(PacketBuffer::kOK, buffer->InsertPacket(packet)); |
472 EXPECT_EQ(PacketBuffer::kInvalidPointer, buffer->NextTimestamp(NULL)); | 468 EXPECT_EQ(PacketBuffer::kInvalidPointer, buffer->NextTimestamp(NULL)); |
473 EXPECT_EQ(PacketBuffer::kInvalidPointer, | 469 EXPECT_EQ(PacketBuffer::kInvalidPointer, |
474 buffer->NextHigherTimestamp(0, NULL)); | 470 buffer->NextHigherTimestamp(0, NULL)); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 std::unique_ptr<Packet> a(gen.NextPacket(10)); // SN = 0, TS = 0. | 505 std::unique_ptr<Packet> a(gen.NextPacket(10)); // SN = 0, TS = 0. |
510 std::unique_ptr<Packet> b(gen.NextPacket(10)); // SN = 1, TS = 10. | 506 std::unique_ptr<Packet> b(gen.NextPacket(10)); // SN = 1, TS = 10. |
511 EXPECT_FALSE(*a == *b); | 507 EXPECT_FALSE(*a == *b); |
512 EXPECT_TRUE(*a != *b); | 508 EXPECT_TRUE(*a != *b); |
513 EXPECT_TRUE(*a < *b); | 509 EXPECT_TRUE(*a < *b); |
514 EXPECT_FALSE(*a > *b); | 510 EXPECT_FALSE(*a > *b); |
515 EXPECT_TRUE(*a <= *b); | 511 EXPECT_TRUE(*a <= *b); |
516 EXPECT_FALSE(*a >= *b); | 512 EXPECT_FALSE(*a >= *b); |
517 | 513 |
518 // Testing wrap-around case; 'a' is earlier but has a larger timestamp value. | 514 // Testing wrap-around case; 'a' is earlier but has a larger timestamp value. |
519 a->header.timestamp = 0xFFFFFFFF - 10; | 515 a->timestamp = 0xFFFFFFFF - 10; |
520 EXPECT_FALSE(*a == *b); | 516 EXPECT_FALSE(*a == *b); |
521 EXPECT_TRUE(*a != *b); | 517 EXPECT_TRUE(*a != *b); |
522 EXPECT_TRUE(*a < *b); | 518 EXPECT_TRUE(*a < *b); |
523 EXPECT_FALSE(*a > *b); | 519 EXPECT_FALSE(*a > *b); |
524 EXPECT_TRUE(*a <= *b); | 520 EXPECT_TRUE(*a <= *b); |
525 EXPECT_FALSE(*a >= *b); | 521 EXPECT_FALSE(*a >= *b); |
526 | 522 |
527 // Test equal packets. | 523 // Test equal packets. |
528 EXPECT_TRUE(*a == *a); | 524 EXPECT_TRUE(*a == *a); |
529 EXPECT_FALSE(*a != *a); | 525 EXPECT_FALSE(*a != *a); |
530 EXPECT_FALSE(*a < *a); | 526 EXPECT_FALSE(*a < *a); |
531 EXPECT_FALSE(*a > *a); | 527 EXPECT_FALSE(*a > *a); |
532 EXPECT_TRUE(*a <= *a); | 528 EXPECT_TRUE(*a <= *a); |
533 EXPECT_TRUE(*a >= *a); | 529 EXPECT_TRUE(*a >= *a); |
534 | 530 |
535 // Test equal timestamps but different sequence numbers (0 and 1). | 531 // Test equal timestamps but different sequence numbers (0 and 1). |
536 a->header.timestamp = b->header.timestamp; | 532 a->timestamp = b->timestamp; |
537 EXPECT_FALSE(*a == *b); | 533 EXPECT_FALSE(*a == *b); |
538 EXPECT_TRUE(*a != *b); | 534 EXPECT_TRUE(*a != *b); |
539 EXPECT_TRUE(*a < *b); | 535 EXPECT_TRUE(*a < *b); |
540 EXPECT_FALSE(*a > *b); | 536 EXPECT_FALSE(*a > *b); |
541 EXPECT_TRUE(*a <= *b); | 537 EXPECT_TRUE(*a <= *b); |
542 EXPECT_FALSE(*a >= *b); | 538 EXPECT_FALSE(*a >= *b); |
543 | 539 |
544 // Test equal timestamps but different sequence numbers (32767 and 1). | 540 // Test equal timestamps but different sequence numbers (32767 and 1). |
545 a->header.sequenceNumber = 0xFFFF; | 541 a->sequence_number = 0xFFFF; |
546 EXPECT_FALSE(*a == *b); | 542 EXPECT_FALSE(*a == *b); |
547 EXPECT_TRUE(*a != *b); | 543 EXPECT_TRUE(*a != *b); |
548 EXPECT_TRUE(*a < *b); | 544 EXPECT_TRUE(*a < *b); |
549 EXPECT_FALSE(*a > *b); | 545 EXPECT_FALSE(*a > *b); |
550 EXPECT_TRUE(*a <= *b); | 546 EXPECT_TRUE(*a <= *b); |
551 EXPECT_FALSE(*a >= *b); | 547 EXPECT_FALSE(*a >= *b); |
552 | 548 |
553 // Test equal timestamps and sequence numbers, but differing priorities. | 549 // Test equal timestamps and sequence numbers, but differing priorities. |
554 a->header.sequenceNumber = b->header.sequenceNumber; | 550 a->sequence_number = b->sequence_number; |
555 a->priority = {1, 0}; | 551 a->priority = {1, 0}; |
556 b->priority = {0, 0}; | 552 b->priority = {0, 0}; |
557 // a after b | 553 // a after b |
558 EXPECT_FALSE(*a == *b); | 554 EXPECT_FALSE(*a == *b); |
559 EXPECT_TRUE(*a != *b); | 555 EXPECT_TRUE(*a != *b); |
560 EXPECT_FALSE(*a < *b); | 556 EXPECT_FALSE(*a < *b); |
561 EXPECT_TRUE(*a > *b); | 557 EXPECT_TRUE(*a > *b); |
562 EXPECT_FALSE(*a <= *b); | 558 EXPECT_FALSE(*a <= *b); |
563 EXPECT_TRUE(*a >= *b); | 559 EXPECT_TRUE(*a >= *b); |
564 | 560 |
565 std::unique_ptr<Packet> c(gen.NextPacket(0)); // SN = 2, TS = 20. | 561 std::unique_ptr<Packet> c(gen.NextPacket(0)); // SN = 2, TS = 20. |
566 std::unique_ptr<Packet> d(gen.NextPacket(0)); // SN = 3, TS = 20. | 562 std::unique_ptr<Packet> d(gen.NextPacket(0)); // SN = 3, TS = 20. |
567 c->header.timestamp = b->header.timestamp; | 563 c->timestamp = b->timestamp; |
568 d->header.timestamp = b->header.timestamp; | 564 d->timestamp = b->timestamp; |
569 c->header.sequenceNumber = b->header.sequenceNumber; | 565 c->sequence_number = b->sequence_number; |
570 d->header.sequenceNumber = b->header.sequenceNumber; | 566 d->sequence_number = b->sequence_number; |
571 c->priority = {1, 1}; | 567 c->priority = {1, 1}; |
572 d->priority = {0, 1}; | 568 d->priority = {0, 1}; |
573 // c after d | 569 // c after d |
574 EXPECT_FALSE(*c == *d); | 570 EXPECT_FALSE(*c == *d); |
575 EXPECT_TRUE(*c != *d); | 571 EXPECT_TRUE(*c != *d); |
576 EXPECT_FALSE(*c < *d); | 572 EXPECT_FALSE(*c < *d); |
577 EXPECT_TRUE(*c > *d); | 573 EXPECT_TRUE(*c > *d); |
578 EXPECT_FALSE(*c <= *d); | 574 EXPECT_FALSE(*c <= *d); |
579 EXPECT_TRUE(*c >= *d); | 575 EXPECT_TRUE(*c >= *d); |
580 | 576 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 // Test the IsObsoleteTimestamp method with different limit timestamps. | 681 // Test the IsObsoleteTimestamp method with different limit timestamps. |
686 TEST(PacketBuffer, IsObsoleteTimestamp) { | 682 TEST(PacketBuffer, IsObsoleteTimestamp) { |
687 TestIsObsoleteTimestamp(0); | 683 TestIsObsoleteTimestamp(0); |
688 TestIsObsoleteTimestamp(1); | 684 TestIsObsoleteTimestamp(1); |
689 TestIsObsoleteTimestamp(0xFFFFFFFF); // -1 in uint32_t. | 685 TestIsObsoleteTimestamp(0xFFFFFFFF); // -1 in uint32_t. |
690 TestIsObsoleteTimestamp(0x80000000); // 2^31. | 686 TestIsObsoleteTimestamp(0x80000000); // 2^31. |
691 TestIsObsoleteTimestamp(0x80000001); // 2^31 + 1. | 687 TestIsObsoleteTimestamp(0x80000001); // 2^31 + 1. |
692 TestIsObsoleteTimestamp(0x7FFFFFFF); // 2^31 - 1. | 688 TestIsObsoleteTimestamp(0x7FFFFFFF); // 2^31 - 1. |
693 } | 689 } |
694 } // namespace webrtc | 690 } // namespace webrtc |
OLD | NEW |