| 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_INTERFACE_H_ | |
| 10 #define NET_QUIC_QUIC_FEC_GROUP_INTERFACE_H_ | |
| 11 | |
| 12 #include <stddef.h> | |
| 13 | |
| 14 #include "base/macros.h" | |
| 15 #include "base/strings/string_piece.h" | |
| 16 #include "net/base/net_export.h" | |
| 17 #include "net/quic/quic_protocol.h" | |
| 18 | |
| 19 namespace net { | |
| 20 | |
| 21 class NET_EXPORT_PRIVATE QuicFecGroupInterface { | |
| 22 public: | |
| 23 ~QuicFecGroupInterface() {} | |
| 24 | |
| 25 // Updates the FEC group based on the delivery of a data packet decrypted at | |
| 26 // |encryption_level|. Returns false if this packet has already been seen, | |
| 27 // true otherwise. | |
| 28 virtual bool Update(EncryptionLevel encryption_level, | |
| 29 const QuicPacketHeader& header, | |
| 30 base::StringPiece decrypted_payload) = 0; | |
| 31 | |
| 32 // Updates the FEC group based on the delivery of an FEC packet decrypted at | |
| 33 // |encryption_level|. Returns false if this packet has already been seen or | |
| 34 // if it does not claim to protect all the packets previously seen in this | |
| 35 // group. | |
| 36 virtual bool UpdateFec(EncryptionLevel encryption_level, | |
| 37 const QuicPacketHeader& header, | |
| 38 base::StringPiece redundancy) = 0; | |
| 39 | |
| 40 // Returns true if a packet can be revived from this FEC group. | |
| 41 virtual bool CanRevive() const = 0; | |
| 42 | |
| 43 // Returns true if all packets (FEC and data) from this FEC group have been | |
| 44 // seen or revived. | |
| 45 virtual bool IsFinished() const = 0; | |
| 46 | |
| 47 // Revives the missing packet from this FEC group. This may return a packet | |
| 48 // that is null padded to a greater length than the original packet, but | |
| 49 // the framer will handle it correctly. Returns the length of the data | |
| 50 // written to |decrypted_payload|, or 0 if the packet could not be revived. | |
| 51 virtual size_t Revive(QuicPacketHeader* header, | |
| 52 char* decrypted_payload, | |
| 53 size_t decrypted_payload_len) = 0; | |
| 54 | |
| 55 // Returns true if the group is waiting for any packets with sequence numbers | |
| 56 // less than |num|. | |
| 57 virtual bool IsWaitingForPacketBefore(QuicPacketNumber num) const = 0; | |
| 58 | |
| 59 // The FEC data in the FEC packet. | |
| 60 virtual const base::StringPiece PayloadParity() const = 0; | |
| 61 | |
| 62 // Number of packets in the group. | |
| 63 virtual QuicPacketCount NumReceivedPackets() const = 0; | |
| 64 | |
| 65 // Returns the effective encryption level of the FEC group. | |
| 66 virtual EncryptionLevel EffectiveEncryptionLevel() const = 0; | |
| 67 | |
| 68 // Return the FEC group number of this group. | |
| 69 virtual QuicFecGroupNumber FecGroupNumber() const = 0; | |
| 70 | |
| 71 // An optimized version of running |output| ^= |input|, where ^ is | |
| 72 // byte-by-byte XOR and both |output| and |input| are of size |size_in_bytes|. | |
| 73 static void XorBuffers(const char* input, size_t size_in_bytes, char* output); | |
| 74 | |
| 75 protected: | |
| 76 QuicFecGroupInterface() {} | |
| 77 | |
| 78 private: | |
| 79 DISALLOW_COPY_AND_ASSIGN(QuicFecGroupInterface); | |
| 80 }; | |
| 81 | |
| 82 } // namespace net | |
| 83 | |
| 84 #endif // NET_QUIC_QUIC_FEC_GROUP_INTERFACE_H_ | |
| OLD | NEW |