| 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 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 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 bool UpdateFec(QuicPacketSequenceNumber fec_packet_sequence_number, | 32 bool UpdateFec(QuicPacketSequenceNumber fec_packet_sequence_number, |
| 33 bool fec_entropy_flag, |
| 33 const QuicFecData& fec); | 34 const QuicFecData& fec); |
| 34 | 35 |
| 35 // 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. |
| 36 bool CanRevive() const; | 37 bool CanRevive() const; |
| 37 | 38 |
| 38 // 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 |
| 39 // seen or revived | 40 // seen or revived |
| 40 bool IsFinished() const; | 41 bool IsFinished() const; |
| 41 | 42 |
| 42 // 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 |
| 43 // 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 |
| 44 // 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 |
| 45 // 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. |
| 46 size_t Revive(QuicPacketHeader* header, | 47 size_t Revive(QuicPacketHeader* header, |
| 47 char* decrypted_payload, | 48 char* decrypted_payload, |
| 48 size_t decrypted_payload_len); | 49 size_t decrypted_payload_len); |
| 49 | 50 |
| 50 // Returns true of this FEC group protects any packets with sequence | 51 // Returns true of this FEC group protects any packets with sequence |
| 51 // numbers less than |num|. | 52 // numbers less than |num|. |
| 52 bool ProtectsPacketsBefore(QuicPacketSequenceNumber num) const; | 53 bool ProtectsPacketsBefore(QuicPacketSequenceNumber num) const; |
| 53 | 54 |
| 54 const base::StringPiece parity() const { | 55 const base::StringPiece payload_parity() const { |
| 55 return base::StringPiece(parity_, parity_len_); | 56 return base::StringPiece(payload_parity_, payload_parity_len_); |
| 57 } |
| 58 |
| 59 bool entropy_parity() const { |
| 60 return entropy_parity_; |
| 56 } | 61 } |
| 57 | 62 |
| 58 QuicPacketSequenceNumber min_protected_packet() const { | 63 QuicPacketSequenceNumber min_protected_packet() const { |
| 59 return min_protected_packet_; | 64 return min_protected_packet_; |
| 60 } | 65 } |
| 61 | 66 |
| 62 size_t NumReceivedPackets() const { | 67 size_t NumReceivedPackets() const { |
| 63 return received_packets_.size(); | 68 return received_packets_.size(); |
| 64 } | 69 } |
| 65 | 70 |
| 66 private: | 71 private: |
| 67 bool UpdateParity(base::StringPiece payload); | 72 bool UpdateParity(base::StringPiece payload, bool entropy); |
| 68 // Returns the number of missing packets, or size_t max if the number | 73 // Returns the number of missing packets, or size_t max if the number |
| 69 // of missing packets is not known. | 74 // of missing packets is not known. |
| 70 size_t NumMissingPackets() const; | 75 size_t NumMissingPackets() const; |
| 71 | 76 |
| 72 // Set of packets that we have recevied. | 77 // Set of packets that we have recevied. |
| 73 std::set<QuicPacketSequenceNumber> received_packets_; | 78 SequenceNumberSet received_packets_; |
| 74 // Sequence number of the first protected packet in this group (the one | 79 // Sequence number of the first protected packet in this group (the one |
| 75 // with the lowest packet sequence number). Will only be set once the FEC | 80 // with the lowest packet sequence number). Will only be set once the FEC |
| 76 // packet has been seen. | 81 // packet has been seen. |
| 77 QuicPacketSequenceNumber min_protected_packet_; | 82 QuicPacketSequenceNumber min_protected_packet_; |
| 78 // Sequence number of the last protected packet in this group (the one | 83 // Sequence number of the last protected packet in this group (the one |
| 79 // with the highest packet sequence number). Will only be set once the FEC | 84 // with the highest packet sequence number). Will only be set once the FEC |
| 80 // packet has been seen. | 85 // packet has been seen. |
| 81 QuicPacketSequenceNumber max_protected_packet_; | 86 QuicPacketSequenceNumber max_protected_packet_; |
| 82 // The cumulative parity calculation of all received packets. | 87 // The cumulative parity calculation of all received packets. |
| 83 char parity_[kMaxPacketSize]; | 88 char payload_parity_[kMaxPacketSize]; |
| 84 size_t parity_len_; | 89 size_t payload_parity_len_; |
| 90 bool entropy_parity_; |
| 85 }; | 91 }; |
| 86 | 92 |
| 87 } // namespace net | 93 } // namespace net |
| 88 | 94 |
| 89 #endif // NET_QUIC_QUIC_FEC_GROUP_H_ | 95 #endif // NET_QUIC_QUIC_FEC_GROUP_H_ |
| OLD | NEW |