OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // Tracks information about an FEC group, including the packets | 5 // Tracks information about an FEC group, including the packets |
6 // that have been seen, and the running parity. Provided the ability | 6 // that have been seen, and the running parity. Provided the ability |
7 // to revive a dropped packet. | 7 // to revive a dropped packet. |
8 | 8 |
9 #ifndef NET_QUIC_QUIC_FEC_GROUP_H_ | 9 #ifndef NET_QUIC_QUIC_FEC_GROUP_H_ |
10 #define NET_QUIC_QUIC_FEC_GROUP_H_ | 10 #define NET_QUIC_QUIC_FEC_GROUP_H_ |
(...skipping 13 matching lines...) Expand all Loading... |
24 // Updates the FEC group based on the delivery of a data packet. | 24 // Updates the FEC group based on the delivery of a data packet. |
25 // Returns false if this packet has already been seen, true otherwise. | 25 // Returns false if this packet has already been seen, true otherwise. |
26 bool Update(const QuicPacketHeader& header, | 26 bool Update(const QuicPacketHeader& header, |
27 base::StringPiece decrypted_payload); | 27 base::StringPiece decrypted_payload); |
28 | 28 |
29 // Updates the FEC group based on the delivery of an FEC packet. | 29 // Updates the FEC group based on the delivery of an FEC packet. |
30 // Returns false if this packet has already been seen or if it does | 30 // Returns false if this packet has already been seen or if it does |
31 // not claim to protect all the packets previously seen in this group. | 31 // not claim to protect all the packets previously seen in this group. |
32 // |fec_packet_entropy|: XOR of entropy of all packets in the fec group. | 32 // |fec_packet_entropy|: XOR of entropy of all packets in the fec group. |
33 bool UpdateFec(QuicPacketSequenceNumber fec_packet_sequence_number, | 33 bool UpdateFec(QuicPacketSequenceNumber fec_packet_sequence_number, |
34 bool fec_packet_entropy, | |
35 const QuicFecData& fec); | 34 const QuicFecData& fec); |
36 | 35 |
37 // Returns true if a packet can be revived from this FEC group. | 36 // Returns true if a packet can be revived from this FEC group. |
38 bool CanRevive() const; | 37 bool CanRevive() const; |
39 | 38 |
40 // Returns true if all packets (FEC and data) from this FEC group have been | 39 // Returns true if all packets (FEC and data) from this FEC group have been |
41 // seen or revived | 40 // seen or revived |
42 bool IsFinished() const; | 41 bool IsFinished() const; |
43 | 42 |
44 // Revives the missing packet from this FEC group. This may return a packet | 43 // Revives the missing packet from this FEC group. This may return a packet |
45 // that is null padded to a greater length than the original packet, but | 44 // that is null padded to a greater length than the original packet, but |
46 // the framer will handle it correctly. Returns the length of the data | 45 // the framer will handle it correctly. Returns the length of the data |
47 // written to |decrypted_payload|, or 0 if the packet could not be revived. | 46 // written to |decrypted_payload|, or 0 if the packet could not be revived. |
48 size_t Revive(QuicPacketHeader* header, | 47 size_t Revive(QuicPacketHeader* header, |
49 char* decrypted_payload, | 48 char* decrypted_payload, |
50 size_t decrypted_payload_len); | 49 size_t decrypted_payload_len); |
51 | 50 |
52 // Returns true of this FEC group protects any packets with sequence | 51 // Returns true of this FEC group protects any packets with sequence |
53 // numbers less than |num|. | 52 // numbers less than |num|. |
54 bool ProtectsPacketsBefore(QuicPacketSequenceNumber num) const; | 53 bool ProtectsPacketsBefore(QuicPacketSequenceNumber num) const; |
55 | 54 |
56 const base::StringPiece payload_parity() const { | 55 const base::StringPiece payload_parity() const { |
57 return base::StringPiece(payload_parity_, payload_parity_len_); | 56 return base::StringPiece(payload_parity_, payload_parity_len_); |
58 } | 57 } |
59 | 58 |
60 bool entropy_parity() const { | |
61 return entropy_parity_; | |
62 } | |
63 | |
64 QuicPacketSequenceNumber min_protected_packet() const { | 59 QuicPacketSequenceNumber min_protected_packet() const { |
65 return min_protected_packet_; | 60 return min_protected_packet_; |
66 } | 61 } |
67 | 62 |
68 size_t NumReceivedPackets() const { | 63 size_t NumReceivedPackets() const { |
69 return received_packets_.size(); | 64 return received_packets_.size(); |
70 } | 65 } |
71 | 66 |
72 private: | 67 private: |
73 bool UpdateParity(base::StringPiece payload, bool entropy); | 68 bool UpdateParity(base::StringPiece payload); |
74 // Returns the number of missing packets, or size_t max if the number | 69 // Returns the number of missing packets, or size_t max if the number |
75 // of missing packets is not known. | 70 // of missing packets is not known. |
76 size_t NumMissingPackets() const; | 71 size_t NumMissingPackets() const; |
77 | 72 |
78 // Set of packets that we have recevied. | 73 // Set of packets that we have recevied. |
79 SequenceNumberSet received_packets_; | 74 SequenceNumberSet received_packets_; |
80 // Sequence number of the first protected packet in this group (the one | 75 // Sequence number of the first protected packet in this group (the one |
81 // with the lowest packet sequence number). Will only be set once the FEC | 76 // with the lowest packet sequence number). Will only be set once the FEC |
82 // packet has been seen. | 77 // packet has been seen. |
83 QuicPacketSequenceNumber min_protected_packet_; | 78 QuicPacketSequenceNumber min_protected_packet_; |
84 // Sequence number of the last protected packet in this group (the one | 79 // Sequence number of the last protected packet in this group (the one |
85 // with the highest packet sequence number). Will only be set once the FEC | 80 // with the highest packet sequence number). Will only be set once the FEC |
86 // packet has been seen. | 81 // packet has been seen. |
87 QuicPacketSequenceNumber max_protected_packet_; | 82 QuicPacketSequenceNumber max_protected_packet_; |
88 // The cumulative parity calculation of all received packets. | 83 // The cumulative parity calculation of all received packets. |
89 char payload_parity_[kMaxPacketSize]; | 84 char payload_parity_[kMaxPacketSize]; |
90 size_t payload_parity_len_; | 85 size_t payload_parity_len_; |
91 bool entropy_parity_; | |
92 | 86 |
93 DISALLOW_COPY_AND_ASSIGN(QuicFecGroup); | 87 DISALLOW_COPY_AND_ASSIGN(QuicFecGroup); |
94 }; | 88 }; |
95 | 89 |
96 } // namespace net | 90 } // namespace net |
97 | 91 |
98 #endif // NET_QUIC_QUIC_FEC_GROUP_H_ | 92 #endif // NET_QUIC_QUIC_FEC_GROUP_H_ |
OLD | NEW |