Chromium Code Reviews| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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->header.sequenceNumber = seq_no_; |
| 57 packet->header.timestamp = ts_; | 57 packet->header.timestamp = ts_; |
| 58 packet->header.payloadType = pt_; | 58 packet->header.payloadType = pt_; |
| 59 packet->header.markerBit = false; | 59 packet->header.markerBit = false; |
| 60 packet->header.ssrc = 0x12345678; | 60 packet->header.ssrc = 0x12345678; |
| 61 packet->header.numCSRCs = 0; | 61 packet->header.numCSRCs = 0; |
| 62 packet->header.paddingLength = 0; | 62 packet->header.paddingLength = 0; |
| 63 packet->primary = true; | 63 packet->priority = Packet::kHighestPriority; |
|
kwiberg-webrtc
2016/09/20 09:14:45
Why can you skip this?
ossu
2016/09/20 13:51:56
Because Priority is now default constructed at the
kwiberg-webrtc
2016/09/20 14:56:22
Acknowledged.
| |
| 64 packet->payload.SetSize(payload_size_bytes); | 64 packet->payload.SetSize(payload_size_bytes); |
| 65 ++seq_no_; | 65 ++seq_no_; |
| 66 ts_ += frame_size_; | 66 ts_ += frame_size_; |
| 67 return packet; | 67 return packet; |
| 68 } | 68 } |
| 69 | 69 |
| 70 struct PacketsToInsert { | 70 struct PacketsToInsert { |
| 71 uint16_t sequence_number; | 71 uint16_t sequence_number; |
| 72 uint32_t timestamp; | 72 uint32_t timestamp; |
| 73 uint8_t payload_type; | 73 uint8_t payload_type; |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 277 std::vector<Packet*> expect_order(kExpectPacketsInBuffer); | 277 std::vector<Packet*> expect_order(kExpectPacketsInBuffer); |
| 278 | 278 |
| 279 PacketGenerator gen(0, 0, 0, kFrameSize); | 279 PacketGenerator gen(0, 0, 0, kFrameSize); |
| 280 | 280 |
| 281 for (int i = 0; i < kPackets; ++i) { | 281 for (int i = 0; i < kPackets; ++i) { |
| 282 gen.Reset(packet_facts[i].sequence_number, | 282 gen.Reset(packet_facts[i].sequence_number, |
| 283 packet_facts[i].timestamp, | 283 packet_facts[i].timestamp, |
| 284 packet_facts[i].payload_type, | 284 packet_facts[i].payload_type, |
| 285 kFrameSize); | 285 kFrameSize); |
| 286 Packet* packet = gen.NextPacket(kPayloadLength); | 286 Packet* packet = gen.NextPacket(kPayloadLength); |
| 287 packet->primary = packet_facts[i].primary; | 287 packet->priority.red_level = packet_facts[i].primary ? 0 : 1; |
| 288 EXPECT_EQ(PacketBuffer::kOK, buffer.InsertPacket(packet)); | 288 EXPECT_EQ(PacketBuffer::kOK, buffer.InsertPacket(packet)); |
| 289 if (packet_facts[i].extract_order >= 0) { | 289 if (packet_facts[i].extract_order >= 0) { |
| 290 expect_order[packet_facts[i].extract_order] = packet; | 290 expect_order[packet_facts[i].extract_order] = packet; |
| 291 } | 291 } |
| 292 } | 292 } |
| 293 | 293 |
| 294 EXPECT_EQ(kExpectPacketsInBuffer, buffer.NumPacketsInBuffer()); | 294 EXPECT_EQ(kExpectPacketsInBuffer, buffer.NumPacketsInBuffer()); |
| 295 | 295 |
| 296 size_t drop_count; | 296 size_t drop_count; |
| 297 for (size_t i = 0; i < kExpectPacketsInBuffer; ++i) { | 297 for (size_t i = 0; i < kExpectPacketsInBuffer; ++i) { |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 551 a->header.sequenceNumber = 0xFFFF; | 551 a->header.sequenceNumber = 0xFFFF; |
| 552 EXPECT_FALSE(*a == *b); | 552 EXPECT_FALSE(*a == *b); |
| 553 EXPECT_TRUE(*a != *b); | 553 EXPECT_TRUE(*a != *b); |
| 554 EXPECT_TRUE(*a < *b); | 554 EXPECT_TRUE(*a < *b); |
| 555 EXPECT_FALSE(*a > *b); | 555 EXPECT_FALSE(*a > *b); |
| 556 EXPECT_TRUE(*a <= *b); | 556 EXPECT_TRUE(*a <= *b); |
| 557 EXPECT_FALSE(*a >= *b); | 557 EXPECT_FALSE(*a >= *b); |
| 558 | 558 |
| 559 // Test equal timestamps and sequence numbers, but only 'b' is primary. | 559 // Test equal timestamps and sequence numbers, but only 'b' is primary. |
| 560 a->header.sequenceNumber = b->header.sequenceNumber; | 560 a->header.sequenceNumber = b->header.sequenceNumber; |
| 561 a->primary = false; | 561 a->priority = {1, 0}; |
|
hlundin-webrtc
2016/09/15 09:33:30
Add tests for the other cases too.
ossu
2016/09/15 12:22:53
Acknowledged.
| |
| 562 b->primary = true; | 562 b->priority = {0, 0}; |
| 563 EXPECT_FALSE(*a == *b); | 563 EXPECT_FALSE(*a == *b); |
| 564 EXPECT_TRUE(*a != *b); | 564 EXPECT_TRUE(*a != *b); |
| 565 EXPECT_FALSE(*a < *b); | 565 EXPECT_FALSE(*a < *b); |
| 566 EXPECT_TRUE(*a > *b); | 566 EXPECT_TRUE(*a > *b); |
| 567 EXPECT_FALSE(*a <= *b); | 567 EXPECT_FALSE(*a <= *b); |
| 568 EXPECT_TRUE(*a >= *b); | 568 EXPECT_TRUE(*a >= *b); |
| 569 | 569 |
| 570 delete a; | 570 delete a; |
| 571 delete b; | 571 delete b; |
| 572 } | 572 } |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 645 // Test the IsObsoleteTimestamp method with different limit timestamps. | 645 // Test the IsObsoleteTimestamp method with different limit timestamps. |
| 646 TEST(PacketBuffer, IsObsoleteTimestamp) { | 646 TEST(PacketBuffer, IsObsoleteTimestamp) { |
| 647 TestIsObsoleteTimestamp(0); | 647 TestIsObsoleteTimestamp(0); |
| 648 TestIsObsoleteTimestamp(1); | 648 TestIsObsoleteTimestamp(1); |
| 649 TestIsObsoleteTimestamp(0xFFFFFFFF); // -1 in uint32_t. | 649 TestIsObsoleteTimestamp(0xFFFFFFFF); // -1 in uint32_t. |
| 650 TestIsObsoleteTimestamp(0x80000000); // 2^31. | 650 TestIsObsoleteTimestamp(0x80000000); // 2^31. |
| 651 TestIsObsoleteTimestamp(0x80000001); // 2^31 + 1. | 651 TestIsObsoleteTimestamp(0x80000001); // 2^31 + 1. |
| 652 TestIsObsoleteTimestamp(0x7FFFFFFF); // 2^31 - 1. | 652 TestIsObsoleteTimestamp(0x7FFFFFFF); // 2^31 - 1. |
| 653 } | 653 } |
| 654 } // namespace webrtc | 654 } // namespace webrtc |
| OLD | NEW |