| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 // | |
| 5 // Tracks information about an FEC group, including the packets | |
| 6 // that have been seen, and the running parity. Provides the ability | |
| 7 // to revive a dropped packet. | |
| 8 | |
| 9 #ifndef NET_QUIC_QUIC_FEC_GROUP_H_ | |
| 10 #define NET_QUIC_QUIC_FEC_GROUP_H_ | |
| 11 | |
| 12 #include <cstddef> | |
| 13 | |
| 14 #include "base/macros.h" | |
| 15 #include "base/strings/string_piece.h" | |
| 16 #include "net/quic/quic_fec_group_interface.h" | |
| 17 #include "net/quic/quic_protocol.h" | |
| 18 | |
| 19 namespace net { | |
| 20 | |
| 21 class NET_EXPORT_PRIVATE QuicFecGroup : public QuicFecGroupInterface { | |
| 22 public: | |
| 23 explicit QuicFecGroup(QuicPacketNumber fec_group_number); | |
| 24 virtual ~QuicFecGroup(); | |
| 25 | |
| 26 // Implementation of QuicFecGroupInterface. | |
| 27 bool Update(EncryptionLevel encryption_level, | |
| 28 const QuicPacketHeader& header, | |
| 29 base::StringPiece decrypted_payload) override; | |
| 30 bool UpdateFec(EncryptionLevel encryption_level, | |
| 31 const QuicPacketHeader& header, | |
| 32 base::StringPiece redundancy) override; | |
| 33 bool CanRevive() const override; | |
| 34 bool IsFinished() const override; | |
| 35 size_t Revive(QuicPacketHeader* header, | |
| 36 char* decrypted_payload, | |
| 37 size_t decrypted_payload_len) override; | |
| 38 bool IsWaitingForPacketBefore(QuicPacketNumber num) const override; | |
| 39 const base::StringPiece PayloadParity() const override; | |
| 40 QuicPacketCount NumReceivedPackets() const override; | |
| 41 EncryptionLevel EffectiveEncryptionLevel() const override; | |
| 42 QuicFecGroupNumber FecGroupNumber() const override; | |
| 43 | |
| 44 private: | |
| 45 bool UpdateParity(base::StringPiece payload); | |
| 46 // Returns the number of missing packets, or QuicPacketCount max | |
| 47 // if the number of missing packets is not known. | |
| 48 QuicPacketCount NumMissingPackets() const; | |
| 49 | |
| 50 bool has_received_fec_packet() const { | |
| 51 return max_protected_packet_ != kInvalidPacketNumber; | |
| 52 } | |
| 53 | |
| 54 // Set of packets that we have recevied. | |
| 55 PacketNumberSet received_packets_; | |
| 56 // packet number of the first protected packet in this group (the one | |
| 57 // with the lowest packet number). Will only be set once the FEC | |
| 58 // packet has been seen. | |
| 59 const QuicPacketNumber min_protected_packet_; | |
| 60 // packet number of the last protected packet in this group (the one | |
| 61 // with the highest packet number). Will only be set once the FEC | |
| 62 // packet has been seen. | |
| 63 QuicPacketNumber max_protected_packet_; | |
| 64 // The cumulative parity calculation of all received packets. | |
| 65 char payload_parity_[kMaxPacketSize]; | |
| 66 size_t payload_parity_len_; | |
| 67 // The effective encryption level, which is the lowest encryption level of | |
| 68 // the data and FEC in the group. | |
| 69 EncryptionLevel effective_encryption_level_; | |
| 70 | |
| 71 DISALLOW_COPY_AND_ASSIGN(QuicFecGroup); | |
| 72 }; | |
| 73 | |
| 74 } // namespace net | |
| 75 | |
| 76 #endif // NET_QUIC_QUIC_FEC_GROUP_H_ | |
| OLD | NEW |